This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/angular/angular.js/blob/master/src/Angular.js#L72 | |
function isArrayLike(obj) { | |
if (!obj || (typeof obj.length !== 'number')) return false; | |
// We have on object which has length property. Should we treat it as array? | |
if (typeof obj.hasOwnProperty != 'function' && | |
typeof obj.constructor != 'function') { | |
// This is here for IE8: it is a bogus object treat it as array; | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ajax(url, opts){ | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function(){ | |
var completed = 4; | |
if(xhr.readyState === completed){ | |
if(xhr.status === 200){ | |
opts.success(xhr.responseText, xhr); | |
}else{ | |
opts.error(xhr.responseText, xhr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function esCif(c){ | |
var ultima, | |
uletra = ["J", "A", "B", "C", "D", "E", "F", "G", "H", "I"], | |
par = 0, | |
non = 0, | |
regular =/^[ABCDEFGHJKLMNPQRSUVW]\d\d\d\d\d\d\d[0-9,A-J]$/g, | |
nn, parcial, control; | |
c = c.toUpperCase(); | |
if (!regular.exec(c)) {return false; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function esNie(c){ | |
var aux = c.charAt(0); | |
if(aux.toUpperCase()!=="X" && aux.toUpperCase()!=="Y"){ return false;} | |
return comprobarNIE(c.substr(1,c.length), aux); | |
} | |
function comprobarNIE(c, letraInicio){ | |
if(!/^[0-9]{7}([A-Za-z]{1})$/.test(c)) return false; | |
var letras = 'TRWAGMYFPDXBNJZSQVHLCKET', | |
letraFin = c.substr(7,8).toUpperCase(), | |
numero = c.substr(0,7); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function controlHeight(elems, num){ | |
var len = elems.length; | |
if(len !== 0){ | |
for(var i = 0; i < len; i+=num) { | |
var divs = elems.slice(i, i+num), | |
height, numArray = []; | |
for(var j = 0; j < num; j++){ | |
numArray.push(divs.eq(j).height()); | |
} | |
height = Math.max.apply(null, numArray); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Stack(stackLimit) | |
{ | |
this.stack = new Array(); | |
this.stackLimit = stackLimit; | |
} | |
Stack.prototype.isEmpty = function() | |
{ | |
return (this.stack.length == 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.yeikos.com/2013/01/javascript-tips-cadena-aleatoria.html | |
Math.random().toString(36).substring(2); // 9xfq8ssn2hjjor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/5016313/how-to-determine-if-a-number-is-odd-in-javascript | |
function oddOrEven(x) { | |
return ( x & 1 ) ? "odd" : "even"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/1232040/how-to-empty-an-array-in-javascript | |
// related: Splicing is the worst by far: http://jsperf.com/emptying-arrays/4 | |
matrix.splice(0,matrix.length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i, len = titles.length; | |
for(i = len-1; i >- 1; i--){ | |
} |