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
casper.test.begin('test 163 mail login', 2, function(test) { | |
casper.start('http://mail.163.com/', function() { | |
this.capture('step1.png'); | |
test.assertExists('#loginBtn'); | |
this.fill('form', { | |
'username': 'xxx', | |
'password': 'xxx' | |
}, true); | |
this.click('#loginBtn'); | |
this.capture('step2.png'); |
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 Factory () {} | |
Factory.prototype.defaultGender = Boy; | |
Factory.prototype.createFactory = function (options) { | |
if (options.name === 'girl') { | |
this.defaultGender = Girl; | |
} else { | |
this.defaultGender = Boy; | |
} | |
return new this.defaultGender(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
display -webkit-box | |
-webkit-line-clamp 1 | |
text-overflow ellipsis | |
-webkit-box-orient vertical | |
word-break break-all |
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; | |
} |
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
/* 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
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
<!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
/** | |
* 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
/** | |
* @author alteredq / http://alteredqualia.com/ | |
*/ | |
Detector = { | |
// supported features | |
canvas : !!window.CanvasRenderingContext2D, | |
webgl : !!window.WebGLRenderingContext, |