got things basically working

This commit is contained in:
sm
2013-04-23 22:48:16 -07:00
parent d9f52e3860
commit 191ebc3285
5 changed files with 88 additions and 31 deletions
+3
View File
@@ -16,3 +16,6 @@
padding-top: 30px;
}
.wrong {
background: red;
}
+36
View File
@@ -0,0 +1,36 @@
function update_board(f, o, s) {
$("#first").text(f);
$("#operation").text(o);
$("#second").text(s);
}
function new_problem() {
$.get("/api/v0/problem/", function(d) {
update_board(d["first"], d["operation"], d["second"]);
$("#answer").val("");
})
}
function deal_with_answer(e) {
var data = {
"first": $("#first").text(),
"operation": $("#operation").text(),
"second": $("#second").text(),
"answer": $("#answer").val(),
};
console.log(data);
$.post("/api/v0/attempt/", data, function(d) {
if(d["status"]) {
$("#content").removeClass("wrong");
new_problem();
}
else {
$("#content").addClass("wrong");
}
});
}
$(function() {
new_problem();
$("#check").click(deal_with_answer);
});