diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2009-10-20 00:48:28 -0400 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2009-10-20 00:48:28 -0400 |
commit | 85639907d617aa4b5e286eb604acb428f399c17b (patch) | |
tree | f6e136519e5f3e9054efce87e122c3a0a8493bc3 /mainpage.html | |
parent | Add ftp logic to zx2c4 host becuase ap engine doesnt allow port 21. (diff) | |
download | FramedPrototype-85639907d617aa4b5e286eb604acb428f399c17b.tar.xz FramedPrototype-85639907d617aa4b5e286eb604acb428f399c17b.zip |
Finished implementation.
Diffstat (limited to '')
-rw-r--r-- | mainpage.html | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/mainpage.html b/mainpage.html new file mode 100644 index 0000000..d198ed4 --- /dev/null +++ b/mainpage.html @@ -0,0 +1,109 @@ +<html> +<head> +<title>Framed</title> +<script language="JavaScript"> +var requestObj = null; +var answerObj = null; +var questions = new Array(); +var hasLoadedFirst; +var thumbnail = null; +var title = null; +var optionBox = null; +var currentQuestion = null; + +function fillQuestionQueue() { + requestObj.open("GET", "/newquestion"); + requestObj.onreadystatechange = function() { + if (requestObj.readyState != 4) + return; + if (requestObj.responseText == "") { + fillQuestionQueue(); + return; + } + var question = eval("(" + requestObj.responseText + ")"); + var preloadImage = new Image(); + preloadImage.src = question.frame; + question.frame = preloadImage; + questions.push(question); + if (!hasLoadedFirst) { + showNextQuestion(); + hasLoadedFirst = true; + } + if (questions.length < 5) + fillQuestionQueue(); + }; + requestObj.send(null); +} + +function showNextQuestion() { + if (questions.length == 0) { + hasLoadedFirst = false; + fillQuestionQueue(); + return; + } + currentQuestion = questions.shift(); + thumbnail.src = currentQuestion.frame.src; + title.innerHTML = currentQuestion.title; + var checkBoxes = ""; + for (var i = 0; i < currentQuestion.cast.length; i++) { + checkBoxes += "<label><input type=\"checkbox\" id=\"cast" + i.toString() + "\" \\>"+ currentQuestion.cast[i][0] + " as " + currentQuestion.cast[i][1] + "</label><br \\>"; + } + optionBox.innerHTML = checkBoxes; + fillQuestionQueue(); +} + +function answerQuestion() { + var castInFrame = new Array(); + for (var i = 0; i < currentQuestion.cast.length; i++) { + if (document.getElementById("cast" + i.toString()).checked) + castInFrame.push(i); + } + if (castInFrame.length == 0) { + alert("Please select the characters in the frame. If you do not know, press skip. If there are none, press none."); + return; + } + answerObj.open("GET", "/answerquestion?code=" + currentQuestion.code + "&inframe=" + castInFrame.toString()); + answerObj.send(null); + showNextQuestion(); +} +function emptyAnswer() { + answerObj.open("GET", "/answerquestion?code=" + currentQuestion.code + "&inframe=-1"); + answerObj.send(null); + showNextQuestion(); +} + +function init() { + if (navigator.appName == "Microsoft Internet Explorer") + answerObj = requestObj = new ActiveXObject("Microsoft.XMLHTTP"); + else + answerObj = requestObj = new XMLHttpRequest(); + thumbnail = document.getElementById("thumbnail"); + title = document.getElementById("title"); + optionBox = document.getElementById("options"); + hasLoadedFirst = false; + fillQuestionQueue(); +} + +</script> +</head> +<body onLoad="init();"> +<h1>Framed <i>by AnyClip</i></h1> +<table> +<tr> +<td valign="top" width="500"> +<div id="title" style="font-size:14pt;font-weight:bold;"></div> +<img width="480" id="thumbnail" /> +</td> +<td valign="top" width="300"> +<div id="options"> +</div> +</td> +<td valign="top" width="200"> +<button onClick="answerQuestion()"><h2>Answer & Next</h2></button><br /> +<button onClick="emptyAnswer()">None of the Above</button><br /> +<button onClick="showNextQuestion()">Skip Question</button><br /> +</td> +</tr> +</table> +</body> +</html>
\ No newline at end of file |