@@ -2375,8 +2375,13 @@ SQLActiveCode.prototype.init = function(opts) {
23752375
23762376 ActiveCode . prototype . init . apply ( this , arguments ) ;
23772377
2378+ if ( eBookConfig . useRunestoneServices ) {
2379+ var fnprefix = '/runestone/books/published/' + eBookConfig . basecourse + '/_static' ;
2380+ } else {
2381+ var fnprefix = '/_static' ;
2382+ }
23782383 this . config = {
2379- locateFile : filename => `/_static /${ filename } `
2384+ locateFile : filename => `${ fnprefix } /${ filename } `
23802385 }
23812386
23822387 var self = this ;
@@ -2406,19 +2411,24 @@ SQLActiveCode.prototype.init = function(opts) {
24062411
24072412SQLActiveCode . prototype . runProg = function ( ) {
24082413
2409- // Run a query without reading the results
2410- //this.db.run("CREATE TABLE test (col1, col2);");
2411- // Insert two rows: (1,111) and (2,222)
2412- //this.db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]);
2413-
2414+ // Clear any old results
24142415 let divid = this . divid + '_sql_out' ;
24152416 let respDiv = document . getElementById ( divid ) ;
24162417 if ( respDiv ) {
24172418 respDiv . parentElement . removeChild ( respDiv )
24182419 }
2420+ $ ( this . output ) . text ( "" )
2421+ // Run this query
24192422 let query = this . buildProg ( ) ;
2420- var res = this . db . exec ( query ) ;
2421- console . log ( res ) ; //res is an array??
2423+ try {
2424+ var res = this . db . exec ( query ) ;
2425+ } catch ( error ) {
2426+ $ ( this . output ) . text ( error )
2427+ $ ( this . outDiv ) . show ( )
2428+ return
2429+ }
2430+
2431+ //
24222432 let table = createTable ( res [ 0 ] ) ;
24232433 respDiv = document . createElement ( 'div' )
24242434 respDiv . id = divid ;
0 commit comments