learn.html
5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Learn</title>
<link rel="icon" href="/static/favicon.ico">
<!-- MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["$$$","$$$"], ["$","$"], ["\\(","\\)"]]
}
});
</script>
<script type="text/javascript" src="/static/mathjax/MathJax.js?delayStartupUntil=onload&config=TeX-AMS_CHTML-full"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
<!-- <link rel="stylesheet" href="/static/bootstrap/css/bootstrap-theme.min.css"> -->
<!-- other -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/static/css/github.css">
<!-- <link rel="stylesheet" href="/static/css/sticky-footer-navbar.css"> -->
<!-- <link rel="stylesheet" href="/static/css/test.css"> -->
<link rel="stylesheet" href="/static/css/learn.css">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/js/nunjucks.min.js"></script>
<script src="/static/js/learn.js"></script>
</head>
<!-- ===================================================================== -->
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid drop-shadow">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
Penalty
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-user" aria-hidden="true"></i>
<span id="name"> {{ name }}</span>
(<span id="number">{{ uid }}</span>)
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="/logout"><i class="fa fa-sign-out" aria-hidden="true"></i> Sair</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- ===================================================================== -->
<div class="container">
<form action="/question" method="post" id="question_form" autocomplete="off">
{% module xsrf_form_html() %}
<div id="question_div">
O jogo está prestes a começar. A bola está do teu lado.
</div>
</form>
<button class="btn btn-primary" id="submit">Chuta!</button>
</div> <!-- container -->
<script>
$.fn.extend({
animateCSS: function (animation) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
this.addClass('animated ' + animation).one(animationEnd, function() {
$(this).removeClass('animated ' + animation);
});
}
});
// function getCookie(name) {
// var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
// return r ? r[1] : undefined;
// }
// jQuery.postJSON = function(url, args, callback) {
// args._xsrf = getCookie("_xsrf");
// alert(args);
// $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST",
// success: function(response) {
// callback(eval("(" + response + ")"));
// }});
// }
function updateQuestion(response){
$("#question_div").html(response["html"]);
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question"]);
if (response["correct"])
$('#question_div').animateCSS('pulse');
else
$('#question_div').animateCSS('shake');
$("input:text").keypress(function (e) {
if (e.keyCode == 13) {
e.preventDefault();
getQuestion();
}
});
$("textarea").keydown(function (e) {
if (e.keyCode == 13 && e.shiftKey) {
e.preventDefault();
getQuestion();
}
});
}
function getQuestion() {
// var data = $("#question_form").serialize();
// $.postJSON('/question', data, function(response){
// $("#question_div").html(response["html"]);
// MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question"]);
// if (response["correct"]) {
// $('#question_div').animateCSS('pulse');
// }
// else {
// $('#question_div').animateCSS('shake');
// }
// $("input:text").bind("keypress", function (e) {
// if (e.keyCode == 13) {
// e.preventDefault();
// getQuestion();
// }
// });
// });
$.ajax({
type: "POST",
url: "/question",
// headers: {"X-XSRFToken": token},
data: $("#question_form").serialize(),//{'a':10,'b':20},
dataType: "json", // expected from server
success: updateQuestion,
error: function() {alert("O servidor não responde.");}
});
}
$(document).ready(function() {
// getQuestion();
$("#submit").click(getQuestion);
});
</script>
</body>
</html>