diff options
author | portix <none@none> | 2012-06-09 10:44:26 +0200 |
---|---|---|
committer | portix <none@none> | 2012-06-09 10:44:26 +0200 |
commit | 24f8b43b392c3fb5d930bf81cb41098c7c694c9d (patch) | |
tree | e0e0cfc912ed25d43d85eee2df901a750d878283 /examples/js/googledocs.js | |
parent | 44d64cadd95a2240d2ce4aef6d9a161ca126f71f (diff) | |
download | dwb-24f8b43b392c3fb5d930bf81cb41098c7c694c9d.zip |
Adding googledocs.js to examples
--HG--
rename : examples/autoquvi.js => examples/js/autoquvi.js
rename : examples/formfiller.js => examples/js/formfiller.js
Diffstat (limited to 'examples/js/googledocs.js')
-rw-r--r-- | examples/js/googledocs.js | 63 |
1 files changed, 63 insertions, 0 deletions
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"); |