摘要:
/*global Backbone */var app = app || {};(function () { 'use strict'; // Todo Router // ---------- var Workspace = Backbone.Router.extend({ routes: { '*filter': 'setFilter' }, setFilter: function (param) { // Set the current filter to be used app.TodoFilter = param || ' 阅读全文
摘要:
1 /*********对象冒充**********/ 2 function Parent(username){ 3 this.username=username; 4 this.sayHello=function(){ 5 alert(this.username); 6 } 7 } 8 function Child(username,password){ 9 this.method=Parent;10 this.method(username);11 ... 阅读全文
摘要:
1 var GiantCorp=window.GiantCorp || {} 2 GiantCorp.DataParser={ 3 _stripWhitespace:function(str){ 4 return str.replace(/\s+/,''); 5 }, 6 _stringSplit:function(str,delimiter){ 7 return str.split(delimiter); 8 }, 9 stringToArray:... 阅读全文
摘要:
1 function extend(subClass,superClass){ 2 var f=function(){}; 3 f.prototype=superClass.prototype; 4 subClass.prototype=new f(); 5 subClass.prototype.constructor=subClass; 6 7 subClass.superClass=superClass.prototype; 8 if(superClass.prototype.constructor==Object.prototype.c... 阅读全文
摘要:
1 var Book=(function(){ 2 var numOfBooks=0; 3 function checkIsbn(isbn){ 4 5 } 6 return function(isbn,title,author){ 7 var _isbn,_title,_author; 8 9 this.setIsbn=function(isbn){10 _isbn=isbn;11 }12 ... 阅读全文
摘要:
1 /** 2 * 创建接口对象 3 * @param name 接口名 4 * @param methods 接口方法 5 */ 6 var Interface = function(name,methods){ 7 if(arguments.length != 2){ 8 throw new Error('必须输入两个参数,当前个数'+arguments.length); 9 }10 11 this.name=name;12 this.meth... 阅读全文
摘要:
1 Function.prototype.method=function(name,fn){2 this.prototype[name]=fn;3 } 阅读全文
摘要:
window.onload=function(){ var a=[1,2,4,6,71,7,23,4,5,7,6,1,2,4,6] alert(a.chong())}Array.prototype.chong=function() { var tmp = new Array(); this.sort(); for(var i=0;i<this.length;i++) { if(this[i]===this[i+1]) { continue; } tmp[tmp.length]=this[i]; } return tmp} 阅读全文
摘要:
1 $("#bankCard").keypress(function(e){ //把bankCard替换成你需要的输入框ID 2 var code=e.which; 3 if(code==8 || code==0)return true; 4 if (e.shiftKey || code>57 || code<48) return false; 5 }) 6 $("#bankCard").keyup(function(e){ 7 var v=this.value.split(" ").join(""); 阅读全文
摘要:
/***** 判断是否为json对象 ******** @param obj: 对象(可以是jq取到对象)* @return isjson: 是否是json对象 true/false*/jm.isJson = function(obj){var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; return isjson;} 阅读全文