Advertisement
joris

Full Script

Oct 22nd, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //===================================  GET JSON =====================================================
  2. var JSONP=(function(){var a=0,c,f,b,d=this;function e(j){var i=document.createElement("script");var h=false;i.src=j;i.async=true;i.onload=i.onreadystatechange=function(){if(!h&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){h=true;i.onload=i.onreadystatechange=null;if(i&&i.parentNode){i.parentNode.removeChild(i)}}};if(!c){c=document.getElementsByTagName("head")[0]}c.appendChild(i)}function g(i,k,h,l){f="?";k=k||{};for(b in k){if(k.hasOwnProperty(b)){f+=encodeURIComponent(b)+"="+encodeURIComponent(k[b])+"&"}}var j="json"+(++a);d[j]=function(m){l(m);try{delete d[j]}catch(n){}d[j]=null};e(i+f+"callback="+j);h=h||function(){};d.setTimeout(function(){if(typeof d[j]=="function"){d[j]=function(m){try{delete d[j]}catch(n){}d[j]=null};h();d.setTimeout(function(){if(typeof d[j]=="function"){try{delete d[j]}catch(m){}d[j]=null}},120000)}},10000);return j}return{get:g}}());
  3. // =================================== GET JSON ======================================================
  4.  
  5. var strData = "all"
  6.  
  7. function ALL_loadAfterTimeout() {
  8.     document.getElementById('waiting').style.display = 'none';
  9.     document.getElementById('dataList').style.visibility = 'visible';
  10. }
  11.  
  12.  
  13. function ALLProses_initialLoad() {
  14.    
  15.     var url = 'http://crud.berthoristhy.co.cc/api/DataReadAll.php';
  16.     var error = function() {
  17.         alert('Koneksi ke server bermasalah. Silahkan diulangi lagi.');
  18.         document.getElementById('waiting').style.display = 'none';
  19.         document.getElementById('nodata').style.visibility = 'visible';
  20.     };
  21.     var success = function(response) {
  22.         var listItem, container, dataList = document.getElementById("dataList"),
  23.         id          = "",
  24.         depan       = "",
  25.         belakang    = "",
  26.         phone       = "",
  27.         email       = "";
  28.        
  29.                 for ( var i = 0; i < response.length; ++i ) {
  30.                     id      = response[i].id;
  31.                     depan       = response[i].firstname;
  32.                     belakang    = response[i].lastname;
  33.                     phone       = response[i].phone;
  34.                     email       = response[i].email;
  35.                            
  36.                
  37.     var Gabung,Gabung2 = ""
  38.     Gabung  = depan+' '+belakang
  39.     Gabung2 = "ID : "+id+"\nNama Depan : "+depan+"\nNama Belakang : "+belakang+"\nPhone : "+phone+"\nEmail : "+email
  40.  
  41.                     listItem = document.createElement('div');
  42.                     listItem.setAttribute('data-bb-type', 'item');
  43.                     listItem.setAttribute('data-bb-img', 'images/icons/user.png');
  44.                     listItem.setAttribute('data-bb-title', Gabung);
  45.                     listItem.onclick = (function(opt) {
  46.                         return function() {
  47.  
  48.                             if (confirm(opt)) {
  49.                                 bb.pushScreen('UPDATE.html', 'UPDATE', {'data_id':id,'data_depan':depan,'data_belakang':belakang,'data_phone':phone,'data_email':email}
  50.                                 );
  51.                             } else {
  52.                                 //Do Nothing
  53.                             }
  54.                         };
  55.                     })(Gabung2+"\n\nDo you want to update this data ?");
  56.                     listItem.innerHTML = email;
  57.                     container = document.createElement('div');
  58.                     container.appendChild(listItem);
  59.                     bb.imageList.apply([container]);
  60.                     dataList.appendChild(container.firstChild);  
  61.                     if (bb.scroller) {
  62.                         bb.scroller.refresh();
  63.                     }
  64.                
  65.                 }
  66.     };
  67.     JSONP.get( url, {key: strData}, error, success);
  68.     setTimeout(ALL_loadAfterTimeout,10000);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement