Skip to content

Commit a2e4a4f

Browse files
committed
Merge pull request #516 from ghost/dot-notation
[{a}] is better to be written in dot notation
2 parents 1cfe33f + a5232b3 commit a2e4a4f

24 files changed

+94
-94
lines changed

common/content/autocommands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const AutoCommands = Module("autocommands", {
117117

118118
for (let autoCmd of autoCmds) {
119119
if (autoCmd.pattern.test(url)) {
120-
if (options["verbose"] >= 9 && (!lastPattern || lastPattern.source != autoCmd.pattern.source))
120+
if (options.verbose >= 9 && (!lastPattern || lastPattern.source != autoCmd.pattern.source))
121121
liberator.echomsg("Executing " + event + " Auto commands for \"" + autoCmd.pattern.source + "\"");
122122

123123
lastPattern = autoCmd.pattern;

common/content/bookmarks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ const Bookmarks = Module("bookmarks", {
364364
// @returns the url for the search string
365365
// if the search also requires a postData, [url, postData] is returned
366366
getSearchURL: function getSearchURL(text, useDefsearch) {
367-
let searchString = (useDefsearch ? options["defsearch"] + " " : "") + text;
367+
let searchString = (useDefsearch ? options.defsearch + " " : "") + text;
368368

369369
// we need to make sure our custom alias have been set, even if the user
370370
// did not :open <tab> once before
@@ -762,7 +762,7 @@ const Bookmarks = Module("bookmarks", {
762762
if (!context.filter)
763763
return;
764764

765-
let engineList = (engineAliases || options["suggestengines"] || "google").split(",");
765+
let engineList = (engineAliases || options.suggestengines || "google").split(",");
766766

767767
engineList.forEach(function (name) {
768768
let engine = services.get("search").getEngineByAlias(name);

common/content/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Browser = Module("browser", {
3737
scope: Option.SCOPE_LOCAL,
3838
getter: function () config.browser.docShell.QueryInterface(Ci.nsIDocCharset).charset,
3939
setter: function (val) {
40-
if (options["encoding"] == val)
40+
if (options.encoding == val)
4141
return val;
4242

4343
// Stolen from browser.jar/content/browser/browser.js, more or less.

common/content/buffer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const Buffer = Module("buffer", {
193193
if (doc == config.browser.contentDocument) {
194194
// we want to stay in command mode after a page has loaded
195195
// TODO: move somewhere else, as focusing can already happen earlier than on "load"
196-
if (options["focuscontent"]) {
196+
if (options.focuscontent) {
197197
setTimeout(function () {
198198
let focused = liberator.focus;
199199
if (focused && (focused.value != null) && focused.value.length == 0)
@@ -282,7 +282,7 @@ const Buffer = Module("buffer", {
282282
asyncUpdateUI.superapply(this, arguments);
283283
},
284284
setOverLink: function setOverLink(link, b) {
285-
let ssli = options["showstatuslinks"];
285+
let ssli = options.showstatuslinks;
286286

287287
if (ssli == 3) {
288288
setOverLink.superapply(this, arguments);
@@ -768,15 +768,15 @@ const Buffer = Module("buffer", {
768768
count = count || 1;
769769
let elem = Buffer.findScrollable(direction, false);
770770

771-
if (options["scroll"] > 0)
772-
this.scrollLines(options["scroll"] * direction);
771+
if (options.scroll > 0)
772+
this.scrollLines(options.scroll * direction);
773773
else // scroll half a page down in pixels
774774
elem.scrollTop += Buffer.findScrollableWindow().innerHeight / 2 * direction;
775775
},
776776

777777
_scrollByScrollSize: function _scrollByScrollSize(count, direction) {
778778
if (count > 0)
779-
options["scroll"] = count;
779+
options.scroll = count;
780780
buffer.scrollByScrollSize(direction);
781781
},
782782

@@ -932,7 +932,7 @@ const Buffer = Module("buffer", {
932932
return;
933933
}
934934

935-
let option = sections || options["pageinfo"];
935+
let option = sections || options.pageinfo;
936936
let list = template.map2(xml, option, function (option) {
937937
let opt = buffer.pageInfo[option];
938938
return opt ? template.table2(xml, opt[1], opt[0](true)) : undefined;
@@ -1253,8 +1253,8 @@ const Buffer = Module("buffer", {
12531253
liberator.assert(!arg || titles.indexOf(arg) >= 0,
12541254
"Invalid argument: " + arg);
12551255

1256-
if (options["usermode"])
1257-
options["usermode"] = false;
1256+
if (options.usermode)
1257+
options.usermode = false;
12581258

12591259
window.stylesheetSwitchAll(config.browser.contentWindow, arg);
12601260
},
@@ -1532,7 +1532,7 @@ const Buffer = Module("buffer", {
15321532
"Start caret mode",
15331533
function () {
15341534
if (Editor.windowIsEditable()) {
1535-
if (options["insertmode"])
1535+
if (options.insertmode)
15361536
modes.set(modes.INSERT);
15371537
else if (Buffer.focusedWindow.getSelection().toString() != "")
15381538
modes.set(modes.VISUAL, modes.TEXTAREA);

common/content/commandline.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const CommandLine = Module("commandline", {
7070
this._messageHistory = { //{{{
7171
_messages: [],
7272
get messages() {
73-
let max = options["messages"];
73+
let max = options.messages;
7474

7575
// resize if 'messages' has changed
7676
if (this._messages.length > max)
@@ -89,7 +89,7 @@ const CommandLine = Module("commandline", {
8989
if (!message)
9090
return;
9191

92-
if (this._messages.length >= options["messages"])
92+
if (this._messages.length >= options.messages)
9393
this._messages.shift();
9494

9595
this._messages.push(message);
@@ -112,7 +112,7 @@ const CommandLine = Module("commandline", {
112112
});
113113

114114
this._autocompleteTimer = new Timer(200, 500, function autocompleteTell(tabPressed) {
115-
if (!events.feedingKeys && self._completions && options["autocomplete"]) {
115+
if (!events.feedingKeys && self._completions && options.autocomplete) {
116116
self._completions.complete(true, false);
117117
self._completions.itemList.show();
118118
}
@@ -298,10 +298,10 @@ const CommandLine = Module("commandline", {
298298

299299
this._setHighlightGroup(highlightGroup);
300300
this._messageBox.value = str;
301-
if (str && options["messagetimeout"] != -1 &&
301+
if (str && options.messagetimeout != -1 &&
302302
[this.HL_INFOMSG, this.HL_WARNINGMSG].indexOf(highlightGroup) != -1)
303303
timeID = this.setTimeout(function(){ this._messageBox.classList.add("liberator-hiding"); },
304-
options["messagetimeout"]);
304+
options.messagetimeout);
305305

306306
liberator.triggerObserver("echoLine", str, highlightGroup, forceSingle);
307307

@@ -1085,7 +1085,7 @@ const CommandLine = Module("commandline", {
10851085
return;
10861086
this.store.mutate("filter", function (line) (line.value || line) != str);
10871087
this.store.push({ value: str, timestamp: Date.now(), privateData: this.checkPrivate(str) });
1088-
this.store.truncate(options["history"], true);
1088+
this.store.truncate(options.history, true);
10891089
},
10901090
/**
10911091
* @property {function} Returns whether a data item should be
@@ -1102,8 +1102,8 @@ const CommandLine = Module("commandline", {
11021102
*/
11031103
sanitize: function (timespan) {
11041104
let range = [0, Number.MAX_VALUE];
1105-
if (liberator.has("sanitizer") && (timespan || options["sanitizetimespan"]))
1106-
range = sanitizer.getClearRange(timespan || options["sanitizetimespan"]);
1105+
if (liberator.has("sanitizer") && (timespan || options.sanitizetimespan))
1106+
range = sanitizer.getClearRange(timespan || options.sanitizetimespan);
11071107

11081108
this.store.mutate("filter", function (item) {
11091109
let timestamp = (item.timestamp || Date.now()/1000) * 1000;
@@ -1593,7 +1593,7 @@ const CommandLine = Module("commandline", {
15931593

15941594
options.add(["complete", "cpt"],
15951595
"Items which are completed at the :open prompts",
1596-
"charlist", typeof(config.defaults["complete"]) == "string" ? config.defaults["complete"] : "sl",
1596+
"charlist", typeof(config.defaults.complete) == "string" ? config.defaults.complete : "sl",
15971597
{
15981598
completer: function (context) array(values(completion.urlCompleters))
15991599
});
@@ -1752,7 +1752,7 @@ const ItemList = Class("ItemList", {
17521752
<div key="completions"/>
17531753
<div highlight="Completions">
17541754
${
1755-
template.map2(xml, util.range(0, options["maxitems"] * 2), function (i)
1755+
template.map2(xml, util.range(0, options.maxitems * 2), function (i)
17561756
xml`<span highlight="CompItem">
17571757
<li highlight="NonText">~</li>
17581758
</span>`)
@@ -1793,11 +1793,11 @@ const ItemList = Class("ItemList", {
17931793
return false;
17941794

17951795
this._startIndex = offset;
1796-
this._endIndex = Math.min(this._startIndex + options["maxitems"], this._items.allItems.items.length);
1796+
this._endIndex = Math.min(this._startIndex + options.maxitems, this._items.allItems.items.length);
17971797

17981798
let haveCompletions = false;
17991799
let off = 0;
1800-
let end = this._startIndex + options["maxitems"];
1800+
let end = this._startIndex + options.maxitems;
18011801
function getRows(context) {
18021802
function fix(n) util.Math.constrain(n, 0, len);
18031803
let len = context.items.length;
@@ -1890,7 +1890,7 @@ const ItemList = Class("ItemList", {
18901890
let sel = this._selIndex;
18911891
let len = this._items.allItems.items.length;
18921892
let newOffset = this._startIndex;
1893-
let maxItems = options["maxitems"];
1893+
let maxItems = options.maxitems;
18941894
let contextLines = Math.min(3, parseInt((maxItems - 1) / 2));
18951895

18961896
if (index == -1 || index == null || index == len) { // wrapped around

common/content/completion.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ const CompletionContext = Class("CompletionContext", {
517517
},
518518

519519
getText: function getText(item) {
520-
let text = item[self.keys["text"]];
520+
let text = item[self.keys.text];
521521
//if (self.quote)
522522
//return self.quote(text);
523523
return text;
@@ -714,14 +714,14 @@ const Completion = Module("completion", {
714714
let start = 0;
715715
let skip = 0;
716716

717-
if (options["urlseparator"])
718-
skip = context.filter.match("^.*" + options["urlseparator"]); // start after the last 'urlseparator'
717+
if (options.urlseparator)
718+
skip = context.filter.match("^.*" + options.urlseparator); // start after the last 'urlseparator'
719719

720720
if (skip)
721721
context.advance(skip[0].length);
722722

723723
if (typeof complete === "undefined")
724-
complete = options["complete"];
724+
complete = options.complete;
725725

726726
// Will, and should, throw an error if !(c in opts)
727727
Array.forEach(complete, function (c) {

common/content/editor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ const Editor = Module("editor", {
285285

286286
editFileExternally: function (path) {
287287
// TODO: save return value in v:shell_error
288-
let args = commands.parseArgs(options["editor"], [], [], "*", true);
288+
let args = commands.parseArgs(options.editor, [], [], "*", true);
289289

290290
liberator.assert(args.length >= 1, "No editor specified");
291291

@@ -295,7 +295,7 @@ const Editor = Module("editor", {
295295

296296
// TODO: clean up with 2 functions for textboxes and currentEditor?
297297
editFieldExternally: function (forceEditing, field) {
298-
if (!options["editor"])
298+
if (!options.editor)
299299
return;
300300

301301
let textBox = null, nsEditor = null;

common/content/events.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const Events = Module("events", {
6161
// HACK: as Gecko does not include an event for <, we must add this in manually.
6262
if (!("<" in this._key_code)) {
6363
this._key_code["<"] = 60;
64-
this._key_code["lt"] = 60;
64+
this._key_code.lt = 60;
6565
this._code_key[60] = "lt";
6666
}
6767

@@ -707,7 +707,7 @@ const Events = Module("events", {
707707
}
708708

709709
if (elem instanceof HTMLTextAreaElement || (elem && elem.contentEditable == "true")) {
710-
if (options["insertmode"])
710+
if (options.insertmode)
711711
modes.set(modes.INSERT);
712712
else if (elem.selectionEnd - elem.selectionStart > 0)
713713
modes.set(modes.VISUAL, modes.TEXTAREA);
@@ -719,7 +719,7 @@ const Events = Module("events", {
719719
}
720720

721721
if (Editor.windowIsEditable(win)) {
722-
if (options["insertmode"])
722+
if (options.insertmode)
723723
modes.set(modes.INSERT);
724724
else if (win.getSelection().toString() != "")
725725
modes.set(modes.VISUAL, modes.TEXTAREA);
@@ -756,7 +756,7 @@ const Events = Module("events", {
756756
if (couldCopy) {
757757
if ((liberator.mode == modes.TEXTAREA ||
758758
(modes.extended & modes.TEXTAREA))
759-
&& !options["insertmode"])
759+
&& !options.insertmode)
760760
modes.set(modes.VISUAL, modes.TEXTAREA);
761761
else if (liberator.mode == modes.CARET)
762762
modes.set(modes.VISUAL, modes.CARET);
@@ -834,7 +834,7 @@ const Events = Module("events", {
834834
return (elem instanceof HTMLInputElement && !/image/.test(elem.type));
835835
}
836836

837-
if (options["insertmode"] || isInputField())
837+
if (options.insertmode || isInputField())
838838
liberator.mode = modes.INSERT;
839839
else
840840
modes.reset();
@@ -1147,7 +1147,7 @@ const Events = Module("events", {
11471147
return;
11481148
}
11491149

1150-
if (!options['passthrough'])
1150+
if (!options.passthrough)
11511151
event.stopPropagation();
11521152

11531153
// liberator.echo ("key: " + key + "\nkeycode: " + event.keyCode + "\nchar: " + event.charCode + "\ntype: " + event.type + "\nwhich: " + event.which);

common/content/finder.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var Finder = Module("finder", {
5757
fm = findbar.FIND_LINKS;
5858
else if (/\\L/.test(pattern))
5959
fm = findbar.FIND_NORMAL;
60-
else if (options["linksearch"])
60+
else if (options.linksearch)
6161
fm = findbar.FIND_LINKS;
6262
else
6363
fm = findbar.FIND_NORMAL;
@@ -72,9 +72,9 @@ var Finder = Module("finder", {
7272
cs = false;
7373
else if (/\\C/.test(pattern))
7474
cs = true;
75-
else if (options["ignorecase"] && options["smartcase"] && /[A-Z]/.test(pattern))
75+
else if (options.ignorecase && options.smartcase && /[A-Z]/.test(pattern))
7676
cs = true;
77-
else if (options["ignorecase"])
77+
else if (options.ignorecase)
7878
cs = false;
7979
else
8080
cs = true;
@@ -102,7 +102,7 @@ var Finder = Module("finder", {
102102
//commandline.open(this._backwards ? "Find backwards" : "Find", "", mode);
103103
commandline.input(this._backwards ? "Find backwards" : "Find", this.closure.onSubmit, {
104104
onChange: function() {
105-
if (options["incsearch"] && !commandline._isIMEComposing) {
105+
if (options.incsearch && !commandline._isIMEComposing) {
106106
finder.find(commandline.command);
107107
}
108108
}
@@ -230,7 +230,7 @@ var Finder = Module("finder", {
230230
}
231231

232232
// liberator.log('inc: ' + options["incsearch"] + ' sea:' + this._searchPattern + ' pat:' + pattern);
233-
if (!options["incsearch"] || this._searchPattern != pattern) {
233+
if (!options.incsearch || this._searchPattern != pattern) {
234234
this.find(pattern);
235235
}
236236

@@ -248,7 +248,7 @@ var Finder = Module("finder", {
248248
if (this._backwards)
249249
this.findAgain(true);
250250

251-
if (options["hlsearch"])
251+
if (options.hlsearch)
252252
this.highlight();
253253
},
254254

0 commit comments

Comments
 (0)