aboutsummaryrefslogtreecommitdiffstats
path: root/googlekanji.js
diff options
context:
space:
mode:
authordrry2008-09-05 08:39:22 +0000
committerdrry2008-09-05 08:39:22 +0000
commitc9a08b2a58c3da49fc3b4281fd0cd19ba14db933 (patch)
tree45f60fcdc9eaacc8c50068bb55468c53114852b0 /googlekanji.js
parent764e41a333195090b73d48b79e30b302ccc3cdb2 (diff)
downloadvimperator-plugins-c9a08b2a58c3da49fc3b4281fd0cd19ba14db933.tar.bz2
* removed an unused variable.
* et cetera. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@18895 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'googlekanji.js')
-rw-r--r--googlekanji.js49
1 files changed, 19 insertions, 30 deletions
diff --git a/googlekanji.js b/googlekanji.js
index 56eb5c9..59eed15 100644
--- a/googlekanji.js
+++ b/googlekanji.js
@@ -13,22 +13,21 @@
// が開き、補完が可能になるので、正しそうな漢字を選びます。
// すると、クリップボードにその漢字がコピーされます。
-(function () { try{
+(function () { try {
var copycompl = [];
function getKanji (word) {
var re = /[一-龠]+/g;
var ignore = /検索|関連/;
- var spaces = /^\s+$/;
var req = new XMLHttpRequest();
var word = encodeURIComponent(word);
liberator.log(word);
req.open('GET', 'http://www.google.co.jp/search?hl=ja&q=' + word + '&lr=lang_ja', true);
var f = function () {
var cnt = {};
- for each (var it in req.responseText.match(re)) {
- if (!it.match || it.match(ignore))
+ for each (let it in req.responseText.match(re)) {
+ if (ignore.test(it))
continue;
if (cnt[it])
cnt[it] += 1;
@@ -36,7 +35,7 @@
cnt[it] = 1;
}
var cnta = [];
- for (var i in cnt) {
+ for (let i in cnt) {
if (cnt[i] < 3)
continue;
cnta.push([i, cnt[i]]);
@@ -44,31 +43,27 @@
cnta.sort(function (a, b) b[1] - a[1]);
copycompl = cnta;
liberator.commandline.open(":", "gkcopy ", liberator.modes.EX);
- };
+ };
req.onreadystatechange = function (aEvt) {
- if (req.readyState == 4) {
- if(req.status == 200) {
- f();
- }
+ if (req.readyState == 4 && req.status == 200) {
+ f();
}
};
- req.send(null);
+ req.send(null);
}
liberator.commands.addUserCommand(
['gkanji', 'googlekanji'],
- 'google kanji',
- function (word) {
- getKanji(word);
- }
+ 'Google kanji',
+ getKanji
);
function copyToClipboard (copytext) {
- const supstr = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
- const trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
- const clipid = Ci.nsIClipboard;
- const clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid);
-
+ const supstr = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
+ const trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
+ const clipid = Ci.nsIClipboard;
+ const clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid);
+
supstr.data = copytext;
trans.addDataFlavor("text/unicode");
trans.setTransferData("text/unicode", supstr, copytext.length * 2);
@@ -78,16 +73,10 @@
liberator.commands.addUserCommand(
['gkcopy'],
- 'google kanji',
- function (word) {
- copyToClipboard(word);
- },
- {
- completer: function (args) {
- return [0, copycompl];
- }
- }
+ 'Google kanji',
+ copyToClipboard,
+ { completer: function (args) [0, copycompl] }
);
-}catch(e){liberator.log(e)}})();
+} catch (e) { liberator.log(e) } })();