Rollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle

Use "strict" mode in JS scripts

Part of #93058.

r? `@notriddle`
This commit is contained in:
Matthias Krüger 2022-05-05 15:43:04 +02:00 committed by GitHub
commit 9520641e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 5 deletions

View File

@ -7,6 +7,8 @@
/* global onEach, onEachLazy, removeClass */
/* global switchTheme, useSystemTheme */
"use strict";
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
@ -292,15 +294,12 @@ function loadCss(cssFileName) {
}
(function() {
"use strict";
function loadScript(url) {
const script = document.createElement('script');
script.src = url;
document.head.append(script);
}
getSettingsButton().onclick = event => {
event.preventDefault();
loadScript(window.settingsJS);

View File

@ -4,6 +4,8 @@
/* eslint prefer-arrow-callback: "error" */
/* global addClass, hasClass, removeClass, onEachLazy */
"use strict";
(function () {
// Number of lines shown when code viewer is not expanded
const MAX_LINES = 10;

View File

@ -5,7 +5,9 @@
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
(function () {
"use strict";
(function() {
// This mapping table should match the discriminants of
// `rustdoc::formats::item_type::ItemType` type in Rust.
const itemTypes = [

View File

@ -7,6 +7,8 @@
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
"use strict";
(function () {
const isSettingsPage = window.location.pathname.endsWith("/settings.html");

View File

@ -9,7 +9,10 @@
// Local js definitions:
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global updateLocalStorage */
(function () {
"use strict";
(function() {
function getCurrentFilePath() {
const parts = window.location.pathname.split("/");

View File

@ -3,6 +3,8 @@
/* eslint prefer-const: "error" */
/* eslint prefer-arrow-callback: "error" */
"use strict";
const darkThemes = ["dark", "ayu"];
window.currentTheme = document.getElementById("themeStyle");
window.mainTheme = document.getElementById("mainThemeStyle");