Unified · Split
| @@ -119,7 +119,7 @@ class App extends Events { · 118 unmodified lines | ||
| 119 | 119 | bootAll() { |
| 120 | 120 | const docs = this.settings.getDocs(); |
| 121 | 121 | for (var doc of this.DOCS) { |
| 122 | − (docs.indexOf(doc.slug) >= 0 ? this.docs : this.disabledDocs).add(doc); | |
| 122 | + (docs.includes(doc.slug) ? this.docs : this.disabledDocs).add(doc); | |
| 123 | 123 | } |
| 124 | 124 | this.migrateDocs(); |
| 125 | 125 | this.docs.load(this.start.bind(this), this.onBootError.bind(this), { |
| @@ -267,7 +267,7 @@ class App extends Events { · 141 unmodified lines | ||
| 267 | 267 | return; |
| 268 | 268 | } |
| 269 | 269 | const tips = this.settings.getTips(); |
| 270 | − if (tips.indexOf(tip) === -1) { | |
| 270 | + if (!tips.includes(tip)) { | |
| 271 | 271 | tips.push(tip); |
| 272 | 272 | this.settings.setTips(tips); |
| 273 | 273 | new app.views.Tip(tip); |
| @@ -358,11 +358,7 @@ Please check your browser extensions/addons. `); · 84 unmodified lines | ||
| 358 | 358 | |
| 359 | 359 | isAppError(error, file) { |
| 360 | 360 | // Ignore errors from external scripts. |
| 361 | − return ( | |
| 362 | − file && | |
| 363 | − file.indexOf("devdocs") !== -1 && | |
| 364 | − file.indexOf(".js") === file.length - 3 | |
| 365 | − ); | |
| 361 | + return file && file.includes("devdocs") && file.endsWith(".js"); | |
| 366 | 362 | } |
| 367 | 363 | |
| 368 | 364 | isSupportedBrowser() { |
| @@ -414,7 +410,7 @@ Please check your browser extensions/addons. `); · 45 unmodified lines | ||
| 414 | 410 | isInvalidLocation() { |
| 415 | 411 | return ( |
| 416 | 412 | this.config.env === "production" && |
| 417 | − location.host.indexOf(app.config.production_host) !== 0 | |
| 413 | + !location.host.startsWith(app.config.production_host) | |
| 418 | 414 | ); |
| 419 | 415 | } |
| 420 | 416 | } |
| @@ -106,7 +106,7 @@ function scoreExactMatch() { · 105 unmodified lines | ||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | function fuzzyMatch() { |
| 109 | − if (valueLength <= queryLength || value.indexOf(query) >= 0) { | |
| 109 | + if (valueLength <= queryLength || value.includes(query)) { | |
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | if (!(match = fuzzyRegexp.exec(value))) { |
| @@ -109,7 +109,7 @@ app.Settings = class Settings { · 108 unmodified lines | ||
| 109 | 109 | $.arrayDelete(layout, ""); |
| 110 | 110 | |
| 111 | 111 | if (enable) { |
| 112 | − if (layout.indexOf(name) === -1) { | |
| 112 | + if (!layout.includes(name)) { | |
| 113 | 113 | layout.push(name); |
| 114 | 114 | } |
| 115 | 115 | } else { |
| @@ -125,7 +125,7 @@ app.Settings = class Settings { · 9 unmodified lines | ||
| 125 | 125 | |
| 126 | 126 | hasLayout(name) { |
| 127 | 127 | const layout = (this.store.get("layout") || "").split(" "); |
| 128 | − return layout.indexOf(name) !== -1; | |
| 128 | + return layout.includes(name); | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | setSize(value) { |
| @@ -155,7 +155,7 @@ app.Settings = class Settings { · 23 unmodified lines | ||
| 155 | 155 | } |
| 156 | 156 | for (key in data) { |
| 157 | 157 | value = data[key]; |
| 158 | − if (Settings.PREFERENCE_KEYS.indexOf(key) !== -1) { | |
| 158 | + if (Settings.PREFERENCE_KEYS.includes(key)) { | |
| 159 | 159 | this.set(key, value); |
| 160 | 160 | } |
| 161 | 161 | } |
| @@ -75,7 +75,7 @@ this.viewTree = function (view, level, visited) { · 74 unmodified lines | ||
| 75 | 75 | if (visited == null) { |
| 76 | 76 | visited = []; |
| 77 | 77 | } |
| 78 | − if (visited.indexOf(view) >= 0) { | |
| 78 | + if (visited.includes(view)) { | |
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | visited.push(view); |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | class Events { |
| 2 | 2 | on(event, callback) { |
| 3 | − if (event.indexOf(" ") >= 0) { | |
| 3 | + if (event.includes(" ")) { | |
| 4 | 4 | for (var name of event.split(" ")) { |
| 5 | 5 | this.on(name, callback); |
| 6 | 6 | } |
| @@ -14,7 +14,7 @@ class Events { · 7 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | off(event, callback) { |
| 16 | 16 | let callbacks, index; |
| 17 | − if (event.indexOf(" ") >= 0) { | |
| 17 | + if (event.includes(" ")) { | |
| 18 | 18 | for (var name of event.split(" ")) { |
| 19 | 19 | this.off(name, callback); |
| 20 | 20 | } |
| @@ -284,7 +284,7 @@ var onclick = function (event) { · 283 unmodified lines | ||
| 284 | 284 | }; |
| 285 | 285 | |
| 286 | 286 | var isSameOrigin = (url) => |
| 287 | − url.indexOf(`${location.protocol}//${location.hostname}`) === 0; | |
| 287 | + url.startsWith(`${location.protocol}//${location.hostname}`); | |
| 288 | 288 | |
| 289 | 289 | var updateCanonicalLink = function () { |
| 290 | 290 | if (!this.canonicalLink) { |
| @@ -61,7 +61,7 @@ $.on = function (el, event, callback, useCapture) { · 60 unmodified lines | ||
| 61 | 61 | if (useCapture == null) { |
| 62 | 62 | useCapture = false; |
| 63 | 63 | } |
| 64 | − if (event.indexOf(" ") >= 0) { | |
| 64 | + if (event.includes(" ")) { | |
| 65 | 65 | for (var name of event.split(" ")) { |
| 66 | 66 | $.on(el, name, callback); |
| 67 | 67 | } |
| @@ -74,7 +74,7 @@ $.off = function (el, event, callback, useCapture) { · 6 unmodified lines | ||
| 74 | 74 | if (useCapture == null) { |
| 75 | 75 | useCapture = false; |
| 76 | 76 | } |
| 77 | − if (event.indexOf(" ") >= 0) { | |
| 77 | + if (event.includes(" ")) { | |
| 78 | 78 | for (var name of event.split(" ")) { |
| 79 | 79 | $.off(el, name, callback); |
| 80 | 80 | } |
| @@ -520,55 +520,37 @@ $.popup = function (value) { · 439 unmodified lines | ||
| 520 | 520 | |
| 521 | 521 | let isMac = null; |
| 522 | 522 | $.isMac = () => |
| 523 | − isMac != null | |
| 524 | − ? isMac | |
| 525 | − : (isMac = | |
| 526 | − (navigator.userAgent != null | |
| 527 | − ? navigator.userAgent.indexOf("Mac") | |
| 528 | − : undefined) >= 0); | |
| 523 | + isMac != null ? isMac : (isMac = navigator.userAgent.includes("Mac")); | |
| 529 | 524 | |
| 530 | 525 | let isIE = null; |
| 531 | 526 | $.isIE = () => |
| 532 | 527 | isIE != null |
| 533 | 528 | ? isIE |
| 534 | 529 | : (isIE = |
| 535 | − (navigator.userAgent != null | |
| 536 | − ? navigator.userAgent.indexOf("MSIE") | |
| 537 | − : undefined) >= 0 || | |
| 538 | − (navigator.userAgent != null | |
| 539 | − ? navigator.userAgent.indexOf("rv:11.0") | |
| 540 | − : undefined) >= 0); | |
| 530 | + navigator.userAgent.includes("MSIE") || | |
| 531 | + navigator.userAgent.includes("rv:11.0")); | |
| 541 | 532 | |
| 542 | 533 | let isChromeForAndroid = null; |
| 543 | 534 | $.isChromeForAndroid = () => |
| 544 | 535 | isChromeForAndroid != null |
| 545 | 536 | ? isChromeForAndroid |
| 546 | 537 | : (isChromeForAndroid = |
| 547 | − (navigator.userAgent != null | |
| 548 | − ? navigator.userAgent.indexOf("Android") | |
| 549 | − : undefined) >= 0 && | |
| 538 | + navigator.userAgent.includes("Android") && | |
| 550 | 539 | /Chrome\/([.0-9])+ Mobile/.test(navigator.userAgent)); |
| 551 | 540 | |
| 552 | 541 | let isAndroid = null; |
| 553 | 542 | $.isAndroid = () => |
| 554 | 543 | isAndroid != null |
| 555 | 544 | ? isAndroid |
| 556 | − : (isAndroid = | |
| 557 | − (navigator.userAgent != null | |
| 558 | − ? navigator.userAgent.indexOf("Android") | |
| 559 | − : undefined) >= 0); | |
| 545 | + : (isAndroid = navigator.userAgent.includes("Android")); | |
| 560 | 546 | |
| 561 | 547 | let isIOS = null; |
| 562 | 548 | $.isIOS = () => |
| 563 | 549 | isIOS != null |
| 564 | 550 | ? isIOS |
| 565 | 551 | : (isIOS = |
| 566 | − (navigator.userAgent != null | |
| 567 | − ? navigator.userAgent.indexOf("iPhone") | |
| 568 | − : undefined) >= 0 || | |
| 569 | − (navigator.userAgent != null | |
| 570 | − ? navigator.userAgent.indexOf("iPad") | |
| 571 | − : undefined) >= 0); | |
| 552 | + navigator.userAgent.includes("iPhone") || | |
| 553 | + navigator.userAgent.includes("iPad")); | |
| 572 | 554 | |
| 573 | 555 | $.overlayScrollbarsEnabled = function () { |
| 574 | 556 | if (!$.isMac()) { |
| @@ -24,9 +24,9 @@ app.views.Mobile = class Mobile extends app.View { · 23 unmodified lines | ||
| 24 | 24 | .matches || |
| 25 | 25 | // Need to sniff the user agent because some Android and Windows Phone devices don't take |
| 26 | 26 | // resolution (dpi) into account when reporting device width/height. |
| 27 | − (navigator.userAgent.indexOf("Android") !== -1 && | |
| 28 | − navigator.userAgent.indexOf("Mobile") !== -1) || | |
| 29 | − navigator.userAgent.indexOf("IEMobile") !== -1 | |
| 27 | + (navigator.userAgent.includes("Android") && | |
| 28 | + navigator.userAgent.includes("Mobile")) || | |
| 29 | + navigator.userAgent.includes("IEMobile") | |
| 30 | 30 | ); |
| 31 | 31 | } catch (error) { |
| 32 | 32 | return false; |
| @@ -65,7 +65,7 @@ app.views.Settings = class Settings extends app.View { · 64 unmodified lines | ||
| 65 | 65 | (() => { |
| 66 | 66 | const result = []; |
| 67 | 67 | for (var doc of app.docs.all()) { |
| 68 | − if (docs.indexOf(doc.slug) === -1) { | |
| 68 | + if (!docs.includes(doc.slug)) { | |
| 69 | 69 | result.push(doc); |
| 70 | 70 | } |
| 71 | 71 | } |
| @@ -56,7 +56,7 @@ app.views.ListFocus = class ListFocus extends app.View { · 55 unmodified lines | ||
| 56 | 56 | return this.findNext(cursor); |
| 57 | 57 | } else if (next.tagName === "DIV") { |
| 58 | 58 | // sub-list |
| 59 | − if (cursor.className.indexOf(" open") >= 0) { | |
| 59 | + if (cursor.className.includes(" open")) { | |
| 60 | 60 | return this.findFirst(next) || this.findNext(next); |
| 61 | 61 | } else { |
| 62 | 62 | return this.findNext(next); |
| @@ -96,7 +96,7 @@ app.views.ListFocus = class ListFocus extends app.View { · 33 unmodified lines | ||
| 96 | 96 | return this.findPrev(cursor); |
| 97 | 97 | } else if (prev.tagName === "DIV") { |
| 98 | 98 | // sub-list |
| 99 | − if (prev.previousSibling.className.indexOf("open") >= 0) { | |
| 99 | + if (prev.previousSibling.className.includes("open")) { | |
| 100 | 100 | return this.findLast(prev) || this.findPrev(prev); |
| 101 | 101 | } else { |
| 102 | 102 | return this.findPrev(prev); |