forked from srijanshetty/by-elections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myvote.js
48 lines (46 loc) · 1.1 KB
/
myvote.js
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
function nopref() {
$("input:radio").not("#pref0").attr("checked", false);
}
function detectFS() {
if(window.innerHeight != screen.height) {
//alert("GO TO FULLSCREEN MODE!");
document.getElementById("sound").play();
}
setTimeout(detectFS, 2000);
}
function validate(x) {
n=$('input[type=radio]:checked').size();
if(x==0) {
if(n==1)
return true;
else {
alert('You have to fill in 1 preference for your vote to be valid OR no preference');
return false;
}
}
if(n==1 && $("#pref0").is(":checked")) {
return true;
}
if(n!=x) {
alert('You have to fill in '+x+' preferences for your vote to be valid OR no preference (if available)');
return false;
}
else {
return true;
}
}
$(document).ready(function() {
$(".pref").on('change', function() {
$("#pref0").attr("checked", false);
//console.log($(this).parent()[0]);
var par=$(this).parent()[0];
$(par).children(":input").not($(this)).attr("checked", false);
});
detectFS();
});
// To disable f5 i.e. refresh
function disableF5(e) {
if ((e.which || e.keyCode) == 116)
e.preventDefault();
};
$(document).bind("keydown", disableF5);