@@ -668,12 +668,13 @@ HTMLActiveCode.prototype.createOutput = function () {
668668
669669} ;
670670
671- //todo -- make all of this ivars of the audiotour object
672671
673672String . prototype . replaceAll = function ( target , replacement ) {
674673 return this . split ( target ) . join ( replacement ) ;
675674} ;
676675
676+ AudioTour . prototype = new RunestoneBase ( ) ;
677+
677678// function to display the audio tours
678679function AudioTour ( divid , code , bnum , audio_text ) {
679680 this . elem = null ; // current audio element playing
@@ -693,7 +694,7 @@ function AudioTour (divid, code, bnum, audio_text) {
693694 code = code . replaceAll ( "*open*" , "(" ) ;
694695 code = code . replaceAll ( "*close*" , ")" ) ;
695696 code = code . replaceAll ( "*nline*" , "<br/>" ) ;
696- var codeArray = code . split ( "<br/> " ) ;
697+ var codeArray = code . split ( "\n " ) ;
697698
698699 var audio_hash = new Array ( ) ;
699700 var bval = new Array ( ) ;
@@ -733,7 +734,9 @@ function AudioTour (divid, code, bnum, audio_text) {
733734 //html_string += "<p id='hightest'></p><p id='hightest1'></p><br/><br/><p id='test'></p><br/><p id='audi'></p></div>";
734735 html_string += "</div>" ;
735736
736- $ ( '#cont' ) . html ( html_string ) ;
737+ var tourdiv = document . createElement ( 'div' ) ;
738+ document . body . appendChild ( tourdiv ) ;
739+ $ ( tourdiv ) . html ( html_string ) ;
737740 $ ( '#windowcode' ) . html ( first ) ;
738741
739742 // Position modal box
@@ -753,15 +756,16 @@ function AudioTour (divid, code, bnum, audio_text) {
753756 $ ( '.modal-close-profile' ) . show ( ) ;
754757
755758 // closes modal box once close link is clicked, or if the lights out divis clicked
756- $ ( '.modal-close-profile, .modal-lightsout' ) . click ( function ( ) {
759+ $ ( '.modal-close-profile, .modal-lightsout' ) . click ( ( function ( ) {
757760 if ( this . playing ) {
758761 this . elem . pause ( ) ;
759762 }
760763 //log change to db
761- logBookEvent ( { 'event' : 'Audio' , 'act' : 'closeWindow' , 'div_id' : divid } ) ;
764+ this . logBookEvent ( { 'event' : 'Audio' , 'act' : 'closeWindow' , 'div_id' : divid } ) ;
762765 $ ( '.modal-profile' ) . fadeOut ( "slow" ) ;
763766 $ ( '.modal-lightsout' ) . fadeOut ( "slow" ) ;
764- } ) ;
767+ document . body . removeChild ( tourdiv ) ;
768+ } ) . bind ( this ) ) ;
765769
766770 // Accommodate buttons for a maximum of five tours
767771
@@ -842,7 +846,7 @@ AudioTour.prototype.tour = function (divid, audio_type, bcount) {
842846 $ ( '#status' ) . html ( "Starting the " + name ) ;
843847
844848 //log tour type to db
845- logBookEvent ( { 'event' : 'Audio' , 'act' : name , 'div_id' : divid } ) ;
849+ this . logBookEvent ( { 'event' : 'Audio' , 'act' : name , 'div_id' : divid } ) ;
846850
847851 var max = atype . length ;
848852 var str = "" ;
@@ -1037,9 +1041,9 @@ AudioTour.prototype.playWhenReady = function (afile, divid, ahash) {
10371041 $ ( '#status' ) . html ( "Playing the " + this . tourName ) ;
10381042 this . elem . currentTime = 0 ;
10391043 this . highlightLines ( divid , ahash [ afile ] ) ;
1040- $ ( '#' + afile ) . bind ( 'ended' , function ( ) {
1041- outerAudio ( ) ;
1042- } ) ;
1044+ $ ( '#' + afile ) . bind ( 'ended' , ( function ( ) {
1045+ this . outerAudio ( ) ;
1046+ } ) . bind ( this ) ) ;
10431047 this . playing = true ;
10441048 this . elem . play ( ) ;
10451049
@@ -1056,13 +1060,13 @@ AudioTour.prototype.playaudio = function (i, aname, divid, ahash) {
10561060 if ( isNaN ( this . elem . duration ) || this . elem . duration == 0 ) {
10571061 // set the status
10581062 $ ( '#status' ) . html ( "Loading audio. Please wait. If it doesn't start soon close this window (click on the red X) and try again" ) ;
1059- $ ( '#' + this . afile ) . bind ( 'canplaythrough' , function ( ) {
1060- playWhenReady ( this . afile , divid , ahash ) ;
1061- } ) ;
1063+ $ ( '#' + this . afile ) . bind ( 'canplaythrough' , ( function ( ) {
1064+ this . playWhenReady ( this . afile , divid , ahash ) ;
1065+ } ) . bind ( this ) ) ;
10621066 }
10631067 // otherwise it is ready so play it
10641068 else {
1065- playWhenReady ( this . afile , divid , ahash ) ;
1069+ this . playWhenReady ( this . afile , divid , ahash ) ;
10661070 }
10671071} ;
10681072
@@ -1078,7 +1082,7 @@ AudioTour.prototype.pauseAndPlayAudio = function () {
10781082 document . getElementById ( "pause_audio" ) . src = "../_static/pause.png" ;
10791083 document . getElementById ( "pause_audio" ) . title = "Pause current audio" ;
10801084 //log change to db
1081- logBookEvent ( { 'event' : 'Audio' , 'act' : 'play' , 'div_id' : this . theDivid } ) ;
1085+ this . logBookEvent ( { 'event' : 'Audio' , 'act' : 'play' , 'div_id' : this . theDivid } ) ;
10821086 }
10831087
10841088 // if audio was this.playing pause it
@@ -1087,7 +1091,7 @@ AudioTour.prototype.pauseAndPlayAudio = function () {
10871091 document . getElementById ( "pause_audio" ) . src = "../_static/play.png" ;
10881092 document . getElementById ( "pause_audio" ) . title = "Play paused audio" ;
10891093 //log change to db
1090- logBookEvent ( { 'event' : 'Audio' , 'act' : 'pause' , 'div_id' : this . theDivid } ) ;
1094+ this . logBookEvent ( { 'event' : 'Audio' , 'act' : 'pause' , 'div_id' : this . theDivid } ) ;
10911095 }
10921096
10931097} ;
0 commit comments