summaryrefslogtreecommitdiff
path: root/examples/js/autoquvi.js
diff options
context:
space:
mode:
authorportix <none@none>2012-06-09 10:44:26 +0200
committerportix <none@none>2012-06-09 10:44:26 +0200
commit24f8b43b392c3fb5d930bf81cb41098c7c694c9d (patch)
treee0e0cfc912ed25d43d85eee2df901a750d878283 /examples/js/autoquvi.js
parent44d64cadd95a2240d2ce4aef6d9a161ca126f71f (diff)
downloaddwb-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/autoquvi.js')
-rw-r--r--examples/js/autoquvi.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/js/autoquvi.js b/examples/js/autoquvi.js
new file mode 100644
index 00000000..41ea5f3d
--- /dev/null
+++ b/examples/js/autoquvi.js
@@ -0,0 +1,31 @@
+#!javascript
+
+var supported = [];
+var quvi = "quvi -f best ";
+var mplayer = ' --exec "mplayer %u"';
+function quviSpawn(wv, o) {
+ var host = wv.host;
+ for (var i=0; i<supported.length; i++) {
+ var s = supported[i];
+ if (s.test(host)) {
+ system.spawn(quvi + wv.uri + mplayer, null, null);
+ }
+ }
+}
+
+function stdoutCallback(response) {
+ var lines = response.split("\n");
+ for (var i=0; i<lines.length; i++) {
+ try {
+ var pattern = lines[i].match(/^\s*\S+/)[0];
+ supported.push(new RegExp(pattern.replace(/%/g, "\\")));
+ }
+ catch(e) {
+ io.print(e);
+ }
+ }
+ signals.connect("loadCommitted", quviSpawn);
+}
+if (system.spawn("quvi --support", stdoutCallback) & SpawnError.spawnFailed) {
+ io.print("\033[31mDWB SCRIPT ERROR:\033[0m Initiating quvi failed, aborting");
+}