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 roundRect(ctx, x, y, width, height, radius, fill, stroke) { | |
if (typeof stroke == "undefined" ) { | |
stroke = true; | |
} | |
if (typeof radius === "undefined") { | |
radius = 5; | |
} | |
ctx.beginPath(); | |
ctx.moveTo(x + radius, y); | |
ctx.lineTo(x + width - radius, y); |
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
document.addEventListener("DOMNodeInserted",function(event){addlink(event)},false); | |
function addlink(event){ | |
var node = event.target; | |
if(node instanceof HTMLLIElement){ | |
} | |
} |
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
//delete a item in indexed array | |
Array.prototype.remove=function(dx) | |
{ | |
if(isNaN(dx)||dx>this.length){return false;} | |
for(var i=0,n=0;i<this.length;i++) | |
{ | |
if(this[i]!=this[dx]) | |
{ | |
this[n++]=this[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 removeDuplicates(arr) { | |
var temp = {}, | |
r = [], | |
i,k; | |
for (i = 0;i < arr.length;i++) { | |
temp[arr[i]] = true; | |
} | |
var r = []; | |
for (k in temp) { |
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
// 基本jQuery插件形式1 | |
function($) { | |
// 向jQuery中被保护的“fn”命名空间中添加你的插件代码,用“pluginName”作为插件的函数名称 | |
$.fn.pluginName = function(options) { | |
// 返回“this”(函数each()的返回值也是this),以便进行链式调用。 | |
return this.each(function() { | |
// 此处运行代码,可以通过“this”来获得每个单独的元素 |
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 autoTextarea = function (elem, extra, maxHeight) { | |
extra = extra || 0; | |
var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window, | |
isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'), | |
addEvent = function (type, callback) { | |
elem.addEventListener ? | |
elem.addEventListener(type, callback, false) : | |
elem.attachEvent('on' + type, callback); | |
}, | |
getStyle = elem.currentStyle ? function (name) { |
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 throttle( fn, time ) { | |
var t = 0; | |
return function() { | |
var args = arguments, ctx = this; | |
clearTimeout(t); | |
t = setTimeout( function() { | |
fn.apply( ctx, args ); | |
}, time ); | |
}; |
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 type="text/css"> | |
.star_bg{ | |
width: 120px; | |
height: 20px; | |
background: url('star.png') repeat-x; |
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 make_promise () { | |
var status = 'unresolved', | |
outcome, | |
waiting = [], | |
dreading = []; | |
function vouch(deed, func) { | |
switch (status) { | |
case 'unresolved': | |
(deed === 'fulfilled' ? waiting : dreading).push(func); |
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 Html2Dom(str) { | |
var tempDiv = document.createElement('div'); | |
tempDiv.innerHTML = str; | |
var dom = tempDiv.childNodes[0]; | |
return dom; | |
} |
OlderNewer