aboutsummaryrefslogtreecommitdiffstats
path: root/static/js/fouc.js
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-13 12:53:21 +0100
committerGravatar Gareth Coles <[email protected]>2018-06-13 12:53:21 +0100
commitafff6a5a1b25729f6be3f3b565d61ff3e56d9c36 (patch)
treebbcdb7c0ae54a8d3f14f4df77bf98eda2bf37ca8 /static/js/fouc.js
parentUpdate GitLab URL (diff)
Add JavaScript linting
Diffstat (limited to 'static/js/fouc.js')
-rw-r--r--static/js/fouc.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/static/js/fouc.js b/static/js/fouc.js
index b8f1d07f..01354863 100644
--- a/static/js/fouc.js
+++ b/static/js/fouc.js
@@ -1,5 +1,7 @@
+"use strict";
+
function getScript(url, integrity, crossorigin){
- var script = document.createElement("script")
+ const script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.defer = true;
@@ -9,28 +11,28 @@ function getScript(url, integrity, crossorigin){
}
function setClass(selector, myClass) {
- element = document.querySelector(selector);
- console.log(element)
+ const element = document.querySelector(selector);
+ // console.log(element);
element.className = myClass;
}
function removeClass(selector, myClass) {
- element = document.querySelector(selector);
- var reg = new RegExp('(^| )'+myClass+'($| )','g');
- element.className = element.className.replace(reg,' ');
+ const element = document.querySelector(selector);
+ const reg = new RegExp(`(^| )${myClass}($| )`, "g");
+ element.className = element.className.replace(reg, " ");
}
// hide the html when the page loads, but only if js is turned on.
-setClass('html', 'prevent-fouc');
+setClass("html", "prevent-fouc");
// when the DOM has finished loading, unhide the html
document.onreadystatechange = function () {
- if (document.readyState == "interactive") {
- removeClass('html', 'prevent-fouc');
+ if (document.readyState === "interactive") {
+ removeClass("html", "prevent-fouc");
getScript(
- 'https://pro.fontawesome.com/releases/v5.0.13/js/all.js', // URL
- 'sha384-d84LGg2pm9KhR4mCAs3N29GQ4OYNy+K+FBHX8WhimHpPm86c839++MDABegrZ3gn', // Integrity
- 'anonymous' // Cross-origin
+ "https://pro.fontawesome.com/releases/v5.0.13/js/all.js", // URL
+ "sha384-d84LGg2pm9KhR4mCAs3N29GQ4OYNy+K+FBHX8WhimHpPm86c839++MDABegrZ3gn", // Integrity
+ "anonymous" // Cross-origin
);
}
-} \ No newline at end of file
+};