Tokiwa Battle Royale  GE777
A PHP Battle Royale inspired game
 All Data Structures Namespaces Files Functions Variables Pages
game20130526.js
Go to the documentation of this file.
1 function hotkey(evt)
2 {
3  if(document.activeElement.tagName != 'INPUT'){
4  evt = (evt) ? evt : ((window.event) ? window.event : '');
5  var ky = evt.keyCode ? evt.keyCode : evt.which;
6  if(!evt.ctrlKey && !evt.altKey && !evt.shiftKey){
7  if(ky==90){
8  $('submit').click();
9  }
10  }
11  }
12 }
13 
14 //update time
15 function updateTime(timing,mode)
16 {
17  if(timing){
18  t = timing;
19  tm = mode;
20  h = Math.floor(t/3600);
21  m = Math.floor((t%3600)/60);
22  s = t%60;
23  // add a zero in front of numbers<10
24  h=checkTime(h);
25  m=checkTime(m);
26  s=checkTime(s);
27  $('timing').innerHTML = h + ':' + m + ':' +s;
28  tm ? t++ : t--;
29  setTimeout("updateTime(t,tm)",1000);
30  }
31  else{
32  window.location.reload();
33  }
34 }
35 
36 
37 function demiSecTimer(){
38  if($('timer') && ms>=itv) {
39  ms -= itv;
40  var sec = Math.floor(ms/1000);
41  var dsec = Math.floor((ms%1000)/100);
42  $('timer').innerHTML = sec + '.' + dsec;
43  } else {
44  clearInterval(timerid);
45  delete timerid;
46  }
47 }
48 
49 function demiSecTimerStarter(msec){
50  itv = 100;//by millisecend
51  ms = msec;
52  timerid = setInterval("demiSecTimer()",itv);
53 }
54 
55 function itemmixchooser(){
56  for(i=1;i<=6;i++){
57  var mname = 'mitm'+i;
58  if($(mname) != null){
59  if($(mname).checked){
60  $(mname).value=i;
61  }
62  }
63  }
64 }
65 
66 //icon select
67 //function iconMover(){
68 // gd = document.valid.gender[0].checked ? 'm' : 'f';
69 // inum = document.valid.icon.selectedIndex;
70 // $('iconImg').innerHTML = '<img src="img/' + gd + '_' + inum + '.gif" alt="' + inum + '">';
71 //}
72 function userIconMover(){
73  ugd = $('male').checked ? 'm' : 'f';
74  uinum = $('icon').selectedIndex;
75  $('userIconImg').innerHTML = '<img src="img/' + ugd + '_' + uinum + '.gif" alt="' + uinum + '">';
76 }
77 function dniconMover(){
78  dngd = $('male').checked ? 'm' : 'f';
79  dninum = $('dnicon').selectedIndex;
80  $('dniconImg').innerHTML = '<img src="img/' + dngd + '_' + dninum + '.gif" alt="' + dninum + '">';
81 }
82 
83 function showNotice(sNotice) {
84  $('notice').innerText = sNotice;
85 }
86 
87 function sl(id) {
88  $(id).checked = true;
89 }
90 
91 //function postCommand(){
92 // $('submit').disabled = true;
93 // var oXmlHttp = zXmlHttp.createRequest();
94 // var sBody = getRequestBody(document.forms['gamecmd']);
95 // oXmlHttp.open("post", "command.php", true);
96 // oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
97 // oXmlHttp.onreadystatechange = function () {
98 // if (oXmlHttp.readyState == 4) {
99 // if (oXmlHttp.status == 200) {
100 // showGamedata(oXmlHttp.responseText);
101 // $('submit').disabled = false;
102 // } else {
103 // showNotice(oXmlHttp.statusText);
104 // }
105 // }
106 // };
107 // oXmlHttp.send(sBody);
108 //}
109 //
110 //function showGamedata(sGamedata){
111 // gamedata = sGamedata.parseJSON();
112 // if(gamedata['url']) {
113 // window.location.href = gamedata['url'];
114 // } else if(!gamedata['main']) {
115 // //window.location.href = 'index.php';
116 // $('notice').innerHTML = sGamedata;
117 // }
118 // //timer = 0;
119 // for(var id in gamedata) {
120 // if(id == 'toJSONString' || id == 'timer') {
121 // continue;
122 // } else if(gamedata[id]){
123 // if(id == 'team'){
124 // $('team').value = gamedata['team'];
125 // }else{
126 // $(id).innerHTML = gamedata[id];
127 // }
128 // } else{
129 // $(id).innerHTML = '';
130 // }
131 //
132 // }
133 // if(gamedata['timer'] && typeof(timerid)=='undefined'){
134 // demiSecTimerStarter(gamedata['timer']);
135 // }
136 //}
137 
138 //function postRegCommand(){
139 // $('post').disabled = true;
140 // $('reset').disabled = true;
141 // var oXmlHttp = zXmlHttp.createRequest();
142 // var sBody = getRequestBody(document.forms['reg']);
143 // oXmlHttp.open("post", "register.php", true);
144 // oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
145 // oXmlHttp.onreadystatechange = function () {
146 // if (oXmlHttp.readyState == 4) {
147 // if (oXmlHttp.status == 200) {
148 // $('post').disabled = false;
149 // $('reset').disabled = false;
150 // showRegdata(oXmlHttp.responseText);
151 // } else {
152 // showNotice(oXmlHttp.statusText);
153 // }
154 // }
155 // };
156 // oXmlHttp.send(sBody);
157 //}
158 //
159 //function showRegdata(sRegdata){
160 // regdata = sRegdata.parseJSON();
161 // for(var id in regdata) {
162 // if(id == 'toJSONString') {
163 // continue;
164 // } else if(regdata[id]){
165 // $(id).innerHTML = regdata[id];
166 // } else{
167 // $(id).innerHTML = '';
168 // }
169 // }
170 //}
171 
172 //function showNews(n){
173 // var oXmlHttp = zXmlHttp.createRequest();
174 //
175 // oXmlHttp.open("post", "news.php", true);
176 // oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
177 // oXmlHttp.onreadystatechange = function () {
178 // if (oXmlHttp.readyState == 4) {
179 // if (oXmlHttp.status == 200) {
180 // showNewsdata(oXmlHttp.responseText);
181 // } else {
182 // showNotice(oXmlHttp.statusText);
183 // }
184 // }
185 // };
186 // oXmlHttp.send('newsmode=' + n);
187 //}
188 //
189 //function showNewsdata(newsdata) {
190 // news = newsdata.parseJSON();
191 // if(news['msg']){
192 // newchat = '';
193 // for(var nid in news['msg']) {
194 // if(nid == 'toJSONString') {continue;}
195 // newchat += news['msg'][nid];
196 // }
197 // $('newsinfo').innerHTML = newchat;
198 // } else {
199 // $('newsinfo').innerHTML = news;
200 // }
201 //}
202 
203 //function showAlive(mode){
204 // //window.location.href = 'alive.php?alivemode=' + mode;
205 //
206 // var oXmlHttp = zXmlHttp.createRequest();
207 //
208 // oXmlHttp.open("post", "alive.php", true);
209 // oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
210 // oXmlHttp.onreadystatechange = function () {
211 // if (oXmlHttp.readyState == 4) {
212 // if (oXmlHttp.status == 200) {
213 // showAlivedata(oXmlHttp.responseText);
214 // } else {
215 // showNotice(oXmlHttp.statusText);
216 // }
217 // }
218 // };
219 // oXmlHttp.send('alivemode=' + mode);
220 //}
221 //function showAlivedata(alivedata) {
222 // alive = alivedata.parseJSON();
223 // $('alivelist').innerHTML = alive;
224 //}
225 
226 function postCmd(formName,sendto){
227  var oXmlHttp = zXmlHttp.createRequest();
228  var sBody = getRequestBody(document.forms[formName]);
229  oXmlHttp.open("post", sendto, true);
230  oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
231  oXmlHttp.onreadystatechange = function () {
232  if (oXmlHttp.readyState == 4) {
233  if (oXmlHttp.status == 200) {
234  showData(oXmlHttp.responseText);
235  } else {
236  showNotice(oXmlHttp.statusText);
237  }
238  }
239  }
240  oXmlHttp.send(sBody);
241 }
242 
243 function showData(sdata){
244  shwData = sdata.parseJSON();
245  if(shwData['url']) {
246  window.location.href = shwData['url'];
247  }else if(!shwData['innerHTML']) {
248  $('error').innerHTML=sdata;
249  //window.location.href = 'index.php';
250  }else{
251  sDv = shwData['value'];
252  for(var id in sDv){
253  if($(id)!=null){
254  $(id).value = sDv[id];
255  }
256  }
257  sDi = shwData['innerHTML'];
258  for(var id in sDi){
259  if($(id)!=null){
260  if(sDi['id'] !== ''){
261  $(id).innerHTML = sDi[id];
262  }else{
263  $(id).innerHTML = '';
264  }
265  }
266  }
267  sDd = shwData['display'];
268  for(var id in sDd){
269  if($(id)!=null){
270 
271  $(id).style.display = sDd[id];
272  }
273  }
274  }
275  if(shwData['timer'] && typeof(timerid)=='undefined'){
276  demiSecTimerStarter(shwData['timer']);
277  }
278  if ($('HsUipfcGhU')) //Ë¢ÐÂÒ³Ãæ±ê¼Ç { window.location.reload(); } } var refchat = null; function chat(mode,reftime) { clearTimeout(refchat); var oXmlHttp = zXmlHttp.createRequest(); var sBody = getRequestBody(document.forms['sendchat']); oXmlHttp.open("post", "chat.php", true); oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); oXmlHttp.onreadystatechange = function () { if (oXmlHttp.readyState == 4) { if (oXmlHttp.status == 200) { showChatdata(oXmlHttp.responseText); } else { showNotice(oXmlHttp.statusText); } } }; oXmlHttp.send(sBody); if(mode == 'send'){$('chatmsg').value = '';$('sendmode').value = 'ref';} rtime = reftime; refchat = setTimeout("chat('ref',rtime)",rtime); } function showChatdata(jsonchat) { chatdata = jsonchat.parseJSON(); if(chatdata['msg']) { $('lastcid').value=chatdata['lastcid']; newchat = ''; for(var cid in chatdata['msg']) { if(cid == 'toJSONString') {continue;} newchat += chatdata['msg'][cid]; } $('chatlist').innerHTML = newchat + $('chatlist').innerHTML; } } function openShutManager(oSourceObj,oTargetObj,shutAble,oOpenTip,oShutTip){ var sourceObj = typeof oSourceObj == "string" ? document.getElementById(oSourceObj) : oSourceObj; var targetObj = typeof oTargetObj == "string" ? document.getElementById(oTargetObj) : oTargetObj; var openTip = oOpenTip || ""; var shutTip = oShutTip || ""; if(targetObj.style.display!="none"){ if(shutAble) return; targetObj.style.display="none"; if(openTip && shutTip){ sourceObj.innerHTML = shutTip; } } else { targetObj.style.display="block"; if(openTip && shutTip){ sourceObj.innerHTML = openTip; } } } //1
279  {
280  window.location.reload();
281  }
282 }
283 
284 var refchat = null;
285 
286 function chat(mode,reftime) {
287  clearTimeout(refchat);
288  var oXmlHttp = zXmlHttp.createRequest();
289  var sBody = getRequestBody(document.forms['sendchat']);
290  oXmlHttp.open("post", "chat.php", true);
291  oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
292  oXmlHttp.onreadystatechange = function () {
293  if (oXmlHttp.readyState == 4) {
294  if (oXmlHttp.status == 200) {
295  showChatdata(oXmlHttp.responseText);
296  } else {
297  showNotice(oXmlHttp.statusText);
298  }
299  }
300  };
301  oXmlHttp.send(sBody);
302  if(mode == 'send'){$('chatmsg').value = '';$('sendmode').value = 'ref';}
303  rtime = reftime;
304  refchat = setTimeout("chat('ref',rtime)",rtime);
305 }
306 
307 
308 function showChatdata(jsonchat) {
309  chatdata = jsonchat.parseJSON();
310  if(chatdata['msg']) {
311  $('lastcid').value=chatdata['lastcid'];
312  newchat = '';
313  for(var cid in chatdata['msg']) {
314  if(cid == 'toJSONString') {continue;}
315  newchat += chatdata['msg'][cid];
316  }
317  $('chatlist').innerHTML = newchat + $('chatlist').innerHTML;
318  }
319 }
320 
321 function openShutManager(oSourceObj,oTargetObj,shutAble,oOpenTip,oShutTip){
322  var sourceObj = typeof oSourceObj == "string" ? document.getElementById(oSourceObj) : oSourceObj;
323  var targetObj = typeof oTargetObj == "string" ? document.getElementById(oTargetObj) : oTargetObj;
324  var openTip = oOpenTip || "";
325  var shutTip = oShutTip || "";
326  if(targetObj.style.display!="none"){
327  if(shutAble) return;
328  targetObj.style.display="none";
329  if(openTip && shutTip){
330  sourceObj.innerHTML = shutTip;
331  }
332  } else {
333  targetObj.style.display="block";
334  if(openTip && shutTip){
335  sourceObj.innerHTML = openTip;
336  }
337  }
338 }
339 
340 //1
function demiSecTimerStarter(msec)
Definition: game20130526.js:49
function getRequestBody(oForm)
Definition: common.js:36
function demiSecTimer()
Definition: game20130526.js:37
function zXmlHttp()
Definition: common.js:19
function chat(mode, reftime)
function id
Definition: common.js:3
function openShutManager(oSourceObj, oTargetObj, shutAble, oOpenTip, oShutTip)
< inputtype="radio"name="tplrefresh"value="0"<?phpif(!$tplrefresh){?> checked
function postCmd(formName, sendto)
function checkTime(i)
Definition: common.js:9
function hotkey(evt)
Definition: game20130526.js:1
function updateTime(timing, mode)
Definition: game20130526.js:15
function showNotice(sNotice)
Definition: game20130526.js:83
value
Definition: 1_alive.tpl.php:10
function userIconMover()
Definition: game20130526.js:72
function showData(sdata)
function showChatdata(jsonchat)
function itemmixchooser()
Definition: game20130526.js:55
function dniconMover()
Definition: game20130526.js:77
function sl(id)
Definition: game20130526.js:87
var refchat