From 24f8b43b392c3fb5d930bf81cb41098c7c694c9d Mon Sep 17 00:00:00 2001
From: portix <none@none>
Date: Sat, 9 Jun 2012 10:44:26 +0200
Subject: Adding googledocs.js to examples

--HG--
rename : examples/autoquvi.js => examples/js/autoquvi.js
rename : examples/formfiller.js => examples/js/formfiller.js
---
 examples/js/googledocs.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 examples/js/googledocs.js

(limited to 'examples/js/googledocs.js')

diff --git a/examples/js/googledocs.js b/examples/js/googledocs.js
new file mode 100644
index 00000000..92163111
--- /dev/null
+++ b/examples/js/googledocs.js
@@ -0,0 +1,63 @@
+#!javascript
+
+/*
+ * Shortcut to toggle usage of Google Docs
+ */
+var shortCut = "tgd";
+
+/*
+ * Whether to initially use Google Docs
+ */
+var useDocs = true;
+
+/*
+ * list off all supported filetypes, comment / uncomment to enable/disable
+ * filetype
+ */
+var supported = [ 
+  "DOC", 
+  "DOCX", 
+  "XLS", 
+  "XLSX", 
+  "PPT", 
+  "PPTX", 
+  "ODT", 
+  "ODS",
+  "PDF", 
+  "PAGES", 
+  "AI", 
+  "PSD", 
+  "TIFF", 
+  "DXF", 
+  "SVG", 
+  "EPS", 
+  "PS", 
+  "TTF",
+  "OTF", 
+  "XPS", 
+  // "ZIP", 
+  // "RAR"  
+];
+
+
+var id = signals.connect("download", downloadCheck);
+var reg = new RegExp(".*\.(" + supported.join("|") + ")$", "i");
+
+function downloadCheck(w, d) {
+  if (reg.test(d.networkRequest.uri)) {
+    w.loadUri("http://docs.google.com/viewer?url=" + d.networkRequest.uri);
+    return true;
+  }
+}
+function toggleDocs() {
+  useDocs = !useDocs;
+  if (!useDocs) {
+    signals.disconnect(id);
+    io.notify("Google Docs disabled");
+  }
+  else {
+    id = signals.connect("download", downloadCheck);
+    io.notify("Google Docs enabled");
+  }
+}
+bind(shortCut, toggleDocs, "googleDocs");
-- 
cgit v1.2.3