Added some basic form filling-out features.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3224 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
0bd836e915
commit
395495fa12
@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var gSocket;
|
||||||
var gSessionId;
|
var gSessionId;
|
||||||
var gCredentials;
|
var gCredentials;
|
||||||
var gErrorCount = 0;
|
var gErrorCount = 0;
|
||||||
@ -215,9 +216,19 @@ function printStructured(container, data) {
|
|||||||
} else if (data.image) {
|
} else if (data.image) {
|
||||||
node = document.createElement("img");
|
node = document.createElement("img");
|
||||||
node.setAttribute("src", data.image);
|
node.setAttribute("src", data.image);
|
||||||
|
} else if (data.input) {
|
||||||
|
node = document.createElement("input");
|
||||||
|
node.setAttribute("type", data.input);
|
||||||
|
if (data.name) {
|
||||||
|
node.name = data.name;
|
||||||
|
}
|
||||||
|
if (data.input == "submit") {
|
||||||
|
node.onclick = submitButton;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
node = document.createElement("span");
|
node = document.createElement("span");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.style) {
|
if (data.style) {
|
||||||
node.setAttribute("style", data.style);
|
node.setAttribute("style", data.style);
|
||||||
}
|
}
|
||||||
@ -225,7 +236,9 @@ function printStructured(container, data) {
|
|||||||
node.setAttribute("class", data.class);
|
node.setAttribute("class", data.class);
|
||||||
}
|
}
|
||||||
var value = data.value || data.href || data.command || "";
|
var value = data.value || data.href || data.command || "";
|
||||||
if (!value && data.message && data.stackTrace) {
|
if (data.input) {
|
||||||
|
node.value = value;
|
||||||
|
} else if (!value && data.message && data.stackTrace) {
|
||||||
printStructured(node, data.message);
|
printStructured(node, data.message);
|
||||||
node.appendChild(document.createElement("br"));
|
node.appendChild(document.createElement("br"));
|
||||||
printStructured(node, data.fileName + ":" + data.lineNumber + ":");
|
printStructured(node, data.fileName + ":" + data.lineNumber + ":");
|
||||||
@ -427,7 +440,17 @@ function onMessage(event) {
|
|||||||
send({event: "onWindowMessage", message: event.data});
|
send({event: "onWindowMessage", message: event.data});
|
||||||
}
|
}
|
||||||
|
|
||||||
var gSocket;
|
function submitButton() {
|
||||||
|
var inputs = document.getElementsByTagName("input");
|
||||||
|
var data = {};
|
||||||
|
for (var i in inputs) {
|
||||||
|
var input = inputs[i];
|
||||||
|
if (input.name) {
|
||||||
|
data[input.name] = input.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
send({event: "submit", value: data});
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener("load", function() {
|
window.addEventListener("load", function() {
|
||||||
if (window.Notification) {
|
if (window.Notification) {
|
||||||
|
Loading…
Reference in New Issue
Block a user