Advertisement
Kinu-chan

Untitled

Nov 14th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* <!--KQute--> */
  2.  
  3. var d, db, h, $, $$;
  4.  
  5. d = document;
  6. db = document.body;
  7. h = document.getElementsByTagName('head')[0];
  8.  
  9. $ = function(s, p){
  10.         if(!p || p == null){
  11.             p = db;
  12.         }
  13.         return p.querySelector(s);
  14.     }  
  15. $$ = function(s, p){
  16.         if(!p || p == null){
  17.             p = db;
  18.         }
  19.         return p.querySelectorAll(s);
  20.     }
  21.    
  22. $.getVal = function(k, v){
  23.         if(typeof(Storage) !=="undefined"){
  24.             if(!v || v == null){
  25.                 return localStorage.k || 'undefined';
  26.             }else{
  27.                 return localStorage.k || v;
  28.             }
  29.         }else{
  30.             return 'storage unavailable';
  31.         }
  32.     }
  33.    
  34. $.setVal = function(k, v){
  35.         if(typeof(Storage) !=="undefined"){
  36.             if(!v || v == null){
  37.                 return 'undefined';
  38.             }else{
  39.                 localStorage.k = v;
  40.                 return false;
  41.             }
  42.         }else{
  43.             return 'storage unavailable';
  44.         }
  45.     }
  46.    
  47. $.delVal = function(k){
  48.         localStorage.removeItem(k);
  49.         return false;
  50.     }
  51.    
  52. $.htm = function(s, v){
  53.         if(!v || v == null){
  54.             return s.innerHTML;
  55.         }else{
  56.             s.innerHTML = v;
  57.         }
  58.         return false;
  59.     }
  60. $$.htm = function(s, v, n){
  61.         if(!v || v == null){
  62.             return s.innerHTML;
  63.         }else{
  64.             if(!n || n == null){           
  65.                 for (var i = 0; i < s.length; i++) {
  66.                     s[i].innerHTML = v;
  67.                 }
  68.             }else{
  69.                 s[n].innerHTML = v;
  70.             }
  71.         }
  72.         return s;
  73.     }
  74.    
  75. $.val = function(s, v){
  76.         if(!v || v == null){
  77.             return s.value;
  78.         }else{
  79.             s.value = v;
  80.         }
  81.         return s;
  82.     }
  83.    
  84. $.att = function(s, a, v){
  85.         if(!v || v == null){
  86.             return s.getAttribute(a);
  87.         }else{
  88.             s.setAttribute(a, v);
  89.             return s;
  90.         }
  91.     }  
  92. $$.att = function(s, a, v, n){
  93.         if(!v || v == null){
  94.             if(!n && n != 0 || n == null && n != 0){
  95.                 var x = [];
  96.                 for (var i = 0; i < $$(s).length; i++) {
  97.                     x.push(s[i].getAttribute(a));
  98.                 }
  99.                 return x;
  100.             }else{
  101.                 return s[n].getAttribute(a);
  102.             }
  103.         }else{
  104.             if(!n || n == null){   
  105.                 for (var i = 0; i < $$(s).length; i++) {
  106.                     s[i].setAttribute(a, v);
  107.                 }
  108.             }else{
  109.                 s[n].setAttribute(a, v);
  110.             }
  111.             return s;
  112.         }
  113.     }
  114.    
  115. $.elm = function(t, a, s){
  116.         var e = d.createElement(t);
  117.         if(a){
  118.             for (key in a){
  119.                 e.setAttribute(key, a[key]);
  120.             }
  121.         }
  122.         if(s){
  123.             s.appendChild(e);
  124.         }
  125.         return e;
  126.     }
  127.    
  128. $.css = function(s) {
  129.         var e = d.createElement('style');
  130.         e.type = 'text/css';
  131.         if (e.styleSheet){
  132.           e.styleSheet.cssText = s;
  133.         } else {
  134.           e.appendChild(d.createTextNode(s));
  135.         }
  136.         h.appendChild(e);
  137.         return e;
  138.     }
  139.    
  140. /* <!--/KQute--> */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement