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 getOSver() { | |
var ua = navigator.userAgent; | |
var uaindex, userOS, userOSver; | |
if(ua.match(/iPad/i) || ua.match(/iPod/i) || ua.match(/iPhone/i)) { | |
userOS = "iOS"; | |
uaindex = ua.indexOf("OS "); | |
} else { | |
userOS = "unknown"; | |
} |
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
for(var prop in id_list){ | |
if(!id_list.hasOwnProperty(prop)) continue; | |
id_list[prop]["details"] = id_list[prop]["details"] || {}; | |
id_list[prop]["details"]["isNovice"] = false; | |
} |
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
// Object that implements the Event Handler Interface | |
var a = { | |
handleEvent: function (e){ | |
console.log('hola', e.detail); | |
} | |
}; | |
// Custom Event | |
var custom = new Event('myevent'); |
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
// Recursive Binary Search | |
// Array must be sorted in ascending order | |
Array.prototype.binarySearch = function(num, from, to) { | |
to = to || this.length-1; | |
from = from || 0; | |
if(!num || from > to) return null; | |
var index = Math.floor((to-from) / 2) + from; | |
if(num < this[index]) return this.binarySearch(num, from, index-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
function MyConstructor(options){ | |
options = options || {}; | |
// Default properties: | |
options.__proto__ = { | |
threshold: 3, | |
quality: 1 | |
etc: "whatever" | |
}; | |
// Use case: |
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> | |
<head> | |
<style> | |
.images { | |
-webkit-column-count: 3; /* Chrome, Safari, Opera */ | |
-moz-column-count: 3; /* Firefox */ | |
column-count: 3; | |
} | |
.images img { width: 100%; } |
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(){ | |
Object.defineProperties(document, { | |
"on": { | |
value: function(evName, callback, useCapture){ | |
return addEvent.call(this, evName, callback, useCapture); | |
} | |
} | |
}); | |
Object.defineProperties(window, { | |
"on": { |
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 CSSRule = (function (){ | |
var prefix = (function getPropertiesPrefix(){ | |
var t, el = document.createElement("fakeelement") | |
,animations = { | |
"animation": "", | |
"OAnimation": "-o-", | |
"msAnimation": "-ms-", | |
"MozAnimation": "-moz-", | |
"WebkitAnimation": "-webkit-" | |
}; |
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 Keyframe = (function (){ | |
var keyframePrefix = (function getKeyframePrefix(){ | |
var t, el = document.createElement("fakeelement") | |
,animations = { | |
"animation": "", | |
"OAnimation": "-o-", | |
"msAnimation": "-ms-", | |
"MozAnimation": "-moz-", | |
"WebkitAnimation": "-webkit-" | |
}; |
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 Animation = (function (){ | |
var animationEvent = (function whichAnimationEvent(){ | |
var t, el = document.createElement("fakeelement") | |
,animation = null | |
,animations = { | |
"WebkitAnimation": "webkitAnimationEnd", | |
"MozAnimation": "animationend", | |
"OAnimation": "oAnimationEnd", | |
"animation": "animationend" | |
}; |