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
// get system info | |
var getOSInfo = function () { | |
var ver = navigator.userAgent; | |
var OS = navigator.platform; | |
if(OS == "Win32" || OS == "Windows") { | |
return 'Windows'; | |
} else if(OS == "Mac68K" || OS == "MacPPC" || OS == "Macintosh" || OS == "MacIntel") { | |
return "Mac"; | |
} else if(OS == "X11") { | |
return "Unix"; |
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
// 定义一个扩展函数,用来将第二个以及后续参数复制只第一个参数 | |
// 这里我们处理了IE bug:在多数IE版本中 | |
// 如果o的属性拥有一个不可枚举的同名属性,则for/in循环 | |
// 除非我们先是检测它 | |
var extend = (function(){ //将这个函数的返回值赋值给extend | |
// 在修复它之前,首先检查是否存在bug | |
for(var p in {toString: null}){ | |
return function extend(o){ | |
// 如果代码执行到这里,那么for/in循环会正确工作并返回 | |
// 一个简单版本的extend()函数 |
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 inherit(p){ | |
if(p ==null) throw TypeError(); | |
if(Object.create){ | |
return Object.create(p); | |
} | |
var t = typeof p; | |
if(t !== "object" && t !== "function") throwTypeError(); | |
function f(){}; | |
f.prototype = p; | |
return new f(); |
NewerOlder