diff options
[checklist] Removed input box width from import/export string format and shortened true to t and false to f in it
1 files changed, 12 insertions, 11 deletions
| -rw-r--r-- | checklist.html | 23 |
diff --git a/checklist.html b/checklist.html index 77f2b12..23d3dcd 100644 --- a/checklist.html +++ b/checklist.html @@ -111,6 +111,10 @@ input { return [].slice.call(container.children[1].children).slice(2); } + function calcInputWidth(text) { + return Math.max(16, text.length) * 10 + "px"; + } + function changeCheck(current, check) { get_checkBox(current).checked = check; if (get_inputBox(current).classList.contains('checked') !== check) { @@ -142,7 +146,7 @@ input { text.type = 'text'; text.style.width = "160px"; text.onkeypress = function () { - this.style.width = Math.max(16, this.value.length) * 10 + "px"; + this.style.width = calcInputWidth(this.value); } var checkbox = document.createElement('input'); @@ -224,7 +228,7 @@ input { children = [].slice.call(lists.children); } else { - str = "\"" + encodeURIComponent(get_inputBox(current).value) + "\"" + get_inputBox(current).style.width + get_checkBox(current).checked; + str = "\"" + encodeURIComponent(get_inputBox(current).value) + "\"" + ((get_checkBox(current).checked) ? "t" : "f"); } children.forEach((child) => str += "-" + stringify(child) + "_"); @@ -236,7 +240,6 @@ input { if (!i) i = 0; var text = ""; - var width = ""; var recurse = true; var current; @@ -250,25 +253,23 @@ input { i = j; break; - // Textbox width + // Textbox width (backwards compatibility) case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - j = str.indexOf('x', i); - width = str.substring(i, j + 1); - i = j; + i = str.indexOf('x', i); break; // Is checked case 't': - current = newBlankItem(text, width, true); + current = newBlankItem(text, calcInputWidth(text), true); par.appendChild(current); - i += 3; + if (str[i+1] == 'u') i += 3; // backwards compatibility with older format break; // Is not checked case 'f': - current = newBlankItem(text, width, false); + current = newBlankItem(text, calcInputWidth(text), false); par.appendChild(current); - i += 4; + if (str[i+1] == 'a') i += 4; // backwards compatibility break; // On end of item |