home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / js / wp-gears.js < prev    next >
Encoding:
JavaScript  |  2008-07-22  |  2.7 KB  |  93 lines

  1.  
  2. wpGears = {
  3.  
  4.     createStore : function() {
  5.         if ( 'undefined' == typeof google || ! google.gears ) return;
  6.  
  7.         if ( 'undefined' == typeof localServer ) 
  8.             localServer = google.gears.factory.create("beta.localserver");
  9.  
  10.         store = localServer.createManagedStore(this.storeName());
  11.         store.manifestUrl = "gears-manifest.php";
  12.         store.checkForUpdate();
  13.         this.message();
  14.     },
  15.  
  16.     getPermission : function() {
  17.         if ( 'undefined' != typeof google && google.gears ) {
  18.             if ( ! google.gears.factory.hasPermission )
  19.                 google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
  20.  
  21.             try {
  22.                 this.createStore();
  23.             } catch(e) {} // silence if canceled
  24.         }
  25.     },
  26.  
  27.     storeName : function() {
  28.         var name = window.location.protocol + window.location.host;
  29.  
  30.         name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
  31.         name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
  32.  
  33.         return name;
  34.     },
  35.  
  36.     message : function(show) {
  37.         var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
  38.  
  39.         if ( ! msg1 ) return;
  40.  
  41.         if ( 'undefined' != typeof google && google.gears ) {
  42.             if ( google.gears.factory.hasPermission ) {
  43.                 msg1.style.display = msg2.style.display = 'none';
  44.                 msg3.style.display = 'block';
  45.  
  46.                 if ( 'undefined' == typeof store )
  47.                     t.createStore();
  48.  
  49.                 store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
  50.                 store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
  51.                 store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
  52.             } else {
  53.                 msg1.style.display = msg3.style.display = 'none';
  54.                 msg2.style.display = 'block';
  55.             }
  56.         }
  57.  
  58.         if ( show ) t.I('gears-info-box').style.display = 'block';
  59.     },
  60.  
  61.     I : function(id) {
  62.         return document.getElementById(id);
  63.     }
  64. };
  65.  
  66. (function() {
  67.     if ( 'undefined' != typeof google && google.gears ) return;
  68.  
  69.     var gf = false;
  70.     if ( 'undefined' != typeof GearsFactory ) {
  71.         gf = new GearsFactory();
  72.     } else {
  73.         try {
  74.             gf = new ActiveXObject('Gears.Factory');
  75.             if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
  76.                 gf.privateSetGlobalObject(this);
  77.         } catch (e) {
  78.             if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
  79.                 gf = document.createElement("object");
  80.                 gf.style.display = "none";
  81.                 gf.width = 0;
  82.                 gf.height = 0;
  83.                 gf.type = "application/x-googlegears";
  84.                 document.documentElement.appendChild(gf);
  85.             }
  86.         }
  87.     }
  88.  
  89.     if ( ! gf ) return;
  90.     if ( 'undefined' == typeof google ) google = {};
  91.     if ( ! google.gears ) google.gears = { factory : gf };
  92. })();
  93.