PageRenderTime 99ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/extension/ubiquity.js

https://github.com/cosimo/ubiquity-opera
JavaScript | 1410 lines | 1187 code | 130 blank | 93 comment | 110 complexity | 9855e8a40aa478de187786b2e11f4136 MD5 | raw file
  1. // -------------------------------------
  2. // ==UserScript==
  3. // @name Ubiquity for Opera
  4. // @author Cosimo Streppone
  5. // @ujs:modified 2010-10-22
  6. // ==/UserScript==
  7. // -------------------------------------
  8. //
  9. (function (opera) {
  10. if (! opera) return;
  11. // -----------------------------------------------
  12. //
  13. // Firefox Ubiquity emulation layer
  14. //
  15. // -----------------------------------------------
  16. //
  17. // CmdUtils
  18. //
  19. if (CmdUtils == undefined) var CmdUtils = {}
  20. noun_arb_text = 1;
  21. CmdUtils.VERSION = 0.01;
  22. CmdUtils.CommandList = new Array ();
  23. CmdUtils.CreateCommand = function CreateCommand (args) {
  24. var cmd_name = args['name'];
  25. var cmd_list = CmdUtils.CommandList;
  26. if (cmd_name in cmd_list) {
  27. return;
  28. }
  29. CmdUtils.CommandList.push(args);
  30. }
  31. CmdUtils.closeWindow = function closeWindow () { CmdUtils.getWindow().close(); }
  32. CmdUtils.getDocument = function getDocument () { return document; }
  33. CmdUtils.getLocation = function getLocation () { return CmdUtils.getDocument().location; }
  34. CmdUtils.getWindow = function getWindow () { return window; }
  35. CmdUtils.openWindow = function openWindow (url,name) {
  36. CmdUtils.getWindow().setTimeout(function() {
  37. if (!name) {
  38. CmdUtils.getWindow().open(url);
  39. } else {
  40. CmdUtils.getWindow().open(url, name);
  41. }}, 0);
  42. }
  43. // 2nd order function
  44. CmdUtils.SimpleUrlBasedCommand = function SimpleUrlBasedCommand (url) {
  45. if (! url) return;
  46. var search_func = function (directObj) {
  47. if (! directObj) return;
  48. var text = directObj.text;
  49. text = encodeURIComponent(text);
  50. url = url.replace('{text}', text);
  51. url = url.replace('{location}', CmdUtils.getLocation());
  52. CmdUtils.toggleUbiquityWindow();
  53. Utils.openUrlInBrowser(url);
  54. };
  55. return search_func;
  56. }
  57. CmdUtils.toggleUbiquityWindow = function toggleUbiquityWindow (w) {
  58. if (!w) w = ubiq_window;
  59. var vis = w.style.visibility;
  60. vis = (vis=='hidden') ? 'visible' : 'hidden';
  61. w.style.visibility=vis;
  62. return;
  63. }
  64. //
  65. // Utils
  66. //
  67. if (Utils==undefined) var Utils = {}
  68. Utils.openUrlInBrowser = function(url) {
  69. window.open(url);
  70. };
  71. //
  72. // Application
  73. //
  74. if (Application==undefined) var Application = {
  75. activeWindow: {
  76. activeTab: window
  77. }
  78. }
  79. var ubiq_window;
  80. var ubiq_selection;
  81. var ubiq_element;
  82. var ubiq_remote_server = 'http://people.opera.com/cosimo/ubiquity';
  83. var ubiq_selected_command;
  84. var ubiq_first_match;
  85. // Used to get css url of images and other resources
  86. function ubiq_url_for (path) {
  87. var url = 'url(';
  88. url += ubiq_remote_server;
  89. url += '/';
  90. url += path;
  91. url += ')';
  92. return url;
  93. }
  94. function ubiq_create_window () {
  95. var doc = window.document;
  96. var wnd = document.createElement('div');
  97. var stl = wnd.style;
  98. wnd.setAttribute('id', 'ubiq_window');
  99. stl.position='fixed';
  100. stl.left='1px';
  101. stl.top='1px';
  102. stl.visibility='hidden';
  103. stl.width='810px';
  104. stl.height='561px';
  105. stl.border='0';
  106. stl.padding='0';
  107. // Our window should appear on top of everything
  108. stl.zIndex='99999';
  109. stl.background = ubiq_url_for('ubiq_background.png');
  110. wnd.innerHTML = ubiq_start_mode();
  111. doc.body.appendChild(wnd);
  112. return wnd;
  113. }
  114. function ubiq_start_mode () {
  115. var input_style =
  116. 'border:0; padding:0; height:32px; margin-top:16px;'
  117. + 'margin-left:10px; background:none; color:black;'
  118. + 'font-family: Trebuchet MS, Arial, Helvetica; font-size: 28px;';
  119. var div_style = 'border:0; display:block; float:left; margin:0;';
  120. var results_panel_style = div_style +
  121. 'clear:both; text-align: left; padding-top:2px; font-size: 19px; '
  122. + 'font-weight: normal; color:white; height: 502px;';
  123. var html =
  124. '<div id="ubiq-input-panel" style="' + div_style + ';width:99%;height:55px">'
  125. + '<form id="ubiq1" onsubmit="return false">'
  126. + '<input autocomplete="off" id="ubiq_input" style="' + input_style +'" type="text" size="60" maxlength="500">'
  127. + '</form>'
  128. + '</div>'
  129. + '<br/>'
  130. + '<div id="ubiq-results-panel" style="width:100%;' + results_panel_style + '">'
  131. + ubiq_help()
  132. + '</div>'
  133. + '<div id="ubiq-command-tip" style="position:absolute;left:310px;top:65px;display:block;border:0;color:#ddd;font-family:Helvetica,Arial;font-style:italic;font-size:11pt"></div>'
  134. + '<div id="ubiq-command-preview" style="position:absolute;left:310px;top:85px;display:block;overflow:auto;border:0;color:#ddd;"></div>'
  135. ;
  136. return html;
  137. }
  138. function ubiq_show_preview (cmd) {
  139. var el = document.getElementById('ubiq-command-preview');
  140. if (! el) return;
  141. if (! cmd) {
  142. el.innerHTML = '';
  143. return;
  144. }
  145. preview_func = CmdUtils.CommandList[cmd]['preview'];
  146. if (typeof preview_func == 'string') {
  147. el.innerHTML = preview_func;
  148. }
  149. else {
  150. var directObj = {
  151. text: ubiq_command(),
  152. };
  153. preview_func(el, directObj);
  154. }
  155. return;
  156. }
  157. // ubiq_xml_http(url, function(ajax){
  158. // if (! ajax) return;
  159. // var text=ajax.responseText;
  160. // if (! text) return;
  161. // var preview_block=document.getElementById('ubiq-command-preview');
  162. // if (! preview_block) return;
  163. // preview_block.innerHTML=text;
  164. // });
  165. function ubiq_show_tip (tip) {
  166. var el = document.getElementById('ubiq-command-tip');
  167. if (! el) return;
  168. if (! tip) {
  169. el.innerHTML = '';
  170. return;
  171. }
  172. tip = CmdUtils.CommandList[tip]['description'];
  173. el.innerHTML = tip;
  174. return;
  175. }
  176. function ubiq_execute () {
  177. var cmd = ubiq_command();
  178. if (! cmd) return false;
  179. ubiq_dispatch_command(cmd);
  180. return false;
  181. }
  182. function ubiq_dispatch_command(line) {
  183. var words = line.split(' ');
  184. var cmd = words[0];
  185. var text;
  186. if (ubiq_selection) {
  187. text = ubiq_selection;
  188. } else {
  189. words.shift();
  190. text=words.join(' ');
  191. }
  192. // Expand match (typing 'go' will expand to 'google')
  193. cmd = ubiq_match_first_command(cmd);
  194. ubiq_replace_first_word(cmd);
  195. // Find command element
  196. var cmd_struct;
  197. for (var c in CmdUtils.CommandList) {
  198. var cmd_name = CmdUtils.CommandList[c]['name'];
  199. if (cmd_name == cmd) {
  200. cmd_struct = CmdUtils.CommandList[c];
  201. break;
  202. }
  203. }
  204. if (! cmd_struct) {
  205. return;
  206. }
  207. // Create a fake Ubiquity-like object, to pass to
  208. // command's "execute" function
  209. var cmd_func = cmd_struct['execute'];
  210. var direct_obj = { "text": text };
  211. // Run command's "execute" function
  212. cmd_func(direct_obj);
  213. return;
  214. }
  215. function ubiq_display_results (text) {
  216. var div=document.getElementById('ubiq-results-panel');
  217. if (! div) alert('no div!');
  218. div.innerHTML = text;
  219. div.style.visibility='show';
  220. }
  221. function ubiq_help () {
  222. var style = 'font-size:17px; padding:8px; font-weight:normal';
  223. var html = '<p style="' + style + '">Type the name of a command and press enter to execute it, or <b>help</b> for assistance.</p>';
  224. return html;
  225. }
  226. function ubiq_get_selection () {
  227. var str = '';
  228. if (document.getSelection) {
  229. str = document.getSelection();
  230. } else if (document.selection && document.selection.createRange) {
  231. var range = document.selection.createRange();
  232. str = range.text;
  233. }
  234. return (ubiq_selection = str);
  235. }
  236. function ubiq_toggle_window (w) {
  237. if (!w) w = ubiq_window;
  238. var vis = w.style.visibility;
  239. vis = (vis=='hidden') ? 'visible' : 'hidden';
  240. w.style.visibility=vis;
  241. return;
  242. }
  243. function ubiq_focus() {
  244. line = 'ubiq_input';
  245. el=document.getElementById(line);
  246. if(el.createTextRange){
  247. var oRange=el.createTextRange();
  248. oRange.moveStart("character", 0);
  249. oRange.moveEnd("character", el.value.length);
  250. oRange.select();
  251. }
  252. else if (el.setSelectionRange){
  253. el.setSelectionRange(0, el.value.length);
  254. }
  255. el.focus();
  256. }
  257. function ubiq_enabled () {
  258. var wnd = ubiq_window;
  259. if (! wnd) return;
  260. var vis = wnd.style.visibility;
  261. if (vis=='hidden') return false;
  262. return true;
  263. }
  264. function ubiq_command () {
  265. var cmd = document.getElementById('ubiq_input');
  266. if (! cmd) {
  267. ubiq_selected_command = -1;
  268. return '';
  269. }
  270. return cmd.value;
  271. }
  272. // Gets current selection element
  273. function ubiq_get_current_element () {
  274. var el;
  275. if (document.selection && document.selection.createRange) {
  276. var range = document.selection.createRange();
  277. el = range.parentElement();
  278. }
  279. return (ubiq_element = el);
  280. }
  281. function ubiq_match_first_command(text) {
  282. if (! text) text = ubiq_command();
  283. var first_match = '';
  284. // Command selected through cursor UP/DOWN
  285. if (ubiq_first_match) {
  286. return ubiq_first_match;
  287. }
  288. if (text.length > 0) {
  289. for (var c in CmdUtils.CommandList) {
  290. c = CmdUtils.CommandList[c]['name'];
  291. if (c.match('^' + text)) {
  292. first_match = c;
  293. break;
  294. }
  295. }
  296. }
  297. return first_match;
  298. }
  299. function ubiq_command_icon(c) {
  300. var icon = CmdUtils.CommandList[c]['icon'];
  301. if (!icon) {
  302. icon = 'http://people.opera.com/cosimo/ubiquity/spacer.png';
  303. }
  304. icon = '<img src="' + icon + '" width="16" height="16" border="0" alt="" align="absmiddle"> ';
  305. return icon;
  306. }
  307. function ubiq_command_name(c) {
  308. return CmdUtils.CommandList[c]['name'];
  309. }
  310. function ubiq_replace_first_word(w) {
  311. if (!w) return;
  312. var text = ubiq_command();
  313. var words = text.split(' ');
  314. words[0] = w;
  315. var cmd_line = document.getElementById('ubiq_input');
  316. if (! cmd_line) return;
  317. cmd_line.value = words.join(' ');
  318. return;
  319. }
  320. function ubiq_show_matching_commands (text) {
  321. if (! text) text = ubiq_command();
  322. // Always consider 1st word only
  323. text = text.split(' ')[0];
  324. ubiq_first_match = null;
  325. var show_all = text == '*all';
  326. var matches = new Array();
  327. var substr_matches = new Array();
  328. if (text.length > 0) {
  329. for (var c in CmdUtils.CommandList) {
  330. var cmd = CmdUtils.CommandList[c]['name'];
  331. // Starting match only /^command/
  332. if (show_all || cmd.match('^' + text)) {
  333. matches.push(c);
  334. }
  335. // Substring matching as well, in a separate list
  336. else if (cmd.match(text)) {
  337. substr_matches.push(c);
  338. }
  339. }
  340. }
  341. // Some substring matches found, append to list of matches
  342. if (substr_matches.length > 0) {
  343. var full_matches = matches.length;
  344. for (m in substr_matches) {
  345. matches.push(substr_matches[m]);
  346. // Too long lists overflow from the layer
  347. if ((parseInt(m) + full_matches) > 11) {
  348. matches.push('...');
  349. break;
  350. }
  351. }
  352. }
  353. // Where to show the results
  354. var results_panel = document.getElementById('ubiq-results-panel');
  355. // Don't navigate outside boundaries of the list of matches
  356. if (ubiq_selected_command >= matches.length) {
  357. ubiq_selected_command = matches.length - 1;
  358. }
  359. else if (ubiq_selected_command == -1) {
  360. ubiq_selected_command = 0;
  361. }
  362. // We have matches, show a list
  363. if (matches.length > 0) {
  364. var suggestions_div = document.createElement('div');
  365. var suggestions_list = document.createElement('ul');
  366. suggestions_list.style = 'padding:0; margin:0';
  367. ubiq_show_tip(matches[ubiq_selected_command]);
  368. //ubiq_show_preview(matches[ubiq_selected_command]);
  369. for (var c in matches) {
  370. var is_selected = (c == ubiq_selected_command);
  371. var li=document.createElement('li');
  372. var li_bg=ubiq_url_for(is_selected ? 'selected_background.png' : 'command_background.png');
  373. c = matches[c];
  374. if (c == '...') {
  375. li.innerHTML = c;
  376. }
  377. else {
  378. var icon = ubiq_command_icon(c);
  379. var cmd = ubiq_command_name(c);
  380. if (is_selected) ubiq_first_match = cmd;
  381. li.innerHTML=icon + cmd;
  382. }
  383. li.style = 'color: black; list-style: none; margin:0; padding-top:8px; padding-left:12px;'
  384. + 'font-family: Helvetica,Arial; font-size: 14px; height:26px;'
  385. + 'background-image:'+li_bg+'; background-repeat: no-repeat;';
  386. suggestions_list.appendChild(li);
  387. }
  388. suggestions_div.appendChild(suggestions_list);
  389. results_panel.innerHTML = suggestions_div.innerHTML;
  390. }
  391. else {
  392. ubiq_selected_command = -1;
  393. ubiq_show_tip(null);
  394. results_panel.innerHTML = ubiq_help();
  395. }
  396. return;
  397. }
  398. function ubiq_key_handler (userjs_event) {
  399. if (!userjs_event) return;
  400. var ev = userjs_event;
  401. var kc = ev.keyCode;
  402. // ev.ctrlKey is always false on Opera 9.63 on Linux (?)
  403. var magic_key_pressed = kc==85 && (ev.ctrlKey || ev.metaKey) && ev.shiftKey;
  404. // If we're in the background (or not created), return immediately
  405. // Otherwise, activate only on magic key
  406. if (! ubiq_enabled()) {
  407. // Create our window if not already done
  408. if (! ubiq_window) {
  409. ubiq_window = ubiq_create_window();
  410. }
  411. if (magic_key_pressed) {
  412. // Get text selection before switching window focus
  413. ubiq_get_selection();
  414. ubiq_get_current_element();
  415. ubiq_toggle_window();
  416. ubiq_focus();
  417. }
  418. }
  419. else {
  420. // Magic key or ESC, hide the Ubiquity window
  421. if (magic_key_pressed || kc==27) {
  422. ubiq_toggle_window();
  423. return;
  424. }
  425. // On ENTER, execute the given command
  426. if (kc==13) {
  427. ubiq_execute();
  428. return;
  429. }
  430. // Cursor up
  431. if (kc==38) {
  432. ubiq_select_prev_command();
  433. }
  434. // Cursor Down
  435. else if (kc==40) {
  436. ubiq_select_next_command();
  437. }
  438. ubiq_show_matching_commands();
  439. }
  440. }
  441. function ubiq_select_prev_command () {
  442. if (ubiq_selected_command > 0) {
  443. ubiq_selected_command--;
  444. }
  445. }
  446. function ubiq_select_next_command () {
  447. ubiq_selected_command++;
  448. }
  449. function ubiq_xml(node){
  450. return (node && node.nodeType) ? new XMLSerializer().serializeToString(node):'('+node+')';
  451. }
  452. function ubiq_xml_http (url,callback) {
  453. var xmlhttp = new XMLHttpRequest();
  454. xmlhttp.onreadystatechange = function(){
  455. var s = ''+this+'\n';
  456. s += 'status: '+this.status+'\n';
  457. s += 'statusText: '+this.statusText+'\n\n';
  458. s += 'allheaders: '+this.getAllResponseHeaders()+'\n\n';
  459. s += 'responseText: '+this.responseText+'\n\n';
  460. s += 'responseXML: '+(ubiq_xml(this.responseXML))+'\n\n';
  461. var obj = {
  462. status: this.status,
  463. statusText: this.statusText,
  464. allheaders: this.getAllResponseHeaders(),
  465. responseText: this.responseText,
  466. responseXML: ubiq_xml(this.responseXML),
  467. };
  468. callback(obj);
  469. }
  470. xmlhttp.onload = function(){};
  471. //
  472. // var obj = document.getElementById(elem);
  473. // if (! obj) return;
  474. // obj.innerHTML='';
  475. // obj.style.display='';
  476. //}
  477. xmlhttp.open('GET', url, true);
  478. xmlhttp.send('a=b&c=d');
  479. }
  480. //--------------------------------------------------------
  481. //
  482. // Command definitions
  483. //
  484. //--------------------------------------------------------
  485. CmdUtils.CreateCommand({
  486. name: "amazon-search",
  487. takes: {"search_string": noun_arb_text},
  488. description: "Search Amazon for books matching:",
  489. author: {},
  490. icon: "http://www.amazon.com/favicon.ico",
  491. homepage: "",
  492. license: "",
  493. preview: "Search Amazon for books matching:",
  494. execute: CmdUtils.SimpleUrlBasedCommand(
  495. 'http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Dstripbooks&field-keywords={text}'
  496. )
  497. });
  498. CmdUtils.CreateCommand({
  499. name: "answers-search",
  500. takes: {"search_string": noun_arb_text},
  501. description: "Search Answers.com for:",
  502. author: {},
  503. icon: "http://www.answers.com/favicon.ico",
  504. homepage: "",
  505. license: "",
  506. preview: "Search Answers.com for:",
  507. execute: CmdUtils.SimpleUrlBasedCommand('http://www.answers.com/{text}')
  508. });
  509. CmdUtils.CreateCommand({
  510. name: "ask-search",
  511. takes: {"search_string": noun_arb_text},
  512. description: "Search Ask.com for the given words",
  513. author: {},
  514. icon: "http://www.ask.com/favicon.ico",
  515. homepage: "",
  516. license: "",
  517. preview: "Search Ask.com for the given words:",
  518. execute: CmdUtils.SimpleUrlBasedCommand('http://www.ask.com/web?q={text}')
  519. });
  520. CmdUtils.CreateCommand({
  521. name: "back",
  522. takes: {"pages": noun_arb_text}, // FIXME SHOULD BE INTEGER SOMETHING
  523. description: "Go back in browser history",
  524. author: {},
  525. icon: "",
  526. homepage: "",
  527. license: "",
  528. preview: "Go back {text} steps in history",
  529. execute: function (directObj) {
  530. var steps = parseInt (directObj.text);
  531. steps = - steps - 1;
  532. history.go(steps);
  533. CmdUtils.toggleUbiquityWindow();
  534. }
  535. });
  536. CmdUtils.CreateCommand({
  537. name: "bing",
  538. takes: {"expr": noun_arb_text},
  539. description: "Search the web with Microsoft Bing",
  540. author: {},
  541. icon: "http://www.bing.com/favicon.ico",
  542. homepage: "",
  543. license: "",
  544. preview: "Search the web with Microsoft Bing",
  545. execute: CmdUtils.SimpleUrlBasedCommand(
  546. "http://www.bing.com/search?q={text}&form=OPRTSD&pc=OPER"
  547. )
  548. });
  549. CmdUtils.CreateCommand({
  550. name: "bugzilla",
  551. takes: {"search_string": noun_arb_text},
  552. description: "Perform a bugzilla search for",
  553. author: {},
  554. icon: "http://www.mozilla.org/favicon.ico",
  555. homepage: "",
  556. license: "",
  557. preview: "Perform a bugzilla search for",
  558. execute: CmdUtils.SimpleUrlBasedCommand(
  559. "https://bugzilla.mozilla.org/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&content={text}"
  560. )
  561. });
  562. CmdUtils.CreateCommand({
  563. name: "close",
  564. takes: {},
  565. description: "Close the current window",
  566. author: {},
  567. icon: "",
  568. homepage: "",
  569. license: "",
  570. preview: "Close the current window",
  571. execute: function (directObj) {
  572. CmdUtils.toggleUbiquityWindow();
  573. CmdUtils.closeWindow();
  574. }
  575. });
  576. CmdUtils.CreateCommand({
  577. name: "clusty",
  578. takes: {"search_string": noun_arb_text},
  579. description: "Perform a clustered search through clusty.com",
  580. author: {},
  581. icon: "http://clusty.com/images/clusty-favicon.ico",
  582. homepage: "",
  583. license: "",
  584. preview: "Perform a clustered search through clusty.com",
  585. execute: CmdUtils.SimpleUrlBasedCommand(
  586. "http://clusty.com/search?query={text}"
  587. )
  588. });
  589. CmdUtils.CreateCommand({
  590. name: "code-search",
  591. takes: {"search_string": noun_arb_text},
  592. description: "Search any source code for the given string",
  593. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  594. icon: "http://www.google.com/favicon.ico",
  595. homepage: "http://codesearch.google.com",
  596. license: "",
  597. preview: "Search any source code for the given string",
  598. execute: CmdUtils.SimpleUrlBasedCommand(
  599. 'http://www.google.com/codesearch?client=opera&sourceid=opera&q={text}'
  600. )
  601. });
  602. CmdUtils.CreateCommand({
  603. name: "command-list",
  604. takes: {},
  605. description: "Shows the list of Ubiquity commands and what they do",
  606. author: {},
  607. icon: "",
  608. homepage: "",
  609. license: "",
  610. preview: "Shows the list of Ubiquity commands and what they do",
  611. execute: function (directObj) {
  612. ubiq_show_matching_commands('*all');
  613. }
  614. });
  615. CmdUtils.CreateCommand({
  616. name: "cpan",
  617. icon: "http://search.cpan.org/favicon.ico",
  618. description: "Search for a CPAN package information",
  619. homepage: "",
  620. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org"},
  621. license: "",
  622. takes: {"package_name": noun_arb_text},
  623. preview: "Search for a CPAN package information",
  624. execute: CmdUtils.SimpleUrlBasedCommand(
  625. "http://search.cpan.org/dist/{text}"
  626. )
  627. });
  628. CmdUtils.CreateCommand({
  629. name: "currency-converter",
  630. takes: {"currency_spec": noun_arb_text},
  631. description: "Convert currency using xe.com converter service.<br/><i>Ex.: 5000 NOK to EUR</i>",
  632. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  633. icon: "http://www.xe.com/favicon.ico",
  634. homepage: "http://xe.com/ucc/",
  635. license: "",
  636. preview: "Convert currency values using xe.com converter service.",
  637. execute: function( directObj ) {
  638. var currency_spec = directObj.text;
  639. var matches = currency_spec.match(/^([\d\.]+)\s+(\w+)\s+to\s+(\w+)$/);
  640. var amount = matches[1];
  641. var curr_from = matches[2].toUpperCase();
  642. var curr_to = matches[3].toUpperCase();
  643. var xe_url = "http://www.xe.com/ucc/convert.cgi?Amount=" + escape(amount)
  644. + "&From=" + escape(curr_from) + "&To=" + escape(curr_to);
  645. Utils.openUrlInBrowser(xe_url);
  646. }
  647. });
  648. CmdUtils.CreateCommand({
  649. name: "dictionary",
  650. description: "Gives the meaning of a word.",
  651. author: { name: "Isidoros Passadis", email: "isidoros.passadis@gmail.com"},
  652. help: "Try issuing &quot;dictionary ubiquity&quot;",
  653. license: "MPL",
  654. icon: "http://dictionary.reference.com/favicon.ico",
  655. takes: {"word": noun_arb_text},
  656. execute: function( directObj ) {
  657. var word = directObj.text;
  658. Utils.openUrlInBrowser( "http://dictionary.reference.com/search?q=" + escape(word) );
  659. },
  660. preview: "Gives the meaning of a word.",
  661. });
  662. CmdUtils.CreateCommand({
  663. name: "dramatic-chipmunk",
  664. takes: {},
  665. description: "Prepare for a dramatic moment of your life",
  666. author: {},
  667. icon: "http://www.youtube.com/favicon.ico",
  668. homepage: "",
  669. license: "",
  670. preview: "Prepare for a dramatic moment of your life",
  671. execute: CmdUtils.SimpleUrlBasedCommand(
  672. "http://www.youtube.com/watch?v=a1Y73sPHKxw"
  673. )
  674. });
  675. CmdUtils.CreateCommand({
  676. name: "duckduckgo",
  677. takes: {"search_string": noun_arb_text},
  678. description: "Search on DuckDuckGo for the given words",
  679. author: {},
  680. icon: "http://duckduckgo.com/favicon.ico",
  681. homepage: "http://duckduckgo.com",
  682. license: "",
  683. preview: "Search on DuckDuckGo for the given words",
  684. execute: CmdUtils.SimpleUrlBasedCommand(
  685. "http://duckduckgo.com/?client=opera&q={text}&sourceid=opera&ie=utf-8&oe=utf-8"
  686. )
  687. });
  688. CmdUtils.CreateCommand({
  689. name: "ebay-search",
  690. takes: {"search_string": noun_arb_text},
  691. description: "Search ebay for the given words",
  692. author: {},
  693. icon: "http://ebay.com/favicon.ico",
  694. homepage: "",
  695. license: "",
  696. preview: "Search ebay for the given words",
  697. execute: CmdUtils.SimpleUrlBasedCommand(
  698. "http://search.ebay.com/search/search.dll?satitle={text}"
  699. )
  700. });
  701. CmdUtils.CreateCommand({
  702. name: "fizy",
  703. icon: "http://www.fizy.com/favicon.ico",
  704. description: "Search Music and Video",
  705. preview: "Search Music and Video on fizy.com:",
  706. execute: CmdUtils.SimpleUrlBasedCommand(
  707. "http://fizy.com/?q={text}&type=&quality=&duration=&x=0&y=0"
  708. )
  709. });
  710. CmdUtils.CreateCommand({
  711. name: "flickr",
  712. takes: {"search_string": noun_arb_text},
  713. description: "Search photos on Flickr",
  714. author: {},
  715. icon: "http://flickr.com/favicon.ico",
  716. homepage: "",
  717. license: "",
  718. preview: "Search photos on Flickr",
  719. execute: CmdUtils.SimpleUrlBasedCommand(
  720. "http://www.flickr.com/search/?q={text}&w=all"
  721. )
  722. });
  723. CmdUtils.CreateCommand({
  724. name: "gcalculate",
  725. takes: {"expression": noun_arb_text}, // FIXME a different type?
  726. description: "Examples: 3^4/sqrt(2)-pi, 3 inch in cm, speed of light, 0xAF in decimal (<a href=\"http://www.googleguide.com/calculator.html\">Command list</a>)",
  727. author: {},
  728. icon: "http://www.google.com/favicon.ico",
  729. homepage: "",
  730. license: "",
  731. preview: "Examples: 3^4/sqrt(2)-pi, 3 inch in cm, speed of light, 0xAF in decimal (<a href=\"http://www.googleguide.com/calculator.html\">Command list</a>)",
  732. execute: CmdUtils.SimpleUrlBasedCommand(
  733. "http://www.google.com/search?client=opera&num=1&q={text}&sourceid=opera&ie=utf-8&oe=utf-8"
  734. )
  735. });
  736. CmdUtils.CreateCommand({
  737. name: "google-search",
  738. takes: {"search_string": noun_arb_text},
  739. description: "Search on Google for the given words",
  740. author: {},
  741. icon: "http://www.google.com/favicon.ico",
  742. homepage: "",
  743. license: "",
  744. preview: "Search on Google for the given words",
  745. execute: CmdUtils.SimpleUrlBasedCommand(
  746. "http://www.google.com/search?client=opera&q={text}&sourceid=opera&ie=utf-8&oe=utf-8"
  747. )
  748. });
  749. CmdUtils.CreateCommand({
  750. name: "help",
  751. takes: {},
  752. description: "Provides basic help on using Ubiquity for Opera",
  753. author: {},
  754. icon: "",
  755. homepage: "",
  756. license: "",
  757. preview: "Provides basic help on using Ubiquity for Opera",
  758. execute: CmdUtils.SimpleUrlBasedCommand(
  759. "http://people.opera.com/cosimo/ubiquity/help.html"
  760. )
  761. });
  762. CmdUtils.CreateCommand({
  763. name: "image-search",
  764. takes: {"search_string": noun_arb_text},
  765. description: "Search on Google for images",
  766. author: {},
  767. icon: "http://www.google.com/favicon.ico",
  768. homepage: "",
  769. license: "",
  770. preview: "Search on Google for images",
  771. execute: CmdUtils.SimpleUrlBasedCommand(
  772. "http://images.google.com/images?hl=en&q={text}&client=opera&sourceid=opera"
  773. )
  774. });
  775. CmdUtils.CreateCommand({
  776. name: "imdb",
  777. takes: {"search_string": noun_arb_text},
  778. description: "Searches for movies on IMDb",
  779. author: {},
  780. icon: "http://www.imdb.com/favicon.ico",
  781. homepage: "",
  782. license: "",
  783. preview: "Searches for movies on IMDb",
  784. execute: CmdUtils.SimpleUrlBasedCommand(
  785. "http://www.imdb.com/find?s=all&q={text}&x=0&y=0"
  786. )
  787. });
  788. CmdUtils.CreateCommand({
  789. name: "instant-rimshot",
  790. takes: {},
  791. description: "Instant Rimshot at your fingertips!",
  792. author: {},
  793. icon: "",
  794. homepage: "http://instantrimshot.com",
  795. license: "",
  796. preview: "Instant Rimshot at your fingertips!",
  797. execute: CmdUtils.SimpleUrlBasedCommand(
  798. "http://instantrimshot.com/rimshot.swf"
  799. )
  800. });
  801. CmdUtils.CreateCommand({
  802. name: "icon-search",
  803. takes: {"search_string": noun_arb_text},
  804. description: "IconFinder icon search:",
  805. author: {},
  806. icon: "http://cdn.iconfinder.net/design/images/favicon.ico",
  807. homepage: "",
  808. license: "",
  809. preview: "",
  810. execute: CmdUtils.SimpleUrlBasedCommand(
  811. 'http://www.iconfinder.com/search/?q={text}'
  812. )
  813. });
  814. //
  815. // From Ubiquity feed:
  816. // https://ubiquity.mozilla.com/herd/all-feeds/9b0b1de981e80b6fcfee0659ffdbb478d9abc317-4742/
  817. //
  818. // Modified to get the current window domain
  819. //
  820. CmdUtils.CreateCommand({
  821. name: "isdown",
  822. icon: "http://downforeveryoneorjustme.com/favicon.ico",
  823. description: "Check if selected/typed URL is down",
  824. homepage: "http://www.andyfilms.net",
  825. author: { name: "Andy Jarosz", email: "andyfilms1@yahoo.com"},
  826. license: "GPL",
  827. takes: {URL: noun_arb_text},
  828. preview: function(pblock, directObject) {
  829. //ubiq_show_preview(urlString);
  830. //searchText = jQuery.trim(directObject.text);
  831. searchText = directObject.text;
  832. var words = searchText.split(' ');
  833. var host = words[1];
  834. if(searchText.length < 1) {
  835. pblock.innerHTML = "Checks if URL is down";
  836. return;
  837. }
  838. var previewTemplate = "Checks if <b>" + host + "</b> is down";
  839. pblock.innerHTML = previewTemplate;
  840. },
  841. execute: function(directObject) {
  842. var url = "http://downforeveryoneorjustme.com/{QUERY}"
  843. var query = directObject.text;
  844. // Get the hostname from url
  845. if (! query) {
  846. var host = window.location.href;
  847. var url_comp = host.split('/');
  848. query = url_comp[2];
  849. }
  850. var urlString = url.replace("{QUERY}", query);
  851. //Utils.openUrlInBrowser(urlString);
  852. ubiq_xml_http(urlString, function (ajax) {
  853. if (! ajax) return;
  854. var text = ajax.responseText;
  855. if (! text) return;
  856. var pblock = document.getElementById('ubiq-command-preview');
  857. if (text.match('is up.')) {
  858. pblock.innerHTML = '<br/><p style="font-size: 18px;">It\'s just you. The site is <b>up!</b></p>';
  859. } else {
  860. pblock.innerHTML = '<br/><p style="font-size: 18px;">It\'s <b>not</b> just you. The site is <b>down!</b></p>';
  861. }
  862. });
  863. }
  864. });
  865. CmdUtils.CreateCommand({
  866. name: "lastfm",
  867. takes: {"search_string": noun_arb_text},
  868. description: "Listen to some artist radio on Last.fm",
  869. author: {},
  870. icon: "http://last.fm/favicon.ico",
  871. homepage: "",
  872. license: "",
  873. preview: "Listen to some artist radio on Last.fm",
  874. execute: CmdUtils.SimpleUrlBasedCommand(
  875. "http://www.lastfm.com/listen/artist/{text}/similarartists"
  876. )
  877. });
  878. CmdUtils.CreateCommand({
  879. name: "maps",
  880. takes: {"address": noun_arb_text},
  881. description: "Shows a location on the map",
  882. author: {},
  883. icon: "http://www.google.com/favicon.ico",
  884. homepage: "",
  885. license: "",
  886. preview: "Shows a location on the map",
  887. execute: CmdUtils.SimpleUrlBasedCommand(
  888. "http://maps.google.com/maps?q={text}"
  889. )
  890. });
  891. CmdUtils.CreateCommand({
  892. name: "mini-simulator",
  893. takes: {"url": noun_arb_text},
  894. description: "Preview the current URL in the Opera Mini Simulator",
  895. author: {},
  896. icon: "http://www.opera.com/favicon.ico",
  897. homepage: "",
  898. license: "",
  899. preview: "Previews the current URL in the Opera Mini simulator",
  900. execute: CmdUtils.SimpleUrlBasedCommand(
  901. "http://demo.opera-mini.net/public/index.html?{location}"
  902. )
  903. });
  904. CmdUtils.CreateCommand({
  905. name: "msn-search",
  906. takes: {"search_string": noun_arb_text},
  907. description: "Search MSN for the given words",
  908. author: {},
  909. icon: "http://www.msn.com/favicon.ico",
  910. homepage: "",
  911. license: "",
  912. preview: "Searches MSN for the given words",
  913. execute: CmdUtils.SimpleUrlBasedCommand(
  914. "http://search.msn.com/results.aspx?q={text}"
  915. )
  916. });
  917. CmdUtils.CreateCommand({
  918. name: "myopera-blog-search",
  919. takes: {"search_string": noun_arb_text},
  920. description: "Search for blogs on the My Opera Community",
  921. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  922. icon: "http://static.myopera.com/community/favicon.ico",
  923. homepage: "http://my.opera.com",
  924. license: "",
  925. preview: "Search for blogs on the My Opera Community",
  926. execute: CmdUtils.SimpleUrlBasedCommand(
  927. "http://my.opera.com/community/blogs/?search={text}"
  928. )
  929. });
  930. CmdUtils.CreateCommand({
  931. name: "myopera-photo-search",
  932. takes: {"search_string": noun_arb_text},
  933. description: "Search for photos on the My Opera Community",
  934. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  935. icon: "http://static.myopera.com/community/favicon.ico",
  936. homepage: "http://my.opera.com",
  937. license: "",
  938. preview: "Search for photos on the My Opera Community",
  939. execute: CmdUtils.SimpleUrlBasedCommand(
  940. "http://my.opera.com/community/photos/?search={text}"
  941. )
  942. });
  943. CmdUtils.CreateCommand({
  944. name: "new-tab",
  945. takes: {"URL": noun_arb_text}, // FIXME URL type??
  946. description: "Open a new tab (or window) with the specified URL",
  947. author: {},
  948. icon: "",
  949. homepage: "",
  950. license: "",
  951. preview: "Open a new tab (or window) with the specified URL",
  952. execute: function (directObj) {
  953. var url = 'about:';
  954. if (directObj) {
  955. url = directObj.text;
  956. }
  957. CmdUtils.toggleUbiquityWindow();
  958. window.open(url);
  959. }
  960. });
  961. CmdUtils.CreateCommand({
  962. name: "opera-cache",
  963. takes: {},
  964. description: "Show Opera browser cache contents",
  965. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  966. icon: "http://www.opera.com/favicon.ico",
  967. homepage: "http://www.opera.com",
  968. license: "",
  969. preview: "Show Opera browser cache contents",
  970. execute: CmdUtils.SimpleUrlBasedCommand("opera:cache")
  971. });
  972. CmdUtils.CreateCommand({
  973. name: "opera-config",
  974. takes: { "config_option": noun_arb_text },
  975. description: "Show Opera browser preferences (filtered by given words)",
  976. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  977. icon: "http://www.opera.com/favicon.ico",
  978. homepage: "http://www.opera.com",
  979. license: "",
  980. preview: "Show Opera browser preferences (filtered by given words)",
  981. execute: CmdUtils.SimpleUrlBasedCommand(
  982. "opera:config#{text}"
  983. )
  984. });
  985. CmdUtils.CreateCommand({
  986. name: "opera-skins",
  987. takes: {"search_string": noun_arb_text},
  988. description: "Search for Opera browser skins on the My Opera Community",
  989. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  990. icon: "http://static.myopera.com/community/favicon.ico",
  991. homepage: "http://my.opera.com/community/customize/skins/",
  992. license: "",
  993. preview: "Search for Opera browser skins on the My Opera Community",
  994. execute: CmdUtils.SimpleUrlBasedCommand(
  995. "http://my.opera.com/community/customize/skins/?search={text}"
  996. )
  997. });
  998. CmdUtils.CreateCommand({
  999. name: "print",
  1000. takes: {},
  1001. description: "Print the current page",
  1002. author: {},
  1003. icon: "",
  1004. homepage: "",
  1005. license: "",
  1006. preview: "Print the current page",
  1007. execute: function (directObj) {
  1008. CmdUtils.toggleUbiquityWindow();
  1009. window.print();
  1010. }
  1011. });
  1012. CmdUtils.CreateCommand({
  1013. name: "refresh",
  1014. takes: {},
  1015. description: "Reloads the current document",
  1016. author: {},
  1017. icon: "",
  1018. homepage: "",
  1019. license: "",
  1020. preview: "Reloads the current document",
  1021. execute: function (directObj) {
  1022. CmdUtils.toggleUbiquityWindow();
  1023. CmdUtils.getLocation().reload();
  1024. }
  1025. });
  1026. CmdUtils.CreateCommand({
  1027. name: "scan",
  1028. icon: "http://safeweb.norton.com/favicon.ico",
  1029. description: "Scan site with Norton Safeweb",
  1030. preview: "Scan site with Norton Safeweb:",
  1031. execute: CmdUtils.SimpleUrlBasedCommand(
  1032. "http://safeweb.norton.com/report/show?url={location}&x=0&y=0"
  1033. )
  1034. });
  1035. CmdUtils.CreateCommand({
  1036. name: "search",
  1037. takes: {"search_string": noun_arb_text},
  1038. description: "Search on Google for the given words",
  1039. author: {},
  1040. icon: "http://www.google.com/favicon.ico",
  1041. homepage: "",
  1042. license: "",
  1043. preview: "Search on Google for the given words",
  1044. execute: CmdUtils.SimpleUrlBasedCommand(
  1045. "http://www.google.com/search?client=opera&q={text}&sourceid=opera&ie=utf-8&oe=utf-8"
  1046. )
  1047. });
  1048. var bitly_api_user = "ubiquityopera";
  1049. var bitly_api_key = "R_59da9e09c96797371d258f102a690eab";
  1050. CmdUtils.CreateCommand({
  1051. name: "shorten-url",
  1052. icon: "http://bit.ly/static/images/favicon.ico",
  1053. description: "Shorten your URLs with the least possible keystrokes",
  1054. homepage: "http://bit.ly",
  1055. author: {name: "Cosimo Streppone", email: "cosimo@cpan.org"},
  1056. license: "GPL",
  1057. takes: {URL: noun_arb_text},
  1058. preview: function(pblock, directObject) {
  1059. var searchText = directObject.text;
  1060. var words = searchText.split(' ');
  1061. var host = words[1];
  1062. if(searchText.length < 1) {
  1063. pblock.innerHTML = "Shortens an URL (or the current tab) with bit.ly";
  1064. return;
  1065. }
  1066. var previewTemplate = "Shortens the URL '" + host + "' with bit.ly";
  1067. pblock.innerHTML = previewTemplate;
  1068. },
  1069. execute: function(directObject) {
  1070. var url = "http://api.bit.ly/shorten?version=2.0.1&longUrl={QUERY}&login="
  1071. + bitly_api_user + "&apiKey=" + bitly_api_key;
  1072. var query = directObject.text;
  1073. // Get the url from current open tab if none specified
  1074. if (! query || query == "") query = window.location.href;
  1075. var urlString = url.replace("{QUERY}", query);
  1076. ubiq_xml_http(urlString, function (ajax) {
  1077. if (! ajax) return;
  1078. var api_response = ajax.responseText;
  1079. if (! api_response) return;
  1080. var pblock = document.getElementById('ubiq-command-preview');
  1081. var err_code = api_response.errorCode;
  1082. var err_msg = api_response.errorMessage;
  1083. // Received an error from bit.ly API?
  1084. if (err_code > 0 || err_msg) {
  1085. pblock.innerHTML = '<br/><p style="font-size: 18px; color:orange">'
  1086. + 'Bit.ly API error ' + err_code + ': ' + err_msg + '</p>';
  1087. return;
  1088. }
  1089. // API successful. URL has been shortened
  1090. eval('api_response='+api_response);
  1091. var short_url = api_response.results[query].shortUrl;
  1092. pblock.innerHTML = '<br/><p style="font-size: 24px; font-weight: bold; color: #ddf">'
  1093. + '&rarr; <a href="' + short_url + '">' + short_url + '</a>'
  1094. + '</p>';
  1095. });
  1096. }
  1097. });
  1098. CmdUtils.CreateCommand({
  1099. name: "slideshare",
  1100. icon: "http://www.slideshare.com/favicon.ico",
  1101. description: "Search for online presentations on SlideShare",
  1102. homepage: "",
  1103. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org"},
  1104. license: "",
  1105. takes: {"search_term": noun_arb_text},
  1106. preview: "Search for online presentations on SlideShare",
  1107. execute: CmdUtils.SimpleUrlBasedCommand(
  1108. "http://www.slideshare.net/search/slideshow?q={text}&submit=post&searchfrom=header&x=0&y=0"
  1109. )
  1110. });
  1111. CmdUtils.CreateCommand({
  1112. name: "stackoverflow-search",
  1113. takes: {"search_string": noun_arb_text},
  1114. description: "Searches questions and answers on stackoverflow.com",
  1115. author: { name: "Cosimo Streppone", email: "cosimo@cpan.org" },
  1116. icon: "http://stackoverflow.com/favicon.ico",
  1117. homepage: "",
  1118. license: "",
  1119. preview: "Searches questions and answers on stackoverflow.com",
  1120. execute: CmdUtils.SimpleUrlBasedCommand(
  1121. "http://stackoverflow.com/search?q={text}"
  1122. )
  1123. });
  1124. CmdUtils.CreateCommand({
  1125. name: "torrent-search",
  1126. takes: { "search_string": noun_arb_text },
  1127. description: "Search PirateBay, Isohunt, and Torrentz in new tabs.",
  1128. author: { name: "Axel Boldt", email: "axelboldt@yahoo.com"},
  1129. homepage: "http://math-www.uni-paderborn.de/~axel/",
  1130. license: "Public domain",
  1131. preview: "Search for torrent on PirateBay, Isohunt and Torrentz.",
  1132. execute: function( directObj ) {
  1133. var search_string = encodeURIComponent(directObj.text);
  1134. Utils.openUrlInBrowser( "http://thepiratebay.org/search.php?q=" + search_string);
  1135. Utils.openUrlInBrowser( "http://isohunt.com/torrents/?ihq=" + search_string);
  1136. Utils.openUrlInBrowser( "http://www.torrentz.com/search?q=" + search_string);
  1137. }
  1138. });
  1139. CmdUtils.CreateCommand({
  1140. name: "translate",
  1141. takes: { "words": noun_arb_text },
  1142. description: "Translates the given words (or text selection, or the current window) to English",
  1143. author: {},
  1144. icon: "http://www.google.com/favicon.ico",
  1145. homepage: "",
  1146. license: "",
  1147. preview: "Translates the given words (or text selection, or the current window) to English",
  1148. execute: function (directObj) {
  1149. CmdUtils.toggleUbiquityWindow();
  1150. var text = directObj.text;
  1151. // HARD !!!
  1152. //alert(ubiq_element.innerHTML);
  1153. //var html = ubiq_element.innerHTML.replace(text, 'blah blah blah');
  1154. //ubiq_element.innerHTML = html;
  1155. var words = text.split(/\s+/);
  1156. var dest = 'en';
  1157. // Detect the destination language ("translate ... to it")
  1158. if (words.length >= 3 && words[words.length - 2].toLowerCase()=='to') {
  1159. // Get destination language
  1160. dest = words.pop();
  1161. // Remove the 'to'
  1162. words.pop();
  1163. // Update the text to be translated
  1164. text = words.join('');
  1165. }
  1166. // Translate text or current URL
  1167. var url = 'http://translate.google.com/translate_t?#auto|'+dest+'|';
  1168. if (! text || text.length == 0 || text.match('^https?://')) {
  1169. if (! text) text = CmdUtils.getLocation();
  1170. url = 'http://translate.google.com/translate?prev=_t&ie=UTF-8&sl=auto&tl='+dest+'&history_state0=&u=';
  1171. }
  1172. CmdUtils.openWindow(url+text);
  1173. }
  1174. });
  1175. CmdUtils.CreateCommand({
  1176. name: "validate",
  1177. icon: "http://www.imageboo.com/files/uhee2ii315oxd8akq0nm.ico",
  1178. description: "Checks the markup validity of the current Web document",
  1179. preview: "Sends this page to the W3C validator",
  1180. execute: CmdUtils.SimpleUrlBasedCommand(
  1181. "http://validator.w3.org/check?uri={location}"
  1182. )
  1183. });
  1184. CmdUtils.CreateCommand({
  1185. name: "wayback",
  1186. homepage: "http://www.pendor.com.ar/ubiquity",
  1187. author: { name: "Juan Pablo Zapata", email: "admin@pendor.com.ar" },
  1188. description: "Search old versions of a site using the Wayback Machine (archive.org)",
  1189. help: "wayback <i>sitio a buscar</i>",
  1190. icon: "http://web.archive.org/favicon.ico",
  1191. takes: {"Site to search": noun_arb_text},
  1192. preview: function(pblock, theShout) {
  1193. pblock.innerHTML = "Buscar versiones antiguas del sitio <b>" + theShout.text + "</b>"
  1194. },
  1195. execute: function (directObj) {
  1196. CmdUtils.toggleUbiquityWindow();
  1197. var url = directObj.text;
  1198. if (! url) url = CmdUtils.getLocation();
  1199. var wayback_machine = "http://web.archive.org/web/*/" + url;
  1200. // Take me back!
  1201. CmdUtils.openWindow(wayback_machine);
  1202. }
  1203. });
  1204. CmdUtils.CreateCommand({
  1205. name: "weather",
  1206. takes: {"location": noun_arb_text},
  1207. description: "Show the weather forecast for",
  1208. author: {},
  1209. icon: "http://www.accuweather.com/favicon.ico",
  1210. homepage: "",
  1211. license: "",
  1212. preview: "Show the weather forecast for",
  1213. execute: CmdUtils.SimpleUrlBasedCommand(
  1214. "http://www.wunderground.com/cgi-bin/findweather/getForecast?query={text}"
  1215. )
  1216. });
  1217. CmdUtils.CreateCommand({
  1218. name: "whois",
  1219. icon: "http://www.who.is/favicon.ico",
  1220. description: "Query a domain name owner",
  1221. preview: "Whois query on who.is:",
  1222. execute: CmdUtils.SimpleUrlBasedCommand(
  1223. "http://who.is/whois/{text}"
  1224. )
  1225. });
  1226. CmdUtils.CreateCommand({
  1227. name: "wikipedia",
  1228. takes: {"search_string": noun_arb_text},
  1229. description: "Search Wikipedia for the given words",
  1230. author: {},
  1231. icon: "http://en.wikipedia.org/favicon.ico",
  1232. homepage: "",
  1233. license: "",
  1234. preview: "Search Wikipedia for the given words",
  1235. execute: CmdUtils.SimpleUrlBasedCommand(
  1236. "http://en.wikipedia.org/wiki/Special:Search?search={text}"
  1237. )
  1238. });
  1239. CmdUtils.CreateCommand({
  1240. name: "yahoo-answers",
  1241. takes: {"question": noun_arb_text},
  1242. description: "Search Yahoo! Answers for",
  1243. author: {},
  1244. icon: "http://l.yimg.com/a/i/us/sch/gr/answers_favicon.ico",
  1245. homepage: "",
  1246. license: "",
  1247. preview: "Search Yahoo! Answers for",
  1248. execute: CmdUtils.SimpleUrlBasedCommand(
  1249. "http://answers.yahoo.com/search/search_result;_ylv=3?p={text}"
  1250. )
  1251. });
  1252. CmdUtils.CreateCommand({
  1253. name: "yahoo-search",
  1254. takes: {"search_string": noun_arb_text},
  1255. description: "Search Yahoo! for",
  1256. author: {},
  1257. icon: "http://www.yahoo.com/favicon.ico",
  1258. homepage: "",
  1259. license: "",
  1260. preview: "Search Yahoo! for",
  1261. execute: CmdUtils.SimpleUrlBasedCommand(
  1262. "http://search.yahoo.com/search?p={text}&ei=UTF-8"
  1263. )
  1264. });
  1265. CmdUtils.CreateCommand({
  1266. name: "youtube",
  1267. takes: {"videos": noun_arb_text},
  1268. description: "Search for videos on YouTube",
  1269. author: {},
  1270. icon: "http://www.youtube.com/favicon.ico",
  1271. homepage: "",
  1272. license: "",
  1273. preview: "Search for videos on YouTube",
  1274. execute: CmdUtils.SimpleUrlBasedCommand(
  1275. "http://www.youtube.com/results?search_type=search_videos&search_sort=relevance&search_query={text}&search=Search"
  1276. )
  1277. });
  1278. window.addEventListener('keypress', ubiq_key_handler, false);
  1279. }) (window);
  1280. // vim: ts=4 sw=4 tw=0 et