@@ -49,9 +49,10 @@ var structures = {
49
49
</section>
50
50
</footer>`
51
51
}
52
- var secondaryScripts =
53
- `<script src="../scripts/js/themes.js"></script>
54
- <script src="../scripts/js/events.js"></script>` ;
52
+ var secondaryScripts = [
53
+ "../scripts/js/themes.js" ,
54
+ "../scripts/js/events.js"
55
+ ] ;
55
56
56
57
construct ( ) ;
57
58
@@ -66,7 +67,9 @@ function construct() {
66
67
processSelectedButton ( ) ;
67
68
68
69
// Insert other universal scripts
69
- insertSnippet ( "afterend" , "constructor" , secondaryScripts )
70
+ for ( let i = 0 ; i < secondaryScripts . length ; i ++ ) {
71
+ insertScript ( secondaryScripts [ i ] )
72
+ }
70
73
}
71
74
72
75
// Inserts an HTML snippet at a given position relative to a unique element
@@ -75,6 +78,14 @@ function insertSnippet(position, id, snippet) {
75
78
element . insertAdjacentHTML ( position , snippet ) ;
76
79
}
77
80
81
+ // Inserts a script tag at the given location
82
+ function insertScript ( source ) {
83
+ let script = document . createElement ( 'script' ) ;
84
+ let location = document . getElementById ( 'scripts' ) ;
85
+ script . src = source ;
86
+ location . appendChild ( script ) ;
87
+ }
88
+
78
89
// Marks one of the nav buttons as selected if the page is a primary one
79
90
function processSelectedButton ( ) {
80
91
let title = document . title . split ( " | " ) [ 1 ] . toLowerCase ( ) ;
0 commit comments