Skip to content
Snippets Groups Projects
Commit fe2704e2 authored by Nils G.'s avatar Nils G.
Browse files

Clicking a submit button prepares the user submit JSON

parent 17e4ee48
No related branches found
No related tags found
No related merge requests found
......@@ -73,12 +73,15 @@ function renderRole(_definition, _roleIdle) {
e.html(value);
break;
case "input":
e = $("<input type='text'/>");
e = $("<input class='game_input' type='text'/>");
e.attr("placeholder", value);
break;
case "submit":
e = $("<input type='submit'/>");
e = $("<input class='game_input' type='submit'/>");
e.val(value);
e.click(function(){
submit(e);
});
break;
default:
e = $("<span>Invalid Element</span>");
......@@ -95,3 +98,24 @@ function renderRole(_definition, _roleIdle) {
function sanitizeCSS(_css) {
return(_css.replace(/</g, ""))
}
function submit(_button) {
var submit = {"inputs": []};
var inputs = $("#game_content .game_input").each(function(index, element) {
element.setAttribute("disabled", "true");
var obj = {};
obj[element.getAttribute("name")] = element.value;
switch(element.getAttribute("type")) {
case "text":
submit["inputs"].push(obj);
break;
}
});
submit["submit"] = _button.attr("name");
alert(JSON.stringify(submit));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment