got things basically working
This commit is contained in:
@@ -16,3 +16,6 @@
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.wrong {
|
||||
background: red;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user