@@ -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
886892function 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