Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

coffee version upgraded, correspond to manifest version 2

  • Loading branch information...
commit 74f2616d1fa5ec07fa390ccd2383990c7e2c1369 1 parent 34b3e7d
@k2nr authored
View
3  background.html
@@ -1,13 +1,12 @@
<html>
<head>
<script type="text/javascript" src="tab.js"></script>
-<script type="text/javascript" src="background.js"></script>
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript" src="settings.js"></script>
<script type="text/javascript" src="lib/jsapi"></script>
<script type="text/javascript" src="lib/crocro.webAi.WebSrch.js"></script>
+<script type="text/javascript" src="background.js"></script>
<script>
- this.vichrome.bg.init();
</script>
</head>
</html>
View
147 background.js
@@ -1,19 +1,26 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var extendURL, g;
+ var extendURL, g, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
extendURL = function(base) {
var url;
- if (base.search(/^javascript:/i) >= 0) return base;
+ if (base.search(/^javascript:/i) >= 0) {
+ return base;
+ }
if (base.indexOf("%clipboard") >= 0) {
url = encodeURI(base.replace(/%clipboard/g, g.clipboard.get()));
} else {
url = encodeURI(base);
}
- if (url.indexOf("://") < 0) url = "http://" + url;
+ if (url.indexOf("://") < 0) {
+ url = "http://" + url;
+ }
return url;
};
@@ -79,7 +86,7 @@
getDefaultNewTabPage: function() {
switch (g.SettingManager.get("defaultNewTab")) {
case "home":
- break;
+ return void 0;
case "newtab":
return "chrome://newtab";
case "blank":
@@ -87,12 +94,12 @@
}
},
reqTabOpenNew: function(req) {
- var arg, extend, focus, len, next, pinned, times, urls, _i, _len, _ref, _ref2, _ref3,
+ var arg, extend, focus, len, next, pinned, times, urls, _i, _len, _ref1, _ref2, _ref3,
_this = this;
urls = [];
focus = true;
pinned = false;
- extend = (_ref = req.extend) != null ? _ref : false;
+ extend = (_ref1 = req.extend) != null ? _ref1 : false;
_ref2 = req.args;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
arg = _ref2[_i];
@@ -115,8 +122,10 @@
len = urls.length;
times = (_ref3 = req.times) != null ? _ref3 : 1;
chrome.tabs.getSelected(null, function(tab) {
- var index, url, _j, _len2;
- if (next) index = tab.index + 1;
+ var index, url, _j, _len1;
+ if (next) {
+ index = tab.index + 1;
+ }
if (len === 0) {
while (times--) {
chrome.tabs.create({
@@ -127,9 +136,11 @@
});
}
} else {
- for (_j = 0, _len2 = urls.length; _j < _len2; _j++) {
+ for (_j = 0, _len1 = urls.length; _j < _len1; _j++) {
url = urls[_j];
- if (extend) url = extendURL(url);
+ if (extend) {
+ url = extendURL(url);
+ }
chrome.tabs.create({
url: url,
selected: focus,
@@ -155,13 +166,13 @@
});
},
reqWinOpenNew: function(req) {
- var arg, focus, pop, urls, _i, _len, _ref;
+ var arg, focus, pop, urls, _i, _len, _ref1;
urls = [];
focus = true;
pop = false;
- _ref = req.args;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- arg = _ref[_i];
+ _ref1 = req.args;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ arg = _ref1[_i];
switch (arg) {
case "-b":
case "--background":
@@ -191,7 +202,9 @@
}
});
} else {
- if (urls.length === 0) urls = this.getDefaultNewTabPage();
+ if (urls.length === 0) {
+ urls = this.getDefaultNewTabPage();
+ }
chrome.windows.create({
url: urls,
focused: focus
@@ -200,11 +213,11 @@
return false;
},
reqTabCloseCurrent: function(req) {
- var arg, prev, _i, _len, _ref,
+ var arg, prev, _i, _len, _ref1,
_this = this;
- _ref = req.args;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- arg = _ref[_i];
+ _ref1 = req.args;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ arg = _ref1[_i];
switch (arg) {
case "--focusprev":
prev = true;
@@ -222,10 +235,10 @@
return false;
},
reqTabCloseAll: function(req) {
- var arg, only, _i, _len, _ref;
- _ref = req.args;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- arg = _ref[_i];
+ var arg, only, _i, _len, _ref1;
+ _ref1 = req.args;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ arg = _ref1[_i];
switch (arg) {
case "--only":
only = true;
@@ -234,10 +247,12 @@
if (only) {
chrome.tabs.getAllInWindow(null, function(tabs) {
return chrome.tabs.getSelected(null, function(selected) {
- var tab, _j, _len2;
- for (_j = 0, _len2 = tabs.length; _j < _len2; _j++) {
+ var tab, _j, _len1;
+ for (_j = 0, _len1 = tabs.length; _j < _len1; _j++) {
tab = tabs[_j];
- if (selected.id !== tab.id) chrome.tabs.remove(tab.id);
+ if (selected.id !== tab.id) {
+ chrome.tabs.remove(tab.id);
+ }
}
});
});
@@ -249,16 +264,20 @@
return false;
},
reqTabReloadAll: function(req) {
- var _ref;
- if ((_ref = g.tabs) != null) {
- if (typeof _ref.reloadAllTabs === "function") _ref.reloadAllTabs();
+ var _ref1;
+ if ((_ref1 = g.tabs) != null) {
+ if (typeof _ref1.reloadAllTabs === "function") {
+ _ref1.reloadAllTabs();
+ }
}
return false;
},
reqTabFocusNext: function(req) {
- var _ref;
- if (((_ref = req.args) != null ? _ref[0] : void 0) != null) {
- if (req.args[0] <= 0) return;
+ var _ref1;
+ if (((_ref1 = req.args) != null ? _ref1[0] : void 0) != null) {
+ if (req.args[0] <= 0) {
+ return;
+ }
this.moveTab(parseInt(req.args[0]) - 1, 0);
} else {
if (req.timesSpecified && req.times > 0) {
@@ -270,9 +289,9 @@
return false;
},
reqTabFocusPrev: function(req) {
- var times, _ref;
+ var times, _ref1;
times = req.times ? req.times : 1;
- if (((_ref = req.args) != null ? _ref[0] : void 0) != null) {
+ if (((_ref1 = req.args) != null ? _ref1[0] : void 0) != null) {
this.moveTab(-parseInt(req.args[0]));
} else {
this.moveTab(-times);
@@ -305,7 +324,9 @@
},
reqNMap: function(req, sendResponse) {
var msg;
- if (!((req.args[0] != null) && (req.args[1] != null))) return;
+ if (!((req.args[0] != null) && (req.args[1] != null))) {
+ return;
+ }
msg = {
command: "Settings",
name: "keyMappingNormal",
@@ -316,7 +337,9 @@
},
reqIMap: function(req, sendResponse) {
var msg;
- if (!((req.args[0] != null) && (req.args[1] != null))) return;
+ if (!((req.args[0] != null) && (req.args[1] != null))) {
+ return;
+ }
msg = {
command: "Settings",
name: "keyMappingInsert",
@@ -327,7 +350,9 @@
},
reqAlias: function(req, sendResponse) {
var msg;
- if (!((req.args[0] != null) && (req.args[1] != null))) return;
+ if (!((req.args[0] != null) && (req.args[1] != null))) {
+ return;
+ }
msg = {
command: "Settings",
name: "aliases",
@@ -347,12 +372,18 @@
},
reqPushSearchHistory: function(req) {
var history, idx;
- if (req.value == null) return;
+ if (req.value == null) {
+ return;
+ }
history = JSON.parse(localStorage.getItem("_searchHistory"));
history || (history = []);
- if ((idx = history.indexOf(req.value)) >= 0) history.splice(idx, 1);
+ if ((idx = history.indexOf(req.value)) >= 0) {
+ history.splice(idx, 1);
+ }
history.push(req.value);
- if (history.length > 10) history.shift();
+ if (history.length > 10) {
+ history.shift();
+ }
localStorage.setItem("_searchHistory", JSON.stringify(history));
return false;
},
@@ -382,8 +413,12 @@
return true;
},
reqGetGoogleSuggest: function(req, sendResponse) {
- if (!this.gglLoaded) return false;
- if (this.cWSrch.isExec) return false;
+ if (!this.gglLoaded) {
+ return false;
+ }
+ if (this.cWSrch.isExec) {
+ return false;
+ }
this.cWSrch.reset().sgst({
kw: req.value,
hl: g.util.getLang(),
@@ -395,8 +430,12 @@
},
reqGetWebSuggest: function(req, sendResponse) {
var _this = this;
- if (!this.gglLoaded) return false;
- if (this.cWSrch.isExec) return false;
+ if (!this.gglLoaded) {
+ return false;
+ }
+ if (this.cWSrch.isExec) {
+ return false;
+ }
this.cWSrch.init({
type: "web",
opt: function(obj) {
@@ -408,14 +447,14 @@
page: 1,
key: req.value,
res: function(res) {
- var i, item, msg, obj, _len;
+ var i, item, msg, obj, _i, _len;
if (!res || res.length <= 0) {
_this.cWSrch.cmndsBreak();
sendResponse();
return;
}
msg = [];
- for (i = 0, _len = res.length; i < _len; i++) {
+ for (i = _i = 0, _len = res.length; _i < _len; i = ++_i) {
item = res[i];
obj = {};
obj.titleNoFormatting = item.titleNoFormatting;
@@ -435,10 +474,10 @@
return true;
},
reqOpenOptionPage: function(req) {
- var arg, key, url, _i, _len, _ref;
- _ref = req.args;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- arg = _ref[_i];
+ var arg, key, url, _i, _len, _ref1;
+ _ref1 = req.args;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ arg = _ref1[_i];
switch (arg) {
case "-k":
case "--key":
@@ -449,7 +488,9 @@
req.args = [];
req.times = 1;
url = chrome.extension.getURL("options.html");
- if (key) url += "#keymapping";
+ if (key) {
+ url += "#keymapping";
+ }
req.args.push(url);
return this.reqTabOpenNew(req);
},
@@ -565,4 +606,6 @@
}
};
+ g.bg.init();
+
}).call(this);
View
2  coffee/background.coffee
@@ -455,3 +455,5 @@ g.bg =
localStorage.version = g.VICHROME_VERSION
+g.bg.init()
+
View
45 command.js
@@ -1,13 +1,18 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var escape, g, passToTopFrame, sendToBackground, triggerInsideContent,
- __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+ var escape, g, passToTopFrame, sendToBackground, triggerInsideContent, _ref,
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
sendToBackground = function(com, args, times, timesSpecified, callback) {
- if (callback == null) callback = g.handler.onCommandResponse;
+ if (callback == null) {
+ callback = g.handler.onCommandResponse;
+ }
return chrome.extension.sendRequest({
command: com,
args: args,
@@ -23,7 +28,9 @@
};
passToTopFrame = function(com, args, times, timesSpecified, callback) {
- if (callback == null) callback = g.handler.onCommandResponse;
+ if (callback == null) {
+ callback = g.handler.onCommandResponse;
+ }
return chrome.extension.sendRequest({
command: "TopFrame",
innerCommand: com,
@@ -99,8 +106,8 @@
};
CommandExecuter.prototype.get = function() {
- var _ref;
- return (_ref = this.command) != null ? _ref : "";
+ var _ref1;
+ return (_ref1 = this.command) != null ? _ref1 : "";
};
CommandExecuter.prototype.getArgs = function() {
@@ -133,7 +140,7 @@
};
CommandExecuter.prototype.delimLine = function(line) {
- var c, i, len, pos, pre, result, start, _ref;
+ var c, i, len, pos, pre, result, start, _i, _ref1;
result = [];
pos = 0;
pre = 0;
@@ -164,8 +171,10 @@
}
}
result.push(line.slice(pre, pos));
- for (i = _ref = result.length - 1; _ref <= 0 ? i <= 0 : i >= 0; _ref <= 0 ? i++ : i--) {
- if (result[i].length === 0) result.splice(i, 1);
+ for (i = _i = _ref1 = result.length - 1; _ref1 <= 0 ? _i <= 0 : _i >= 0; i = _ref1 <= 0 ? ++_i : --_i) {
+ if (result[i].length === 0) {
+ result.splice(i, 1);
+ }
}
return result;
};
@@ -183,7 +192,9 @@
CommandExecuter.prototype.parse = function() {
var command;
- if (!this.command) throw "invalid command";
+ if (!this.command) {
+ throw "invalid command";
+ }
this.args = this.delimLine(this.command);
command = this.solveAlias(this.args[0]);
if (command != null) {
@@ -238,7 +249,9 @@
}
},
startTimer: function(callback, ms) {
- if (this.waiting) return;
+ if (this.waiting) {
+ return;
+ }
this.waiting = true;
return this.timerId = setTimeout(callback, ms);
},
@@ -305,8 +318,12 @@
function CommandManager(model, timeout, useNumPrefix) {
this.model = model;
- if (timeout == null) timeout = 2000;
- if (useNumPrefix == null) useNumPrefix = true;
+ if (timeout == null) {
+ timeout = 2000;
+ }
+ if (useNumPrefix == null) {
+ useNumPrefix = true;
+ }
this.keyQueue.init(this.model, timeout, useNumPrefix);
}
View
223 commandbox.js
@@ -1,9 +1,12 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var MyCommandManager, commandFixedListener, frameID, g, onRequest, opt, searchFixedListener, searchUpdatedListener, sender,
- __hasProp = Object.prototype.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+ var MyCommandManager, commandFixedListener, frameID, g, onRequest, opt, searchFixedListener, searchUpdatedListener, sender, _ref,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -161,20 +164,24 @@
CommandBox.prototype.show = function(modeChar, input) {
var _this = this;
- if (input == null) input = "";
+ if (input == null) {
+ input = "";
+ }
this.input.attr("value", input);
this.modeChar.html(modeChar);
this.bfInput = input;
this.box.show();
this.inputField.show();
$(document).keyup(function(e) {
- var listener, val, _i, _len, _ref;
+ var listener, val, _i, _len, _ref1;
val = _this.input.val();
- if (_this.selectedCand === val) return;
+ if (_this.selectedCand === val) {
+ return;
+ }
if (_this.bfInput !== val && _this.isVisible()) {
- _ref = _this.inputListeners;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- listener = _ref[_i];
+ _ref1 = _this.inputListeners;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ listener = _ref1[_i];
listener(val);
}
}
@@ -193,8 +200,10 @@
};
CommandBox.prototype.focus = function() {
- var _ref;
- if ((_ref = this.input.get(0)) != null) _ref.focus();
+ var _ref1;
+ if ((_ref1 = this.input.get(0)) != null) {
+ _ref1.focus();
+ }
return this;
};
@@ -211,7 +220,9 @@
};
CommandBox.prototype.setCandidateBox = function(candBox) {
- if (!opt.enableCompletion) return this;
+ if (!opt.enableCompletion) {
+ return this;
+ }
if (this.candidateBox != null) {
this.candidateBox.stop();
this.candidateBox.detachFrom();
@@ -223,21 +234,25 @@
};
CommandBox.prototype.nextCandidate = function() {
- var focused, _ref;
+ var focused, _ref1;
if (this.candidateBox != null) {
focused = this.candidateBox.focusNext();
- if (focused == null) return this;
- this.selectedCand = (_ref = focused.value) != null ? _ref : focused.str;
+ if (focused == null) {
+ return this;
+ }
+ this.selectedCand = (_ref1 = focused.value) != null ? _ref1 : focused.str;
this.value(this.selectedCand);
}
return this;
};
CommandBox.prototype.prevCandidate = function() {
- var focused, _ref, _ref2;
+ var focused, _ref1, _ref2;
if (this.candidateBox != null) {
- focused = (_ref = this.candidateBox) != null ? _ref.focusPrev() : void 0;
- if (focused == null) return this;
+ focused = (_ref1 = this.candidateBox) != null ? _ref1.focusPrev() : void 0;
+ if (focused == null) {
+ return this;
+ }
this.selectedCand = (_ref2 = focused.value) != null ? _ref2 : focused.str;
this.value(this.selectedCand);
}
@@ -253,18 +268,22 @@
};
CommandBox.prototype.isValidKeySeqAvailable = function(keySeq) {
- var cmpStr, command, length, pos, seq, _ref;
+ var cmpStr, command, length, pos, seq, _ref1;
length = keySeq.length;
- _ref = this.keyMap;
- for (seq in _ref) {
- command = _ref[seq];
+ _ref1 = this.keyMap;
+ for (seq in _ref1) {
+ command = _ref1[seq];
cmpStr = seq.slice(0, length);
pos = cmpStr.indexOf("<", 0);
if (pos >= 0) {
pos = seq.indexOf(">", pos);
- if (pos >= length) cmpStr = seq.slice(0, pos + 1);
+ if (pos >= length) {
+ cmpStr = seq.slice(0, pos + 1);
+ }
+ }
+ if (keySeq === cmpStr) {
+ return true;
}
- if (keySeq === cmpStr) return true;
}
return false;
};
@@ -310,11 +329,11 @@
};
CandidateBox.prototype.getItemCnt = function() {
- var items, result, src, _ref;
+ var items, result, src, _ref1;
result = 0;
- _ref = this.items;
- for (src in _ref) {
- items = _ref[src];
+ _ref1 = this.items;
+ for (src in _ref1) {
+ items = _ref1[src];
result += items.length;
}
return result;
@@ -353,16 +372,18 @@
dscr = $("<div id=\"vichromecandtext\" class=\"vichrome-canddscr\" />").html(item.dscr);
srcType = $("<div id=\"vichromecandtext\" class=\"vichrome-canddscr\" />").html(item.source);
line.append(text).append(srcType).append(dscr);
- if (item.value != null) line.attr("value", item.value);
+ if (item.value != null) {
+ line.attr("value", item.value);
+ }
return line;
};
CandidateBox.prototype.update = function(id) {
- var i, item, _len, _ref;
+ var i, item, _i, _len, _ref1;
$('#vichromecanditem' + ("[source=" + id + "]")).remove();
- _ref = this.items[id];
- for (i = 0, _len = _ref.length; i < _len; i++) {
- item = _ref[i];
+ _ref1 = this.items[id];
+ for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
+ item = _ref1[i];
this.box.append(this.makeItemLine(id, i, item));
}
return this;
@@ -419,12 +440,16 @@
var val;
$settee.addClass("vichrome-canditemfocused");
$settee.children().addClass("vichrome-canditemfocused");
- if ((val = $settee.attr("value"))) return this.setFocusedValue(val);
+ if ((val = $settee.attr("value"))) {
+ return this.setFocusedValue(val);
+ }
};
CandidateBox.prototype.focusNext = function() {
var $focused, $next;
- if (!(this.getItemCnt() > 0)) return null;
+ if (!(this.getItemCnt() > 0)) {
+ return null;
+ }
$focused = $("#vichromecanditem.vichrome-canditemfocused");
this.removeFocus($focused);
$next = $focused.next();
@@ -440,7 +465,9 @@
CandidateBox.prototype.focusPrev = function() {
var $focused, $next;
- if (!(this.getItemCnt() > 0)) return null;
+ if (!(this.getItemCnt() > 0)) {
+ return null;
+ }
$focused = $("#vichromecanditem.vichrome-canditemfocused");
this.removeFocus($focused);
$next = $focused.prev();
@@ -461,11 +488,13 @@
};
CandidateBox.prototype.onInput = function(word) {
- var id, src, _ref;
- if (this.stopped) return;
- _ref = this.sources;
- for (id in _ref) {
- src = _ref[id];
+ var id, src, _ref1;
+ if (this.stopped) {
+ return;
+ }
+ _ref1 = this.sources;
+ for (id in _ref1) {
+ src = _ref1[id];
src.cbInputUpdated(word);
}
};
@@ -517,10 +546,10 @@
};
CandidateSource.prototype.notifyUpdated = function() {
- var listener, _i, _len, _ref;
- _ref = this.updatedListeners;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- listener = _ref[_i];
+ var listener, _i, _len, _ref1;
+ _ref1 = this.updatedListeners;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ listener = _ref1[_i];
listener(this.items);
}
return this;
@@ -528,7 +557,9 @@
CandidateSource.prototype.cbInputUpdated = function(word) {
var _this = this;
- if (this.timer != null) clearTimeout(this.timer);
+ if (this.timer != null) {
+ clearTimeout(this.timer);
+ }
if ((this.prefix != null) && word.charAt(1) === " " && word.charAt(0) !== this.prefix) {
g.logger.d("different prefix:" + this.prefix);
this.resetItem();
@@ -572,14 +603,18 @@
}
CandSourceCommand.prototype.onInput = function(word) {
- var com, _i, _len, _ref;
- if (!(word.length > 0)) return;
- if (this.commands == null) return;
+ var com, _i, _len, _ref1;
+ if (!(word.length > 0)) {
+ return;
+ }
+ if (this.commands == null) {
+ return;
+ }
this.resetItem();
word = word.toUpperCase();
- _ref = this.commands;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- com = _ref[_i];
+ _ref1 = this.commands;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ com = _ref1[_i];
if (com.toUpperCase().slice(0, word.length) === word) {
this.addItem({
str: com,
@@ -613,14 +648,18 @@
}
CandSourceAlias.prototype.onInput = function(word) {
- var alias, com, _ref;
- if (!(word.length > 0)) return;
- if (this.aliases == null) return;
+ var alias, com, _ref1;
+ if (!(word.length > 0)) {
+ return;
+ }
+ if (this.aliases == null) {
+ return;
+ }
this.resetItem();
word = word.toUpperCase();
- _ref = this.aliases;
- for (alias in _ref) {
- com = _ref[alias];
+ _ref1 = this.aliases;
+ for (alias in _ref1) {
+ com = _ref1[alias];
if (alias.toUpperCase().slice(0, word.length) === word) {
this.addItem({
str: alias,
@@ -641,7 +680,7 @@
__extends(CandSourceHistory, _super);
function CandSourceHistory() {
- CandSourceHistory.__super__.constructor.apply(this, arguments);
+ return CandSourceHistory.__super__.constructor.apply(this, arguments);
}
CandSourceHistory.prototype.id = "WebHistory";
@@ -650,7 +689,9 @@
CandSourceHistory.prototype.onInput = function(word) {
var _this = this;
- if (!(word.length > 0)) return;
+ if (!(word.length > 0)) {
+ return;
+ }
this.resetItem();
return chrome.extension.sendRequest({
command: "GetHistory",
@@ -684,7 +725,7 @@
__extends(CandSourceBookmark, _super);
function CandSourceBookmark() {
- CandSourceBookmark.__super__.constructor.apply(this, arguments);
+ return CandSourceBookmark.__super__.constructor.apply(this, arguments);
}
CandSourceBookmark.prototype.id = "Bookmark";
@@ -693,7 +734,9 @@
CandSourceBookmark.prototype.onInput = function(word) {
var _this = this;
- if (!(word.length > 0)) return;
+ if (!(word.length > 0)) {
+ return;
+ }
this.resetItem();
return chrome.extension.sendRequest({
command: "GetBookmark",
@@ -740,13 +783,15 @@
}
CandSourceSearchHist.prototype.onInput = function(word) {
- var hist, _i, _len, _ref;
- if (this.history == null) return;
+ var hist, _i, _len, _ref1;
+ if (this.history == null) {
+ return;
+ }
this.resetItem();
word = word.toUpperCase();
- _ref = this.history;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- hist = _ref[_i];
+ _ref1 = this.history;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ hist = _ref1[_i];
if (hist.toUpperCase().slice(0, word.length) === word) {
this.addItem({
str: hist,
@@ -767,7 +812,7 @@
__extends(CandSourceGoogleSuggest, _super);
function CandSourceGoogleSuggest() {
- CandSourceGoogleSuggest.__super__.constructor.apply(this, arguments);
+ return CandSourceGoogleSuggest.__super__.constructor.apply(this, arguments);
}
CandSourceGoogleSuggest.prototype.id = "GoogleSuggest";
@@ -776,7 +821,9 @@
CandSourceGoogleSuggest.prototype.onInput = function(word) {
var _this = this;
- if (!(word.length > 0)) return;
+ if (!(word.length > 0)) {
+ return;
+ }
this.resetItem();
return chrome.extension.sendRequest({
command: "GetGoogleSuggest",
@@ -810,7 +857,7 @@
__extends(CandSourceWebSuggest, _super);
function CandSourceWebSuggest() {
- CandSourceWebSuggest.__super__.constructor.apply(this, arguments);
+ return CandSourceWebSuggest.__super__.constructor.apply(this, arguments);
}
CandSourceWebSuggest.prototype.id = "WebSuggest";
@@ -819,7 +866,9 @@
CandSourceWebSuggest.prototype.onInput = function(word) {
var _this = this;
- if (!(word.length > 0)) return;
+ if (!(word.length > 0)) {
+ return;
+ }
this.resetItem();
if (word.charAt(1) === " " && word.charAt(0) !== "w") {
this.notifyUpdated();
@@ -870,13 +919,15 @@
}
CandSourceTabs.prototype.onInput = function(word) {
- var a, tab, _i, _len, _ref;
- if (this.tabs == null) return;
+ var a, tab, _i, _len, _ref1;
+ if (this.tabs == null) {
+ return;
+ }
this.resetItem();
word = word.toUpperCase();
- _ref = this.tabs;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- tab = _ref[_i];
+ _ref1 = this.tabs;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ tab = _ref1[_i];
a = tab.title.toUpperCase();
if (tab.title.toUpperCase().indexOf(word) >= 0) {
this.addItem({
@@ -928,33 +979,37 @@
};
onRequest = function(req) {
- var candBox, obj, reqPrefix, src, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4;
+ var candBox, obj, reqPrefix, src, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4;
switch (req.mode) {
case "Command":
sender = req.sender;
window.focus();
candBox = new g.CandidateBox;
- _ref = req.sources;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- src = _ref[_i];
+ _ref1 = req.sources;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ src = _ref1[_i];
reqPrefix = (_ref2 = src.reqPrefix) != null ? _ref2 : false;
obj = (new g[src["class"]](src.num)).requirePrefix(reqPrefix);
candBox.addSource(obj);
}
- if (g.commandBox != null) g.commandBox.detachFrom();
+ if (g.commandBox != null) {
+ g.commandBox.detachFrom();
+ }
return g.commandBox = (new g.CommandBox).init(opt.commandBoxWidth, opt.commandBoxAlign).attachTo().show(req.modeChar).focus().setKeyMap(req.keyMap).setAlias(req.aliases).setFixedListener(commandFixedListener).setCandidateBox(candBox);
case "Search":
sender = req.sender;
window.focus();
candBox = new g.CandidateBox;
_ref3 = req.sources;
- for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
+ for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
src = _ref3[_j];
reqPrefix = (_ref4 = src.reqPrefix) != null ? _ref4 : false;
obj = (new g[src["class"]](src.num)).requirePrefix(reqPrefix);
candBox.addSource(obj);
}
- if (g.commandBox != null) g.commandBox.detachFrom();
+ if (g.commandBox != null) {
+ g.commandBox.detachFrom();
+ }
g.commandBox = (new g.CommandBox).init(opt.commandBoxWidth, opt.commandBoxAlign).attachTo().show(req.modeChar).focus().setIncremental(req.incSearch).setKeyMap(req.keyMap).setAlias(req.aliases).setFixedListener(searchFixedListener).setCandidateBox(candBox);
if (req.incSearch) {
return g.commandBox.addInputUpdateListener(searchUpdatedListener);
View
35 eventhandler.js
@@ -1,7 +1,10 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g;
+ var g, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -18,7 +21,9 @@
EventHandler.prototype.onKeyPress = function(e) {
if (g.model.isInSearchMode() || g.model.isInCommandMode()) {
- if (!e.ctrlKey && !e.altKey && !e.metaKey) return event.stopPropagation();
+ if (!e.ctrlKey && !e.altKey && !e.metaKey) {
+ return event.stopPropagation();
+ }
}
};
@@ -26,19 +31,21 @@
var msg;
g.logger.d("onKeyDown", e);
msg = this.getHandlableKey(e);
- if (msg != null) return this.model.handleKey(msg);
+ if (msg != null) {
+ return this.model.handleKey(msg);
+ }
};
EventHandler.prototype.getHandlableKey = function(e) {
var code;
if (g.KeyManager.isOnlyModifier(e.keyIdentifier, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey)) {
g.logger.d("getHandlableKey:only modifier");
- return;
+ return void 0;
}
code = g.KeyManager.getLocalKeyCode(e.keyIdentifier, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey);
if (code == null) {
g.logger.d("getHandlableKey:cant be handled");
- return;
+ return void 0;
}
if (this.model.prePostKeyEvent(code, e.ctrlKey, e.altKey, e.metaKey)) {
return {
@@ -85,7 +92,7 @@
EventHandler.prototype.addExtListener = function() {
var _this = this;
return chrome.extension.onRequest.addListener(function(req, sender, sendResponse) {
- var a, aliases, com, commands, method, _ref, _ref2;
+ var a, aliases, com, commands, method, _ref1, _ref2;
g.logger.d("onRequest command: " + req.command);
if ((req.frameID != null) && req.frameID !== g.model.frameID) {
g.logger.d("onRequest: different frameID");
@@ -94,9 +101,9 @@
switch (req.command) {
case "GetCommandTable":
commands = [];
- _ref = g.CommandExecuter.prototype.commandTable;
- for (com in _ref) {
- method = _ref[com];
+ _ref1 = g.CommandExecuter.prototype.commandTable;
+ for (com in _ref1) {
+ method = _ref1[com];
commands.push(com);
}
return sendResponse(commands);
@@ -147,8 +154,12 @@
};
EventHandler.prototype.onCommandResponse = function(msg) {
- if (msg == null) return;
- if (msg.command === "Settings") this.model.onSettings(msg);
+ if (msg == null) {
+ return;
+ }
+ if (msg.command === "Settings") {
+ this.model.onSettings(msg);
+ }
if ((msg.error != null) && msg.error === true) {
g.logger.e("onCommandResponse: error occured!!!", msg);
g.model.curMode.reqEscape();
View
31 key.js
@@ -1,7 +1,10 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g, keyCodes, keyIdentifier, shiftWinKeyIdentifier_ja, shiftWinKeyIdentifier_us, util, winKeyIdentifier_ja, winKeyIdentifier_us;
+ var g, keyCodes, keyIdentifier, shiftWinKeyIdentifier_ja, shiftWinKeyIdentifier_us, util, winKeyIdentifier_ja, winKeyIdentifier_us, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -233,13 +236,17 @@
g.KeyManager = {
isAlphabet: function(str) {
var c;
- if (str.length !== 1) return false;
+ if (str.length !== 1) {
+ return false;
+ }
c = str.charCodeAt(0);
return ((65 <= c && c <= 90)) || ((97 <= c && c <= 122));
},
isNumber: function(str) {
var c;
- if (str.length !== 1) return false;
+ if (str.length !== 1) {
+ return false;
+ }
c = str.charCodeAt(0);
return (48 <= c && c <= 57);
},
@@ -257,11 +264,19 @@
getKeyCodeStr: function(msg) {
var result;
result = msg.code;
- if (msg.ctrl) result = "C-" + result;
- if (msg.alt) result = "A-" + result;
- if (msg.meta) result = "M-" + result;
+ if (msg.ctrl) {
+ result = "C-" + result;
+ }
+ if (msg.alt) {
+ result = "A-" + result;
+ }
+ if (msg.meta) {
+ result = "M-" + result;
+ }
if (msg.ctrl || msg.alt || msg.meta || keyCodes[msg.code]) {
- if (keyCodes[msg.code] ? msg.shift : void 0) result = "S-" + result;
+ if (keyCodes[msg.code] ? msg.shift : void 0) {
+ result = "S-" + result;
+ }
result = "<" + result + ">";
}
return result;
View
25 manifest.json
@@ -1,8 +1,12 @@
{
+ "manifest_version": 2,
"name": "Vichrome",
"version": "0.11.0",
"description": "vi like interface for Google Chrome™. For every Google Chrome™ user who hate using a mouse.",
- "background_page": "background.html",
+ "background": {
+ "persistent": true,
+ "page": "background.html"
+ },
"options_page": "options.html",
"icons":{
"16" :"icons/16.png",
@@ -43,5 +47,24 @@
"all_frames": true,
"run_at": "document_start"
}
+ ],
+ "web_accessible_resources": [
+ "commandbox.html",
+ "lib/dicts//a2.txt",
+ "lib/dicts/alpha2.txt",
+ "lib/dicts/ba2.txt",
+ "lib/dicts/da2.txt",
+ "lib/dicts/ga2.txt",
+ "lib/dicts/ha2.txt",
+ "lib/dicts/ka2.txt",
+ "lib/dicts/ma2.txt",
+ "lib/dicts/na2.txt",
+ "lib/dicts/pa2.txt",
+ "lib/dicts/ra2.txt",
+ "lib/dicts/sa2.txt",
+ "lib/dicts/ta2.txt",
+ "lib/dicts/wa2.txt",
+ "lib/dicts/ya2.txt",
+ "lib/dicts/za2.txt"
]
}
View
159 mode.js
@@ -1,9 +1,12 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g,
- __hasProp = Object.prototype.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+ var g, _ref,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -74,7 +77,7 @@
};
Mode.prototype.reqOpen = function(args) {
- var arg, bookmark, com, history, i, interactive, opt, search, url, urls, web, word, _i, _j, _len, _len2;
+ var arg, bookmark, com, history, i, interactive, opt, search, url, urls, web, word, _i, _j, _len, _len1;
urls = [];
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
@@ -110,7 +113,7 @@
return this.enterInteractiveOpen(com, opt);
} else if (search) {
word = "";
- for (_j = 0, _len2 = urls.length; _j < _len2; _j++) {
+ for (_j = 0, _len1 = urls.length; _j < _len1; _j++) {
i = urls[_j];
word += "+" + encodeURIComponent(i);
}
@@ -128,9 +131,11 @@
};
Mode.prototype.reqTabOpenNew = function(args, times) {
- var arg, bookmark, com, history, i, interactive, opt, search, url, web, word, words, _i, _j, _len, _len2;
+ var arg, bookmark, com, history, i, interactive, opt, search, url, web, word, words, _i, _j, _len, _len1;
words = [];
- if (times > 10) times = 1;
+ if (times > 10) {
+ times = 1;
+ }
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
switch (arg) {
@@ -165,7 +170,7 @@
return this.enterInteractiveOpen(com, opt);
} else if (search) {
word = "";
- for (_j = 0, _len2 = words.length; _j < _len2; _j++) {
+ for (_j = 0, _len1 = words.length; _j < _len1; _j++) {
i = words[_j];
word += "+" + encodeURIComponent(i);
}
@@ -348,7 +353,9 @@
};
Mode.prototype.req_ChangeLogLevel = function(args) {
- if (!args || args.length < 1) return;
+ if (!args || args.length < 1) {
+ return;
+ }
if (g.logLevels[args[0]] != null) {
return g.LOG_LEVEL = g.logLevels[args[0]];
} else {
@@ -369,7 +376,7 @@
__extends(NormalMode, _super);
function NormalMode() {
- NormalMode.__super__.constructor.apply(this, arguments);
+ return NormalMode.__super__.constructor.apply(this, arguments);
}
NormalMode.prototype.getName = function() {
@@ -407,7 +414,7 @@
__extends(InsertMode, _super);
function InsertMode() {
- InsertMode.__super__.constructor.apply(this, arguments);
+ return InsertMode.__super__.constructor.apply(this, arguments);
}
InsertMode.prototype.getName = function() {
@@ -423,8 +430,12 @@
};
InsertMode.prototype.prePostKeyEvent = function(key, ctrl, alt, meta) {
- if (ctrl || alt || meta) return true;
- if (g.KeyManager.isNumber(key) || g.KeyManager.isAlphabet(key)) return false;
+ if (ctrl || alt || meta) {
+ return true;
+ }
+ if (g.KeyManager.isNumber(key) || g.KeyManager.isAlphabet(key)) {
+ return false;
+ }
return true;
};
@@ -437,7 +448,7 @@
__extends(SearchMode, _super);
function SearchMode() {
- SearchMode.__super__.constructor.apply(this, arguments);
+ return SearchMode.__super__.constructor.apply(this, arguments);
}
SearchMode.prototype.getName = function() {
@@ -497,7 +508,9 @@
SearchMode.prototype.notifyInputUpdated = function(msg) {
var _this = this;
- if (this.waiting) clearTimeout(this.timerId);
+ if (this.waiting) {
+ clearTimeout(this.timerId);
+ }
this.timerId = setTimeout(function() {
g.logger.e("set");
_this.searcher.updateInput(msg.word);
@@ -529,7 +542,7 @@
__extends(CommandMode, _super);
function CommandMode() {
- CommandMode.__super__.constructor.apply(this, arguments);
+ return CommandMode.__super__.constructor.apply(this, arguments);
}
CommandMode.prototype.getName = function() {
@@ -551,8 +564,10 @@
};
CommandMode.prototype.enter = function() {
- var param;
- if (this.executer == null) this.executer = new g.CommandExecuter;
+ var param, _ref1;
+ if ((_ref1 = this.executer) == null) {
+ this.executer = new g.CommandExecuter;
+ }
if (this.executer.getDescription() != null) {
g.view.setStatusLineText(this.executer.getDescription());
} else {
@@ -594,7 +609,7 @@
__extends(EmergencyMode, _super);
function EmergencyMode() {
- EmergencyMode.__super__.constructor.apply(this, arguments);
+ return EmergencyMode.__super__.constructor.apply(this, arguments);
}
EmergencyMode.prototype.getName = function() {
@@ -611,7 +626,9 @@
text = "Emergency Mode: press ";
for (key in keyMap) {
mapped = keyMap[key];
- if (mapped === "Escape") text += key + ", ";
+ if (mapped === "Escape") {
+ text += key + ", ";
+ }
}
text = text.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/, $/, " ");
text += "to escape";
@@ -623,7 +640,9 @@
};
EmergencyMode.prototype.blur = function(target) {
- if (g.util.isEmbededFlash(target)) return g.model.enterNormalMode();
+ if (g.util.isEmbededFlash(target)) {
+ return g.model.enterNormalMode();
+ }
};
EmergencyMode.prototype.getKeyMapping = function() {
@@ -639,7 +658,7 @@
__extends(FMode, _super);
function FMode() {
- FMode.__super__.constructor.apply(this, arguments);
+ return FMode.__super__.constructor.apply(this, arguments);
}
FMode.prototype.getName = function() {
@@ -657,7 +676,9 @@
target = $(this.hints[i].target);
if (target.is('a')) {
primary = this.opt.newTab;
- if (!this.opt.continuous) g.model.enterNormalMode();
+ if (!this.opt.continuous) {
+ g.model.enterNormalMode();
+ }
} else {
target.focus();
if (g.util.isEditable(target.get(0))) {
@@ -674,11 +695,13 @@
};
FMode.prototype.searchTarget = function() {
- var elem, i, _len, _ref;
- _ref = this.hints;
- for (i = 0, _len = _ref.length; i < _len; i++) {
- elem = _ref[i];
- if (this.currentInput === elem.key) return i;
+ var elem, i, _i, _len, _ref1;
+ _ref1 = this.hints;
+ for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
+ elem = _ref1[i];
+ if (this.currentInput === elem.key) {
+ return i;
+ }
}
return -1;
};
@@ -702,7 +725,9 @@
if (idx >= 0) {
this.hit(idx);
} else {
- if (!this.opt.continuous) g.model.enterNormalMode();
+ if (!this.opt.continuous) {
+ g.model.enterNormalMode();
+ }
}
if (this.opt.continuous) {
this.currentInput = "";
@@ -714,9 +739,15 @@
};
FMode.prototype.prePostKeyEvent = function(key, ctrl, alt, meta) {
- if (key === "ESC") return true;
- if (ctrl || alt || meta) return true;
- if (g.model.getSetting("fModeIgnoreCase")) key = key.toUpperCase();
+ if (key === "ESC") {
+ return true;
+ }
+ if (ctrl || alt || meta) {
+ return true;
+ }
+ if (g.model.getSetting("fModeIgnoreCase")) {
+ key = key.toUpperCase();
+ }
if (this.isValidKey(key)) {
event.stopPropagation();
event.preventDefault();
@@ -728,30 +759,36 @@
};
FMode.prototype.getKeyLength = function(candiNum) {
- if (candiNum === 1) return 1;
- if (this.keys.length === 1) return 1;
+ if (candiNum === 1) {
+ return 1;
+ }
+ if (this.keys.length === 1) {
+ return 1;
+ }
return Math.ceil(Math.log(candiNum) / Math.log(this.keys.length));
};
FMode.prototype.updateHints = function() {
- var c, hint, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _results;
- _ref = this.hints;
+ var c, hint, _i, _j, _k, _len, _len1, _len2, _ref1, _ref2, _ref3, _results;
+ _ref1 = this.hints;
_results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- hint = _ref[_i];
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ hint = _ref1[_i];
if (hint.key.indexOf(this.currentInput) === 0) {
hint.elem.find("span#vichromehintchar").remove();
_ref2 = this.currentInput;
- for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
+ for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
c = _ref2[_j];
hint.elem = hint.elem.append($('<span id="vichromehintchar" />').css("color", g.model.getSetting("hintColorSelected")).html(c));
}
_ref3 = hint.key.slice(this.currentInput.length);
- for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
+ for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
c = _ref3[_k];
hint.elem = hint.elem.append($('<span id="vichromehintchar" />').css("color", g.model.getSetting("hintColor")).html(c));
}
- if (!hint.elem.is(':visible')) this.showFunc.call(hint.elem);
+ if (!hint.elem.is(':visible')) {
+ this.showFunc.call(hint.elem);
+ }
_results.push($(hint.target).addClass('vichrome-fModeTarget'));
} else {
this.hideFunc.call(hint.elem);
@@ -762,8 +799,8 @@
};
FMode.prototype.createHints = function(links) {
- var c, elem, hint, hintHeight, i, j, k, key, left, offset, tmpElem, top, _i, _j, _len, _len2, _len3, _ref, _ref2, _results;
- for (i = 0, _len = links.length; i < _len; i++) {
+ var c, elem, hint, hintHeight, i, j, k, key, left, offset, tmpElem, top, _i, _j, _k, _len, _len1, _len2, _ref1, _ref2, _results;
+ for (i = _i = 0, _len = links.length; _i < _len; i = ++_i) {
elem = links[i];
key = '';
j = this.keyLength;
@@ -779,19 +816,23 @@
}
hintHeight = "" + (g.model.getSetting("hintFontSize") + 4) + "px";
tmpElem = $('<span id="vichromehint" />').css("height", hintHeight).css("line-height", hintHeight).css("font-size", "" + g.model.getSetting("hintFontSize") + "px").css("background-color", g.model.getSetting("hintBackgroundColor"));
- _ref = this.hints;
+ _ref1 = this.hints;
_results = [];
- for (_i = 0, _len2 = _ref.length; _i < _len2; _i++) {
- hint = _ref[_i];
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ hint = _ref1[_j];
offset = hint.target._offset_;
top = offset.top - 7;
left = offset.left - 7;
- if (top < 0) top = 0;
- if (left < 0) left = 0;
+ if (top < 0) {
+ top = 0;
+ }
+ if (left < 0) {
+ left = 0;
+ }
elem = tmpElem.clone().css("top", top).css("left", left);
_ref2 = hint.key;
- for (_j = 0, _len3 = _ref2.length; _j < _len3; _j++) {
- c = _ref2[_j];
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+ c = _ref2[_k];
elem = elem.append($('<span id="vichromehintchar" />').html(c)).css("color", g.model.getSetting("hintColor")).hide();
}
hint.elem = elem;
@@ -850,10 +891,18 @@
winH = window.innerHeight;
winW = window.innerWidth;
offset = $(elem).offset();
- if (winTop > offset.top || winTop + winH < offset.top) return false;
- if (winLeft > offset.left || offset.left > winLeft + winW) return false;
- if ($.expr[':'].hidden(elem)) return false;
- if ($.curCSS(elem, 'visibility') === 'hidden') return false;
+ if (winTop > offset.top || winTop + winH < offset.top) {
+ return false;
+ }
+ if (winLeft > offset.left || offset.left > winLeft + winW) {
+ return false;
+ }
+ if ($.expr[':'].hidden(elem)) {
+ return false;
+ }
+ if ($.curCSS(elem, 'visibility') === 'hidden') {
+ return false;
+ }
elem._offset_ = offset;
return true;
}
View
96 model.js
@@ -1,21 +1,26 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g, getAliasFirst, getCMapFirst, getEMapFirst, getIMapFirst, getNMapFirst;
+ var g, getAliasFirst, getCMapFirst, getEMapFirst, getIMapFirst, getNMapFirst, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
getNMapFirst = function() {
- var map, myMap, nmap, pageMap, url, _ref;
+ var map, myMap, nmap, pageMap, url, _ref1;
nmap = g.object(this.getSetting("keyMappingNormal"));
pageMap = this.getSetting("pageMap");
- if (!(((_ref = g.view.getHref()) != null ? _ref.length : void 0) > 0)) {
+ if (!(((_ref1 = g.view.getHref()) != null ? _ref1.length : void 0) > 0)) {
return nmap;
}
myMap = nmap;
for (url in pageMap) {
map = pageMap[url];
- if (this.isUrlMatched(g.view.getHref(), url)) g.extend(map.nmap, myMap);
+ if (this.isUrlMatched(g.view.getHref(), url)) {
+ g.extend(map.nmap, myMap);
+ }
}
this.getNMap = function() {
return myMap;
@@ -24,16 +29,18 @@
};
getIMapFirst = function() {
- var imap, map, myMap, pageMap, url, _ref;
+ var imap, map, myMap, pageMap, url, _ref1;
imap = g.object(this.getSetting("keyMappingInsert"));
pageMap = this.getSetting("pageMap");
- if (!(((_ref = g.view.getHref()) != null ? _ref.length : void 0) > 0)) {
+ if (!(((_ref1 = g.view.getHref()) != null ? _ref1.length : void 0) > 0)) {
return imap;
}
myMap = imap;
for (url in pageMap) {
map = pageMap[url];
- if (this.isUrlMatched(g.view.getHref(), url)) g.extend(map.imap, myMap);
+ if (this.isUrlMatched(g.view.getHref(), url)) {
+ g.extend(map.imap, myMap);
+ }
}
this.getIMap = function() {
return myMap;
@@ -42,16 +49,18 @@
};
getCMapFirst = function() {
- var cmap, map, myMap, pageMap, url, _ref;
+ var cmap, map, myMap, pageMap, url, _ref1;
cmap = g.object(this.getSetting("keyMappingCommand"));
pageMap = this.getSetting("pageMap");
- if (!(((_ref = g.view.getHref()) != null ? _ref.length : void 0) > 0)) {
+ if (!(((_ref1 = g.view.getHref()) != null ? _ref1.length : void 0) > 0)) {
return cmap;
}
myMap = cmap;
for (url in pageMap) {
map = pageMap[url];
- if (this.isUrlMatched(g.view.getHref(), url)) g.extend(map.cmap, myMap);
+ if (this.isUrlMatched(g.view.getHref(), url)) {
+ g.extend(map.cmap, myMap);
+ }
}
this.getCMap = function() {
return myMap;
@@ -60,16 +69,18 @@
};
getEMapFirst = function() {
- var emap, map, myMap, pageMap, url, _ref;
+ var emap, map, myMap, pageMap, url, _ref1;
emap = g.object(this.getSetting("keyMappingEmergency"));
pageMap = this.getSetting("pageMap");
- if (!(((_ref = g.view.getHref()) != null ? _ref.length : void 0) > 0)) {
+ if (!(((_ref1 = g.view.getHref()) != null ? _ref1.length : void 0) > 0)) {
return emap;
}
myMap = emap;
for (url in pageMap) {
map = pageMap[url];
- if (this.isUrlMatched(g.view.getHref(), url)) g.extend(map.emap, myMap);
+ if (this.isUrlMatched(g.view.getHref(), url)) {
+ g.extend(map.emap, myMap);
+ }
}
this.getEMap = function() {
return myMap;
@@ -78,16 +89,18 @@
};
getAliasFirst = function() {
- var aliases, map, myAlias, pageMap, url, _ref;
+ var aliases, map, myAlias, pageMap, url, _ref1;
aliases = g.object(this.getSetting("aliases"));
pageMap = this.getSetting("pageMap");
- if (!(((_ref = g.view.getHref()) != null ? _ref.length : void 0) > 0)) {
+ if (!(((_ref1 = g.view.getHref()) != null ? _ref1.length : void 0) > 0)) {
return aliases;
}
myAlias = aliases;
for (url in pageMap) {
map = pageMap[url];
- if (this.isUrlMatched(g.view.getHref(), url)) g.extend(map.alias, myAlias);
+ if (this.isUrlMatched(g.view.getHref(), url)) {
+ g.extend(map.alias, myAlias);
+ }
}
this.getAlias = function() {
return myAlias;
@@ -109,11 +122,13 @@
return this.pmRegister = pmRegister != null ? pmRegister : new g.PageMarkRegister;
},
changeMode: function(newMode) {
- var _ref;
- if (this.curMode != null) this.curMode.exit();
+ var _ref1;
+ if (this.curMode != null) {
+ this.curMode.exit();
+ }
this.curMode = newMode;
this.curMode.enter();
- return (_ref = this.commandManager) != null ? _ref.setUseNumPrefix(this.curMode.getUseNumPrefix()) : void 0;
+ return (_ref1 = this.commandManager) != null ? _ref1.setUseNumPrefix(this.curMode.getUseNumPrefix()) : void 0;
},
isReady: function() {
return this.initEnabled && this.domReady;
@@ -129,14 +144,16 @@
goPageMark: function(key) {
var offset;
offset = this.pmRegister.get(key);
- if (offset) return g.view.scrollTo(offset.left, offset.top);
+ if (offset) {
+ return g.view.scrollTo(offset.left, offset.top);
+ }
},
setSearcher: function(searcher) {
this.searcher = searcher;
},
cancelSearchHighlight: function() {
- var _ref;
- return (_ref = this.searcher) != null ? _ref.cancelHighlight() : void 0;
+ var _ref1;
+ return (_ref1 = this.searcher) != null ? _ref1.cancelHighlight() : void 0;
},
enterNormalMode: function() {
g.logger.d("enterNormalMode");
@@ -187,7 +204,9 @@
return this.curMode.getName() === "EmergencyMode";
},
goNextSearchResult: function(reverse) {
- if (this.searcher == null) return;
+ if (this.searcher == null) {
+ return;
+ }
this.setPageMark();
return this.searcher.goNext(reverse);
},
@@ -202,7 +221,9 @@
escape: function() {
this.commandManager.reset();
g.view.hideStatusLine();
- if (!this.isInNormalMode()) return this.enterNormalMode();
+ if (!this.isInNormalMode()) {
+ return this.enterNormalMode();
+ }
},
onBlur: function(target) {
return this.curMode.blur(target);
@@ -228,9 +249,13 @@
pos = cmpStr.indexOf("<", 0);
if (pos >= 0) {
pos = seq.indexOf(">", pos);
- if (pos >= length) cmpStr = seq.slice(0, pos + 1);
+ if (pos >= length) {
+ cmpStr = seq.slice(0, pos + 1);
+ }
+ }
+ if (keySeq === cmpStr) {
+ return true;
}
- if (keySeq === cmpStr) return true;
}
return false;
},
@@ -333,7 +358,9 @@
frameID: this.frameID
});
}
- if (this.domReady) return this.onDomReady();
+ if (this.domReady) {
+ return this.onDomReady();
+ }
},
onDomReady: function() {
g.logger.d("onDomReady");
@@ -352,6 +379,7 @@
}
},
openCommandBox: function(param) {
+ var _ref1, _ref2, _ref3;
if (typeof top !== "undefined" && top !== null) {
param.command = "SendToCommandBox";
g.view.showCommandFrame();
@@ -359,9 +387,15 @@
param.command = "TopFrame";
}
param.innerCommand = 'OpenCommandBox';
- if (param.sender == null) param.sender = this.frameID;
- if (param.keyMap == null) param.keyMap = g.extendDeep(this.getCMap());
- if (param.aliases == null) param.aliases = g.extendDeep(this.getAlias());
+ if ((_ref1 = param.sender) == null) {
+ param.sender = this.frameID;
+ }
+ if ((_ref2 = param.keyMap) == null) {
+ param.keyMap = g.extendDeep(this.getCMap());
+ }
+ if ((_ref3 = param.aliases) == null) {
+ param.aliases = g.extendDeep(this.getAlias());
+ }
return chrome.extension.sendRequest(param, function(msg) {
return g.handler.onCommandResponse(msg);
});
View
27 options.js
@@ -1,7 +1,10 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var escChars, g, initCheckBox, initDropDown, initInputNumber, initInputText, onSettings, setSetting, settings, updateKeyMappingList;
+ var escChars, g, initCheckBox, initDropDown, initInputNumber, initInputText, onSettings, setSetting, settings, updateKeyMappingList, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -21,12 +24,12 @@
};
updateKeyMappingList = function() {
- var com, curMap, key, map, url, _ref, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _results;
+ var com, curMap, key, map, url, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _results;
curMap = $('#keyMappingList');
curMap.append($('<div />').html('<h3>Normal Mode Mapping (nmap)</h3>'));
- _ref = settings.keyMappingNormal;
- for (key in _ref) {
- com = _ref[key];
+ _ref1 = settings.keyMappingNormal;
+ for (key in _ref1) {
+ com = _ref1[key];
curMap.append($('<div />').html(escChars(key + " : " + escChars(com))));
}
curMap.append($('<div />').html('<h3>Insert Mode Mapping (imap)</h3>'));
@@ -85,14 +88,14 @@
}
curMap.append($('<div />').html('<h3>Command Aliases</h3>'));
_results.push((function() {
- var _ref11, _results2;
+ var _ref11, _results1;
_ref11 = map.alias;
- _results2 = [];
+ _results1 = [];
for (key in _ref11) {
com = _ref11[key];
- _results2.push(curMap.append($('<div />').html(escChars(key + " : " + escChars(com)))));
+ _results1.push(curMap.append($('<div />').html(escChars(key + " : " + escChars(com)))));
}
- return _results2;
+ return _results1;
})());
}
return _results;
@@ -127,7 +130,9 @@
};
onSettings = function(msg) {
- if (msg.name === "all") settings = msg.value;
+ if (msg.name === "all") {
+ settings = msg.value;
+ }
initInputNumber("scrollPixelCount");
initInputNumber("commandWaitTimeOut");
initInputNumber("minIncSearch");
View
15 register.js
@@ -1,7 +1,10 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g;
+ var g, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -14,13 +17,17 @@
PageMarkRegister.prototype.defaultKeyName = "unnamed";
PageMarkRegister.prototype.set = function(pos, key) {
- if (key == null) key = this.defaultKeyName;
+ if (key == null) {
+ key = this.defaultKeyName;
+ }
this.values[key] = pos;
return this;
};
PageMarkRegister.prototype.get = function(key) {
- if (key == null) key = this.defaultKeyName;
+ if (key == null) {
+ key = this.defaultKeyName;
+ }
return this.values[key];
};
View
35 search.js
@@ -1,9 +1,12 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g,
- __hasProp = Object.prototype.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+ var g, _ref,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -34,12 +37,14 @@
};
NormalSearcher.prototype.getFirstInnerSearchResultIndex = function() {
- var i, idx, span, total, _ref;
+ var i, idx, span, total, _i, _ref1;
total = this.getResultCnt();
- for (i = 0, _ref = total - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
+ for (i = _i = 0, _ref1 = total - 1; 0 <= _ref1 ? _i <= _ref1 : _i >= _ref1; i = 0 <= _ref1 ? ++_i : --_i) {
idx = this.opt.backward ? total - 1 - i : i;
span = this.getResult(idx);
- if ((span != null) && span.isWithinScreen()) return idx;
+ if ((span != null) && span.isWithinScreen()) {
+ return idx;
+ }
}
return -1;
};
@@ -105,12 +110,12 @@
};
NormalSearcher.prototype.getResult = function(cnt) {
- var _ref;
- return (_ref = this.sortedResults[cnt]) != null ? _ref.value : void 0;
+ var _ref1;
+ return (_ref1 = this.sortedResults[cnt]) != null ? _ref1.value : void 0;
};
NormalSearcher.prototype.fix = function(word) {
- var span, _ref;
+ var span, _ref1;
if (!this.opt.incSearch || word.length < this.opt.minIncSearch || this.word !== word) {
if (this.opt.useMigemo && word.length < this.opt.minMigemoLength) {
this.opt.useMigemo = false;
@@ -139,13 +144,15 @@
});
span = this.getResult(this.getCurIndex());
if (span != null) {
- if ((_ref = span.closest("a").get(0)) != null) _ref.focus();
+ if ((_ref1 = span.closest("a").get(0)) != null) {
+ _ref1.focus();
+ }
}
return this.fixed = true;
};
NormalSearcher.prototype.moveTo = function(pos) {
- var span, _ref;
+ var span, _ref1;
if (this.getResultCnt() > pos) {
span = this.getResult(pos);
if (span != null) {
@@ -155,7 +162,7 @@
g.view.setStatusLineText((pos + 1) + " / " + this.getResultCnt());
if (this.fixed) {
g.view.blurActiveElement();
- return (_ref = span.closest("a").get(0)) != null ? _ref.focus() : void 0;
+ return (_ref1 = span.closest("a").get(0)) != null ? _ref1.focus() : void 0;
}
}
} else {
@@ -217,7 +224,7 @@
__extends(LinkTextSearcher, _super);
function LinkTextSearcher() {
- LinkTextSearcher.__super__.constructor.apply(this, arguments);
+ return LinkTextSearcher.__super__.constructor.apply(this, arguments);
}
LinkTextSearcher.prototype.highlight = function(word) {
View
31 settings.js
@@ -1,7 +1,10 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g, mapping;
+ var g, mapping, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -200,8 +203,12 @@
}).split('\n');
for (_i = 0, _len = lines.length; _i < _len; _i++) {
line = lines[_i];
- if (line.length === 0) continue;
- if (line.charAt(0) === '#') continue;
+ if (line.length === 0) {
+ continue;
+ }
+ if (line.charAt(0) === '#') {
+ continue;
+ }
args = line.split(/[\t ]+/);
if (typeof this[_name = "_" + args[0]] === "function") {
this[_name](this.userMap, args.slice(1));
@@ -210,7 +217,7 @@
return this;
},
initUserMap: function() {
- var com, command, defAliases, defCommand, defEmergency, defInsert, defNormal, defPageMap, key, map, url, _ref, _ref2, _ref3, _ref4, _ref5;
+ var com, command, defAliases, defCommand, defEmergency, defInsert, defNormal, defPageMap, key, map, url, _ref1, _ref2, _ref3, _ref4, _ref5;
defNormal = this.defaultSettings.keyMappingNormal;
defInsert = this.defaultSettings.keyMappingInsert;
defCommand = this.defaultSettings.keyMappingCommand;
@@ -242,9 +249,9 @@
for (url in defPageMap) {
map = defPageMap[url];
this.pageMap[url] = g.extendDeep(mapping);
- _ref = map.nmap;
- for (key in _ref) {
- com = _ref[key];
+ _ref1 = map.nmap;
+ for (key in _ref1) {
+ com = _ref1[key];
this.pageMap[url].nmap[key] = com;
}
_ref2 = map.imap;
@@ -271,11 +278,11 @@
return this;
},
getAll: function() {
- var name, settings, value, _ref;
+ var name, settings, value, _ref1;
settings = {};
- _ref = this.defaultSettings;
- for (name in _ref) {
- value = _ref[name];
+ _ref1 = this.defaultSettings;
+ for (name in _ref1) {
+ value = _ref1[name];
switch (name) {
case "keyMappingNormal":
settings[name] = this.userMap.nmap;
View
131 tab.js
@@ -1,7 +1,10 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var g;
+ var g, _ref;
- if (this.vichrome == null) this.vichrome = {};
+ if ((_ref = this.vichrome) == null) {
+ this.vichrome = {};
+ }
g = this.vichrome;
@@ -17,14 +20,14 @@
this.curPos = 0;
this.isUpdating = false;
chrome.tabs.onSelectionChanged.addListener(function(tabId, info) {
- var elem, i, _len, _ref, _ref2;
+ var elem, i, _i, _len, _ref1, _ref2;
g.logger.d("selhist selChanged id:" + tabId, _this);
- if (((_ref = _this.array[_this.curPos]) != null ? _ref.id : void 0) === tabId) {
+ if (((_ref1 = _this.array[_this.curPos]) != null ? _ref1.id : void 0) === tabId) {
return;
}
_this.array.splice(_this.curPos + 1);
_ref2 = _this.array;
- for (i = 0, _len = _ref2.length; i < _len; i++) {
+ for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
elem = _ref2[i];
if (elem.id === tabId) {
_this.array.splice(i, 1);
@@ -38,15 +41,17 @@
return _this.curPos = _this.array.length - 1;
});
chrome.tabs.onRemoved.addListener(function(tabId, info) {
- var elem, i, _len, _ref, _results;
+ var elem, i, _i, _len, _ref1, _results;
g.logger.d("selhist tab removed id:" + tabId, _this);
- _ref = _this.array;
+ _ref1 = _this.array;
_results = [];
- for (i = 0, _len = _ref.length; i < _len; i++) {
- elem = _ref[i];
+ for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
+ elem = _ref1[i];
if (elem.id === tabId) {
_this.array.splice(i, 1);
- if (_this.curPos >= i) _this.curPos--;
+ if (_this.curPos >= i) {
+ _this.curPos--;
+ }
break;
} else {
_results.push(void 0);
@@ -59,8 +64,12 @@
TabSelectionHistory.prototype.moveBackward = function() {
var _this = this;
- if (!(this.array.length > 0)) return;
- if (this.isUpdating) return;
+ if (!(this.array.length > 0)) {
+ return;
+ }
+ if (this.isUpdating) {
+ return;
+ }
if (this.curPos > 0) {
--this.curPos;
} else {
@@ -77,8 +86,12 @@
TabSelectionHistory.prototype.moveForward = function() {
var _this = this;
- if (!(this.array.length > 0)) return;
- if (this.isUpdating) return;
+ if (!(this.array.length > 0)) {
+ return;
+ }
+ if (this.isUpdating) {
+ return;
+ }
if (this.curPos < this.array.length - 1) {
++this.curPos;
} else {
@@ -95,9 +108,15 @@
TabSelectionHistory.prototype.switchToLast = function() {
var _this = this;
- if (!(this.array.length > 0)) return;
- if (!(this.curPos > 0)) return;
- if (this.isUpdating) return;
+ if (!(this.array.length > 0)) {
+ return;
+ }
+ if (!(this.curPos > 0)) {
+ return;
+ }
+ if (this.isUpdating) {
+ return;
+ }
chrome.tabs.update(this.array[this.curPos - 1].id, {
selected: true
}, function() {
@@ -120,19 +139,21 @@
TabHistory.prototype.openTabs = {};
TabHistory.prototype.findOpenTabItem = function(tabId) {
- var tabs, win, _ref;
- _ref = this.openTabs;
- for (win in _ref) {
- tabs = _ref[win];
- if (tabs[tabId]) return tabs[tabId];
+ var tabs, win, _ref1;
+ _ref1 = this.openTabs;
+ for (win in _ref1) {
+ tabs = _ref1[win];
+ if (tabs[tabId]) {
+ return tabs[tabId];
+ }
}
};
TabHistory.prototype.popOpenTabItem = function(tabId) {
- var result, tabs, win, _ref;
- _ref = this.openTabs;
- for (win in _ref) {
- tabs = _ref[win];
+ var result, tabs, win, _ref1;
+ _ref1 = this.openTabs;
+ for (win in _ref1) {
+ tabs = _ref1[win];
if (tabs[tabId]) {
result = tabs[tabId];
tabs[tabId] = void 0;
@@ -154,46 +175,46 @@
};
TabHistory.prototype.setTopFrameID = function(tab, id) {