2008-05-15 18:57:14 -04:00
|
|
|
|
|
|
|
wpGears = {
|
|
|
|
|
|
|
|
createStore : function() {
|
|
|
|
if ( 'undefined' == typeof google || ! google.gears ) return;
|
|
|
|
|
2008-08-09 01:36:14 -04:00
|
|
|
if ( 'undefined' == typeof localServer )
|
2008-05-19 11:41:31 -04:00
|
|
|
localServer = google.gears.factory.create("beta.localserver");
|
|
|
|
|
2008-05-15 18:57:14 -04:00
|
|
|
store = localServer.createManagedStore(this.storeName());
|
|
|
|
store.manifestUrl = "gears-manifest.php";
|
|
|
|
store.checkForUpdate();
|
|
|
|
this.message();
|
|
|
|
},
|
|
|
|
|
2008-05-19 11:41:31 -04:00
|
|
|
getPermission : function() {
|
|
|
|
if ( 'undefined' != typeof google && google.gears ) {
|
|
|
|
if ( ! google.gears.factory.hasPermission )
|
|
|
|
google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
|
2008-05-15 18:57:14 -04:00
|
|
|
|
2008-05-19 11:41:31 -04:00
|
|
|
try {
|
|
|
|
this.createStore();
|
|
|
|
} catch(e) {} // silence if canceled
|
|
|
|
}
|
2008-05-15 18:57:14 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
storeName : function() {
|
2008-07-22 00:03:36 -04:00
|
|
|
var name = window.location.protocol + window.location.host;
|
2008-05-15 18:57:14 -04:00
|
|
|
|
2008-07-22 00:03:36 -04:00
|
|
|
name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
|
|
|
|
name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
|
2008-05-15 18:57:14 -04:00
|
|
|
|
2008-07-22 00:03:36 -04:00
|
|
|
return name;
|
|
|
|
},
|
2008-05-15 18:57:14 -04:00
|
|
|
|
2008-07-22 00:03:36 -04:00
|
|
|
message : function(show) {
|
2008-05-15 18:57:14 -04:00
|
|
|
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');
|
|
|
|
|
|
|
|
if ( ! msg1 ) return;
|
|
|
|
|
2008-05-19 11:41:31 -04:00
|
|
|
if ( 'undefined' != typeof google && google.gears ) {
|
|
|
|
if ( google.gears.factory.hasPermission ) {
|
|
|
|
msg1.style.display = msg2.style.display = 'none';
|
|
|
|
msg3.style.display = 'block';
|
|
|
|
|
|
|
|
if ( 'undefined' == typeof store )
|
|
|
|
t.createStore();
|
|
|
|
|
|
|
|
store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
|
|
|
|
store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
|
|
|
|
store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
|
|
|
|
} else {
|
|
|
|
msg1.style.display = msg3.style.display = 'none';
|
|
|
|
msg2.style.display = 'block';
|
|
|
|
}
|
2008-05-15 18:57:14 -04:00
|
|
|
}
|
2008-05-19 11:41:31 -04:00
|
|
|
|
|
|
|
if ( show ) t.I('gears-info-box').style.display = 'block';
|
2008-05-15 18:57:14 -04:00
|
|
|
},
|
2008-05-19 11:41:31 -04:00
|
|
|
|
2008-05-15 18:57:14 -04:00
|
|
|
I : function(id) {
|
|
|
|
return document.getElementById(id);
|
|
|
|
}
|
2008-07-22 00:03:36 -04:00
|
|
|
};
|
2008-05-15 18:57:14 -04:00
|
|
|
|
2008-07-22 00:03:36 -04:00
|
|
|
(function() {
|
2008-05-15 18:57:14 -04:00
|
|
|
if ( 'undefined' != typeof google && google.gears ) return;
|
|
|
|
|
|
|
|
var gf = false;
|
2008-07-22 00:03:36 -04:00
|
|
|
if ( 'undefined' != typeof GearsFactory ) {
|
2008-05-15 18:57:14 -04:00
|
|
|
gf = new GearsFactory();
|
2008-07-22 00:03:36 -04:00
|
|
|
} else {
|
2008-05-15 18:57:14 -04:00
|
|
|
try {
|
|
|
|
gf = new ActiveXObject('Gears.Factory');
|
2008-07-22 00:03:36 -04:00
|
|
|
if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
|
|
|
|
gf.privateSetGlobalObject(this);
|
|
|
|
} catch (e) {
|
|
|
|
if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
|
|
|
|
gf = document.createElement("object");
|
|
|
|
gf.style.display = "none";
|
|
|
|
gf.width = 0;
|
|
|
|
gf.height = 0;
|
|
|
|
gf.type = "application/x-googlegears";
|
|
|
|
document.documentElement.appendChild(gf);
|
|
|
|
}
|
|
|
|
}
|
2008-05-15 18:57:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! gf ) return;
|
|
|
|
if ( 'undefined' == typeof google ) google = {};
|
|
|
|
if ( ! google.gears ) google.gears = { factory : gf };
|
2008-07-22 00:03:36 -04:00
|
|
|
})();
|