2 // Module to open/close the network
3 // used in macchk.html in lang(ja/en) directory
11 // create object of XMLHttpRequest
12 function createXMLHttpRequest() {
13 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
14 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
15 try { return new XMLHttpRequest(); } catch(e) {}
19 // send AJAX request for status(=open/close)
20 // timer is started at open-request and stopped at close-request.
21 function ajaxRequest(status){
22 if((httpObj=createXMLHttpRequest())!=null){
24 httpObj.open('post', cginame ,false);
25 httpObj.setRequestHeader('content-type',
26 'application/x-www-form-urlencoded,charset=utf-8');
27 httpObj.send('status='+status+'&macaddr='+macaddr);
28 if(status=='open') startTimer();
34 // send 'open' AJAX request
36 document.checkform.open.disabled=true;
37 document.checkform.close.disabled=false;
39 document.regform.macaddr.value=macaddr;
43 // send 'close' AJAX request
45 document.checkform.open.disabled=false;
46 document.checkform.close.disabled=true;
51 function startTimer(){
53 setTimeout('onTimeout()', 1000);
61 // decrement counter and show the value on page
62 // if the counter reachs zero, close-request is sent automatically
64 document.checkform.timer.value=seconds;
66 if(seconds<0) closeNet();
67 else setTimeout('onTimeout()', 1000);
70 // get the checked mac address in the list
71 function getMacAddr(){
72 if(document.checkform.macaddr==undefined) macaddr='';
73 else if(document.checkform.macaddr.length==undefined)
74 macaddr=document.checkform.macaddr.value;
76 for(var i=0; i<document.checkform.macaddr.length; i++){
77 if(document.checkform.macaddr[i].checked){
78 macaddr=document.checkform.macaddr[i].value;
84 // set parameters at starting of page(<body onload=..>)
85 function setParameters(cginameArg, timeoutArg){