Set strict JavaScript mode globally in each file

Makes sure we don't miss it anywhere.
This commit is contained in:
Pierre Ossman 2017-01-18 16:49:18 +01:00
parent 413ea87741
commit 4c3ecd3794
13 changed files with 26 additions and 37 deletions

View File

@ -20,10 +20,11 @@
* import WebUtil from "./webutil";
*/
"use strict";
var UI;
(function () {
"use strict";
// Fallback for all uncought errors
window.addEventListener('error', function(event) {

View File

@ -14,6 +14,8 @@
* import Util from "../core/util";
*/
"use strict";
// Globals defined here
var WebUtil = {};
@ -25,7 +27,6 @@ var WebUtil = {};
// init log level reading the logging HTTP param
WebUtil.init_logging = function (level) {
"use strict";
if (typeof level !== "undefined") {
Util._log_level = level;
} else {
@ -37,7 +38,6 @@ WebUtil.init_logging = function (level) {
WebUtil.dirObj = function (obj, depth, parent) {
"use strict";
if (! depth) { depth = 2; }
if (! parent) { parent = ""; }
@ -66,7 +66,6 @@ WebUtil.dirObj = function (obj, depth, parent) {
// Read a query string variable
WebUtil.getQueryVar = function (name, defVal) {
"use strict";
var re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
match = document.location.href.match(re);
if (typeof defVal === 'undefined') { defVal = null; }
@ -79,7 +78,6 @@ WebUtil.getQueryVar = function (name, defVal) {
// Read a hash fragment variable
WebUtil.getHashVar = function (name, defVal) {
"use strict";
var re = new RegExp('.*[&#]' + name + '=([^&]*)'),
match = document.location.hash.match(re);
if (typeof defVal === 'undefined') { defVal = null; }
@ -93,7 +91,6 @@ WebUtil.getHashVar = function (name, defVal) {
// Read a variable from the fragment or the query string
// Fragment takes precedence
WebUtil.getConfigVar = function (name, defVal) {
"use strict";
var val = WebUtil.getHashVar(name);
if (val === null) {
val = WebUtil.getQueryVar(name, defVal);
@ -107,7 +104,6 @@ WebUtil.getConfigVar = function (name, defVal) {
// No days means only for this browser session
WebUtil.createCookie = function (name, value, days) {
"use strict";
var date, expires;
if (days) {
date = new Date();
@ -127,7 +123,6 @@ WebUtil.createCookie = function (name, value, days) {
};
WebUtil.readCookie = function (name, defaultValue) {
"use strict";
var nameEQ = name + "=",
ca = document.cookie.split(';');
@ -140,7 +135,6 @@ WebUtil.readCookie = function (name, defaultValue) {
};
WebUtil.eraseCookie = function (name) {
"use strict";
WebUtil.createCookie(name, "", -1);
};
@ -149,7 +143,6 @@ WebUtil.eraseCookie = function (name) {
*/
WebUtil.initSettings = function (callback /*, ...callbackArgs */) {
"use strict";
var callbackArgs = Array.prototype.slice.call(arguments, 1);
if (window.chrome && window.chrome.storage) {
window.chrome.storage.sync.get(function (cfg) {
@ -169,7 +162,6 @@ WebUtil.initSettings = function (callback /*, ...callbackArgs */) {
// No days means only for this browser session
WebUtil.writeSetting = function (name, value) {
"use strict";
if (window.chrome && window.chrome.storage) {
//console.log("writeSetting:", name, value);
if (WebUtil.settings[name] !== value) {
@ -182,7 +174,6 @@ WebUtil.writeSetting = function (name, value) {
};
WebUtil.readSetting = function (name, defaultValue) {
"use strict";
var value;
if (window.chrome && window.chrome.storage) {
value = WebUtil.settings[name];
@ -200,7 +191,6 @@ WebUtil.readSetting = function (name, defaultValue) {
};
WebUtil.eraseSetting = function (name) {
"use strict";
if (window.chrome && window.chrome.storage) {
window.chrome.storage.sync.remove(name);
delete WebUtil.settings[name];
@ -345,7 +335,6 @@ WebUtil.get_include_uri = function (root_dir) {
WebUtil._loading_scripts = [];
WebUtil._pending_scripts = [];
WebUtil.load_scripts = function (files_by_dir) {
"use strict";
var head = document.getElementsByTagName('head')[0], script,
ls = WebUtil._loading_scripts, ps = WebUtil._pending_scripts;

View File

@ -7,6 +7,8 @@
/*jslint white: false */
/*global console */
"use strict";
var Base64 = {
/* Convert data (an array of integers) to a Base64 string. */
toBase64Table : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split(''),

View File

@ -77,9 +77,10 @@
/* jslint white: false */
/* [module] export default */ function DES(passwd) {
"use strict";
/* [module] export default */ function DES(passwd) {
// Tables, permutations, S-boxes, etc.
// jshint -W013
var PC2 = [13,16,10,23, 0, 4, 2,27,14, 5,20, 9,22,18,11, 3,

View File

@ -15,6 +15,8 @@
* import Base64 from "./base64";
*/
"use strict";
/* [module] export default */ function Display(defaults) {
this._drawCtx = null;
this._c_forceCanvas = false;
@ -99,7 +101,6 @@
};
(function () {
"use strict";
var SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
try {

View File

@ -13,10 +13,11 @@
* import KeyboardUtil from "./util";
*/
"use strict";
/* [module] export */ var Keyboard;
(function () {
"use strict";
//
// Keyboard event handler

View File

@ -1,3 +1,5 @@
"use strict";
var KeyTable = {
XK_VoidSymbol: 0xffffff, /* Void symbol */

File diff suppressed because one or more lines are too long

View File

@ -3,10 +3,11 @@
* import keysyms from "./keysymdef";
*/
"use strict";
var KeyboardUtil = {};
(function() {
"use strict";
function substituteCodepoint(cp) {
// Any Unicode code points which do not have corresponding keysym entries
@ -289,8 +290,6 @@ var KeyboardUtil = {};
})();
KeyboardUtil.QEMUKeyEventDecoder = function(modifierState, next) {
"use strict";
function sendAll(evts) {
for (var i = 0; i < evts.length; ++i) {
next(evts[i]);
@ -359,7 +358,6 @@ KeyboardUtil.QEMUKeyEventDecoder = function(modifierState, next) {
};
KeyboardUtil.TrackQEMUKeyState = function(next) {
"use strict";
var state = [];
return function (evt) {
@ -427,7 +425,6 @@ KeyboardUtil.TrackQEMUKeyState = function(next) {
// - generates a "stall" event in cases where it might be necessary to wait and see if a keypress event follows a keydown
// This information is collected into an object which is passed to the next() function. (one call per event)
KeyboardUtil.KeyEventDecoder = function(modifierState, next) {
"use strict";
function sendAll(evts) {
for (var i = 0; i < evts.length; ++i) {
next(evts[i]);
@ -514,7 +511,6 @@ KeyboardUtil.KeyEventDecoder = function(modifierState, next) {
// The only way we can distinguish these cases is to wait and see if a keypress event arrives
// When we receive a "stall" event, wait a few ms before processing the next keydown. If a keypress has also arrived, merge the two
KeyboardUtil.VerifyCharModifier = function(next) {
"use strict";
var queue = [];
var timer = null;
function process() {
@ -571,7 +567,6 @@ KeyboardUtil.VerifyCharModifier = function(next) {
// key repeat events should be merged into a single entry.
// Because we can't always identify which entry a keydown or keyup event corresponds to, we sometimes have to guess
KeyboardUtil.TrackKeyState = function(next) {
"use strict";
var state = [];
return function (evt) {
@ -655,7 +650,6 @@ KeyboardUtil.TrackKeyState = function(next) {
// Handles "escaping" of modifiers: if a char modifier is used to produce a keysym (such as AltGr-2 to generate an @),
// then the modifier must be "undone" before sending the @, and "redone" afterwards.
KeyboardUtil.EscapeModifiers = function(next) {
"use strict";
return function(evt) {
if (evt.type !== 'keydown' || evt.escape === undefined) {
next(evt);

View File

@ -1,3 +1,5 @@
"use strict";
var XtScancode = {
"Escape": 0x0001,
"Digit1": 0x0002,

View File

@ -24,8 +24,9 @@
/*jslint white: false, browser: true */
/*global window, Util, Display, Keyboard, Mouse, Websock, Websock_native, Base64, DES, KeyTable, Inflator, XtScancode */
/* [module] export default */ function RFB(defaults) {
"use strict";
/* [module] export default */ function RFB(defaults) {
if (!defaults) {
defaults = {};
}

View File

@ -9,6 +9,8 @@
/* jshint white: false, nonstandard: true */
/*global window, console, document, navigator, ActiveXObject, INCLUDE_URI */
"use strict";
var Util = {};
/*
@ -23,7 +25,6 @@ var Util = {};
Util._log_level = 'warn';
Util.init_logging = function (level) {
"use strict";
if (typeof level === 'undefined') {
level = Util._log_level;
} else {
@ -57,7 +58,6 @@ Util.get_logging = function () {
Util.init_logging();
Util.make_property = function (proto, name, mode, type) {
"use strict";
var getter;
if (type === 'arr') {
@ -150,7 +150,6 @@ Util.make_property = function (proto, name, mode, type) {
};
Util.make_properties = function (constructor, arr) {
"use strict";
for (var i = 0; i < arr.length; i++) {
Util.make_property(constructor.prototype, arr[i][0], arr[i][1], arr[i][2]);
}
@ -184,7 +183,6 @@ Util.set_defaults = function (obj, conf, defaults) {
* Decode from UTF-8
*/
Util.decodeUTF8 = function (utf8string) {
"use strict";
return decodeURIComponent(escape(utf8string));
};
@ -195,7 +193,6 @@ Util.decodeUTF8 = function (utf8string) {
*/
Util.getPosition = function(obj) {
"use strict";
// NB(sross): the Mozilla developer reference seems to indicate that
// getBoundingClientRect includes border and padding, so the canvas
// style should NOT include either.
@ -213,7 +210,6 @@ Util.getPointerEvent = function (e) {
// Get mouse event position in DOM element
Util.getEventPosition = function (e, obj, scale) {
"use strict";
var evt, docX, docY, pos;
evt = Util.getPointerEvent(e);
if (evt.pageX || evt.pageY) {
@ -281,7 +277,6 @@ Util.browserSupportsCursorURIs = function () {
Util.Features = {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)};
(function () {
"use strict";
// 'presto': (function () { return (!window.opera) ? false : true; }()),
var detectPresto = function () {
return !!window.opera;
@ -351,7 +346,6 @@ Util.Features = {xpath: !!(document.evaluate), air: !!(window.runtime), query: !
})();
Util.Flash = (function () {
"use strict";
var v, version;
try {
v = navigator.plugins['Shockwave Flash'].description;

View File

@ -22,9 +22,10 @@
/*jslint browser: true, bitwise: true */
/*global Util*/
/* [module] export default */ function Websock() {
"use strict";
/* [module] export default */ function Websock() {
this._websocket = null; // WebSocket object
this._rQi = 0; // Receive queue index
@ -51,7 +52,6 @@
};
(function () {
"use strict";
// this has performance issues in some versions Chromium, and
// doesn't gain a tremendous amount of performance increase in Firefox
// at the moment. It may be valuable to turn it on in the future.