This file contains 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
app.filter('capitalize', function() { | |
return function(input, scope) { | |
if (input!=null) | |
input = input.toLowerCase(); | |
return input.substring(0,1).toUpperCase()+input.substring(1); | |
} | |
}); |
This file contains 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
$browser-context: 16; // Default | |
@function em($pixels, $context: $browser-context) { | |
@return #{$pixels/$context}em | |
} | |
h1 { | |
font-size: em(21, 15); // Outputs 1.4em | |
} |
This file contains 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
/* | |
==SHORTEN LONG STRINGS | |
-----------------------------------------------------*/ | |
function truncateLongText(elem, maxwidth, sufix) { | |
if (elem === null) { | |
return ''; | |
} | |
elem = String(elem); | |
var newElem; | |
if (elem.length > maxwidth) { |
This file contains 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
/* | |
==CHECK IF IS NUMBER | |
-----------------------------------------------------*/ | |
function isNumber(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} |
This file contains 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
/* ==CHECK IF ARRAY CONTAINS VARIABLE | |
-----------------------------------------------------*/ | |
function oc(a) { | |
var o = {}; | |
for(var i=0;i<a.length;i++){ | |
o[a[i]]=''; | |
} | |
return o; | |
} |
This file contains 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
/* | |
==GET JSON DATA | |
-----------------------------------------------------*/ | |
function getData(url, callback, errorCallback, completeCallback) { | |
$.getJSON(url, function (data) { | |
log('success'); | |
log(data); | |
callback(data); | |
}).error(function (data) { | |
log('error'); |
This file contains 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
/*==GET URL VARIABLES | |
-----------------------------------------------------*/ | |
function getUrlVars() { | |
var vars = {}; | |
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m,key,value) { | |
vars[key] = value; | |
}); | |
return vars; | |
} |
This file contains 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
/* | |
==GET A RANDOM NUMBER | |
-----------------------------------------------------*/ | |
function randomNumber(min, max) { | |
return Math.ceil(Math.random() * (max - min) + min); | |
} |
This file contains 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
/* | |
==ESC | |
-----------------------------------------------------*/ | |
function esc(text) { | |
if (typeof text !== 'string') { | |
text = String(text); | |
} | |
var html = text.split("&").join("&").split("\"").join(""").split("'").join("'").split("<").join("<").split(">").join(">"); | |
return html.replace(/\r?\n/g, ' '); | |
} |
This file contains 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 log(msg) { | |
try { | |
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') { | |
console.log(msg); | |
} | |
} catch (e) {} | |
} |