-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
87 lines (78 loc) · 2.6 KB
/
index.html
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
<html>
<script>
function isOneChecked() {
// All <input> tags...
var chx = document.getElementsByTagName('input');
for (var i=0; i<chx.length; i++) {
// If you have more than one radio group, also check the name attribute
// for the one you want as in && chx[i].name == 'choose'
// Return true from the function on first match of a checked item
if (chx[i].type == 'radio' && chx[i].checked) {
return true;
}
}
// End of the loop, return false
alert("At least choose one value")
return false;
}
</script>
<body>
{% if currentUser!="DefaultUser" %}
<h2>Hello, {{currentUser}}!</h2>
<a href="{{ url }}">{{ url_linktext }}</a>
<hr>
<div>
<h3>View vote results:</h3>
<form action="/view_results" onsubmit="return isOneChecked()" method="post">
{% for category in categories1 %}
<input type="radio" name="category" value="{{ category.name|escape }}">{{ category.name|escape }}<br>
{% endfor %}
<button name="action" type="submit" value="Select">Select</button>
</form>
</div>
<hr>
<div>
<h3>Select category to vote:</h3>
<form action="/vote_category" onsubmit="return isOneChecked()" method="post">
{% for category in categories2 %}
<input type="radio" name="vote" value="{{ category.name|escape }}">{{ category.name|escape }}<br>
{% endfor %}
<button name="action" type="submit" value="Select">Select</button>
</form>
</div>
<hr>
<div>
<h3>Create new category</h3>
<br>
<form action="/create_category" method="post">
Category Name: <input type="text" name="category_name"><br>
<input type="submit" value="Create">
</form>
</div>
<hr>
<div>
<h3>Edit current user created category</h3>
{% if editableCategory.count != 0 %}
<form action="/edit_category" onsubmit="return isOneChecked()" method="post">
{% for category in editableCategory %}
<input type="radio" name="edit" value="{{ category.name|escape }}">{{ category.name|escape }}<br>
{% endfor %}
<button name="action" type="submit" value="Edit">Edit</button>
<button name="action" type="submit" value="Remove">Remove</button>
</form>
{% endif %}
</div>
<hr>
<div>
<h3>Import category from XML:</h3>
<form action="/import_category" ENCTYPE="multipart/form-data" method="post">
<input type="file" name="filename"><br>
<input type="submit" value="Upload">
</form>
</div>
{% else %}
<h2>You have not logged in yet, please log in!</h2>
<a href="{{ url }}">{{ url_linktext }}</a>
{% endif %}
</body>
</html>