diff --git a/static/game/debug/renderer.css b/static/game/debug/renderer.css deleted file mode 100644 index 1e14ac42044eb1d0efeec96b17cafd06dec32cc0..0000000000000000000000000000000000000000 --- a/static/game/debug/renderer.css +++ /dev/null @@ -1,19 +0,0 @@ -html { - background-color: lightblue; -} - -body { - background-color: lightgreen; -} - -input { - font-size: 20px; - width: 90%; - height: 50px; -} - -#game_content { - font-size: 25px; - padding-top: 10px; - padding-bottom: 55px; -} diff --git a/static/game/debug/renderer.js b/static/game/debug/renderer.js deleted file mode 100644 index 1a3ec6987feee370482909e2b3f8c88319ec50f0..0000000000000000000000000000000000000000 --- a/static/game/debug/renderer.js +++ /dev/null @@ -1,180 +0,0 @@ -function render(_role, _roles){ - - HEADER_SET(ROOM_CODE, "Lynchburg", PLAYER_NAME+":"+_role); - - if(submit_done) { - _role = role_next; - } - - if(_role in _roles) { - renderRole(_roles[_role], _roles["idle"]); - return; - } - - if(_role === "idle") { - //We have no role definitions yet, but the role is default idle - $("#game_content").html(ERROR_WAIT); - return; - } - - //This is not good - set_error(ERROR_RENDERTARGET); -} - -function renderRole(_definition, _roleIdle) { - - if(_roleIdle && (_definition !== _roleIdle)){ - var old_css_idle = $("#game_css_idle"); - - if(old_css_idle) { - old_css_idle.remove(); - } - - if("css" in _roleIdle) { - //Add idle css - var css = $("<style id='game_css_idle' type='text/css'>" + sanitizeCSS(_roleIdle["css"]) + "</style>"); - $("#current_content").append(css); - } - } - - var old_css = $("#game_css"); - - if(old_css) { - old_css.remove(); - } - - if("css" in _definition) { - //Add additional css - var css = $("<style id='game_css' type='text/css'>" + sanitizeCSS(_definition["css"]) + "</style>"); - $("#current_content").append(css); - } - - var elements = _definition["elements"]; - - $("#game_content").html(""); - - var prompt = prompts[currentPrompt]; - - for(var index in elements) { - - var element = elements[index]; - - var type = element["type"]; - var c = element["class"]; - var name = element["name"]; - var value = element["value"] ? element["value"] : ""; - var length = element["length"]; - - if(prompt) { - var variables = prompt["variables"]; - var selections = prompt["selections"]; - - if(variables) { - for(var varname in variables) { - while(value.indexOf("$"+varname) != -1 ){ - value = value.replace("$"+varname, variables[varname]); - } - } - } - } - - var e; - switch(type) { - case "text": - e = $("<span></span>"); - e.html(value); - break; - case "input": - e = $("<input class='game_input' type='text'/>"); - e.attr("placeholder", value); - if(length) { - e.attr("maxlength", length); - } - if(!prompt) { - e.attr("disabled", "true"); - } - break; - case "submit": - e = $("<input class='game_input' type='submit'/>"); - e.val(value); - if(!prompt) { - e.attr("disabled", "true"); - } else { - e.click(function(o){ - submit($(this)); - }); - } - break; - case "selection": - e = $("<span></span>"); - if(selections && selections[name]) { - for(select in selections[name]) { - var b = $("<input class='game_input' type='submit'/>"); - b.val(selections[name][select]); - b.attr("name", name); - b.attr("selection", select); - b.addClass(c); - b.click(function(o){ - submit($(this)); - }); - e.append(b); - } - } - break; - default: - e = $("<span>Invalid Element</span>"); - break; - } - e.attr("name", name); - e.addClass(c); - - var p = $("<p></p>").append(e); - $("#game_content").append(p); - } -} - -function sanitizeCSS(_css) { - return(_css.replace(/</g, "")) -} - -function submit(_button) { - var submit = {}; - var inputs = {}; - - $("#game_content .game_input").each(function(index, element) { - element.setAttribute("disabled", "true"); - - switch(element.getAttribute("type")) { - case "text": - inputs[element.getAttribute("name")] = element.value.replace(/[^0-9a-zA-Z\s]/g, '');; - break; - } - }); - - submit["submit"] = _button.attr("name"); - if(_button.attr("selection")) { - submit["selection"] = parseInt(_button.attr("selection")); - } - submit["inputs"] = inputs; - - AJAX_JSON(URL_SUBMIT, submit, function(_code, _data) { - switch(_code) { - case 200: - currentPrompt++; - //Fall through: - case 409: - if(!prompts[currentPrompt]) { - submit_done = true; - } - render(role, roles); - break; - case 401: - case 410: - content_reload(); - break; - default: - set_error(_data); - break; - } - }); -}