From 1d766b5fb035709528a968eb81d4cd2c60a0fdf4 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 13 Sep 2015 23:28:26 +0200 Subject: [PATCH] Update chickadee webjump --- conkeror/.conkerorrc/init.js | 42 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/conkeror/.conkerorrc/init.js b/conkeror/.conkerorrc/init.js index 25a3138..5996849 100644 --- a/conkeror/.conkerorrc/init.js +++ b/conkeror/.conkerorrc/init.js @@ -205,27 +205,37 @@ define_opensearch_webjump("wordpress", "wordpress.xml"); /// Chickadee // From http://conkeror.org/Webjumps -function chickadee_completer (input, cursor_position, conservative) { - var completions = []; - var content = yield send_http_request( - load_spec({uri: "http://api.call-cc.org/cdoc/ajax/prefix?q="+ - encodeURIComponent(input)})); - if (content.responseText) { - var parser = Cc["@mozilla.org/xmlextras/domparser;1"] - .createInstance(Ci.nsIDOMParser); - var doc = parser.parseFromString(content.responseText, "text/xml"); - var res = doc.getElementsByTagName("li"); - for (let i = 0, n = res.length; i < n; ++i) { - completions.push(res[i].textContent); +var chickadee_completer = function() { + completer.call(this); +}; + +chickadee_completer.prototype = { + __proto__: completer.prototype, + constructor: chickadee_completer, + toString: function () "#", + complete: function (input, pos) { + var completions = []; + var content = yield send_http_request( + load_spec({uri: "http://api.call-cc.org/cdoc/ajax/prefix?q="+ + encodeURIComponent(input)})); + if (content.responseText) { + var parser = Cc["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Ci.nsIDOMParser); + var doc = parser.parseFromString(content.responseText, "text/xml"); + var res = doc.getElementsByTagName("li") + for (let i = 0, n = res.length; i < n; ++i) { + completions.push(res[i].textContent); + } } + + yield co_return((new prefix_completer($completions = completions)).complete(input, pos)); } - yield co_return(prefix_completer($completions = completions) - (input, cursor_position, conservative)); -} +}; + define_webjump("chickadee", "http://api.call-cc.org/cdoc?q=%s&query-name=Lookup", $alternative = "http://api.call-cc.org/doc/", - $completer = chickadee_completer); + $completer = new chickadee_completer()); /// /Chickadee // content_policy_bytype_table.object = oni_block_flash;