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(){ | |
var formatParams = function(data) {//格式化参数 | |
var arr = []; | |
for (var name in data) { | |
arr.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name])); | |
} | |
return arr.join('&'); | |
} | |
var jsonp = function(options) { | |
options = 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
/* | |
* rem.js | |
* v0.1.1 | |
* fixed 2015-3-12 | |
*/ | |
(function (win){ | |
var doc = win.document, | |
html = doc.documentElement, | |
option = html.getAttribute('data-use-rem'); | |
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
javascript:(function(){var script=document.createElement('script');script.onload=function(){var stats=new Stats();stats.domElement.style.cssText='position:fixed;left:0;top:0;z-index:10000';document.body.appendChild(stats.domElement);requestAnimationFrame(function loop(){stats.update();requestAnimationFrame(loop)});};script.src='//rawgit.com/mrdoob/stats.js/master/build/stats.min.js';document.head.appendChild(script);})() |
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
/** | |
* @author alteredq / http://alteredqualia.com/ | |
*/ | |
Detector = { | |
// supported features | |
canvas : !!window.CanvasRenderingContext2D, | |
webgl : !!window.WebGLRenderingContext, |
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
/** | |
* Provides requestAnimationFrame in a cross browser way. | |
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
*/ | |
if ( !window.requestAnimationFrame ) { | |
window.requestAnimationFrame = ( function() { | |
return window.webkitRequestAnimationFrame || |
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> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style type="text/css"> | |
#main{ | |
position: relative; | |
overflow: hidden; | |
} |
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 n = 2; | |
var arr = [1,2,3,4,5,6]; | |
var arr1 = arr.slice(0,n); | |
var arr2 = arr.slice(n,6) | |
arr1 = arr1.reverse(); | |
arr2 = arr2.reverse(); | |
var arr3 = arr1.concat(arr2).reverse(); |
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
/* bling.js */ | |
window.$ = document.querySelectorAll.bind(document) | |
Node.prototype.on = window.on = function (name, fn) { | |
this.addEventListener(name, fn) | |
} | |
NodeList.prototype.__proto__ = Array.prototype | |
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
//每次set的时候,检查localStorage是否溢出,做LRU处理 | |
var addLocalStorage = function( key, storeObj ) { | |
try { | |
localStorage.setItem( storagePrefix + key, JSON.stringify( storeObj ) ); | |
return true; | |
} catch( e ) { | |
if ( e.name.toUpperCase().indexOf('QUOTA') >= 0 ) { | |
var item; | |
var tempScripts = []; |
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
//设计模式 | |
Singleton(单例)模式 | |
限制了类的实例化次数只能为一次 | |
getInstance = function () { | |
if (this._instance == null) { | |
this._instance = new Singletance(); | |
} | |
return this._instance; | |
} |