summaryrefslogtreecommitdiffstats
path: root/services/cloudsync/docs/example.rst
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-17 20:22:59 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-17 20:22:59 +0200
commit3eb4310cd889e6c8d22c27f0326273acf0a3e8bf (patch)
tree508827a64a5ad5c2d465535afea68eee39775a11 /services/cloudsync/docs/example.rst
parent07381c3edad8ec24b5d820ec0592e0cafa7d73fa (diff)
parent1e868fadf94935bcb4a49ea5eec776d84fe2d1e7 (diff)
downloadUXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.gz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.lz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.xz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.zip
Merge branch 'Sync-weave'
Diffstat (limited to 'services/cloudsync/docs/example.rst')
-rw-r--r--services/cloudsync/docs/example.rst132
1 files changed, 0 insertions, 132 deletions
diff --git a/services/cloudsync/docs/example.rst b/services/cloudsync/docs/example.rst
deleted file mode 100644
index 33d0f0531..000000000
--- a/services/cloudsync/docs/example.rst
+++ /dev/null
@@ -1,132 +0,0 @@
-.. _cloudsync_example:
-
-=======
-Example
-=======
-
-.. code-block:: javascript
-
- Cu.import("resource://gre/modules/CloudSync.jsm");
-
- let HelloWorld = {
- onLoad: function() {
- let cloudSync = CloudSync();
- console.log("CLOUDSYNC -- hello world", cloudSync.local.id, cloudSync.local.name, cloudSync.adapters);
- cloudSync.adapters.register('helloworld', {});
- console.log("CLOUDSYNC -- " + JSON.stringify(cloudSync.adapters.getAdapterNames()));
-
-
- cloudSync.tabs.addEventListener("change", function() {
- console.log("tab change");
- cloudSync.tabs.getLocalTabs().then(
- function(records) {
- console.log(JSON.stringify(records));
- }
- );
- });
-
- cloudSync.tabs.getLocalTabs().then(
- function(records) {
- console.log(JSON.stringify(records));
- }
- );
-
- let remoteClient = {
- id: "001",
- name: "FakeClient",
- };
- let remoteTabs1 = [
- {url:"https://www.google.ca",title:"Google",icon:"https://www.google.ca/favicon.ico",lastUsed:Date.now()},
- ];
- let remoteTabs2 = [
- {url:"https://www.google.ca",title:"Google Canada",icon:"https://www.google.ca/favicon.ico",lastUsed:Date.now()},
- {url:"http://www.reddit.com",title:"Reddit",icon:"http://www.reddit.com/favicon.ico",lastUsed:Date.now()},
- ];
- cloudSync.tabs.mergeRemoteTabs(remoteClient, remoteTabs1).then(
- function() {
- return cloudSync.tabs.mergeRemoteTabs(remoteClient, remoteTabs2);
- }
- ).then(
- function() {
- return cloudSync.tabs.getRemoteTabs();
- }
- ).then(
- function(tabs) {
- console.log("remote tabs:", tabs);
- }
- );
-
- cloudSync.bookmarks.getRootFolder("Hello World").then(
- function(rootFolder) {
- console.log(rootFolder.name, rootFolder.id);
- rootFolder.addEventListener("add", function(guid) {
- console.log("CLOUDSYNC -- bookmark item added: " + guid);
- rootFolder.getLocalItemsById([guid]).then(
- function(items) {
- console.log("CLOUDSYNC -- items: " + JSON.stringify(items));
- }
- );
- });
- rootFolder.addEventListener("remove", function(guid) {
- console.log("CLOUDSYNC -- bookmark item removed: " + guid);
- rootFolder.getLocalItemsById([guid]).then(
- function(items) {
- console.log("CLOUDSYNC -- items: " + JSON.stringify(items));
- }
- );
- });
- rootFolder.addEventListener("change", function(guid) {
- console.log("CLOUDSYNC -- bookmark item changed: " + guid);
- rootFolder.getLocalItemsById([guid]).then(
- function(items) {
- console.log("CLOUDSYNC -- items: " + JSON.stringify(items));
- }
- );
- });
- rootFolder.addEventListener("move", function(guid) {
- console.log("CLOUDSYNC -- bookmark item moved: " + guid);
- rootFolder.getLocalItemsById([guid]).then(
- function(items) {
- console.log("CLOUDSYNC -- items: " + JSON.stringify(items));
- }
- );
- });
-
- function logLocalItems() {
- return rootFolder.getLocalItems().then(
- function(items) {
- console.log("CLOUDSYNC -- local items: " + JSON.stringify(items));
- }
- );
- }
-
- let items = [
- {"id":"9fdoci2KOME6","type":rootFolder.FOLDER,"parent":rootFolder.id,"title":"My Bookmarks 1"},
- {"id":"1fdoci2KOME5","type":rootFolder.FOLDER,"parent":rootFolder.id,"title":"My Bookmarks 2"},
- {"id":"G_UL4ZhOyX8m","type":rootFolder.BOOKMARK,"parent":"1fdoci2KOME5","title":"reddit: the front page of the internet","uri":"http://www.reddit.com/"},
- ];
- function mergeSomeItems() {
- return rootFolder.mergeRemoteItems(items);
- }
-
- logLocalItems().then(
- mergeSomeItems
- ).then(
- function(processedItems) {
- console.log("!!!", processedItems);
- console.log("merge complete");
- },
- function(error) {
- console.log("merge failed:", error);
- }
- ).then(
- logLocalItems
- );
- }
- );
-
-
- },
- };
-
- window.addEventListener("load", function(e) { HelloWorld.onLoad(e); }, false);