mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-25 07:12:53 +02:00
git-svn-id: http://svn.automattic.com/wordpress/trunk@7951 1a063a9b-81f0-0310-95a4-ce76da25c4cd
84 lines
2.3 KiB
JavaScript
84 lines
2.3 KiB
JavaScript
|
|
wpGears = {
|
|
|
|
createStore : function() {
|
|
if ( 'undefined' == typeof google || ! google.gears ) return;
|
|
|
|
if ( 'undefined' == typeof localServer )
|
|
localServer = google.gears.factory.create("beta.localserver");
|
|
|
|
store = localServer.createManagedStore(this.storeName());
|
|
store.manifestUrl = "gears-manifest.php";
|
|
store.checkForUpdate();
|
|
this.message();
|
|
},
|
|
|
|
getPermission : function() {
|
|
if ( 'undefined' != typeof google && google.gears ) {
|
|
if ( ! google.gears.factory.hasPermission )
|
|
google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
|
|
|
|
try {
|
|
this.createStore();
|
|
} catch(e) {} // silence if canceled
|
|
}
|
|
},
|
|
|
|
storeName : function() {
|
|
var name = window.location.protocol + window.location.host;
|
|
|
|
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
|
|
|
|
return name;
|
|
},
|
|
|
|
message : function(show) {
|
|
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;
|
|
|
|
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';
|
|
}
|
|
}
|
|
|
|
if ( show ) t.I('gears-info-box').style.display = 'block';
|
|
},
|
|
|
|
I : function(id) {
|
|
return document.getElementById(id);
|
|
}
|
|
}
|
|
|
|
function gearsInit() {
|
|
if ( 'undefined' != typeof google && google.gears ) return;
|
|
|
|
var gf = false;
|
|
if ( 'undefined' != typeof GearsFactory ) { // Firefox
|
|
gf = new GearsFactory();
|
|
} else { // IE
|
|
try {
|
|
gf = new ActiveXObject('Gears.Factory');
|
|
} catch (e) {}
|
|
}
|
|
|
|
if ( ! gf ) return;
|
|
if ( 'undefined' == typeof google ) google = {};
|
|
if ( ! google.gears ) google.gears = { factory : gf };
|
|
}
|
|
|
|
gearsInit();
|