📄 qzfl.js
字号:
return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},elasticEaseOut:function(t,b,c,d,a,p){if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*0.3;if(!a||a<Math.abs(c)){a=c;var s=p/4;}else{var s=p/(2*Math.PI)*Math.asin(c/a);}return(a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b);},elasticEaseInOut:function(t,b,c,d,a,p){if(t==0){return b;}if((t/=d/2)==2){return b+c;}if(!p){var p=d*(0.3*1.5);}if(!a||a<Math.abs(c)){var a=c;var s=p/4;}else{var s=p/(2*Math.PI)*Math.asin(c/a);}if(t<1){return-0.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;}return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*0.5+c+b;}});QZFL.Tween=function(el,property,func,startValue,finishValue,duration){this._func=func||QZFL.transitions.simple;this._obj=QZFL.dom.get(el);this.isColor=/^#/.test(startValue);this._prop=property;var reSuffix=/\d+([a-z%]+)/i.exec(startValue);this._suffix=reSuffix?reSuffix[1]:"";this._startValue=this.isColor?0:parseFloat(startValue);this._finishValue=this.isColor?100:parseFloat(finishValue);if(this.isColor){this._startColor=QZFL.css.convertHexColor(startValue);this._finishColor=QZFL.css.convertHexColor(finishValue);}this._duration=duration||10;this._timeCount=0;this._startTime=0;this._changeValue=this._finishValue-this._startValue;this.currentValue=0;this.isPlayed=false;this.isLoop=false;this.onMotionStart=QZFL.emptyFn;this.onMotionChange=QZFL.emptyFn;this.onMotionStop=QZFL.emptyFn;};QZFL.Tween.prototype.start=function(loop){this._reloadTimer();this.isPlayed=true;this._runTime();this.isLoop=loop?true:false;this.onMotionStart.apply(this);return"d"};QZFL.Tween.prototype.pause=function(){this.isPlayed=false;};QZFL.Tween.prototype.stop=function(){this.isPlayed=false;this._playTime(this._duration+0.1);};QZFL.Tween.prototype._reloadTimer=function(){this._startTime=new Date().getTime()-this._timeCount*1000;};QZFL.Tween.prototype._playTime=function(time){var _isEnd=false;if(time>this._duration){time=this._duration;_isEnd=true;}var pValue=this._func(time,this._startValue,this._changeValue,this._duration);this.currentValue=/(opacity)/i.test(this._prop)?pValue:Math.round(pValue);if(this.isColor){this.currentValue=this.getColor(this._startColor,this._finishColor,pValue);}var _try2setCSS=QZFL.dom.setStyle(this._obj,this._prop,this.currentValue+this._suffix);if(!_try2setCSS){this._obj[this._prop]=this.currentValue+this._suffix;}this.onMotionChange.apply(this,[this._obj,this._prop,this.currentValue]);if(_isEnd){this.isPlayed=false;if(this.isLoop){this.isPlayed=true;this._reloadTimer();}this.onMotionStop.apply(this);if(window.CollectGarbage)CollectGarbage();}};QZFL.Tween.prototype._runTime=function(){var o=this;if(o.isPlayed){o._playTime((new Date().getTime()-this._startTime)/1000);setTimeout(function(){o._runTime.apply(o,[])},0);}};QZFL.Tween.prototype.getPercent=function(){return(this.currentValue-this._startValue)/this._changeValue*100;};QZFL.Tween.prototype.swapValue=function(){if(this.isColor){var tempValue=this._startColor.join(",");this._startColor=this._finishColor;this._finishColor=tempValue.split(",");}else{var tempValue=this._startValue;this._startValue=this._finishValue;this._finishValue=tempValue;this._changeValue=this._finishValue-this._startValue;}};QZFL.Tween.prototype.getColor=function(startColor,finishColor,percent){var _sc=startColor;var _fc=finishColor;var _color=[];if(percent>100){percent=100;}if(percent<0){percent=0;}for(var i=0;i<3;i++){_color[i]=Math.floor(_sc[i]*1+(percent/100)*(_fc[i]-_sc[i])).toString(16);if(_color[i].length<2){_color[i]="0"+_color[i];}}return"#"+_color.join("");};QZFL.transitions={simple:function(time,startValue,changeValue,duration){return changeValue*time/duration+startValue;},regularEaseIn:function(t,b,c,d){return c*(t/=d)*t+b;},regularEaseOut:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},regularEaseInOut:function(t,b,c,d){if((t/=d/2)<1){return c/2*t*t+b;}return-c/2*((--t)*(t-2)-1)+b;}}QZFL.XHR=function(actionURL,cname,method,data,isAsync,nocache){if(!isURL(actionURL)){rt.error("error actionURL -> {0:Q} in QZFL.XHR construct!",actionURL);return null;}if(!cname){cname="_xhrInstence_"+(QZFL.XHR.counter+1);}var prot;if(QZFL.XHR.instance[cname]instanceof QZFL.XHR){prot=QZFL.XHR.instance[cname];}else{prot=(QZFL.XHR.instance[cname]=this);QZFL.XHR.counter++;}prot._name=cname;prot._nc=!!nocache;prot._method=(!isString(method)||method.toUpperCase()!="GET")?"POST":(method="GET");prot._isAsync=(!(isAsync===false))?true:isAsync;prot._uri=actionURL;prot._data=(isHashMap(data)||typeof(data)=='string')?data:null;prot._sender=null;prot._isHeaderSetted=false;this.onSuccess=QZFL.emptyFn;this.onError=QZFL.emptyFn;this.charset="gb2312";this.proxyPath="";return prot;}QZFL.XHR.instance={};QZFL.XHR.counter=0;QZFL.XHR._errCodeMap={400:{msg:'Bad Request'},401:{msg:'Unauthorized'},403:{msg:'Forbidden'},404:{msg:'Not Found'},999:{msg:'Proxy page error'},1000:{msg:'Bad Response'},1001:{msg:'No Network'},1002:{msg:'No Data'},1003:{msg:'Eval Error'}};QZFL.XHR.xsend=function(o,uri){if(!(o instanceof QZFL.XHR)){return false;}if(ua.firefox&&ua.firefox<3){rt.error("can't surport xsite in firefox!");return false;}function clear(obj){try{obj._sender=obj._sender.callback=obj._sender.errorCallback=obj._sender.onreadystatechange=null;}catch(ignore){}if(ua.safari||ua.opera){setTimeout('removeNode($("_xsend_frm_'+obj._name+'"))',50);}else{removeNode($("_xsend_frm_"+obj._name));}}if(o._sender===null||o._sender===void(0)){var sender=document.createElement("iframe");sender.id="_xsend_frm_"+o._name;sender.style.width=sender.style.height=sender.style.borderWidth="0";document.body.appendChild(sender);sender.callback=QZFL.event.bind(o,function(data){o.onSuccess(data);clear(o);});sender.errorCallback=QZFL.event.bind(o,function(num){o.onError(QZFL.XHR._errCodeMap[num]);clear(o);});o._sender=sender;}var tmp=QZFL.config.gbEncoderPath;o.GBEncoderPath=tmp?tmp:"";o._sender.src=uri.protocol+"://"+uri.host+(this.proxyPath?this.proxyPath:"/xhr_proxy_gbk.html");return true;}QZFL.XHR.prototype.send=function(){if(this._method=='POST'&&this._data==null){rt.warn("QZFL.XHR -> {0:q}, can't send data 'null'!",this._name);return false;}var u=new URI(this._uri);if(u==null){rt.warn("QZFL.XHR -> {0:q}, bad url",this._name);return false;}if(u.host!=location.host){return QZFL.XHR.xsend(this,u);}if(this._sender===null||this._sender===void(0)){var sender=tryThese(function(){return new XMLHttpRequest();},function(){return new ActiveXObject("Msxml2.XMLHTTP");},function(){return new ActiveXObject("Microsoft.XMLHTTP");})||null;if(!sender){rt.error("QZFL.XHR -> {0:q}, create xhr object faild!",this._name);return false;}this._sender=sender;}try{this._sender.open(this._method,this._uri,this._isAsync);}catch(err){rt.error("exception when opening connection to {0:q}:{1}",this._uri,err);return false;}if(this._method=='POST'&&!this._isHeaderSetted){this._sender.setRequestHeader('Content-Type','application/x-www-form-urlencoded');this._isHeaderSetted=true;}if(this._nc){this._sender.setRequestHeader('If-Modified-Since','Thu, 1 Jan 1970 00:00:00 GMT');this._sender.setRequestHeader('Cache-Control','no-cache');}var d=genHttpParamString(this._data);this._sender.onreadystatechange=QZFL.event.bind(this,function(){try{if(this._sender.readyState==4){if(this._sender.status>=200&&this._sender.status<300){this.onSuccess({text:this._sender.responseText,xmlDom:this._sender.responseXML});}else{if(ua.safari&&(typeof(this._sender.status)=='undefined')){this.onError(QZFL.XHR._errCodeMap[1002]);}else{this.onError(QZFL.XHR._errCodeMap[this._sender.status]);}}delete this._sender;this._sender=null;}}catch(err){rt.error("unknow exception in QZFL.XHR.prototype.send()");}});this._sender.send(d);return true;};QZFL.XHR.prototype.destroy=function(){var n=this._name;delete QZFL.XHR.instance[n]._sender;QZFL.XHR.instance[n]._sender=null;delete QZFL.XHR.instance[n];QZFL.XHR.counter--;return null;};QZFL.cookie={set:function(name,value,domain,path,hour){if(hour){var today=new Date();var expire=new Date();expire.setTime(today.getTime()+3600000*hour);}document.cookie=name+"="+value+"; "+(hour?("expires="+expire.toGMTString()+"; "):"")+(path?("path="+path+"; "):"path=/; ")+(domain?("domain="+domain+";"):("domain="+QZFL.config.domainPrefix+";"));return true;},get:function(name){var r=new RegExp("(?:^|;+|\\s+)"+name+"=([^;]*)");var m=document.cookie.match(r);return(!m?"":m[1]);},del:function(name,domain,path){document.cookie=name+"=; expires=Mon, 26 Jul 1997 05:00:00 GMT; "+(path?("path="+path+"; "):"path=/; ")+(domain?("domain="+domain+";"):("domain="+QZFL.config.domainPrefix+";"));}};QZFL.css={getClassRegEx:function(className){var re=QZFL.css.classNameCache[className];if(!re){re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');QZFL.css.classNameCache[className]=re;}return re;},convertHexColor:function(color){color=/^#/.test(color)?color.substr(1):color;var reColor=new RegExp("\\w{2}","ig");color=color.match(reColor);if(!color||color.length<3){return[0,0,0]}var r=parseInt(color[0],16);var g=parseInt(color[1],16);var b=parseInt(color[2],16);return[r,g,b];},styleSheets:{},getStyleSheetById:function(id){try{return QZFL.dom.get(id).sheet||document.styleSheets[id];}catch(e){return null}},getRulesBySheet:function(sheetId){var ss=QZFL.css.getStyleSheetById(sheetId);if(ss){try{return ss.cssRules||ss.rules;}catch(e){return null}}else{return null}},getRuleBySelector:function(sheetId,selector){var _ss=this.getStyleSheetById(sheetId);if(!_ss.cacheSelector){_ss.cacheSelector={}};if(_ss){var _rs=_ss.cssRules||_ss.rules;var re=new RegExp('^'+selector+'$',"i");var _cs=_ss.cacheSelector[selector];if(_cs&&re.test(_rs[_cs].selectorText)){return _rs[_cs];}else{for(var i=0;i<_rs.length;i++){if(re.test(_rs[i].selectorText)){_ss.cacheSelector[selector]=i;return _rs[i];}}return null;}}else{return null;}},insertCSSLink:function(url,id,sco){var dom=document;if(sco!=null){var dom=sco.document;}if(id!=null&&dom.getElementById(id)!=null){return;}var cssLink=dom.createElement("link");if(id){cssLink.id=id;}cssLink.rel="stylesheet";cssLink.rev="stylesheet";cssLink.type="text/css";cssLink.media="screen";cssLink.href=url;dom.getElementsByTagName("head")[0].appendChild(cssLink);return cssLink.sheet||cssLink;},insertStyleSheet:function(sheetId){var ss=document.createElement("style");ss.id=sheetId;document.getElementsByTagName("head")[0].appendChild(ss);return ss.sheet||ss;},removeStyleSheet:function(id){var _ss=this.getStyleSheetById(id);if(_ss){var own=_ss.owningElement||_ss.ownerNode;QZFL.dom.removeElement(own);}},hasClassName:function(elem,cname){return(elem&&cname)?new RegExp('\\b'+trim(cname)+'\\b').test(elem.className):false;},swapClassName:function(elements,class1,class2){function _swap(el,c1,c2){if(QZFL.css.hasClassName(el,c1)){el.className=el.className.replace(c1,c2);}else if(QZFL.css.hasClassName(el,c2)){el.className=el.className.replace(c2,c1);}}if(elements.constructor!=Array){elements=[elements];}for(var i=0,len=elements.length;i<len;i++){_swap(elements[i],class1,class2);}},replaceClassName:function(elements,sourceClass,targetClass){function _replace(el,c1,c2){if(QZFL.css.hasClassName(el,c1)){el.className=el.className.replace(c1,c2);}}if(elements.constructor!=Array){elements=[elements];}for(var i=0,len=elements.length;i<len;i++){_replace(elements[i],sourceClass,targetClass);}},addClassName:function(elem,cname){if(elem&&cname){if(elem.className){if(QZFL.css.hasClassName(elem,cname)){return false;}else{elem.className+=' '+trim(cname);return true;}}else{elem.className=cname;return true;}}else{return false;}},removeClassName:function(elem,cname){if(elem&&cname&&elem.className){var old=elem.className;elem.className=trim(elem.className.replace(new RegExp('\\b'+trim(cname)+'\\b'),''));return elem.className!=old;}else{return false;}},toggleClassName:function(elem,cname){var r=QZFL.css;if(r.hasClassName(elem,cname)){r.removeClassName(elem,cname);}else{r.addClassName(elem,cname);}}}QZFL.css.classNameCache={};QZFL.debug={errorLogs:[],startDebug:function(){window.onerror=function(msg,url,line){var urls=(url||"").replace(/\\/g,"/").split("/");QZFL.console.print(msg+"<br/>"+urls[urls.length-1]+" (line:"+line+")",1);QZFL.debug.errorLogs.push(msg);return false;}},stopDebug:function(){window.onerror=null;},clearErrorLog:function(){this.errorLogs=[];},showLog:function(){var o=ENV.get("debug_out");if(!!o){o.innerHTML=nl2br(escHTML(this.errorLogs.join("\n")));}},getLogString:function(){return(this.errorLogs.join("\n"));}};QZFL.runTime=(function(){function isDebugMode(){return QZFL.enviroment.get("debug");}function log(msg,type){var info;if(isDebugMode()){info=msg+'\n=STACK=\n'+stack();}else{if(type=='error'){info=msg;}else if(type=='warn'){}}QZFL.debug.errorLogs.push(info);}function warn(sf,args){log(write.apply(null,arguments),'warn');}function error(sf,args){log(write.apply(null,arguments),'error');}function stack(e,a){function genTrace(ee,aa){if(ee.stack){return ee.stack;}else if(ee.message.indexOf("\nBacktrace:\n")>=0){var cnt=0;return ee.message.split("\nBacktrace:\n")[1].replace(/\s*\n\s*/g,function(){cnt++;return(cnt%2==0)?"\n":" @ ";});}else{var entry=(aa.callee==stack)?aa.callee.caller:aa.callee;var eas=entry.arguments;var r=[];for(var i=0,len=eas.length;i<len;i++){r.push((typeof eas[i]=='undefined')?("<u>"):((eas[i]===null)?("<n>"):(eas[i])));}var fnp=/function\s+([^\s\(]+)\(/;var fname=fnp.test(entry.toString())?(fnp.exec(entry.toString())[1]):("<ANON>");return(fname+"("+r.join()+");").replace(/\n/g,"");}}var res;if((e instanceof Error)&&(typeof arguments=='object')&&(!!arguments.callee)){res=genTrace(e,a);}else{try{({}).sds();}catch(err){res=genTrace(err,arguments);}}return res.replace(/\n/g," <= ");}return{stack:stack,warn:warn,error:error};})();var rt=QZFL.runTime;QZFL.JsLoader=function(){this.loaded=false;this.debug=true;this.onload=QZFL.emptyFn;this.onerror=QZFL.emptyFn;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -