2012-01-13
(function(window,undefined){ var _toString = {}.toString, _is, _writeScript, _listUrl, alfred = { author : "alfred", version : 1.01, global : this, doc : this.document, reset : function(it){ this.global[it]=alfred;}, log : function(){ if(window.console && console.log){ return console.log(arguments)}}, isNumber : function(it){ return _is(it,"Number")}, isString : function(it){ return _is(it,"String")}, isFunction : function(it){ return _is(it,"Function")}, isObject : function(it){ return _is(it,"Object")}, isArray : function(it){ return _is(it,"Array")}, isBoolean : function(it){ return typeof it ==='boolean'}, scriptMap : { method_url : {},// method --> url < method : url > < 1 : 1 > url_method : {},// url --> method < url : [method,method] > < 1 : n > visited : {}, writted : {}, wait_write:[] }, require : function(method){ var m2u = this.scriptMap.method_url, u2m = this.scriptMap.url_method, r; if (!this.scriptMap.visited[m2u[method][0]] && !this.scriptMap.writted[m2u[method][0]]) { //haven't be visited or write this.scriptMap.visited[m2u[method][0]] = true; //use an beautiful code in here for(; m2u[method][1].length &&(r=m2u[method][1].shift());) { require(r); } _listUrl(); }; }, setMethod : function(url,method,rely){ if (url && method && !this.scriptMap.url_method[url]){ this.scriptMap.url_method[url] = method; for (var i = method.length - 1; i >= 0; i--) { this.scriptMap.method_url[method[i]] = {"0" : url, "1" : rely}; } } }, extend : function(){ var deep = false, len, options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1; len = arguments.length; if (!len) { return this; } if(alfred.isBoolean(target)) { deep = arguments[0]; to = arguments[1]; i = 2; } if (!(alfred.isObject(target) || alfred.isFunction(target))) { target = {}; } if (len = i) { to = this; --i; } for (;i
base.js
This is the first version for my javascript lean.
I need learn more .