Get query string parameters with jQuery

$.urlParam = function (name) { var results = new RegExp(‘[\?&]’ + name + ‘=([^&#]*)’) .exec(window.location.href); if (results == null) { return 0; } return results[1] || 0; } console.log($.urlParam(‘dotmaui’)); //cool

JavaScript loop through json array

If you are not interested in support for old browsers, the best way to browse an array of json is: var dotArrayJSON = [ {“label”: 1}, {“label”: 2}, {“label”: 3}, {“label”: 4} ]; dotArrayJSON.forEach(loopThrough); function…

Upload text file into textarea via Javascript

How to upload a text file in a textarea with Javascript. This script is used in dotmaui.com to upload files completely client-side, to respect the privacy of users. document.forms[‘myForm’].elements[‘myFile’].onchange = function (evt) { if (!window.FileReader)…

Javascript Trim a String

How remove whitespace from both sides of a string (trim function): Pure Javascript var mystring = ”       dotmaui.com        “; mystring.trim(); For browsers that do not support the trim() method: String.prototype.trim = function() {…

JavaScript – Check if a variable is an integer

function isInt(value) { return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10)); } Tests: isInt(7) // true isInt(“7”) // true isInt(7e5) // true isInt(“7e7″) // true isInt(” 7 “) // true isInt(“”) // false isInt(“…