4 createStore : function() {
5 if ( 'undefined' == typeof google || ! google.gears ) return;
7 if ( 'undefined' == typeof localServer )
8 localServer = google.gears.factory.create("beta.localserver");
10 store = localServer.createManagedStore(this.storeName());
11 store.manifestUrl = "gears-manifest.php";
12 store.checkForUpdate();
16 getPermission : function() {
19 if ( 'undefined' != typeof google && google.gears ) {
20 if ( ! google.gears.factory.hasPermission )
21 perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
24 try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
30 storeName : function() {
31 var name = window.location.protocol + window.location.host;
33 name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
34 name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
39 message : function(show) {
40 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');
44 if ( 'undefined' != typeof google && google.gears ) {
45 if ( show && show == 4 ) {
46 msg1.style.display = msg2.style.display = msg3.style.display = 'none';
47 msg4.style.display = 'block';
48 } else if ( google.gears.factory.hasPermission ) {
49 msg1.style.display = msg2.style.display = msg4.style.display = 'none';
50 msg3.style.display = 'block';
52 if ( 'undefined' == typeof store )
55 store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
56 store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
57 store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
59 msg1.style.display = msg3.style.display = msg4.style.display = 'none';
60 msg2.style.display = 'block';
66 return document.getElementById(id);
71 if ( 'undefined' != typeof google && google.gears ) return;
74 if ( 'undefined' != typeof GearsFactory ) {
75 gf = new GearsFactory();
78 gf = new ActiveXObject('Gears.Factory');
79 if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
80 gf.privateSetGlobalObject(this);
82 if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
83 gf = document.createElement("object");
84 gf.style.display = "none";
87 gf.type = "application/x-googlegears";
88 document.documentElement.appendChild(gf);
94 if ( 'undefined' == typeof google ) google = {};
95 if ( ! google.gears ) google.gears = { factory : gf };