Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 4fe53db

Browse files
committed
sometimes the book URL will not contain the word static
1 parent c369fde commit 4fe53db

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

common/js/bookfuncs.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,15 @@ function createScratchActivecode() {
829829
// use the URL to assign a divid - each page should have a unique Activecode block id.
830830
// Remove everything from the URL but the course and page name
831831
var divid = document.URL.split('#')[0];
832-
divid = divid.split('static')[1];
833-
divid = divid.split('?')[0]; // remove any query string (e.g ?lastPosition)
832+
if (divid.indexOf('static') > 0 ) {
833+
divid = divid.split('static')[1];
834+
} else {
835+
// divid = divid.split('//')[1];
836+
divid = divid.split('?')[0]; // remove any query string (e.g ?lastPosition)
837+
}
838+
divid = divid.replaceAll(':','')
834839
divid = divid.replaceAll('/', '').replace('.html', '');
840+
divid = divid.replaceAll('.','')
835841

836842
// generate the HTML
837843
var html = '<div id="ac_modal_' + divid + '" class="modal fade">' +
@@ -884,7 +890,17 @@ function createScratchActivecode() {
884890
}
885891

886892
function toggleScratchActivecode() {
887-
var divid = "ac_modal_" + document.URL.split('#')[0].split('static')[1].split('?')[0].replaceAll('/', '').replace('.html', '');
893+
var bforeanchor = document.URL.split('#')[0]
894+
var suffix = 'index'
895+
if (bforeanchor.indexOf('static') > 0) {
896+
suffix = bforeanchor.split('static')[1].split('?')[0].replaceAll('/', '').replace('.html', '');
897+
} else {
898+
suffix = bforeanchor.split('?')[0].replaceAll('/', '').replace('.html', '');
899+
suffix = suffix.replaceAll(':','')
900+
suffix = suffix.replaceAll('.','')
901+
}
902+
903+
var divid = "ac_modal_" + suffix;
888904
var div = $("#" + divid);
889905

890906
div.modal('toggle');

0 commit comments

Comments
 (0)