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, host = window.location.host;
33 if ( host.match(/[^a-z0-9._-]/i) )
34 host = encodeURIComponent(host);
36 name = window.location.protocol + host;
37 name = name.replace(/[^a-z0-9._-]+/gi, '_');
38 name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
43 message : function(show) {
44 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');
48 if ( 'undefined' != typeof google && google.gears ) {
49 if ( show && show == 4 ) {
50 msg1.style.display = msg2.style.display = msg3.style.display = 'none';
51 msg4.style.display = 'block';
52 } else if ( google.gears.factory.hasPermission ) {
53 msg1.style.display = msg2.style.display = msg4.style.display = 'none';
54 msg3.style.display = 'block';
56 if ( 'undefined' == typeof store )
59 store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
60 store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
61 store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
63 msg1.style.display = msg3.style.display = msg4.style.display = 'none';
64 msg2.style.display = 'block';
70 return document.getElementById(id);
75 if ( 'undefined' != typeof google && google.gears ) return;
78 if ( 'undefined' != typeof GearsFactory ) {
79 gf = new GearsFactory();
82 gf = new ActiveXObject('Gears.Factory');
83 if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
84 gf.privateSetGlobalObject(this);
86 if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
87 gf = document.createElement("object");
88 gf.style.display = "none";
91 gf.type = "application/x-googlegears";
92 document.documentElement.appendChild(gf);
98 if ( 'undefined' == typeof google ) google = {};
99 if ( ! google.gears ) google.gears = { factory : gf };