Tokiwa Battle Royale  GE777
A PHP Battle Royale inspired game
 All Data Structures Namespaces Files Functions Variables Pages
common.js
Go to the documentation of this file.
1 
2 //getElementById
3 function $(id) {
4  return document.getElementById(id);
5 }
6 
7 
8 //时间检查
9 function checkTime(i)
10 {
11 if (i<10)
12  {i="0" + i;}
13  return i;
14 }
15 
16 //ajax
17 var zXml={useActiveX:(typeof ActiveXObject!="undefined"),useXmlHttp:(typeof XMLHttpRequest!="undefined")};
18 zXml.ARR_XMLHTTP_VERS=["MSXML2.XmlHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XmlHttp","Microsoft.XmlHttp"];
19 function zXmlHttp(){}
20 zXmlHttp.createRequest=function(){
21  if(zXml.useXmlHttp){return new XMLHttpRequest();}
22  else if(zXml.useActiveX){
23  if(!zXml.XMLHTTP_VER){
24  for(var i=0;i<zXml.ARR_XMLHTTP_VERS.length;i++){
25  try{new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);
26  zXml.XMLHTTP_VER=zXml.ARR_XMLHTTP_VERS[i];break;}catch(oError){;}
27  }
28  }
29  if(zXml.XMLHTTP_VER){return new ActiveXObject(zXml.XMLHTTP_VER);}
30  else{throw new Error("Could not create XML HTTP Request.");}
31  }else{throw new Error("Your browser doesn't support an XML HTTP Request.");}
32 };
33 zXmlHttp.isSupported=function(){return zXml.useXmlHttp||zXml.useActiveX;};
34 
35 //form转字符串
36 function getRequestBody(oForm) {
37  var aParams = new Array();
38  var n = oForm.elements.length;
39  for (var i=0 ; i < n ; i++) {
40  if((oForm.elements[i].type == 'radio')&&(!oForm.elements[i].checked)){continue;}
41  var sParam = encodeURIComponent(oForm.elements[i].name);
42  sParam += "=" + encodeURIComponent(oForm.elements[i].value);
43  aParams.push(sParam);
44  }
45  return aParams.join("&");
46 }
47 
48 //cookie类
49 function Cookie(){}
50 Cookie.setCookie=function(name,value,option){
51  var str=name+"="+escape(value);
52  if(option){
53  if(option.expireHours){
54  var date=new Date();
55  var ms=option.expireHours*3600*1000;
56  date.setTime(date.getTime()+ms);
57  str+=";expires="+date.toGMTString();
58  }
59  if(option.path)str += ";path="+option.path;
60  if(option.domain)str+=";domain="+option.domain;
61  if(option.secure)str+=";true";
62  }
63  document.cookie=str;
64 }
65 Cookie.getCookie=function(name){
66  var cookie_start = document.cookie.indexOf(name);
67  var cookie_end = document.cookie.indexOf(";", cookie_start);
68  return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
69 }
70 Cookie.deleteCookie=function(name){
71  this.setCookie(name,'',{expireHours:-1});
72 }
73 
function getRequestBody(oForm)
Definition: common.js:36
function zXmlHttp()
Definition: common.js:19
function id
Definition: common.js:3
function Cookie()
Definition: common.js:49
function checkTime(i)
Definition: common.js:9
value
Definition: 1_alive.tpl.php:10
var zXml
Definition: common.js:17