diff --git a/replace2.js b/replace2.js index 20d1ce3..29cb899 100644 --- a/replace2.js +++ b/replace2.js @@ -142,11 +142,11 @@ transform.render = async (obj, divId, previousResults = {}) => { let prevButton = (endMatch && endMatch[1]) === "noback" ? "" - : (questID==='END') ? "" :""; + : (questID === 'END') ? "" : ""; //debugger; - let resetButton = (questID==='END') ? "" - : + let resetButton = (questID === 'END') ? "" + : ""; let nextButton = endMatch @@ -171,7 +171,7 @@ transform.render = async (obj, divId, previousResults = {}) => { //adding displayif with nested questions. nested display if uses !| to |! questText = questText.replace(/!\|(displayif=.+?)\|(.*?)\|!/g, fDisplayIf); function fDisplayIf(containsGroup, condition, text) { - text = text.replace(/\|(?:__\|){2,}(?:([^\|\<]+[^\|]+)\|)?/g,fNum); + text = text.replace(/\|(?:__\|){2,}(?:([^\|\<]+[^\|]+)\|)?/g, fNum); text = text.replace(/\|popup\|([\S][^|]+[\S])\|(?:([\S][^|]+[\S])\|)?([\S][^|]+[\S])\|/g, fPopover); text = text.replace(/\|@\|(?:([^\|\<]+[^\|]+)\|)?/g, fEmail); text = text.replace(/\|date\|(?:([^\|\<]+[^\|]+)\|)?/g, fDate); @@ -181,7 +181,7 @@ transform.render = async (obj, divId, previousResults = {}) => { text = text.replace(/\((\d*)(?:\:(\w+))?(?:\|(\w+))?(?:,(displayif=.+\))?)?\)(.*?)(?=(?:\(\d)|\n|
|$)/g, fRadio); text = text.replace(/\[(\d*)(?:\:(\w+))?(?:\|(\w+))?(?:,(displayif=.+?\))?)?\]\s*(.*?)\s*(?=(?:\[\d)|\n|
|$)/g, fCheck); text = text.replace(/\[text\s?box(?:\s*:\s*(\w+))?\]/g, fTextBox); - text = text.replace(/\|(?:__\|)(?:([^\s<][^|<]+[^\s<])\|)?/g,fText); + text = text.replace(/\|(?:__\|)(?:([^\s<][^|<]+[^\s<])\|)?/g, fText); text = text.replace(/\|___\|((\w+)\|)?/g, fTextArea); text = text.replace(/\|time\|(?:([^\|\<]+[^\|]+)\|)?/g, fTime); text = text.replace( @@ -238,7 +238,7 @@ transform.render = async (obj, divId, previousResults = {}) => { } - + // replace |SSNsm| with SSN input questText = questText.replace(/\|SSNsm\|(?:([^\|\<]+[^\|]+)\|)?/g, fSSNsm); function fSSNsm(fullmatch, opts) { @@ -333,10 +333,10 @@ transform.render = async (obj, divId, previousResults = {}) => { var radioCheckboxAndInput = false; if (questText.match(/(\[|\()(\d*)(?:\:(\w+))?(?:\|(\w+))?(?:,(displayif=.+?\))?)?(\)|\])\s*(.*?\|_.*?\|)/g)) { radioCheckboxAndInput = true; - questOpts = questOpts+ " radioCheckboxAndInput"; + questOpts = questOpts + " radioCheckboxAndInput"; } - // replace (XX) with a radio button... - questText = questText.replace(/
/g,"
\n"); + // replace (XX) with a radio button... + questText = questText.replace(/
/g, "
\n"); questText = questText.replace( /\((\d*)(?:\:(\w+))?(?:\|(\w+))?(?:,(displayif=.+\))?)?\)(.*?)(?=(?:\(\d)|\n|
|$)/g, fRadio @@ -406,7 +406,7 @@ transform.render = async (obj, divId, previousResults = {}) => { //let maxReplace = evalueateCondition("isDefined(AGE,5)"); //instead of replacing max and min with data-min and data-max, they need to be added, as the up down buttons are needed for input type number let optionList = options.split(" "); - for (let i=0; i { ); function fText(fullmatch, opts) { let { options, elementId } = guaranteeIdSet(opts, "txt"); - + if (radioCheckboxAndInput) { options = options + " disabled "; } @@ -534,7 +534,7 @@ transform.render = async (obj, divId, previousResults = {}) => { } // SAME thing but this time with a textarea... - + //displayif with just texts questText = questText.replace(/\|(displayif=.+?)\|(.*?)\|/g, fDisplayIf); function fDisplayIf(containsGroup, condition, text) { @@ -555,10 +555,10 @@ transform.render = async (obj, divId, previousResults = {}) => { questText = questText.replace( /<\s*#NR\s*->\s*([A-Z_][A-Z0-9_#]*)\s*>/g, "" + questID + + "_NR' name='" + + questID + + "' skipTo=$1 checked>" ); // handle skips @@ -570,8 +570,8 @@ transform.render = async (obj, divId, previousResults = {}) => { /" ); - questText = questText.replace(/<\/div>
/g,""); - + questText = questText.replace(/<\/div>
/g, ""); + // If reset is needed only for radio buttons then uncomment out the next lines // if (!questText.includes('input type=\'radio\'')){ // resetButton = ''; @@ -602,12 +602,12 @@ transform.render = async (obj, divId, previousResults = {}) => { /\[DISPLAY IF\s*([A-Z][A-Z0-9+]*)\s*=\s*\(([\w,\s]+)\)\s*\]\s*
/g, "
" ); - + //removing random  unit separator chars contents = contents.replace(//g, ""); // add the HTML/HEAD/BODY tags... document.getElementById(divId).innerHTML =/*html*/ - contents + + contents + `