Use "strict" mode in JS scripts
This commit is contained in:
parent
12d3f107c1
commit
1e204ddb3b
6 changed files with 15 additions and 5 deletions
|
@ -7,6 +7,8 @@
|
||||||
/* global onEach, onEachLazy, removeClass */
|
/* global onEach, onEachLazy, removeClass */
|
||||||
/* global switchTheme, useSystemTheme */
|
/* global switchTheme, useSystemTheme */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
if (!String.prototype.startsWith) {
|
if (!String.prototype.startsWith) {
|
||||||
String.prototype.startsWith = function(searchString, position) {
|
String.prototype.startsWith = function(searchString, position) {
|
||||||
position = position || 0;
|
position = position || 0;
|
||||||
|
@ -292,15 +294,12 @@ function loadCss(cssFileName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function loadScript(url) {
|
function loadScript(url) {
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.src = url;
|
script.src = url;
|
||||||
document.head.append(script);
|
document.head.append(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getSettingsButton().onclick = event => {
|
getSettingsButton().onclick = event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
loadScript(window.settingsJS);
|
loadScript(window.settingsJS);
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
/* eslint prefer-arrow-callback: "error" */
|
/* eslint prefer-arrow-callback: "error" */
|
||||||
/* global addClass, hasClass, removeClass, onEachLazy */
|
/* global addClass, hasClass, removeClass, onEachLazy */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
// Number of lines shown when code viewer is not expanded
|
// Number of lines shown when code viewer is not expanded
|
||||||
const MAX_LINES = 10;
|
const MAX_LINES = 10;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
|
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
|
||||||
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
|
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// This mapping table should match the discriminants of
|
// This mapping table should match the discriminants of
|
||||||
// `rustdoc::formats::item_type::ItemType` type in Rust.
|
// `rustdoc::formats::item_type::ItemType` type in Rust.
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
|
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
|
||||||
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
|
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const isSettingsPage = window.location.pathname.endsWith("/settings.html");
|
const isSettingsPage = window.location.pathname.endsWith("/settings.html");
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
// Local js definitions:
|
// Local js definitions:
|
||||||
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
|
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
|
||||||
/* global updateLocalStorage */
|
/* global updateLocalStorage */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
function getCurrentFilePath() {
|
function getCurrentFilePath() {
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
/* eslint prefer-const: "error" */
|
/* eslint prefer-const: "error" */
|
||||||
/* eslint prefer-arrow-callback: "error" */
|
/* eslint prefer-arrow-callback: "error" */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const darkThemes = ["dark", "ayu"];
|
const darkThemes = ["dark", "ayu"];
|
||||||
window.currentTheme = document.getElementById("themeStyle");
|
window.currentTheme = document.getElementById("themeStyle");
|
||||||
window.mainTheme = document.getElementById("mainThemeStyle");
|
window.mainTheme = document.getElementById("mainThemeStyle");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue