Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 20th, 2011  |  syntax: None  |  size: 1.42 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*Google.de Suche */
  2.  
  3. makeSearchCommand({
  4.   name: "gg",
  5.   url: "http://www.google.de/search?q={QUERY}",
  6.   icon: "http://www.google.com/favicon.ico",
  7.   author: {name: "Mario Priebe", email: "mp@biggle.de"},
  8.   description: "Suchen auf Google.de",
  9.   preview: function(pblock, directObject) {
  10.     var searchTerm = directObject.text;
  11.     var pTemplate = "Suchen auf Google.de nach: <strong>${query}</strong>";
  12.     var pData = {query: searchTerm};
  13.     pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
  14.  
  15.     var url = "http://ajax.googleapis.com/ajax/services/search/web";
  16.     var params = { v: "1.0", q: searchTerm };
  17.  
  18.     jQuery.get( url, params, function(data) {
  19.       var numToDisplay = 4;
  20.       var results = data.responseData.results.splice( 0, numToDisplay );
  21.  
  22.       pblock.innerHTML = CmdUtils.renderTemplate( {file:"google-search.html"},
  23.                                                   {results:results}
  24.                                                 );
  25.       }, "json");
  26.   }
  27. });/* This is a template command. */
  28. CmdUtils.CreateCommand({
  29.   name: "example",
  30.   icon: "http://example.com/example.png",
  31.   homepage: "http://example.com/",
  32.   author: {name: "Your Name", email: "you@example.com"},
  33.   license: "GPL",
  34.   description: "A short description of your command",
  35.   help: "How to use your command",
  36.   takes: {"input": /.*/},
  37.   preview: function(pblock, input) {
  38.     pblock.innerHTML = "Your input is <b>" + input.text + "</b>.";
  39.   },
  40.   execute: function(input) {
  41.     displayMessage("You selected: " + input.text);
  42.   }
  43. });
clone this paste RAW Paste Data