@@ -1100,6 +1100,9 @@ try {
11001100 // Save
11011101 document . querySelectorAll ( "#save-button" ) . forEach ( w => w . addEventListener ( "click" , save ) ) ;
11021102 document . querySelectorAll ( "#create-button" ) . forEach ( w => w . addEventListener ( "click" , createSegment ) ) ;
1103+ document . querySelectorAll ( "#create-and-exit-button" ) . forEach ( w => w . addEventListener ( "click" , ( ) => {
1104+ createSegment ( null , true ) ;
1105+ } ) ) ;
11031106
11041107 async function save ( event , hideResult ) {
11051108 if ( ! active ) return ;
@@ -2882,14 +2885,15 @@ try {
28822885 const top = ( window . screen . height / 2 ) - ( height / 2 ) ;
28832886 const windowFeatures = `width=${ width } ,height=${ height } ,resizable=no,scrollbars=no,status=yes,left=${ left } ,top=${ top } ` ;
28842887 const newWindow = window . open ( url , '_blank' , windowFeatures ) ;
2888+ ui . modeless ( `<i class="bi bi-window-stack"></i>` , "Speed Mode Started" , "Waiting for window to close..." , true ) ;
28852889 let uploadSuccessful = false ;
28862890 let endingQuestionId = startingQuestionId || null ;
28872891 let endingQuestion = startingQuestion || null ;
28882892 window . addEventListener ( 'message' , ( event ) => {
28892893 if ( event . origin !== ( window . location . protocol + '//' + window . location . hostname + ( window . location . port ? ':' + window . location . port : '' ) ) ) return ;
28902894 if ( event . data && ( String ( event . data ) === 'uploadSuccess' ) ) {
28912895 uploadSuccessful = true ;
2892- init ( ) ;
2896+ // init();
28932897 } else if ( event . data && String ( event . data ) . includes ( ';+;' ) ) {
28942898 [ endingQuestionId , endingQuestion ] = event . data . split ( ';+;' ) ;
28952899 } else if ( event . data === 'exitToCourse' ) {
@@ -3782,7 +3786,7 @@ try {
37823786 ui . reloadUnsavedInputs ( ) ;
37833787 }
37843788
3785- function createSegment ( ) {
3789+ function createSegment ( event = null , exitToCourse = false ) {
37863790 if ( ! active ) return ;
37873791 const course = document . getElementById ( "course-period-input" ) ;
37883792 const number = document . getElementById ( "segment-number-input" ) ;
@@ -3802,6 +3806,7 @@ try {
38023806 return name . focus ( ) ;
38033807 }
38043808 document . querySelector ( "#create-button" ) . disabled = true ;
3809+ document . querySelector ( "#create-and-exit-button" ) . disabled = true ;
38053810 const question_ids = JSON . stringify ( Array . from ( document . querySelectorAll ( '.question' ) ) . filter ( q => ( q . querySelectorAll ( 'input' ) [ 1 ] . value . length > 0 ) && ( q . querySelectorAll ( 'input' ) [ 1 ] . value != ' ' ) ) . map ( q => {
38063811 return {
38073812 name : q . querySelectorAll ( 'input' ) [ 1 ] . value ,
@@ -3847,7 +3852,11 @@ try {
38473852 . then ( ( r ) => {
38483853 ui . setUnsavedChanges ( false ) ;
38493854 ui . toast ( loadedSegmentEditor ? "Segment updated successfully." : "Segment created successfully." , 3000 , "success" , "bi bi-check-circle-fill" ) ;
3850- editSegment ( null , loadedSegmentEditor ? loadedSegment . id : ( r . id || null ) ) ;
3855+ if ( exitToCourse ) {
3856+ window . location . href = '/admin/' ;
3857+ } else {
3858+ editSegment ( null , loadedSegmentEditor ? loadedSegment . id : ( r . id || null ) ) ;
3859+ }
38513860 } )
38523861 . catch ( ( e ) => {
38533862 console . error ( e ) ;
@@ -3888,6 +3897,7 @@ try {
38883897 document . getElementById ( "question-list" ) . innerHTML = '' ;
38893898 JSON . parse ( loadedSegment . question_ids ) . filter ( ( item , index , self ) => index === self . findIndex ( ( t ) => ( t . id === item . id ) ) ) . forEach ( q => addExistingQuestion ( q . id ) ) ;
38903899 document . getElementById ( "create-button" ) . innerText = "Save" ;
3900+ document . getElementById ( "create-and-exit-button" ) . innerText = "Save and Exit" ;
38913901 document . querySelector ( '[data-delete-segment]' ) ?. addEventListener ( 'click' , deleteSegmentConfirm ) ;
38923902 document . querySelector ( '[edit-segment-questions]' ) ?. addEventListener ( 'click' , ( ) => {
38933903 if ( ui . unsavedChanges ) return ui . toast ( "You have unsaved changes. Please save or discard them before editing questions." , 3000 , "error" , "bi bi-exclamation-triangle-fill" ) ;
0 commit comments