Posted By

Piotrek290 on 09/02/09


Tagged

javascript js library code SoQ uncompressed


Versions (?)

SoQ Code - full library - uncompressed


 / Published in: JavaScript
 

  1. // Script name: SoQ JS
  2. // Author: Nicko278 and Dealis
  3. // Lastest version: 1.4.2
  4.  
  5. eJS = $ = function(a1,a2,a3){
  6. if(typeof a1=='function')$.document(a1);
  7. if(typeof a1=='string')var a1=$.nA($.init(a1,a2||0,a3||0));
  8. if(!a1.eJS){
  9. for(rx in $.e)a1[rx]=$.e[rx];
  10. a1.eJS=1;
  11. a1.now={};
  12. a1.evt={};
  13. };
  14. return a1;
  15. }
  16.  
  17. $.init = function(a1,a2,a3){
  18. var all=[];
  19. var a2=a2||document;
  20. var a3=a3||'';
  21. var a1s=a1.split(/\s*\,\s*(?!\d)/i);
  22.  
  23. if(a1s.length>1){
  24. for(var x=0;x<a1s.length;x++){
  25. all.push(eJSinit(a1s[x],a2,a3));
  26. };
  27. var all = merge.apply(0,all);
  28. return all.length?all.length==1?all[0]:all:null;
  29. }
  30.  
  31. if(a1.replace(/\s/gi,'')=='')return a2;
  32. var a1 = a1.replace(/\s+/gi,' ').replace(/^\s/,'');
  33. var el=a1.split(' ')[0].replace(/\[.*?\]/gi,'');
  34. if(el.replace(/\s/gi,'')=='+')return eJSinit(a1.slice(el.length+1),a2,'+');
  35. if(el.replace(/\s/gi,'')=='>')return eJSinit(a1.slice(el.length+1),a2,'>');
  36. var nm = el.match(/\(([\-\d\,]+)\)/);
  37. var nm = nm?nm[1].split(','):'';
  38. var co2 = el.match(/\=(\d+)(\,\d+)?/i);
  39. var co = co2?co2[1]:1;
  40. var od = co2&&co2[2]?(co2[2].slice(1).num()-1)%co:co-1;
  41. var szz = a3=='+'?a2.parentNode.childNodes:a3=='>'?a2.childNodes:a2.getElementsByTagName(el.match(/^(\w+)/i)?el.match(/^(\w+)/i)[1]:'*');
  42. var el = el.replace(/^(\w+)/gi,'[tagName=$1]').replace(/\.(\w+)/gi,'[className~=$1]').replace(/\#(\w+)/gi,'[id=$1]').replace(/\([\d\-\,]\)/gi,'')+a1.slice(el.length);
  43. var els = el.match(/\[(.+?)\]/gi);
  44. var els = els||[];
  45. X:for(var x=0;x<szz.length;x++){
  46. var sz = szz[x];
  47. for(var z=0;z<els.length;z++){
  48. var elsz = els[z].slice(1,-1);
  49. var odd = elsz.match(/\!?[\~\^\$\*]?\=\=?/i);
  50. var odd = odd?odd[0]:'!=';
  51. var naz = elsz.split(odd)[0];
  52. var war = elsz.slice(naz.length+odd.length).toLowerCase();
  53. if(odd.search('==')==-1)var war = war.replace(/(\W)/gi,'\\$1');
  54. if(naz.charAt(0)=='.')var war = war.color().toHex();
  55. var szw = naz.charAt(0)=='.'?$.cur(sz,naz.slice(1)).toHex():sz[naz];var szw=szw?szw.toString().toLowerCase():'';
  56. var odz = odd.replace('!','').replace('==','=');
  57. var wrn = szw.search(RegExp(odz=='='?'^'+war+'$':odz=='~='?'(^|\\W)'+war+'(\\W|$)':odz=='^='?'^'+war:odz=='$='?war+'$':odz=='*='?war:''),'gi');
  58. if(odd.search('!')!=-1?wrn!=-1:wrn==-1)continue X;
  59. }
  60. if(a2!=sz&&sz.tagName&&(ns=$.init(a1.slice(a1.split(' ')[0].length),sz)))all.push($(ns));
  61. };
  62.  
  63. var all2 = nm?[]:all;
  64. if(nm)for(var x=0;x<nm.length;x++){
  65. var nma = nm[x].match(/(\-?\d+)\-(\-?\d+)/);
  66. var nma = nma?nma:[0,nm[x],nm[x]];
  67. var xx1 = nma[1]<0?all.length+nma[1].num():nma[1].num();
  68. var xx2 = nma[2]<0?all.length+nma[2].num():nma[2].num();
  69. var xx3 = Math.min(xx1,xx2);
  70. var xx4 = Math.max(xx1,xx2)+1;
  71. for(var xx=xx3;xx<xx4;xx++)if(all[xx-1])all2.push(all[xx-1]);
  72. }
  73.  
  74. var all3=[];
  75. for(var x=od;x<all2.length;x+=co.num())all3.push(all2[x]);
  76. var all3 = $.merge.apply(0,all3);
  77.  
  78. return all3.length?all3:[];
  79. }
  80.  
  81. $.extend = function(a1){
  82. for(x in a1){
  83. $.e[x] = a1[x];
  84. }
  85. };
  86.  
  87. $.create = function(){
  88. return $(document.createElement());
  89. }
  90.  
  91. $.load = function(a1){
  92. return $.o[a1||0];
  93. }
  94.  
  95. $.nA = function(a1){
  96. return a1.length==1?a1[0]:a1;
  97. }
  98.  
  99. $.merge = function(){
  100. var ret=[];
  101. for(var m=0;m<arguments.length;m++){
  102. if(arguments[m].constructor==Array){
  103. for(var mm=0;mm<arguments[m].length;mm++)ret.push(arguments[m][mm]);
  104. } else{
  105. ret.push(arguments[m]);
  106. }
  107. };
  108.  
  109. return ret;
  110. }
  111.  
  112. $.rcss = function(a1){
  113. var dor = ['border!-width','border!-color','border!-style','margin!','padding!'];
  114. var kie = ['top','right','bottom','left'];
  115. var ret = '';
  116.  
  117. for(var r=0;r<5;r++){
  118. var mth = a1.match(RegExp(dor[r].replace('!','')+'\s*\:\s*([^;]+)\;','i'));
  119. var mth2 = a1.match(RegExp(dor[r].replace('!','')+'($|\s|\,)','i'));
  120. if(mth){
  121. for(var rr=0;rr<4;rr++)ret+=dor[r].replace('!','-'+kie[rr])+':'+mth[1].split(' ')[rr%mth[1].split(' ').length]+'; ';
  122. var a1 = a1.replace(mth[0],ret);
  123. } else if(mth2) {
  124. for(var rr=0;rr<4;rr++)ret+=dor[r].replace('!','-'+kie[rr])+', ';
  125. var a1 = a1.replace(mth2[0],ret);
  126. }
  127. };
  128.  
  129. return a1;
  130. }
  131.  
  132. $.zero = function(a1,a2){
  133. return '0'.x(a2-a1.toString().length)+a1;
  134. }
  135.  
  136. $.interval = function(a1,a2,a3,a4){
  137. var a4 = a4||0;
  138. this.now = this.now||{};
  139. this.now[a4] = 0;
  140. var arg = [];
  141.  
  142. for(var x=4;x<arguments.length;x++){
  143. arg.push(arguments[x]);
  144. };
  145.  
  146. arg.push(0);
  147. $.t.push([a1,a2,1,this]);
  148. $.t.push(arg);
  149. this.now[a4] = setInterval(Function('var li='+($.t.length-2)+';$.t[li+1][$.t[li+1].length-1]++;'+(a3?'if(($.t[li][2]++)=='+a3+'){clearInterval($.t[li][3].now["'+a4+'"]);delete $.t[li][3].now["'+a4+'"];};':'')+'$.t[li][0].apply($.t[li][3],$.t[li+1]);'),a2);
  150. }
  151.  
  152. $.between = function(a1,a2,a3){
  153. var a3 = a3||0.5;
  154. if(a1.search(/\#[0-9a-f]+/gi)!=-1||a1.search(/rgb/gi)!=-1){
  155. var a1 = a1.toHex().slice(1).replace(/[0-9a-f]{2}/gi, function(a1){
  156. return $.zero(parseInt(a1,16),3);
  157. }).share(3);
  158.  
  159. var a2 = a2.toHex().slice(1).replace(/[0-9a-f]{2}/gi, function(a1){
  160. return $.zero(parseInt(a1,16),3);
  161. }).share(3);
  162.  
  163. return '#'+$.zero((a1[0]-(a1[0]-a2[0])*a3).round().toString(16),2)+$.zero((a1[1]-(a1[1]-a2[1])*a3).round().toString(16),2)+$.zero((a1[2]-(a1[2]-a2[2])*a3).round().toString(16),2);
  164. } else if(a1.search(/\d+/gi)!=-1){
  165. return (a1.num()-((a1.num()-a2.num())*a3))+(a1.match(/[a-z\%]+/gi)?a1.match(/[a-z\%]+/gi)[0]:'');
  166. } else {
  167. return a2;
  168. }
  169. }
  170.  
  171. $.cur = function(a1,a2){
  172. var ret = window.getComputedStyle?window.opera&&!a1.style[a2]&&(a2=='left'||a2=='top')?
  173. a1['client'+a2.charAt(0).toUpperCase()+a2.slice(1)]+'px':window.getComputedStyle(a1,null).getPropertyValue(a2):(a1.currentStyle[a2.camelCase()]=='auto'?
  174. (a2=='width' ? a1.offsetWidth-$.cur(a1,'padding-left').num()-$.cur(a1,'padding-right').num()-$.cur(a1,'border-left-width').num()-$.cur(a1,'border-right-width').num()+'px':a2=='height'?
  175. a1.offsetHeight-$.cur(a1,'padding-top').num()-$.cur(a1,'padding-bottom').num()-$.cur(a1,'border-top-width').num()-$.cur(a1,'border-bottom-width').num()+'px':'0px') :
  176. a1.currentStyle[a2.camelCase()]||0);
  177.  
  178. if(ret=='normal')ret='0px';
  179. return ret;
  180. }
  181.  
  182. $.obj = function(a1){
  183. if(typeof a1=='string'){
  184. var ret = {};
  185. var spl = a1.split(/\s*\;\s*/gi);
  186.  
  187. for(var x=0;x<spl.length;x++){
  188. spl2 = spl[x].split(/\:\s*/gi);
  189. if(spl[x]!='')ret[spl2[0]]=spl2[1];
  190. };
  191.  
  192. return ret;
  193. } else { return a1;}
  194. // } else return a1;}
  195. }
  196.  
  197. $.each = function(a1){
  198. var th = this.constructor==Array?this:[this];
  199. var a1 = typeof a1=='string'?Function(a1):a1;
  200. var len = th.length;
  201.  
  202. for(var e=0;e<len;e++){
  203. var fu = a1.call(th[e],e,th);
  204. if(fu)th[e]=fu;
  205. };
  206. return th;
  207. }
  208.  
  209. $.rand = function(a1,a2){
  210. return Math.round(Math.random()*(a2-a1))+a1;
  211. }
  212.  
  213. $.document = function(a1){
  214. var obj=window;
  215. var type='load';
  216.  
  217. if(obj.addEventListener){
  218. obj.addEventListener(type,a1,false);
  219. } else if (obj.attachEvent){
  220. obj["e"+type+a1] = a1;
  221. obj[type+a1] = function(){
  222. obj["e"+type+a1](window.event);
  223. };
  224.  
  225. obj.attachEvent("on"+type, obj[type+a1]);
  226. }
  227. }
  228.  
  229. $.le=0;
  230. $.t=[];
  231. $.o={};
  232.  
  233. $.e = {
  234. on : function(a1,a2,a3){
  235. var tt = this.array();
  236. var a3 = a3||'no'+($.le++);
  237.  
  238. for(var y=0;y<tt.length;y++){
  239. if(window.addEventListener){
  240. var a2c = a2;
  241. tt[y].addEventListener(a1,a2c,0);
  242. } else {
  243. var a2c = Function('event','$.t['+($.t.push(a2)-1)+'].call(event.srcElement,event);');
  244. tt[y].attachEvent('on'+a1,a2c);
  245. };
  246.  
  247. tt[y].evt=tt[y].evt||{};
  248. tt[y].evt[a1+'_'+a3]=a2c;
  249. };
  250.  
  251. return this;
  252. },
  253.  
  254. no : function(a1,a2){
  255. var tt = this.array();
  256. for(var y=0;y<tt.length;y++){
  257. var te = tt[y].event(a1);
  258. for(x in te){
  259. if(!a2||x.slice(x.split('_')[0].length+1)==a2){
  260. if(window.removeEventListener)tt[y].removeEventListener(x.split('_')[0],tt[y].evt[x],false);
  261. else tt[y].detachEvent('on'+x.split('_')[0],tt[y].evt[x]);
  262. }
  263. }
  264. };
  265.  
  266. return this;
  267. },
  268.  
  269. event : function(a1,a2){
  270. var ret = {};
  271. var tt = this.array();
  272. if(typeof a1=='object'){
  273. for(var y=0;y<tt.length;y++)for(x in a1)tt[y].on(x.split('_')[0],a1[x],x.slice(x.split('_')[0].length+1));
  274. return this;
  275. } else for(var y=0;y<tt.length;y++)for(x in tt[y].evt)if(!a1||a1=='all'||x.split('_')[0]==a1){
  276. if(a2&&x==a1+'_'+a2){
  277. return tt[y].evt[x]
  278. } else{
  279. ret[x]=tt[y].evt[x];
  280. }
  281. }
  282.  
  283. return ret;
  284. },
  285.  
  286. css : function(a1){
  287. if(typeof a1=='string'&&a1.search(/\:/gi)==-1){
  288. return $.cur(this.array()[0],a1);
  289. };
  290.  
  291. tt = this.array();
  292. var a1 = $.obj(a1);
  293.  
  294. for(var y=0;y<tt.length;y++){
  295. for(x in a1)tt[y].style[x.camelCase()]=a1[x];
  296. }
  297.  
  298. return this;
  299. },
  300.  
  301. anim : function(a1,a2,a3,a4,a5){
  302. var a1 = $.obj($.rcss(a1));
  303. var a2 = a2||1000;
  304. var a3 = a3||a2/25;
  305. var a4 = a4||0;
  306. var a5 = typeof a5=='function'?a5:typeof a5=='string'?Function(a5):Function('');
  307.  
  308. tt = this.array();
  309. var ttl = tt.length;
  310. var xx = 0;
  311.  
  312. for(var y=0;y<ttl;y++){
  313. for(x in a1){
  314. if(tt[y].style[x.camelCase()]!=undefined){
  315. $.interval.call(tt[y],Function("a1","a2","a3","a4","a5","a1.style."+x.camelCase()+"=$.between(a2,'"+a1[x]+"',"+(a4==0||a4==3?"Math.abs(Math.sin(Math.PI/2*(1/"+a3+")*a5)));":a4==1?"(1-Math.sin(Math.PI/2*(1-((1/"+a3+")*a5)))));":"(1/"+a3+")*"+(a4==4?"(a5%"+a3+"||1));":"a5);"))+(!xx++?"if(a5=="+a3+")$.interval.call(a1,function(a1,a2){a1.call(a2);},50,1,'an',a3,a4);":"")),a2/a3,a4==3||a4==4?0:a3,x,tt[y],$.cur(tt[y],x).color(),a5,this);
  316. } else {
  317. $.interval.call(tt[0],function(a1,a2){
  318. a1.call(a2);
  319. }, a2+50,1, 'anim', a5, this);
  320. }
  321. }
  322. };
  323.  
  324. return this;
  325. },
  326.  
  327. stop : function(a11,a111){
  328. ttt = this.array();
  329. var a11 = $.rcss(a11||'');
  330. var a12 = a11.split(/\s*[\,\;]\s*/gi);
  331. for(var z=0;z<a12.length;z++){
  332. for(var y=0;y<ttt.length;y++){
  333. if(ttt[y].now){
  334. for(x in ttt[y].now){
  335. if(a111?(a12[z]!=x):(!a11||a12[z]==x)){
  336. clearInterval(ttt[y].now[x]);
  337. delete ttt[y].now[x];
  338. }
  339. }
  340. }
  341. }
  342. };
  343.  
  344. if(!a11)clearInterval(ttt[0].now['anim']);
  345. return this;
  346. },
  347.  
  348. array : function(){
  349. return this.constructor==Array?this:[this];
  350. },
  351.  
  352. remove : function(){
  353. tt = this.array();
  354. for(var y=0;y<tt.length;y++){
  355. if(tt[y].parentNode)tt[y].parentNode.removeChild(tt[y]);
  356. };
  357.  
  358. return this;
  359. },
  360.  
  361. next : function(a1){
  362. tt = this.array();
  363. Y:for(var y=0;y<tt.length;y++){
  364. var tns = tt[y].nextSibling;
  365. while(tns){
  366. if(tns.tagName){
  367. tt[y] = tns;
  368. break Y;
  369. } else {
  370. tns = tns.nextSibling;
  371. }
  372. };
  373. if(a1)tt[y]=0;
  374. };
  375. return $($.nA(tt));
  376. },
  377.  
  378. prev : function(a1){
  379. tt = this.array();
  380. Y:for(var y=0;y<tt.length;y++){
  381. var tns = tt[y].previousSibling;
  382. while(tns){
  383. if(tns.tagName){
  384. tt[y] = tns;
  385. break Y;
  386. } else {
  387. tns = tns.previousSibling;
  388. }
  389. };
  390. if(a1)tt[y]=0;
  391. };
  392.  
  393. return $($.nA(tt));
  394. },
  395.  
  396. parent : function(){
  397. if(this.length)for(var y=0;y<this.length;y++){
  398. this[y]=this[y].parentNode;
  399. } else return this.parentNode;return this;
  400. },
  401.  
  402. empty : function(){
  403. tt = this.array();
  404. for(var y=0;y<tt.length;y++){
  405. tt[y].innerHTML='';
  406. };
  407.  
  408. return this;
  409. },
  410.  
  411. inneR : function(a1,a2,a3){
  412. if(a1){
  413. var tt = this.array();
  414. for(var y=0;y<tt.length;y++){
  415. var a11 = typeof a1=='function'?a1.call(tt[y],y,tt):a1;
  416. var a12 = a11.constructor==Array?a11[a3?y%a11.length:y]||tt[y][a2==2?'value':'innerHTML']:a11;
  417.  
  418. if(a2==1)tt[y].empty().create(document.createTextNode(a12));
  419. else if(a2==2)tt[y].value=a12;
  420. else tt[y].innerHTML = a12.replace(/^\.\.|\.\.$/gi,tt[y].innerHTML).replace(/\.(-?\d+)\./gi,function(a1,a2){
  421. return y+a2.num();
  422. })
  423. };
  424.  
  425. return this;
  426. };
  427.  
  428. return $($.nA(this.array().each("return this."+(a2==1?"innerHTML.replace(/\<.+?\>/gi,'')":a2==3?"value":"innerHTML"))));
  429. },
  430.  
  431. html : function(a1,a2){
  432. return this.inneR(a1||0,0,a2);
  433. },
  434.  
  435. tekst : function(a1,a2){
  436. return this.inneR(a1||0,1,a2);
  437. },
  438.  
  439. text : function(a1){
  440. return this.inneR(a1);
  441. },
  442.  
  443. val : function(a1,a2){
  444. return this.inneR(a1||0,2,a2);
  445. },
  446.  
  447. show : function(){
  448. var tt = this.array();
  449. for(var y=0;y<tt.length;y++){
  450. tt[y].style.display='';
  451. };
  452.  
  453. return this;
  454. },
  455.  
  456. hide : function(){
  457. var tt = this.array();
  458. for(var y=0;y<tt.length;y++){
  459. tt[y].style.display='none';
  460. };
  461.  
  462. return this;
  463. },
  464.  
  465. clone : function(a1){
  466. var tt = this.array();
  467. var tt2 = [];
  468.  
  469. for(var y=0;y<tt.length;y++){
  470. var tt3 = $(tt[y].cloneNode(1));
  471. var ttc = tt[y].child('*').array();
  472. var tt3c = tt3.child('*').array();
  473.  
  474. if(!document.all){
  475. tt3.event(tt[y].evt);
  476. for(var z=0;z<ttc.length;z++)tt3c[z].event(ttc[z].evt);
  477. };
  478.  
  479. tt2.push(tt3);
  480. };
  481.  
  482. return $($.nA(tt2));
  483. },
  484.  
  485. create : function(a1,a2,a3){
  486. if(a2){
  487. var nt = [];
  488. for(var z=0;z<a2;z++)nt=$.merge(nt,this.create(a1,0,a3));
  489. return $($.nA(nt));
  490. };
  491.  
  492. var tt = this.array();
  493. var tt2 = [];
  494. if(typeof a1=='string'){
  495. for(var y=0;y<tt.length;y++)tt2.push(tt[y].appendChild($(document.createElement(a1))));
  496. return $($.nA(tt2));
  497. } else {
  498. var a1 = $(a1).array();
  499. for(var y=0;y<tt.length;y++)for(var x=(a3?0:y);x<(a3?a1.length:y+1);x++)tt2.push(tt[y].appendChild($(a1[x]).clone(1)));
  500. $(a1).remove();
  501. return $($.nA(tt2));
  502. }
  503. },
  504.  
  505. one : function(){
  506. var tt = this.array();
  507. var tt2 = [];
  508. Y:for(var y=0;y<tt.length;y++){
  509. for(var x=0;x<tt2.length;x++)if(tt[y]==tt2[x])continue Y;
  510. tt2.push(tt[y]);
  511. };
  512.  
  513. return $(tt2);
  514. },
  515.  
  516. to : function(a1,a2){
  517. return $(a1).create(this,0,$(a1).length?a2:1);
  518. },
  519.  
  520. append : function(a1,a2){
  521. return this.create($(a1),0,this.length?a2:1);
  522. },
  523.  
  524. index : function(a1){
  525. var tt = this.array();
  526. for(var y=0;y<tt.length;y++)if(tt[y]==a1)return y+1;
  527. },
  528.  
  529. add : function(a1){
  530. return $($.merge(this,$(a1)));
  531. },
  532.  
  533. sub : function(a1){
  534. var a1 = $(a1).array();
  535. var tt = this.array();
  536. var tt2 = [];
  537.  
  538. Y:for(var y=0;y<tt.length;y++){
  539. for(var x=0;x<a1.length;x++){
  540. if(tt[y]==a1[x])continue Y;
  541. };
  542.  
  543. tt2.push(tt[y]);
  544. };
  545.  
  546. return $($.nA(tt2));
  547. },
  548.  
  549. dif : function(a1){
  550. var a1 = $(a1).array();
  551. var tt = this.array();
  552. var tt2 = [];
  553.  
  554. Y:for(var y=0;y<tt.length;y++)for(var x=0;x<a1.length;x++)if(tt[y]==a1[x])tt2.push(tt[y]);
  555. return $($.nA(tt2));
  556. },
  557.  
  558. child : function(a1,a2){
  559. var tt = this.array();
  560. var tt2 = [];
  561.  
  562. for(var y=0;y<tt.length;y++){
  563. var tt2=$.merge(tt2,$(a1,tt[y],a2||''));
  564. };
  565.  
  566. return $($.nA(tt2));
  567. },
  568.  
  569. sibling : function(a1){
  570. var tt = this.array();
  571. var tt2 = [];
  572.  
  573. for(var y=0;y<tt.length;y++){
  574. var tt2 = $.merge(tt2,$(a1,tt[y],'+'));
  575. };
  576.  
  577. return $($.nA(tt2));
  578. },
  579.  
  580. att : function(){
  581. var tt = this.array();
  582. var ret = [];
  583.  
  584. if(arguments.length==1){
  585. for(var y=0;y<tt.length;y++)ret.push(tt[y].getAttribute(arguments[0]));
  586. return $($.nA(ret));
  587. };
  588.  
  589. for(var y=0;y<tt.length;y++)for(var x=0;x<arguments.length;x+=2)tt[y].setAttribute(arguments[x],typeof arguments[x+1]=='function'?arguments[x+1].call(tt[y]):arguments[x+1]);
  590. return this;
  591. },
  592.  
  593. sort : function(){
  594. var tt = this.array();
  595. var tt2 = [];
  596. var all = $('*');
  597.  
  598. for(var x=0;x<all.length;x++)for(var y=0;y<tt.length;y++)if(tt[y]==all[x])tt2.push($(tt[y]));
  599. return $($.nA(tt2));
  600. },
  601.  
  602. slice : function(){
  603. var ret = [];
  604. for(var x=0;x<arguments.length;x+=2)ret=$.merge(ret,$(Array.prototype.slice.call(this.array(),arguments[x]||0,arguments[x+1]||this.array().length)));
  605. return $($.nA(ret));
  606. },
  607.  
  608. sel : function(){
  609. var ret = [];
  610. for(var x=0;x<arguments.length;x++)if(this.array()[arguments[x]-1])ret=$.merge(ret,this.array()[arguments[x]-1]);
  611. return $($.nA(ret));
  612. },
  613.  
  614. save : function(a1){
  615. return $.o[a1||0]=this;
  616. },
  617.  
  618. load : function(a1){
  619. return $.o[a1||0];
  620. },
  621.  
  622. move : function(a1,a2){
  623. var tt = this.array().sort();
  624. if(a1>-1)var tt=tt.reverse();
  625. var dd = a1<0?-a1:a1+1;
  626.  
  627. for(var y=0;y<tt.length;y++){
  628. var elm = a2?(a2.constructor==Array?a2:[a2])[y]:tt[y];
  629. var elm2 = elm;
  630.  
  631. for(var x=0;x<dd;x++){
  632. var elm = $(elm)[a1<0?'prev':'next'](1);
  633. if(!elm)break;
  634. };
  635.  
  636. elm2.parentNode.insertBefore(tt[y],elm||null);
  637. };
  638.  
  639. return this;
  640. },
  641.  
  642. len : function(){
  643. return this.array().length;
  644. },
  645.  
  646. each : $.each
  647. };
  648.  
  649.  
  650. Ap = Array.prototype;
  651. Sp = String.prototype;
  652. Np = Number.prototype;
  653.  
  654. Np.round = function(){
  655. return Math.round(this);
  656. };
  657.  
  658. Sp.round = function(){
  659. return Math.round(this.num());
  660. };
  661. Np.num = function(){
  662. return this;
  663. };
  664. Sp.num = function(){
  665. return parseFloat(this);
  666. };
  667. Sp.camelCase = function(){
  668. return this.replace(/-(.)/gi, function(a1,a2){
  669. return a2.toUpperCase();
  670. });
  671. };
  672. Sp.x = function(a1,a2){
  673. return Array(a1+1).join(this+(a2||''));
  674. }
  675. Sp.toHex = function(){
  676. var th = this.toString();
  677. if(th.search(/rgb/gi)!=-1){
  678. return '#'+th.split('(')[1].split(')')[0].replace(/\d+/gi,function(a1){return a1.num()<16?'0'+a1.num().toString(16):a1.num().toString(16);}).replace(/\,|\s/gi,'');
  679. }
  680. if(th.search(/\#[0-9a-f]+/gi)!=-1){
  681. var th = th.replace(/\#/gi,'');
  682. var th2 = '';
  683.  
  684. for(var x = 0; x<th.length; x++){
  685. th2 += th.charAt(x).x(Math.round(6/th.length));
  686. }
  687.  
  688. return '#'+th2.slice(0,6);
  689. }
  690.  
  691. return th.color();
  692. };
  693. Sp.rep = function(a1){
  694. var ret = this.toString();
  695. for(x in a1){
  696. ret = ret.replace(RegExp(x,'gi'), a1[x]);
  697. }
  698.  
  699. return ret;
  700. };
  701. Sp.color = function(){
  702. return this.rep({
  703. 'transparent' : '#ffffff',
  704. 'black' : '#000000',
  705. 'maroon' : '#800000',
  706. 'green' : '#008000',
  707. 'olive' : '#808000',
  708. 'navy' : '#000080',
  709. 'purple' : '#800080',
  710. 'teal' : '#008080',
  711. 'silver' : '#c0c0c0',
  712. 'gray' : '#808080',
  713. 'red' : '#ff0000',
  714. 'lime' : '#00ff00',
  715. 'yellow' : '#ffff00',
  716. 'blue' : '#0000ff',
  717. 'fuchsia' : '#ff00ff',
  718. 'aqua' : '#00ffff',
  719. 'white' : '#ffffff'
  720. });
  721. };
  722. Sp.share = function(a1){
  723. var ret = [];
  724. for(var x = 0; x<this.length; x+=a1){
  725. ret.push(this.slice(x,x+a1));
  726. }
  727.  
  728. return ret;
  729. };
  730. Ap.is = function(a1){
  731. for(var i = 0; i<this.length; i++)if(this[i]==a1)return true;
  732. return false;
  733. };
  734. Ap.each = $.each;
  735.  
  736. toUrl = function(p){var tab=[];for(x in p)tab.push(x+"="+p[x]);return tab.join("&");};
  737.  
  738.  
  739. // MODULES
  740. $.mouse = function(e){e=e||window.Event;if(e.pageX&&e.pageY){return{x:e.pageX,y:e.pageY};}else if(e.clientX&&e.clientY){return{x:e.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft),y:e.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)};}else{return null;}}
  741. $.selection = function(){ if(window.getSelection)return window.getSelection(); else if(document.selection)return document.selection.createRange(); }
  742. $.get = function(j){var url=j.url,success=j.success,loading=j.loading,parms=j.parms,obj=(window.XMLHttpRequest)?(new XMLHttpRequest()):(window.ActiveXObject)?(new ActiveXObject("Microsoft.XMLHTTP")):false;obj.onreadystatechange=function(){if(obj.readyState==4&&obj.status==200)if(success)success(obj);else loading(obj);};if(parms)obj.open("GET",url+"?"+toUrl(parms),true);else obj.open("GET",url,true);obj.send(null);};

Report this snippet  

You need to login to post a comment.