]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/wp-gears.dev.js
Wordpress 2.8
[autoinstalls/wordpress.git] / wp-admin / js / wp-gears.dev.js
1
2 var wpGears = {
3
4         createStore : function() {
5                 if ( 'undefined' == typeof google || ! google.gears ) return;
6
7                 if ( 'undefined' == typeof localServer )
8                         localServer = google.gears.factory.create("beta.localserver");
9
10                 store = localServer.createManagedStore(this.storeName());
11                 store.manifestUrl = "gears-manifest.php";
12                 store.checkForUpdate();
13                 this.message(3);
14         },
15
16         getPermission : function() {
17                 var perm = true;
18
19                 if ( 'undefined' != typeof google && google.gears ) {
20                         if ( ! google.gears.factory.hasPermission )
21                                 perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
22
23                         if ( perm )
24                                 try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
25                         else
26                                 this.message(4);
27                 }
28         },
29
30         storeName : function() {
31                 var name = window.location.protocol + window.location.host;
32
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
35
36                 return name;
37         },
38
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');
41
42                 if ( ! msg1 ) return;
43
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';
51
52                                 if ( 'undefined' == typeof store )
53                                         t.createStore();
54
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);};
58                         } else {
59                                 msg1.style.display = msg3.style.display = msg4.style.display = 'none';
60                                 msg2.style.display = 'block';
61                         }
62                 }
63         },
64
65         I : function(id) {
66                 return document.getElementById(id);
67         }
68 };
69
70 (function() {
71         if ( 'undefined' != typeof google && google.gears ) return;
72
73         var gf = false;
74         if ( 'undefined' != typeof GearsFactory ) {
75                 gf = new GearsFactory();
76         } else {
77                 try {
78                         gf = new ActiveXObject('Gears.Factory');
79                         if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
80                                 gf.privateSetGlobalObject(this);
81                 } catch (e) {
82                         if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
83                                 gf = document.createElement("object");
84                                 gf.style.display = "none";
85                                 gf.width = 0;
86                                 gf.height = 0;
87                                 gf.type = "application/x-googlegears";
88                                 document.documentElement.appendChild(gf);
89                         }
90                 }
91         }
92
93         if ( ! gf ) return;
94         if ( 'undefined' == typeof google ) google = {};
95         if ( ! google.gears ) google.gears = { factory : gf };
96 })();