Skip to content
View component-manager.js
var app = app || {};
/**
* Assumptions:
* - Each component has a destroy() method. This could later be refactored to do as much removal as it can, leaving the rest to the component
* - Each component has an onKey event handler at .onKey or .config.onKey
*/
(function(app) {
app.components = {
'components': [],
View jasmine-dynamically-generated-tests.js
describe('add()', function() {
var tests = [
{bool: true, name: 'lol'},
{bool: true, name: 'a'},
{bool: true, name: 'b'},
{bool: true, name: 'b'}
];
tests.forEach(function(test) {
it('correctly adds ' + test.name + ' args', function() {
View traverse.js
// MODIFIED FROM: http://stackoverflow.com/a/722732/1365289
function process(key, value) {
if (key === 'myKey') {
console.error(key, value);
}
}
function traverse(o, func) {
for (var i in o) {
View sort.js
// 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
// 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
function onKey(evt) {
var key = evt.which || evt.charCode || evt.keyCode;
switch (key) {
case 67:
break;
case 18:
break;
default:
break;
}
View generateGUID.js
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
function changeTemplate(newHTML) {
var parentElem = document.getElementById('app');
if (parentElem !== undefined) {
parentElem.innerHTML = newHTML;
} else {
document.body.innerHTML = newHTML;
}
}
View navigation.js
var history = [];
var navigation = {
back: function() {
if (history.length > 1) {
this.show(history[history.length - 2]);
history.pop();
}
},
forward: function(menu) {
history.push(menu);
Something went wrong with that request. Please try again.