-
Notifications
You must be signed in to change notification settings - Fork 1
/
contest.js
188 lines (151 loc) · 4.39 KB
/
contest.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
setInterval('updateMarquee()',20000);
//checkTimeOut();
function updateMarquee()
{
var flag = false;
if(document.getElementById('confirm').checked)
flag = true;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200 && flag == false)
{
document.getElementById("mrqe").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","marquee.php",true);
xmlhttp.send();
}
function checkTimeOut()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("timeOut").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","timeout.php",true);
xmlhttp.send();
}
function confirmNow()
{
if(document.getElementById('confirm').checked)
{
if(document.getElementById('from').value.length >9 || document.getElementById('sourceValue').value.length==0)
{
alert('Please enter the Required Source Fields and then confirm');
document.getElementById('confirm').checked = false;
}
else{
document.getElementById('from').disabled = true;
document.getElementById('sourceValue').disabled = true;
validateSourceValue();
toFieldAjaxCall();
}
}
else
{
document.getElementById('from').disabled = false;
document.getElementById('sourceValue').disabled = false;
document.getElementById('expTable').innerHTML = "";
}
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
function toFieldAjaxCall()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("expTable").innerHTML=xmlhttp.responseText;
}
else
document.getElementById("expTable").innerHTML="<img src='indicator.gif' alt='LOADING PLEASE WAIT' />";
}
xmlhttp.open("GET","update2.php?c= "+document.getElementById('from').value+ "&v=" + document.getElementById('sourceValue').value,true);
xmlhttp.send();
}
function validateSourceValue()
{
var sourceValue = document.getElementById('sourceValue').value;
var fromFieldValue = document.getElementById('from').value;
sourceValue = parseFloat(document.getElementById('sourceValue').value,10);
var table = document.getElementById('amountsTable'),
rows = table.getElementsByTagName('tr'),i, j, cells;
var currentAmounts = new Array();
for (i = 0, j = rows.length; i < j; ++i) {
cells = rows[i].getElementsByTagName('td');
if (!cells.length) {
continue;
}
currentAmounts[i] = cells[1].innerHTML;
}
if(sourceValue >= currentAmounts[fromFieldValue] || sourceValue <=0)
{
document.getElementById('sourceValue').value = currentAmounts[fromFieldValue];
}
}
function convertNow()
{
if(document.getElementById('confirm').checked == false)
{
alert('Please confirm the transaction first!');
}
else{
var fromFieldValue = document.getElementById('from').value;
var toFieldValue = document.getElementById('to').value;
var sourceValue = document.getElementById('sourceValue').value;
convertNowAjaxCall(fromFieldValue, toFieldValue, sourceValue);
}
}
function convertNowAjaxCall(ffv,tfv,sv)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("lastTransaction").innerHTML=xmlhttp.responseText;
window.location.reload();
}
}
xmlhttp.open("GET","convert.php?ffv= "+ffv+ "&tfv=" + tfv + "&sv=" + sv,true);
xmlhttp.send();
}