This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
Incam_SGD/thirdpartyjs/yui/tools/tools.js

1 line
12 KiB
JavaScript
Raw Normal View History

YAHOO.Tools=function(){keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";regExs={quotes:/\x22/g,startspace:/^\s+/g,endspace:/\s+$/g,striptags:/<\/?[^>]+>/gi,hasbr:/<br/i,hasp:/<p>/i,rbr:/<br>/gi,rbr2:/<br\/>/gi,rendp:/<\/p>/gi,rp:/<p>/gi,base64:/[^A-Za-z0-9\+\/\=]/g,syntaxCheck:/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/};jsonCodes={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\"};return {version:"1.0"};}();YAHOO.Tools.getHeight=function(_1){var _2=$(_2);var h=$D.getStyle(_2,"height");if(h=="auto"){_2.style.zoom=1;h=_2.clientHeight+"px";}return h;};YAHOO.Tools.getCenter=function(_4){var _5=$(_5);var cX=Math.round(($D.getViewportWidth()-parseInt($D.getStyle(_5,"width")))/2);var cY=Math.round(($D.getViewportHeight()-parseInt(this.getHeight(_5)))/2);return [cX,cY];};YAHOO.Tools.makeTextObject=function(_8){return document.createTextNode(_8);};YAHOO.Tools.makeChildren=function(_9,_a){var _b=$(_b);for(var i in _9){_val=_9[i];if(typeof _val=="string"){_val=this.makeTxtObject(_val);}_b.appendChild(_val);}};YAHOO.Tools.styleToCamel=function(_d){var _e=_d.split("-");var _f=_e[0];for(var i=1;i<_e.length;i++){_f+=_e[i].substring(0,1).toUpperCase()+_e[i].substring(1,_e[i].length);}return _f;};YAHOO.Tools.removeQuotes=function(str){var _12=new String(str);return String(_12.replace(regExs.quotes,""));};YAHOO.Tools.trim=function(str){return str.replace(regExs.startspace,"").replace(regExs.endspace,"");};YAHOO.Tools.stripTags=function(str){return str.replace(regExs.striptags,"");};YAHOO.Tools.hasBRs=function(str){return str.match(regExs.hasbr)||str.match(regExs.hasp);};YAHOO.Tools.convertBRs2NLs=function(str){return str.replace(regExs.rbr,"\n").replace(regExs.rbr2,"\n").replace(regExs.rendp,"\n").replace(regExs.rp,"");};YAHOO.Tools.stringRepeat=function(str,_18){return new Array(_18+1).join(str);};YAHOO.Tools.stringReverse=function(str){var _1a="";for(i=0;i<str.length;i++){_1a=_1a+str.charAt((str.length-1)-i);}return _1a;};YAHOO.Tools.printf=function(){var num=arguments.length;var _1c=arguments[0];for(var i=1;i<num;i++){var _1e="\\{"+(i-1)+"\\}";var re=new RegExp(_1e,"g");_1c=_1c.replace(re,arguments[i]);}return _1c;};YAHOO.Tools.setStyleString=function(el,str){var _22=str.split(";");for(x in _22){if(x){__tmp=YAHOO.Tools.trim(_22[x]);__tmp=_22[x].split(":");if(__tmp[0]&&__tmp[1]){var _23=YAHOO.Tools.trim(__tmp[0]);var _24=YAHOO.Tools.trim(__tmp[1]);if(_23&&_24){if(_23.indexOf("-")!=-1){_23=YAHOO.Tools.styleToCamel(_23);}$D.setStyle(el,_23,_24);}}}}};YAHOO.Tools.getSelection=function(_25,_26){if(!_25){_25=document;}if(!_26){_26=window;}if(_25.selection){return _25.selection;}return _26.getSelection();};YAHOO.Tools.removeElement=function(el){if(!(el instanceof Array)){el=new Array($(el));}for(var i=0;i<el.length;i++){if(el[i].parentNode){el[i].parentNode.removeChild(el);}}};YAHOO.Tools.setCookie=function(_29,_2a,_2b,_2c,_2d,_2e){var _2f=arguments;var _30=arguments.length;var _31=(_30>2)?_2f[2]:null;var _32=(_30>3)?_2f[3]:"/";var _33=(_30>4)?_2f[4]:null;var _34=(_30>5)?_2f[5]:false;document.cookie=_29+"="+escape(_2a)+((_31==null)?"":("; expires="+_31.toGMTString()))+((_32==null)?"":("; path="+_32))+((_33==null)?"":("; domain="+_33))+((_34==true)?"; secure":"");};YAHOO.Tools.getCookie=function(_35){var dc=document.cookie;var _37=_35+"=";var _38=dc.indexOf("; "+_37);if(_38==-1){_38=dc.indexOf(_37);if(_38!=0){return null;}}else{_38+=2;}var end=document.cookie.indexOf(";",_38);if(end==-1){end=dc.length;}return unescape(dc.substring(_38+_37.length,end));};YAHOO.Tools.deleteCookie=function(_3a,_3b,_3c){if(getCookie(_3a)){document.cookie=_3a+"="+((_3b)?"; path="+_3b:"")+((_3c)?"; domain="+_3c:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}};YAHOO.Tools.getBrowserEngine=function(){var _3d=((window.opera&&window.opera.version)?true:false);var _3e=((navigator.vendor&&navigator.vendor.indexOf("Apple")!=-1)?true:false);var _3f=((document.getElementById&&!document.all&&!_3d&&!_3e)?true:false);var _40=((window.ActiveXObject)?true:false);var _41=false;if(_40){if(typeof document.body