properly handle polls for autocomplete
This commit is contained in:
parent
a64677bbd7
commit
72a3b8d117
1 changed files with 19 additions and 7 deletions
26
index.js
26
index.js
|
@ -12,17 +12,29 @@ async function clickLi(e) {
|
||||||
let content = t.textContent;
|
let content = t.textContent;
|
||||||
if (content == '') return;
|
if (content == '') return;
|
||||||
|
|
||||||
|
let value = input.value;
|
||||||
|
|
||||||
|
let noExtend = false;
|
||||||
|
|
||||||
|
if (content.indexOf(' suggested ') != -1) {
|
||||||
|
noExtend = true;
|
||||||
|
content = content.slice(content.indexOf(' suggested ') + ' suggested '.length, content.length);
|
||||||
|
content = content.slice(content.indexOf(';') + ';'.length, content.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(content)
|
||||||
|
|
||||||
let delimiter = ';';
|
let delimiter = ';';
|
||||||
if (input.value[0] == '/') delimiter = ' ';
|
if (value[0] == '/') delimiter = ' ';
|
||||||
if (input.value.indexOf(',') != -1) delimiter = ',';
|
if (value.indexOf(',') != -1) delimiter = ',';
|
||||||
if (input.value.indexOf(';') != -1) delimiter = ';';
|
if (value.indexOf(';') != -1) delimiter = ';';
|
||||||
if (input.value.indexOf('+') != -1) delimiter = '+';
|
if (value.indexOf('+') != -1) delimiter = '+';
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (input.value == '') {
|
if (value == '' || noExtend) {
|
||||||
input.value = `${e.target.textContent}`;
|
input.value = `${content}`;
|
||||||
} else {
|
} else {
|
||||||
input.value = `${input.value}${delimiter}${e.target.textContent}`;
|
input.value = `${value}${delimiter}${content}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue