This file contains hidden or 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
class ObjectArray extends Object { | |
/** | |
* @param {Object} obj | |
*/ | |
constructor(obj = {}) { | |
super(); | |
this.length = 0; | |
const keys = Object.keys(obj); | |
keys.forEach((key) => { | |
this.length += 1; |
This file contains hidden or 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
// time const in millisecond | |
export const SECOND = 1000; | |
export const MINUTE = 60 * SECOND; // 60 000 | |
export const HOUR = 60 * MINUTE; // 3 600 000 | |
export const DAY = 24 * HOUR; // 86 400 000 | |
export const WEEK = 7 * DAY; // 604 800 000 | |
// export const YEAR = 365 * DAY; // 31 536 000 000 | |
export const YEAR = 365.25 * DAY; // 31 557 600 000 |
This file contains hidden or 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 getUrlParameter(param) { | |
var pageUrl = decodeURIComponent(window.location.search.substring(1)), | |
urlVariables = pageUrl.split('&'), | |
parameterName, | |
i; | |
for (i = 0; i < urlVariables.length; i++) { | |
parameterName = urlVariables[i].split('='); | |
if (parameterName[0] === param) { |
This file contains hidden or 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
/** | |
* @example for (let {key, val} of listeners) { console.log("2", key, val); } | |
*/ | |
const listeners = {}; | |
listeners[Symbol.iterator] = function () { | |
const keys = Object.keys(this); | |
const self = this; | |
var current = 0; | |
var last = keys.length; |
This file contains hidden or 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
var OnScroll = (function () { | |
function OnScroll(config) { | |
if (!config) { | |
config = {} | |
} | |
this.listeners = []; | |
this.timeout = config.timeout || 300; | |
var handler = _scrollHandler.bind(this); | |
if (window.addEventListener) { |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<title>Site Title</title> | |
<link rel="stylesheet" href="/assets/css/style.min.css"> |
This file contains hidden or 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
// https://stackoverflow.com/questions/9260501/html5-video-background-on-ipad-iphone | |
var cvpHandlers = { | |
canvasClickHandler: null, | |
videoTimeUpdateHandler: null, | |
videoCanPlayHandler: null, | |
windowResizeHandler: null | |
}; | |
var CanvasVideoPlayer = function(options) { |
This file contains hidden or 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
var initialFirst = 0; | |
var initialLast = 1; | |
var index = 0; | |
var calcFib = function selfCall (num) { | |
if (num < 1) return; | |
index++; | |
var result = initialFirst + initialLast; | |
initialFirst = initialLast; | |
initialLast = result; |
This file contains hidden or 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
category = [ | |
{id: "animals", parent: null} | |
{id: "mammals", parent: "animals"} | |
{id: "cats", parent: "mammals"} | |
{id: "dogs", parent: "mammals"} | |
{id: "alliance", parent: null} | |
{id: "labrador", parent: "dogs"} | |
{id: "chihuahua", parent: "dogs"} | |
{id: "siamese", parent: "cats"} | |
{id: "persian", parent: "cats"} |
This file contains hidden or 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
_appsHash = {} | |
_appsArr = [] | |
getAll = -> _appsArr | |
getAppById = (appId) -> _appsHash[appId] | |
_fetch = (apps) -> | |
appsHash = {} | |
_appsArr = apps.map (item) -> | |
appsHash[item.id] = _appsHash[item.id] or assign({}, item) |