' +'\n
\n'+text+'\n'; return fullPage; }; function markdown2HTML () { // Warn if markdown-it has not been loaded if(typeof window.markdownit == 'undefined') { document.getElementById('htmlText').value = ` HTML not available "markdown-it.min.js" not found try: https://www.jsdelivr.com/package/npm/markdown-it https://cdnjs.com/libraries/markdown-it ` // Display in HTML text document.getElementById('htmlText').style.display = 'block'; document.getElementById('htmlDisplay').style.display = 'none'; return null; }; currentMarkdown = document.getElementById('markdownText').value ; var processedMarkdown = preProcessMD (currentMarkdown); var htmlText = window.markdownit({ html: true }).render(processedMarkdown); HTMLchanged = false; var newPage = createDisplayHTMLpage (htmlText); if(SwitchedPage > 0){ newPage = setExperimentPageHTMLtext (newPage); }; setSwitchPageButtonColor (newPage) document.getElementById('htmlText').value = newPage; winURL = HTML2URL (newPage); document.getElementById('htmlDisplay').src=winURL; // Set up the couter of for the unblock function requiredNames = document.getElementById('htmlText').value.match(/name\s*\=\s*['"](Audio|Question)[^'"]*['"]/ig); requiredNames = requiredNames.map(x => x.replace(/name\s*\=\s*['"]([^'"]*)['"]/, "$1")); requiredNames = requiredNames.filter(onlyUnique); // Set buttons setHTMLdisplayButtonColor (); document.getElementById('ShowButton').style.backgroundColor = "red"; return document.getElementById('htmlText').value ; } function markdown2HTMLdisplay () { markdown2HTML(); // Display in iFrame document.getElementById('htmlText').style.display = 'none'; document.getElementById('htmlDisplay').style.display = 'block'; setHTMLdisplayButtonColor (); } function markdown2HTMLtext () { markdown2HTML(); // Display in HTML text document.getElementById('htmlText').style.display = 'block'; document.getElementById('htmlDisplay').style.display = 'none'; setHTMLdisplayButtonColor (); } // Switch HTML Display/Text function setHTMLdisplayButtonColor () { var currentSwitchColor = 'white'; if(HTMLchanged) { document.getElementById('RenderButtonDisplay').style.backgroundColor = 'red'; document.getElementById('RenderButtonText').style.backgroundColor = 'red'; } else if(document.getElementById('htmlText').style.display == 'block') { document.getElementById('RenderButtonDisplay').style.backgroundColor = 'white'; document.getElementById('RenderButtonText').style.backgroundColor = 'gray'; } else if (document.getElementById('htmlDisplay').style.display == 'block') { document.getElementById('RenderButtonDisplay').style.backgroundColor = 'gray'; document.getElementById('RenderButtonText').style.backgroundColor = 'white'; }; }; // Switch Cover/Experiment Page button var SwitchedPage = 0; function setSwitchPageButtonColor (text) { var currentSwitchColor = 'gray'; if(text.match(/