Rework of loading the index file.
This commit is contained in:
@@ -873,3 +873,48 @@ exports.get_device_info = async function () {
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// For loading JS file
|
||||
function loadJS(){
|
||||
|
||||
// Gives -1 when the given input is not in the string
|
||||
// i.e this file has not been added
|
||||
|
||||
if(filesAdded.indexOf('script.js') !== -1)
|
||||
return
|
||||
|
||||
// Head tag
|
||||
var head = document.getElementsByTagName('head')[0]
|
||||
|
||||
// Creating script element
|
||||
var script = document.createElement('script')
|
||||
script.src = 'script.js'
|
||||
script.type = 'text/javascript'
|
||||
|
||||
// Adding script element
|
||||
head.append(script)
|
||||
|
||||
// Adding the name of the file to keep record
|
||||
filesAdded += ' script.js'
|
||||
}
|
||||
|
||||
// To load CSS file
|
||||
function loadCSS() {
|
||||
|
||||
if(filesAdded.indexOf('styles.css') !== -1)
|
||||
return
|
||||
|
||||
var head = document.getElementsByTagName('head')[0]
|
||||
|
||||
// Creating link element
|
||||
var style = document.createElement('link')
|
||||
style.href = 'styles.css'
|
||||
style.type = 'text/css'
|
||||
style.rel = 'stylesheet'
|
||||
head.append(style);
|
||||
|
||||
// Adding the name of the file to keep record
|
||||
filesAdded += ' styles.css'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user