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

Commit 212aa0f

Browse files
committed
Bug fix: scratch activecode broken outside of runestone server
1 parent f5466e7 commit 212aa0f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

runestone/activecode/js/activecode.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,15 @@ ActiveCode.createScratchActivecode = function() {
649649
// Remove everything from the URL but the course and page name
650650
// todo: this could probably be eliminated and simply moved to the template file
651651
var divid = document.URL.split('#')[0];
652-
divid = divid.split('static')[1];
652+
if (divid.indexOf('static') > -1) {
653+
divid = divid.split('static')[1];
654+
} else {
655+
divid = divid.split('/');
656+
divid = divid.slice(-2).join("");
657+
}
653658
divid = divid.split('?')[0]; // remove any query string (e.g ?lastPosition)
654659
divid = divid.replaceAll('/', '').replace('.html', '');
655-
660+
eBookConfig.scratchDiv = divid;
656661
// generate the HTML
657662
var html = '<div id="ac_modal_' + divid + '" class="modal fade">' +
658663
' <div class="modal-dialog scratch-ac-modal">' +
@@ -689,7 +694,7 @@ ActiveCode.createScratchActivecode = function() {
689694

690695

691696
ActiveCode.toggleScratchActivecode = function () {
692-
var divid = "ac_modal_" + document.URL.split('#')[0].split('static')[1].split('?')[0].replaceAll('/', '').replace('.html', '');
697+
var divid = "ac_modal_" + eBookConfig.scratchDiv;
693698
var div = $("#" + divid);
694699

695700
div.modal('toggle');

0 commit comments

Comments
 (0)