|
1 | 1 | // Increment the version to invalidate the cached script
|
2 | 2 | const VERSION = 0.75
|
| 3 | +const global_stylesheet = document.head.querySelector("style.span-array-css") |
| 4 | +const local_stylesheet = document.currentScript.parentElement.querySelector("style.span-array-css") |
3 | 5 |
|
4 | 6 | if(window.SpanArray == undefined || window.SpanArray.VERSION == undefined || window.SpanArray.VERSION < VERSION) {
|
5 | 7 |
|
6 | 8 | // Replace global SpanArray CSS with latest copy
|
7 |
| - const global_stylesheet = document.head.querySelector("style.span-array-css") |
8 |
| - const local_stylesheet = document.currentScript.parentElement.querySelector("style.span-array-css") |
9 | 9 | if(local_stylesheet != undefined) {
|
10 | 10 | if(global_stylesheet != undefined) {
|
11 | 11 | document.head.removeChild(global_stylesheet)
|
@@ -385,17 +385,18 @@ if(window.SpanArray == undefined || window.SpanArray.VERSION == undefined || win
|
385 | 385 | if(closest_tr == undefined) return
|
386 | 386 |
|
387 | 387 | const matching_span = doc_object.lookup_table[closest_tr.getAttribute("data-id")]
|
| 388 | + if(matching_span == undefined) return |
388 | 389 |
|
389 | 390 | switch(closest_control_button.getAttribute("data-control")) {
|
390 | 391 | case "visibility":
|
391 | 392 | {
|
392 |
| - if(matching_span != undefined) matching_span.visible = !matching_span.visible |
| 393 | + matching_span.visible = !matching_span.visible |
393 | 394 | source_spanarray.render()
|
394 | 395 | }
|
395 | 396 | break;
|
396 | 397 | case "highlight":
|
397 | 398 | {
|
398 |
| - if(matching_span != undefined) matching_span.highlighted = !matching_span.highlighted |
| 399 | + matching_span.highlighted = !matching_span.highlighted |
399 | 400 | source_spanarray.render()
|
400 | 401 | }
|
401 | 402 | break;
|
@@ -437,9 +438,7 @@ if(window.SpanArray == undefined || window.SpanArray.VERSION == undefined || win
|
437 | 438 | } else {
|
438 | 439 | // SpanArray JS is already defined and not an outdated copy
|
439 | 440 | // Replace global SpanArray CSS with latest copy IFF global stylesheet is undefined
|
440 |
| - |
441 |
| - const global_stylesheet = document.head.querySelector("style.span-array-css") |
442 |
| - const local_stylesheet = document.currentScript.parentElement.querySelector("style.span-array-css") |
| 441 | + |
443 | 442 | if(local_stylesheet != undefined) {
|
444 | 443 | if(global_stylesheet == undefined) {
|
445 | 444 | document.head.appendChild(local_stylesheet)
|
|
0 commit comments