/news/wp-admin/js/wp-gears.js

https://github.com/dzachry/inferno-Demo · JavaScript · 96 lines · 87 code · 9 blank · 0 comment · 10 complexity · 1335ebf3c647fb07e0b9e427e83ed435 MD5 · raw file

  1. wpGears = {
  2. createStore : function() {
  3. if ( 'undefined' == typeof google || ! google.gears ) return;
  4. if ( 'undefined' == typeof localServer )
  5. localServer = google.gears.factory.create("beta.localserver");
  6. store = localServer.createManagedStore(this.storeName());
  7. store.manifestUrl = "gears-manifest.php";
  8. store.checkForUpdate();
  9. this.message(3);
  10. },
  11. getPermission : function() {
  12. var perm = true;
  13. if ( 'undefined' != typeof google && google.gears ) {
  14. if ( ! google.gears.factory.hasPermission )
  15. perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
  16. if ( perm )
  17. try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
  18. else
  19. this.message(4);
  20. }
  21. },
  22. storeName : function() {
  23. var name = window.location.protocol + window.location.host;
  24. name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
  25. name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
  26. return name;
  27. },
  28. message : function(show) {
  29. 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');
  30. if ( ! msg1 ) return;
  31. if ( 'undefined' != typeof google && google.gears ) {
  32. if ( show && show == 4 ) {
  33. msg1.style.display = msg2.style.display = msg3.style.display = 'none';
  34. msg4.style.display = 'block';
  35. } else if ( google.gears.factory.hasPermission ) {
  36. msg1.style.display = msg2.style.display = msg4.style.display = 'none';
  37. msg3.style.display = 'block';
  38. if ( 'undefined' == typeof store )
  39. t.createStore();
  40. store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
  41. store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
  42. store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
  43. } else {
  44. msg1.style.display = msg3.style.display = msg4.style.display = 'none';
  45. msg2.style.display = 'block';
  46. }
  47. }
  48. },
  49. I : function(id) {
  50. return document.getElementById(id);
  51. }
  52. };
  53. (function() {
  54. if ( 'undefined' != typeof google && google.gears ) return;
  55. var gf = false;
  56. if ( 'undefined' != typeof GearsFactory ) {
  57. gf = new GearsFactory();
  58. } else {
  59. try {
  60. gf = new ActiveXObject('Gears.Factory');
  61. if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
  62. gf.privateSetGlobalObject(this);
  63. } catch (e) {
  64. if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
  65. gf = document.createElement("object");
  66. gf.style.display = "none";
  67. gf.width = 0;
  68. gf.height = 0;
  69. gf.type = "application/x-googlegears";
  70. document.documentElement.appendChild(gf);
  71. }
  72. }
  73. }
  74. if ( ! gf ) return;
  75. if ( 'undefined' == typeof google ) google = {};
  76. if ( ! google.gears ) google.gears = { factory : gf };
  77. })();