view wowhead/wowhead.js @ 21:e82bff1ef296

Changed code to be more html-like than JS-ish.
author Atul Varma <varmaa@toolness.com>
date Thu, 07 May 2009 15:26:40 -0700
parents e077838df525
children
line wrap: on
line source

/* 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: "results.html",
  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);
  }
});