Google Gear 基本使用方法

來源:互聯網
上載者:User
轉自:http://zybingliu.blogspot.com/2009/04/google-gear.html

Google Gear從例子上看,好像很容易使用(當然,僅僅是最基本的入門):

首先通過例子的gears_init.js產生一個Google Gears對象:google.gears後面所有的操作通過這個對象進行。這個就直接抄gears_init.js實現,自己不用做任何處理了。對google.gears對象的判斷:if (!window.google || !google.gears) {    textOut("NOTE:  You must install Gears first."); --- 提示沒有安裝google gear,  } else { ---- 安裝了google gear,產生自己的localserver和store    localServer = google.gears.factory.create("beta.localserver");    store = localServer.createManagedStore(STORE_NAME);    textOut("Yeay, Gears is already installed.");  }其中的:STORE_NAME就是一個自己隨意取的名字;MANIFEST的檔案,在create store的時候使用到  if (!window.google || !google.gears) { --- 判斷是否安裝了gear    alert("You must install Gears first.");    return;  }  store.manifestUrl = MANIFEST_FILENAME; --- 這個就是定義manifest檔案名稱字的,而且mainfest的檔案,要和當前的頁面放在同一個目錄中(如果沒有設定目錄的話)  store.checkForUpdate();                                       --- 對store的建立更新  var timerId = window.setInterval(function() {  --- 這是一個把更新的狀態顯示出來的指令碼    // When the currentVersion property has a value, all of the resources    // listed in the manifest file for that version are captured. There is    // an open bug to surface this state change as an event.    if (store.currentVersion) {      window.clearInterval(timerId);      textOut("The documents are now available offline./n" +               "With your browser offline, load the document at " +              "its normal online URL to see the locally stored " +
       "version. The version stored is: " +               store.currentVersion);    } else if (store.updateStatus == 3) {      textOut("Error: " + store.lastErrorMessage);    }  }, 500);  刪除一個store也是相當容易的:  if (!window.google || !google.gears) {    alert("You must install Gears first.");    return;  }  localServer.removeManagedStore(STORE_NAME); --- 刪除,這個STORE_NAME就是上面建立時候的STORE NAME  textOut("Done. The local store has been removed." +          "You will now see online versions of the documents.");

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.