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
/** | |
* | |
* @param {object} obj data object to parse columns from | |
* parses columns from an object's keys | |
*/ | |
export function parseColumns(obj) { | |
if (!obj) { | |
return null; | |
} | |
return Object.keys(obj).map(key => ({ title: key, data: key })); |
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
const apiBaseUrl 'https://localhost/some/api'; | |
/** fetch */ | |
window.fetch(`${apiBaseUrl}`, { | |
credentials: 'include' | |
}) | |
.then(json) | |
.then((data) => { | |
console.log(data); | |
}); | |
/** XHR */ |
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
const timestamp = 1555624965730; | |
const timeCurrent = new Date().getTime(); | |
const timeElapsed = Math.floor((tC - timestamp) / 1000 / 60); //get time elapsed | |
const timeSince = (tE > 60) ? Math.floor((tE * 60) / 3600) + ' hours ago' : tE + ' minutes ago'; |
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 sortData(data, column, direction) { | |
const sortedData = data.sort((a, b) => { | |
let val1 = a[column]; | |
let val2 = b[column]; | |
val1 = typeof val1 === 'string' ? val1.toUpperCase() : val1; | |
val2 = typeof val2 === 'string' ? val2.toUpperCase() : val2; | |
return (val1 < val2) | |
? -1 | |
: 1 | |
? (val1 > val2) |
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
let template = '<h1>My name is {{name}}. This is a {{adjective1}} {{adjective2}} template!</h1>'; | |
let model = { | |
name: 'Jeremy', | |
adjective1: 'super', | |
adjective2: 'awesome' | |
}; | |
function _template(tmpl, data) { | |
for (var property in data) { |
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
this.phrases = [ | |
'Please wait: pay no attention to the man behind the curtain', | |
'Please wait: at least you\'re not on hold', | |
'Please wait: the server is powered by a lemon and two electrodes', | |
'Please wait: we\'re testing your patience', | |
'Please wait: while the satellite moves into position', | |
'My other loading screen is a Ferrari', | |
'Please wait: as if you had any other choice', | |
'Adding Hidden Agendas', | |
'Adjusting Bell Curves', |