2008-05-16 00:57:14 +02:00
|
|
|
|
|
|
|
wpGears = {
|
|
|
|
|
|
|
|
createStore : function() {
|
|
|
|
if ( 'undefined' == typeof google || ! google.gears ) return;
|
|
|
|
|
2008-08-09 07:36:14 +02:00
|
|
|
if ( 'undefined' == typeof localServer )
|
2008-05-19 17:41:31 +02:00
|
|
|
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();
|
2008-09-05 18:29:03 +02:00
|
|
|
this.message(3);
|
2008-05-16 00:57:14 +02:00
|
|
|
},
|
|
|
|
|
2008-05-19 17:41:31 +02:00
|
|
|
getPermission : function() {
|
2008-09-05 18:29:03 +02:00
|
|
|
var perm = true;
|
|
|
|
|
2008-05-19 17:41:31 +02:00
|
|
|
if ( 'undefined' != typeof google && google.gears ) {
|
|
|
|
if ( ! google.gears.factory.hasPermission )
|
2008-09-05 18:29:03 +02:00
|
|
|
perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
|
2008-05-16 00:57:14 +02:00
|
|
|
|
2008-09-05 18:29:03 +02:00
|
|
|
if ( perm )
|
|
|
|
try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
|
|
|
|
else
|
|
|
|
this.message(4);
|
2008-05-19 17:41:31 +02:00
|
|
|
}
|
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-09-05 18:29:03 +02:00
|
|
|
var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), msg4 = t.I('gears-msg4'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
|
2008-05-16 00:57:14 +02:00
|
|
|
|
|
|
|
if ( ! msg1 ) return;
|
|
|
|
|
2008-05-19 17:41:31 +02:00
|
|
|
if ( 'undefined' != typeof google && google.gears ) {
|
2008-09-05 18:29:03 +02:00
|
|
|
if ( show && show == 4 ) {
|
|
|
|
msg1.style.display = msg2.style.display = msg3.style.display = 'none';
|
|
|
|
msg4.style.display = 'block';
|
|
|
|
} else if ( google.gears.factory.hasPermission ) {
|
|
|
|
msg1.style.display = msg2.style.display = msg4.style.display = 'none';
|
2008-05-19 17:41:31 +02:00
|
|
|
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 {
|
2008-09-05 18:29:03 +02:00
|
|
|
msg1.style.display = msg3.style.display = msg4.style.display = 'none';
|
2008-05-19 17:41:31 +02:00
|
|
|
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-09-05 18:29:03 +02:00
|
|
|
else t.I('gears-info-box').style.display = 'none';
|
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
|
|
|
})();
|