View sort.js
1 2 3 4 5 6 7 8 9
// From: http://stackoverflow.com/questions/1129216/sort-array-of-objects-by-property-value-in-javascript
 
function compare(a,b) {
if (a.last_nom < b.last_nom)
return -1;
if (a.last_nom > b.last_nom)
return 1;
return 0;
}
View formatDate.js
1 2 3 4 5 6 7 8 9 10
// From: http://stackoverflow.com/questions/2315408/how-do-i-format-a-timestamp-in-javascript-to-display-it-in-graphs-utc-is-fine
 
function formatDate(date, fmt) {
function pad(value) {
return (value.toString().length < 2) ? '0' + value : value;
}
return fmt.replace(/%([a-zA-Z])/g, function (_, fmtCode) {
switch (fmtCode) {
case 'Y':
return date.getUTCFullYear();
View eventhandler.js
1 2 3 4 5 6 7 8 9 10
function onKey(evt) {
var key = evt.which || evt.charCode || evt.keyCode;
switch (key) {
case 67:
break;
case 18:
break;
default:
break;
}
View generateGUID.js
1 2 3 4 5 6 7 8 9
function generateGUID() {
var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
 
return guid;
}
View changeTemplate.js
1 2 3 4 5 6 7 8
function changeTemplate(newHTML) {
var parentElem = document.getElementById('app');
if (parentElem !== undefined) {
parentElem.innerHTML = newHTML;
} else {
document.body.innerHTML = newHTML;
}
}
View navigation.js
1 2 3 4 5 6 7 8 9 10
var history = [];
var navigation = {
back: function() {
if (history.length > 1) {
this.show(history[history.length - 2]);
history.pop();
}
},
forward: function(menu) {
history.push(menu);
View localStorage.js
1 2 3 4 5 6 7 8 9 10
var store = {
name: 'default_key_name',
get: function(_key) {
var key = _key || this.name;
return JSON.parse(localStorage.getItem(key) || '[]');
},
set: function(value, _key) {
var key = _key || this.name;
localStorage.setItem(key, JSON.stringify(value));
}
View intervals.js
1 2 3 4 5 6 7 8 9
var intervals = [];
 
intervals.push(setInterval(function() {
console.log('apples');
}, 100));
 
intervals.push(setInterval(function() {
console.log('pears');
}, 100));
View insertAdjacentHTML.js
1 2 3 4 5 6 7 8 9 10
/*
* insertAdjacentHTML.js
* Cross-browser full HTMLElement.insertAdjacentHTML implementation.
*
* 2011-10-10
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
View object-watch.js
1 2 3 4 5 6 7 8 9
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
Something went wrong with that request. Please try again.