fix strip
This commit is contained in:
parent
d6d706af95
commit
44218408b0
@ -23,6 +23,10 @@
|
|||||||
autoMode: false
|
autoMode: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function strip(s) {
|
||||||
|
return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
class Poll {
|
class Poll {
|
||||||
polling = true;
|
polling = true;
|
||||||
|
|
||||||
@ -82,9 +86,10 @@
|
|||||||
}
|
}
|
||||||
const labels = child.getElementsByTagName("label");
|
const labels = child.getElementsByTagName("label");
|
||||||
for (const label of labels) {
|
for (const label of labels) {
|
||||||
answers.push(label.innerText.trim());
|
answers.push(strip(label.innerText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(answers);
|
||||||
return question + "\n\n" + answers.map((s) => "- " + s.replaceAll("\t", "")).join("\n");
|
return question + "\n\n" + answers.map((s) => "- " + s.replaceAll("\t", "")).join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,15 +113,15 @@
|
|||||||
const labels = child.getElementsByTagName("label");
|
const labels = child.getElementsByTagName("label");
|
||||||
if (labels.length > 1) {
|
if (labels.length > 1) {
|
||||||
for (const label of labels) {
|
for (const label of labels) {
|
||||||
options[label.innerText.trim().replaceAll("\t", "")] = label.children[0];
|
options[strip(label.innerText)] = label.children[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options[child.innerText.trim().replaceAll("\t", "")] =
|
options[strip(child.innerText)] =
|
||||||
child.children[0].children[0];
|
child.children[0].children[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const answer of answers) {
|
for (const answer of answers) {
|
||||||
const input = options[answer.trim()];
|
const input = options[strip(answer)];
|
||||||
if (!input) {
|
if (!input) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user