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
JSON.search=function(o,str){ | |
oobj = o; | |
o = JSON.stringify(o); | |
idx = o.search(str) | |
if ( idx == -1 ) | |
return []; | |
ocpy = o; | |
starts = [idx]; | |
while ( idx != -1 ) { | |
ocpy = ocpy.substr(idx+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
/** | |
* Simple access to the Hashbang with listeners, filters and query string | |
* deconstruction. | |
*/ | |
class HashRouter { | |
constructor() { | |
if (HashRouter.instance) { | |
return HashRouter.instance; | |
} | |
this.currentHash = HashRouter.toObject(window.location.hash); |
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
/** | |
* Renders a model onto a template literal string. Renders the rendered text. | |
*/ | |
function render(model, templateLiteral) { | |
// declare the vars in function scope needed for our replacement | |
for (let key in model) { | |
let value; | |
if (typeof model[key] == 'string') { | |
value = '"' + model[key] + '"'; | |
} else { |
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
/** | |
* Renders a model onto a template literal string. Renders the rendered text. | |
*/ | |
function render(model, templateLiteral) { | |
// declare the vars in function scope needed for our replacement | |
for (let key in model) { | |
let value; | |
if (typeof model[key] == 'string') { | |
value = '"' + model[key] + '"'; | |
} else { |
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
/** | |
* @license MIT | |
* Copyright 2019 @andrei-m | |
* | |
* See original which this code is based on: | |
* https://gist.github.com/andrei-m/982927/0efdf215b00e5d34c90fdc354639f87ddc3bd0a5 | |
* | |
* Basic modifications include using ES6 `const` and `let`. Additionally | |
* condenses if statement. Changes are somewhat trivial overall :) |
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
/** | |
* ScrollOptions | |
*/ | |
class ScrollOptions { | |
constructor(obj) { | |
/** | |
* @type {Function} Function called when a scroll in occurs. | |
*/ | |
this.scrollIn = function() {}; |