picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit 64a62739935b3c289a7325450ac867b12f9e1d96
parent b9b495dc8ce404737c3d824fcb8872063913c6f8
Author: Alexander Burger <abu@software-lab.de>
Date:   Fri, 28 Dec 2012 12:43:47 +0100

Cosmetics
Diffstat:
Mlib/form.js | 288+++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 142 insertions(+), 146 deletions(-)

diff --git a/lib/form.js b/lib/form.js @@ -1,4 +1,4 @@ -/* 12oct12abu +/* 28dec12abu * (c) Software Lab. Alexander Burger */ @@ -100,149 +100,147 @@ function post(form, file) { form.style.cursor = "wait"; try {FormReq.open("POST", form.action.substr(0,i) + "~!jsForm?" + form.action.substr(i+1));} catch (e) {return true;} - FormReq.onreadystatechange = function() { - if (FormReq.readyState == 4 && FormReq.status == 200) { - var i, j; + FormReq.onload = function() { + var i, j; - if (FormReq.responseText == "T") { - Queue.length = 0; - form.submit(); - } - else { - var txt = FormReq.responseText.split("&"); + if (FormReq.responseText == "T") { + Queue.length = 0; + form.submit(); + } + else { + var txt = FormReq.responseText.split("&"); - if (txt[0]) { - var r = txt[0].split(":"); + if (txt[0]) { + var r = txt[0].split(":"); - if (Auto) - window.clearTimeout(Auto); - if (r[1]) - Auto = window.setTimeout("document.getElementById(\"" + r[0] + "\").click()", r[1]); - } - for (i = 1; i < txt.length;) { - var fld = txt[i++]; - var val = decodeURIComponent(txt[i++]); + if (Auto) + window.clearTimeout(Auto); + if (r[1]) + Auto = window.setTimeout("document.getElementById(\"" + r[0] + "\").click()", r[1]); + } + for (i = 1; i < txt.length;) { + var fld = txt[i++]; + var val = decodeURIComponent(txt[i++]); - if (!fld) { - window[txt[i++]](val); - continue; + if (!fld) { + window[txt[i++]](val); + continue; + } + if (!(fld = document.getElementById(fld))) + continue; + if (fld.tagName == "SPAN") { + if (i != txt.length && txt[i].charAt(0) == "=") + ++i; + if (i == txt.length || txt[i].charAt(0) != "+") { + if (fld.firstChild.tagName != "A") + fld.firstChild.data = val? val : "\u00A0"; + else + fld.replaceChild(document.createTextNode(val? val : "\u00A0"), fld.firstChild); } - if (!(fld = document.getElementById(fld))) - continue; - if (fld.tagName == "SPAN") { - if (i != txt.length && txt[i].charAt(0) == "=") - ++i; - if (i == txt.length || txt[i].charAt(0) != "+") { - if (fld.firstChild.tagName != "A") - fld.firstChild.data = val? val : "\u00A0"; - else - fld.replaceChild(document.createTextNode(val? val : "\u00A0"), fld.firstChild); - } - else { - var a = document.createElement("A"); + else { + var a = document.createElement("A"); - a.href = decodeURIComponent(txt[i++].substr(1)); - a.appendChild(document.createTextNode(val)); - fld.replaceChild(a, fld.firstChild); - } + a.href = decodeURIComponent(txt[i++].substr(1)); + a.appendChild(document.createTextNode(val)); + fld.replaceChild(a, fld.firstChild); } - else if (fld.tagName == "A") { - if (i != txt.length && txt[i].charAt(0) == "=") - ++i; - if (i == txt.length || txt[i].charAt(0) != "+") { - fld.replaceChild(document.createTextNode(val? val : "\u00A0"), fld.firstChild); - fld.removeAttribute("href"); - } - else { - fld.firstChild.data = val; - fld.href = decodeURIComponent(txt[i++].substr(1)); - } + } + else if (fld.tagName == "A") { + if (i != txt.length && txt[i].charAt(0) == "=") + ++i; + if (i == txt.length || txt[i].charAt(0) != "+") { + fld.replaceChild(document.createTextNode(val? val : "\u00A0"), fld.firstChild); + fld.removeAttribute("href"); } - else if (fld.tagName == "IMG") - fld.src = val; else { - if (fld.custom != null) - putCustom(fld.custom, val); - else if (fld.type == "checkbox") { - fld.checked = val != ""; - document.getElementsByName(fld.name)[0].value = ""; - } - else if (fld.type == "select-one") { - for (j = 0; j < fld.options.length; ++j) { - if (fld.options[j].text == val) - fld.selectedIndex = j; - fld.options[j].disabled = false; - } - } - else if (fld.type == "radio") { - fld.value = val; - fld.checked = txt[i++].charAt(0) != ""; - } - else if (fld.type == "image") - fld.src = val; - else if (fld.value != val) { - fld.value = val; - fld.scrollTop = fld.scrollHeight; + fld.firstChild.data = val; + fld.href = decodeURIComponent(txt[i++].substr(1)); + } + } + else if (fld.tagName == "IMG") + fld.src = val; + else { + if (fld.custom != null) + putCustom(fld.custom, val); + else if (fld.type == "checkbox") { + fld.checked = val != ""; + document.getElementsByName(fld.name)[0].value = ""; + } + else if (fld.type == "select-one") { + for (j = 0; j < fld.options.length; ++j) { + if (fld.options[j].text == val) + fld.selectedIndex = j; + fld.options[j].disabled = false; } - fld.disabled = false; - if (i < txt.length && txt[i].charAt(0) == "=") { - if (fld.type == "select-one") { - for (j = 0; j < fld.options.length; ++j) - if (fld.options[j].text != val) - fld.options[j].disabled = true; - } - fld.disabled = true; - InBtn = 0; // 'onblur' on won't come when disabled - if (fld.type == "checkbox" && fld.checked) - document.getElementsByName(fld.name)[0].value = "T"; - ++i; + } + else if (fld.type == "radio") { + fld.value = val; + fld.checked = txt[i++].charAt(0) != ""; + } + else if (fld.type == "image") + fld.src = val; + else if (fld.value != val) { + fld.value = val; + fld.scrollTop = fld.scrollHeight; + } + fld.disabled = false; + if (i < txt.length && txt[i].charAt(0) == "=") { + if (fld.type == "select-one") { + for (j = 0; j < fld.options.length; ++j) + if (fld.options[j].text != val) + fld.options[j].disabled = true; } - if (fld.custom != null) - ableCustom(fld.custom); + fld.disabled = true; + InBtn = 0; // 'onblur' on won't come when disabled + if (fld.type == "checkbox" && fld.checked) + document.getElementsByName(fld.name)[0].value = "T"; + ++i; } - while (i < txt.length && (j = "#*?".indexOf(txt[i].charAt(0))) >= 0) { - switch (j) { - - case 0: // '#' - var cls; - - val = txt[i++].substr(1); - if ((cls = fld.getAttribute("class")) != null && (j = cls.indexOf(" ")) >= 0) - val += cls.substr(j); - fld.setAttribute("class", val); - break; - - case 1: // '*' - var node = fld.parentNode.parentNode.lastChild; - var img = document.createElement("IMG"); - - if (!node.firstChild) - node = fld.parentNode.parentNode.parentNode.lastChild; - node.removeChild(node.firstChild); - img.src = txt[i++].substr(1); - if (!txt[i]) - node.appendChild(img); - else { - var a = document.createElement("A"); - - a.href = decodeURIComponent(txt[i]); - a.appendChild(img); - node.appendChild(a); - } - ++i; - break; - - case 2: // '?' - fld.title = decodeURIComponent(txt[i++].substr(1)); - break; + if (fld.custom != null) + ableCustom(fld.custom); + } + while (i < txt.length && (j = "#*?".indexOf(txt[i].charAt(0))) >= 0) { + switch (j) { + + case 0: // '#' + var cls; + + val = txt[i++].substr(1); + if ((cls = fld.getAttribute("class")) != null && (j = cls.indexOf(" ")) >= 0) + val += cls.substr(j); + fld.setAttribute("class", val); + break; + + case 1: // '*' + var node = fld.parentNode.parentNode.lastChild; + var img = document.createElement("IMG"); + + if (!node.firstChild) + node = fld.parentNode.parentNode.parentNode.lastChild; + node.removeChild(node.firstChild); + img.src = txt[i++].substr(1); + if (!txt[i]) + node.appendChild(img); + else { + var a = document.createElement("A"); + + a.href = decodeURIComponent(txt[i]); + a.appendChild(img); + node.appendChild(a); } + ++i; + break; + + case 2: // '?' + fld.title = decodeURIComponent(txt[i++].substr(1)); + break; } } } - form.style.cursor = ""; - if (Queue.length > 0) - post(Queue.shift(), null); } + form.style.cursor = ""; + if (Queue.length > 0) + post(Queue.shift(), null); } var data = ""; for (var i = 0; i < Btn.length;) @@ -378,26 +376,24 @@ function hintKey(field, event, tok, coy) { "!jsHint?$" + field.id : "!jsHint?+" + field.id.substr(i+1) ) ); } catch (e) {return true;} - HintReq.onreadystatechange = function() { - if (HintReq.readyState == 4 && HintReq.status == 200) { - var i, n, lst, str; - - if ((str = HintReq.responseText).length == 0) - Hint.style.visibility = "hidden"; - else { - lst = str.split("&"); - while (Hints.hasChildNodes()) - Hints.removeChild(Hints.firstChild); - for (i = 0, n = 7; i < lst.length; ++i) { - addHint(i, field, str = decodeURIComponent(lst[i])); - if (str.length > n) - n = str.length; - } - Hints.style.width = n + 3 + "ex"; - Hint.style.width = n + 4 + "ex"; - Hint.style.visibility = "visible"; - Item = -1; + HintReq.onload = function() { + var i, n, lst, str; + + if ((str = HintReq.responseText).length == 0) + Hint.style.visibility = "hidden"; + else { + lst = str.split("&"); + while (Hints.hasChildNodes()) + Hints.removeChild(Hints.firstChild); + for (i = 0, n = 7; i < lst.length; ++i) { + addHint(i, field, str = decodeURIComponent(lst[i])); + if (str.length > n) + n = str.length; } + Hints.style.width = n + 3 + "ex"; + Hint.style.width = n + 4 + "ex"; + Hint.style.visibility = "visible"; + Item = -1; } } var data = "*JsHint=" + encodeURIComponent(field.value.substring(Beg,End));