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
function sequenceTasks(tasks) { | |
function recordValue(results, value) { | |
results.push(value); | |
return results; | |
} | |
var pushValue = recordValue.bind(null, []); | |
return tasks.reduce(function (promise, task) { | |
return promise.then(task).then(pushValue); | |
}, Promise.resolve()); | |
} |
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
function get(uri) { | |
return http(uri,'GET'); | |
} | |
function post(uri,data) { | |
if(typeof data === 'object' && !(data instanceof String || (FormData && data instanceof FormData))) { | |
var params = []; | |
for(var p in data) { | |
if(data[p] instanceof Array) { | |
for(var i = 0; i < data[p].length; i++) { | |
params.push( encodeURIComponenet(p) + '[]=' + encodeURIComponenet(data[p][i]); |
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
Function.prototype.before = function(func) { | |
var that = this; | |
return function() { | |
//debugger | |
if(func.apply(this, arguments) === false) { | |
return false; | |
} | |
return that.apply(this, arguments); | |
} | |
} |
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
var s; | |
s += " 屏幕分辨率的高:"+ window.screen.height+"\n"; | |
s += " 屏幕分辨率的宽:"+ window.screen.width+"\n"; | |
万能的js是这样干的 s += " 网页可见区域宽:"+ document.body.clientWidth+"\n"; | |
s += " 网页可见区域高:"+ document.body.clientHeight+"\n"; | |
s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)"+"\n"; | |
s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)"+"\n"; | |
s += " 网页正文全文宽:"+ document.body.scrollWidth+"\n"; | |
s += " 网页正文全文高:"+ document.body.scrollHeight+"\n"; | |
s += " 网页被卷去的高(ff):"+ document.body.scrollTop+"\n"; |
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
$.ajaxSetup({ scriptCharset: "gbk" , contentType: "application/json; charset=gbk"}); |
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
//浅克隆 | |
/*Object.prototype.clone = function (){ | |
var obj = {}; | |
for(var key in this) { | |
if(this.hasOwnProperty(key)) { | |
obj[key] = this[key]; | |
} | |
} |
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
.Center-Container { | |
position: relative; | |
} | |
.Absolute-Center { | |
width: 50%; | |
height: 50%; | |
overflow: auto; | |
margin: auto; | |
position: absolute; |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<style> | |
.outer { | |
display: table; | |
width: 500px; | |
height: 300px; |
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
/** Event handler for mouse wheel event. | |
*鼠标滚动事件 | |
*/ | |
var wheel = function(event) { | |
var delta = 0; | |
if (!event) /* For IE. */ | |
event = window.event; | |
if (event.wheelDelta) { /* IE/Opera. */ | |
delta = event.wheelDelta / 120; | |
} else if (event.detail) { |
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
Date.prototype.Format = function (fmt) { //author: meizz | |
var o = { | |
"M+": this.getMonth() + 1, //月份 | |
"d+": this.getDate(), //日 | |
"h+": this.getHours(), //小时 | |
"m+": this.getMinutes(), //分 | |
"s+": this.getSeconds(), //秒 | |
"q+": Math.floor((this.getMonth() + 3) / 3), //季度 | |
"S": this.getMilliseconds() //毫秒 | |
}; |
NewerOlder