aboutsummaryrefslogtreecommitdiffstats
path: root/js/src/fouc.js
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-13 16:43:42 +0100
committerGravatar Gareth Coles <[email protected]>2018-06-13 16:43:42 +0100
commitbe2bbe35cf49763ad0258c005f3cbdddd7a21d75 (patch)
tree962d5e52f4bb57c397c068ae6a11b57952cfc459 /js/src/fouc.js
parent[DB] Attempt reconnection if current connection was lost (diff)
Compile as much JS with Gulp as possible
This will concatenate ALL of our JS, and minify it - thus leaving us with a single file to be loaded. There's a few libraries we can't do this with, unfortunately - these are now added in fouc.js: * Ace Editor * Flatpickr * Font-Awesome
Diffstat (limited to '')
-rw-r--r--js/src/fouc.js (renamed from static/js/fouc.js)27
1 files changed, 20 insertions, 7 deletions
diff --git a/static/js/fouc.js b/js/src/fouc.js
index 01354863..3611ec27 100644
--- a/static/js/fouc.js
+++ b/js/src/fouc.js
@@ -1,24 +1,31 @@
"use strict";
-function getScript(url, integrity, crossorigin){
+function getScript(url, integrity, cross_origin) {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.defer = true;
- script.integrity = integrity;
- script.crossOrigin = crossorigin;
+
+ if (integrity !== undefined) {
+ script.integrity = integrity;
+ }
+
+ if (cross_origin !== undefined) {
+ script.crossOrigin = cross_origin;
+ }
+
document.getElementsByTagName("head")[0].appendChild(script);
}
-function setClass(selector, myClass) {
+function setClass(selector, my_class) {
const element = document.querySelector(selector);
// console.log(element);
- element.className = myClass;
+ element.className = my_class;
}
-function removeClass(selector, myClass) {
+function removeClass(selector, my_class) {
const element = document.querySelector(selector);
- const reg = new RegExp(`(^| )${myClass}($| )`, "g");
+ const reg = new RegExp(`(^| )${my_class}($| )`, "g");
element.className = element.className.replace(reg, " ");
}
@@ -34,5 +41,11 @@ document.onreadystatechange = function () {
"sha384-d84LGg2pm9KhR4mCAs3N29GQ4OYNy+K+FBHX8WhimHpPm86c839++MDABegrZ3gn", // Integrity
"anonymous" // Cross-origin
);
+ getScript(
+ "https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js"
+ );
+ getScript(
+ "https://cdn.jsdelivr.net/npm/flatpickr"
+ );
}
};