2008-05-16 00:57:14 +02:00
|
|
|
|
|
|
|
wpGears = {
|
|
|
|
|
|
|
|
createStore : function() {
|
|
|
|
if ( 'undefined' == typeof google || ! google.gears ) return;
|
|
|
|
|
2008-05-19 17:41:31 +02:00
|
|
|
if ( 'undefined' == typeof localServer )
|
|
|
|
localServer = google.gears.factory.create("beta.localserver");
|
|
|
|
|
2008-05-16 00:57:14 +02:00
|
|
|
store = localServer.createManagedStore(this.storeName());
|
|
|
|
store.manifestUrl = "gears-manifest.php";
|
|
|
|
store.checkForUpdate();
|
|
|
|
this.message();
|
|
|
|
},
|
|
|
|
|
2008-05-19 17:41:31 +02:00
|
|
|
getPermission : function() {
|
|
|
|
if ( 'undefined' != typeof google && google.gears ) {
|
|
|
|
if ( ! google.gears.factory.hasPermission )
|
|
|
|
google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
|
2008-05-16 00:57:14 +02:00
|
|
|
|
2008-05-19 17:41:31 +02:00
|
|
|
try {
|
|
|
|
this.createStore();
|
|
|
|
} catch(e) {} // silence if canceled
|
|
|
|
}
|
2008-05-16 00:57:14 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
storeName : function() {
|
2008-07-22 06:03:36 +02:00
|
|
|
var name = window.location.protocol + window.location.host;
|
2008-05-16 00:57:14 +02:00
|
|
|
|
2008-07-22 06:03:36 +02: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-16 00:57:14 +02:00
|
|
|
|
2008-07-22 06:03:36 +02:00
|
|
|
return name;
|
|
|
|
},
|
2008-05-16 00:57:14 +02:00
|
|
|
|
2008-07-22 06:03:36 +02:00
|
|
|
message : function(show) {
|
2008-05-16 00:57:14 +02: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 17:41:31 +02: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-16 00:57:14 +02:00
|
|
|
}
|
2008-05-19 17:41:31 +02:00
|
|
|
|
|
|
|
if ( show ) t.I('gears-info-box').style.display = 'block';
|
2008-05-16 00:57:14 +02:00
|
|
|
},
|
2008-05-19 17:41:31 +02:00
|
|
|
|
2008-05-16 00:57:14 +02:00
|
|
|
I : function(id) {
|
|
|
|
return document.getElementById(id);
|
|
|
|
}
|
2008-07-22 06:03:36 +02:00
|
|
|
};
|
2008-05-16 00:57:14 +02:00
|
|
|
|
2008-07-22 06:03:36 +02:00
|
|
|
(function() {
|
2008-05-16 00:57:14 +02:00
|
|
|
if ( 'undefined' != typeof google && google.gears ) return;
|
|
|
|
|
|
|
|
var gf = false;
|
2008-07-22 06:03:36 +02:00
|
|
|
if ( 'undefined' != typeof GearsFactory ) {
|
2008-05-16 00:57:14 +02:00
|
|
|
gf = new GearsFactory();
|
2008-07-22 06:03:36 +02:00
|
|
|
} else {
|
2008-05-16 00:57:14 +02:00
|
|
|
try {
|
|
|
|
gf = new ActiveXObject('Gears.Factory');
|
2008-07-22 06:03:36 +02: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-16 00:57:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! gf ) return;
|
|
|
|
if ( 'undefined' == typeof google ) google = {};
|
|
|
|
if ( ! google.gears ) google.gears = { factory : gf };
|
2008-07-22 06:03:36 +02:00
|
|
|
})();
|