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;
|
||||
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 = ';';
|
||||
if (input.value[0] == '/') delimiter = ' ';
|
||||
if (input.value.indexOf(',') != -1) delimiter = ',';
|
||||
if (input.value.indexOf(';') != -1) delimiter = ';';
|
||||
if (input.value.indexOf('+') != -1) delimiter = '+';
|
||||
if (value[0] == '/') delimiter = ' ';
|
||||
if (value.indexOf(',') != -1) delimiter = ',';
|
||||
if (value.indexOf(';') != -1) delimiter = ';';
|
||||
if (value.indexOf('+') != -1) delimiter = '+';
|
||||
|
||||
e.preventDefault();
|
||||
if (input.value == '') {
|
||||
input.value = `${e.target.textContent}`;
|
||||
if (value == '' || noExtend) {
|
||||
input.value = `${content}`;
|
||||
} 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