diff wowhead/wowhead.js @ 0:a2715827c482

Origination.
author Atul Varma <varmaa@toolness.com>
date Thu, 19 Mar 2009 23:30:41 -0700
parents
children e077838df525
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wowhead/wowhead.js	Thu Mar 19 23:30:41 2009 -0700
@@ -0,0 +1,31 @@
+/* This is a template command. */
+CmdUtils.CreateCommand({
+  name: "wowhead",
+  icon: "http://www.wowhead.com/favicon.png",
+  homepage: "http://www.wowhead.com/",
+  author: {name: "Your Name", email: "you@example.com"},
+  license: "GPL",
+  description: "A short description of your command",
+  help: "How to use your command",
+  takes: {"input": /.*/},
+  previewUrl: Utils.url({uri: "results.html", base: feed.id}),
+  preview: function(pblock, input) {
+    var url = ("http://www.wowhead.com/?search=" + encodeURI(input.text) +
+               "&opensearch");
+    CmdUtils.previewAjax(pblock, {
+      url: url,
+      dataType: "text",
+      error: function() {
+        pblock.innerHTML = "Sorry, an error occurred.";
+      },
+      success: function(data) {
+        var scriptTag = pblock.ownerDocument.createElement("script");
+        scriptTag.textContent = "showResults(" + data + ");";
+        pblock.appendChild(scriptTag);
+      }
+    });
+  },
+  execute: function(input) {
+    displayMessage("You selected: " + input.text);
+  }
+});