📄 brocade.js
字号:
/*
This releas built by Javascript Releaser at Brocade.
visited the site of brocade : http://Brocade.sourceforge.net.
Author : PubTlk@hotmail.com.
At Thu Nov 30 22:03:41 CST 2006.
*/
bc = {}; bc.w = {}; bc.a = {}; bc.u = {}; Brocade = { Version: '0.1.12-m1', hashCode:function(s){ var h = 0; var len = s.length; for (var i = 0; i < len; i++) { h = 31*h + s.charCodeAt(i); } return h; }, toString: function(){ return 'bc-' + this.Version; } }; function getExpDate(days, hours, minutes) { var expDate = new Date(); if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") { expDate.setDate(expDate.getDate() + parseInt(days)); expDate.setHours(expDate.getHours() + parseInt(hours)); expDate.setMinutes(expDate.getMinutes() + parseInt(minutes)); return expDate.toGMTString(); } } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function setCookie(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } function deleteCookie(name,path,domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } function isArray(a) { return isObject(a) && a.constructor == Array; } function isBoolean(a) { return typeof a == 'boolean'; } function isEmpty(a) { var i, j; if (isObject(a)) { for (i in a) { j = a[i]; if (isUndef(j) && isFunc(j)) { return false; } } } return true; } function isFunc(a) { return typeof a == 'function'; } function isNull(a) { return typeof a == 'object' && !a; } function isNumber(a) { return typeof a == 'number' && isFinite(a); } function isObject(a) { return (a && typeof a == 'object') || isFunc(a); } function isString(a) { return typeof a == 'string'; } function isUndef(a) { return typeof a == 'undefined'; } function extractQueryString(url) { var ret = (url.indexOf('?') >= 0 && url.indexOf('?') < (url.length-1)) ? url.substr(url.indexOf('?')+1) : ''; return ret; } function trimQueryString(url) { var ret = url.indexOf('?') >= 0 ? url.substring(0, url.indexOf('?')) : url; return ret; } Object.extend(Form,{ submit:function(form){ if(typeof form != 'object') form=$(form)||document.getElementsByName(form)[0]; for(i=0;i<form.length;i++){ if(form.elements[i].type=="submit"){ form.elements[i].click(); return; } } var smt = document.createElement("input"); smt.type="submit"; smt.value=null; Element.hide(smt); form.appendChild(smt); smt.click(); } }); Scroll = { position:function(){ var l=0,t=0; l = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; t = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; return [l,t]; }, view:function(){ var w=0,h=0; w = window.innerWidth ||document.documentElement.clientWidth ||document.body.clientWidth ||0; h = window.innerHeight ||document.documentElement.clientHeight ||document.body.clientHeight ||0; if(window.innerWidth){ if (document.height > window.innerHeight) w -=16; if ((document.body.scrollWidth || document.documentElement.scrollWidth) > window.innerWidth) h -=16; } return [w,h]; }, size:function(){ var w=0,h=0; w = window.scrollWidth ||document.documentElement.scrollWidth ||document.body.scrollWidth ||0; h = window.scrollHeight ||document.documentElement.scrollHeight ||document.body.scrollHeight ||0; return [w,h]; } }; bc.u.c={};
bc.u.c.Base=function(){}; bc.u.c.Base.prototype={ setOptions: function(o) { this.options=Object.extend({},o); }, out:function(e){ this.isHover=false; if(this.selectedElement && e==this.selectedElement) return; if(e.getAttribute('disabled')) return; if(this.options.hoveredClass){ Element.removeClassName(e,this.options.hoveredClass); }else{ e.style.backgroundColor=this.cacheStyle; } }, hover:function(e){ this.isHover=true; if(e.getAttribute('disabled')) return; if(this.selectedElement && e==this.selectedElement) return; if(this.options.hoveredClass){ Element.addClassName(e,this.options.hoveredClass); }else{ this.cacheStyle=e.style.backgroundColor; e.style.backgroundColor="#CCCCFF"; } if(null != this.options.cursor) if(window.back) e.style.cursor="pointer"; else e.style.cursor="hand"; } }
bc.u.c.Ul4Menu=Class.create(); bc.u.c.Ul4Menu.prototype =Object.extend({ initialize:function(t,o){ this.hoverListener = this.onHover.bindAsEventListener(this); Event.observe(t, "mouseover", this.hoverListener); if(o.defaultClass || o.disabledClass){ var li = t.getElementsByTagName("li"); for(var j=0;j<li.length;j++){ if(o.disabledClass && li[j].getAttribute('disabled')){ Element.addClassName(li[j],o.disabledClass); }else if(o.defaultClass) Element.addClassName(li[j],o.defaultClass); } } this.setOptions(o); }, onHover:function(evt){ var e=Event.findElement(evt, 'LI'); if(e.type==null)return; Event.observe(e, "mouseout", function(evt){ this.out(e); }.bindAsEventListener(this)); this.hover(e); } },bc.u.c.Base.prototype);
bc.u.c.Ul=Class.create(); bc.u.c.Ul.prototype =Object.extend({ initialize:function(t,o){ var me = this; $A([].concat(t)).each(function(e){ Event.observe(e, "click", me.onClick.bindAsEventListener(me)); Event.observe(e, "mouseover", me.onHover.bindAsEventListener(me)); if(o.defaultClass || o.disabledClass){ var li = e.getElementsByTagName("li"); for(var j=0;j<li.length;j++){ if(o.disabledClass && li[j].getAttribute('disabled')){ Element.addClassName(li[j],o.disabledClass); }else if(o.defaultClass) Element.addClassName(li[j],o.defaultClass); } } }.bind(this)); this.setOptions(o); }, onClick:function(evt){ var vs; var e = Event.findElement(evt, 'LI'); if(e.type==null)return; if(e.getAttribute('disabled')) return; vs = this.collect(e); if(null!=vs && this.options.callback)this.options.callback.call(this,vs);else return false; }, onHover:function(evt){ var e=Event.findElement(evt, 'LI'); if(e.type==null)return; Event.observe(e, "mouseout", function(evt){ this.out(e); Event.stop(evt); }.bindAsEventListener(this)); this.hover(e); Event.stop(evt); }, collect:function(element){ if(element!=this.selectedElement){ if(this.options.selectedClass){ Element.removeClassName(element,this.options.hoveredClass); Element.addClassName(element,this.options.selectedClass); if(this.selectedElement){ Element.removeClassName(this.selectedElement,this.options.selectedClass); } }else{ if(this.selectedElement)this.selectedElement.style.backgroundColor=this.cacheStyle; this.cacheStyle=element.style.backgroundColor="#FFCCFF"; } this.selectedElement=element; } var vs = new Array(); vs[0]=element.id||"#id"; vs[1]=element.getAttribute("text")||element.innerHTML; return vs; } },bc.u.c.Base.prototype);
bc.u.c.Table=Class.create(); bc.u.c.Table.prototype =Object.extend({ initialize:function(t,o){ $A([].concat(t)).each(function(e){ Event.observe(e, "click", this.onClick.bindAsEventListener(this)); var t=e.getElementsByTagName("TR"); for(var i=0;i<t.length;i++){ if(o.disabledClass && t[i].getAttribute('disabled')){ Element.addClassName(t[i],o.disabledClass); }else if(o.defaultClass) Element.addClassName(t[i],o.defaultClass); Event.observe(t[i], "mouseover", this.onHover.bindAsEventListener(this)); } }.bind(this)); this.setOptions(o); }, onClick:function(evt){ var vs; var e = Event.findElement(evt, 'TR'); if(e.getAttribute('disabled')) return; vs = this.collect(e); if(null!=vs && this.options.callback)this.options.callback(vs);else return false; }, onHover:function(evt){ var e=Event.findElement(evt, 'TR'); if(this.options.isHeader && e.rowIndex==0)return; Event.observe(e, "mouseout", function(evt){ this.out(e); Event.stop(evt); }.bindAsEventListener(this)); this.hover(e); Event.stop(evt); }, collect:function(e){ if(e!=this.selectedElement){ if(this.options.selectedClass){ Element.removeClassName(e,this.options.hoveredClass); Element.addClassName(e,this.options.selectedClass); if(this.selectedElement){ Element.removeClassName(this.selectedElement,this.options.selectedClass); } }else{ if(this.selectedElement)this.selectedElement.style.backgroundColor=this.cacheStyle; this.cacheStyle=e.style.backgroundColor="#FFCCFF"; } this.selectedElement=e; } var tds = e.getElementsByTagName('TD'); var vs = new Array(); for(var i=0;i<tds.length;i++){ vs[i]=tds[i].getAttribute('value')||tds[i].innerHTML; } return vs; } },bc.u.c.Base.prototype);
bc.a.Base = function(){}; bc.a.Base.prototype = { setOptions: function(options) { var requestHeaders = []; this.isFailure=false; return this.options = Object.extend({ asynchronous:true, evalScripts:true, onComplete: this.onResponse.bind(this), onException:function(t,e){if(this.isFailure)return;this.isFailure=true;this.error(-1,(e.message||e.toString()));}.bind(this) },options || {}); }, collect: function() { var t = new Array('checkbox','radio','text','textarea','password','hidden','select-one','select-multiple'); var body = (this.url.indexOf('?') >= 0 && this.url.indexOf('?') < (this.url.length-1))? this.url.substr(this.url.indexOf('?')+1): null; this.url = this.url.indexOf('?') >= 0? this.url.substring(0, this.url.indexOf('?')):this.url; if(body != null){ return encodeURI(body); } if(null != this.options.fields){ var a = this.options.fields.split(','); body=""; for(var i=0;i<a.length;i++){ var v = null; if(t.indexOf($(a[i]).type,0) >= 0){ v = $F(a[i]); }else{ v = $(a[i]).innerHTML; } if(null==v) v=""; body += a[i]+"="+encodeURI(v)+"&"; } return body.substring(0,body.length-1); } var f; if(null != (f = $(this.options.form)||document.getElementsByName(this.options.form)[0])){ body=""; body=Form.serialize(f); return body; } return null; }, sendRequest: function() { this.reqType = 'XML'; this.options.postBody = this.collect(); this.ri(true); return new Ajax.Request(this.url,this.options); }, sendUpdateRequest: function(target) { this.reqType = 'text'; this.options.postBody = this.collect(); this.ri(true); return new Ajax.Updater(target,this.url,this.options); }, sendPeriodicalUpdateRequest: function(target) { this.reqType = 'text'; this.options.postBody = this.collect(); this.ri(true); return new Ajax.PeriodicalUpdater(target, this.url,this.options); }, onResponse: function(request) { if (null != request && ((request.status >= 200 && request.status < 300) || request.status == 0)) { var isXML = (this.options.type||this.reqType).toUpperCase() == 'XML'; if(isXML) { var xmlDoc = request.responseXML; if ((et = this.isError(xmlDoc)) > 0 && !isUndef(this.error)){ var ei = ""; if(et == 1){ ei = "<p>Request type is XML,but parse the response XML failured. Case:"+ "<br>- "+xmlDoc.documentElement.firstChild.nodeValue +"</p>"+ "<p>Response XML: <br>"+request.responseText.escapeHTML()+"</p>"; } else { ei = xmlDoc.documentElement.getElementsByTagName("error")[0].firstChild.nodeValue; } this.error(request.status,ei); } else if (this.isEmpty(xmlDoc) && !isUndef(this.empty)){ this.empty(); } else { this.handler(request); } } else { var text = request.responseText; if(text.length ==0 && !isUndef(this.empty)){ this.empty(); } else { this.handler(request); } } }else if(null != request){ this.error(request.status,request.responseText); } }, handler:function(r){ if(this.options.postFunction) this.options.postFunction(r); this.ri(false); }, empty:function () { this.ri(false); }, error:function(n,e) { this.ri(false); }, isEmpty: function(xml) { if( xml == null) return true; var root = xml.documentElement; if (root.getElementsByTagName("elements").length == 0 || root.getElementsByTagName("elements")[0].getElementsByTagName("element").length == 0) { return true; } return false; }, isError: function(xml) { var root = xml.documentElement; if (root.nodeName == "parsererror") { return 1; } if(root.getElementsByTagName("error").length == 1){ return 2; } return 0; }, ri:function(b){ if(this.indicator) this.indicator(b); else this._indicator(b); }, _indicator:function (b){ var i = $("bc.indicator"); if(null == i){ new Insertion.Top(document.getElementsByTagName("body")[0], "<div id=\"bc.indicator\" style=\"padding:2px;" + "background-color:#FF3300;border:0px;position:fixed;right:1px;top:1px;"+ "z-index:10000;filter:Alpha(opacity=90);-moz-opacity:0.9;opacity:0.9;"+ "padding-left:15px;visibility:hidden\"><b>Loading......</b></div>"); i = $("bc.indicator"); } this._indicatorWidth=i.offsetWidth; if(b){ i.style.visibility = ''; if(navigator.appVersion.indexOf('MSIE')>0){ i.style.position="absolute"; this.idtp(null); Event.observe(window,"scroll",this.idtp.bindAsEventListener(this)); Event.observe(window,"resize",this.idtp.bindAsEventListener(this)); } }else{ i.style.visibility = 'hidden'; if(navigator.appVersion.indexOf('MSIE')>0){ Event.stopObserving(window,"scroll",this.idtp.bindAsEventListener(this)); Event.stopObserving(window,"resize",this.idtp.bindAsEventListener(this)); } } }, idtp:function(e){ var t= Scroll.position(); var v=$("bc.indicator"); v.style.top=t[1]+"px"; v.innerHTML=v.innerHTML; }, _catchEvent: function(l) { var isCatch = false; if (this.options.sourceClass) { eo = document.getElementsByClassName(this.options.sourceClass); for (var i=0; i<eo.length; i++) { Event.observe(eo[i], this.options.eventType, l.bindAsEventListener(this)); } isCatch = true; } else if(this.options.source) { Event.observe(this.options.source, this.options.eventType,l.bindAsEventListener(this)); isCatch = true; } return isCatch; } };
bc.a.Ajax = Class.create(); bc.a.Ajax.prototype = Object.extend(new bc.a.Base(),{ initialize: function(url,options) { this.url=url; this.setOptions(options); } });
bc.a.ForSync = function (){}; bc.a.ForSync = Object.extend(new bc.a.Base(),{ initialize: function(url,options) { this.url = url; this.setOptions(options); this.options.type="text"; this.options.asynchronous=false; this.options.evalScripts=false; }, request: function() { if(this.options.preFunction) if(!this.options.preFunction()) return ; var r=this.sendRequest(); this.handler(r.transport); if(this._trans) return this._trans(r.transport.responseText); else return this.errorMessage||r.transport.responseText; }, handler:function(request) { if(this.options.postFunction){ this.options.postFunction(request); } this.ri(false); }, error:function(n,e){ this.isError=true; this.errorMessage=e; this.ri(false); }, isError:function(){ return this.isError; }, indicator:function(b){ if(this.options.indicator) this.options.indicator(b,$(this.options.target)); } });
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -