Reply To: Color-coding text based on inputs

PennController for IBEX Forums Support Color-coding text based on inputs Reply To: Color-coding text based on inputs

#11155
utkuturk
Participant

Hi Laurel, I think you fixed it by using Regex as in: getTextInput(“yours”).test.text(new RegExp(“^”+row.name_4.trim()+”$”,”i”))

that is what I would suggested as well. But if you want to tidy it up a bit, you can use the following in the main part of the main.js


function cloudWord(id, name, fontSize) {
    return [
        newText(id, name),
        getTextInput("yours").test.text(new RegExp("^"+name.trim()+"$","i"))
            .success(getText(id).css("font-size", fontSize).color("red").print().center())
            .failure(getText(id).css("font-size", fontSize).print().center())
    ];
}

and then within the template code:


 newText("choice","Here's what other people said").center().print(),
    newText(" ").center().print(),

    // Word cloud entries, matched against participant's response
    ...cloudWord("n1", row.name_1, row.font_1),
    ...cloudWord("n2", row.name_2, row.font_2),
    ...cloudWord("n3", row.name_3, row.font_3),
    ...cloudWord("n4", row.name_4, row.font_4),
    ...cloudWord("n5", row.name_5, row.font_5),