@@ -598,30 +598,10 @@ function processHints(requestedHints) {
598598 return compiledHints ;
599599}
600600
601- /** Load and parse YAML data, return result to be placed in "info".
602- * @info : String with YAML (including JSON) data to use
603- */
604- function processYamlToInfo ( configurationInfo ) {
605- // This would only allow JSON, but then we don't need to load YAML lib:
606- // let parsedJson = JSON.parse(configurationInfo);
607-
608- let parsedData ; // Parsed data, *if* we manage to parse it.
609- try {
610- parsedData = jsyaml . load ( configurationInfo ) ;
611- }
612- catch ( e ) {
613- showDebugOutput (
614- `Lab Error: Cannot process YAML of info.\n${ e } ` ) ;
615- throw e ; // Rethrow, so containing browser also gets exception
616- }
617-
618- return parsedData ;
619- }
620-
621601/** Set global values based on other than "correct" and "expected" values.
622602 * The correct and expected values may come from elsewhere, but we have to set up the
623603 * info-based values first, because info can change how those are interpreted.
624- * @info : String with YAML (including JSON) data to use
604+ * @configurationInfo : Data to use
625605 */
626606function processInfo ( configurationInfo ) {
627607 const allowedInfoFields = new Set ( [
@@ -746,17 +726,12 @@ function runSelftest() {
746726 * The "info" data includes the regex preprocessing steps, hints, etc.
747727 */
748728function setupInfo ( ) {
749- // We must load info *first*, because it can affect how other things
750- // (like pattern preprocessing) is handled.
751-
752- // Deprecated approach: Load embedded "info" data in YAML file.
753- // If there is "info" data embedded in the HTML (e.g., hints),
754- // load it & set up global variable hints.
755- let infoElement = document . getElementById ( 'info' ) ;
756- if ( infoElement ) {
757- let configurationYamlText = infoElement . textContent ;
758- // Set global variable "info"
759- info = processYamlToInfo ( configurationYamlText ) ;
729+ // We no longer need a *separate* step to load info, we presume the
730+ // HTML loaded it.
731+ // As a safety check, let's make sure some data *was* loaded.
732+
733+ if ( Object . keys ( info ) . length == 0 ) {
734+ alert ( `ERROR: info has no values set. Load/modify your lab .js file.` ) ;
760735 } ;
761736
762737 // If an "info2" exists, report any differences between it and "info".
@@ -768,7 +743,6 @@ function setupInfo() {
768743 }
769744 } ;
770745
771-
772746 // Set global values *except* correct and expected arrays
773747 processInfo ( info ) ;
774748
@@ -830,8 +804,10 @@ function initPage() {
830804 attempt . oninput = runCheck ;
831805 current ++ ;
832806 }
833- for ( let hintButton of document . querySelectorAll ( "button.hintButton" ) ) {
807+ for ( let hintButton of document . querySelectorAll ( "button.hintButton" ) ) {
834808 hintButton . addEventListener ( 'click' , ( e ) => { showHint ( e ) ; } ) ;
809+ // Precompute inputIndexes to work around problems that occur
810+ // if a user uses a browser's built-in natural language translation.
835811 // Presumes button's parent is the form
836812 hintButton . dataset . inputIndexes = findIndexes ( hintButton . parentNode ) ;
837813 if ( ! hintButton . title ) {
0 commit comments