OSDN Git Service

replaced all files
[vem/WITs.git] / JS / Currentcondition.js
1 function Currentcondition(command) {
2
3  var ajax=getAjax();
4
5  if(command == "request"){
6         var position1 = document.getElementById("Position");
7         var magnificant = document.getElementById("Magnificant");
8         var brightness = document.getElementById("Brightness");
9         var contrast = document.getElementById("Contrast");
10         var forcus = document.getElementById("Forcus");
11         var voltage = document.getElementById("Voltage");
12         }else {
13         var position1 = document.anchorsgetElementById("result");
14         }
15
16                 if (ajax) {
17                          try{
18                                  ajax.onreadystatechange = getData;
19                          }catch(e){
20                                 position1.innerHTML="Onreadystate change error.";
21                          }
22
23                          try{
24                                 ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command),true);
25                          }catch(e){
26                                 position1.innerHTML = "ajax open error";
27                          }
28
29
30                         try {
31                                  ajax.send(null);
32                         }catch (e) {
33                                 position1.innerHTML ="send error";
34                         }
35
36                 }else {
37                         position1.innerHTML = "you cannot use ajax....";
38                 }
39
40                                 function getData() {
41                                                 if (ajax.readyState==4) {
42                                                                 if (ajax.status==200) {
43                                                                                          console.log("Hello!");
44                                                                                          var resultjson = ajax.responseText;
45                                                                                          resultjson=JSON.parse(resultjson);
46                                                                                                 console.log(typeof resultjson);
47                                 /*
48                                                                                                  for (key in resultjson) {
49                                                                                                  console.log(key+":"+resultjson(key));
50                                                                                         }
51                                                                                         */
52                                                                                                  //position1.innerHTML=resultjson;
53                                                                                          position1.innerHTML = "x="+resultjson["Current_stageX"]+" y="+resultjson['Current_stageY']+" z="+resultjson['Current_stageZ']+" a="+resultjson['Current_stageA'];
54                                                                                         magnificant.innerHTML = "Magnificant:"+resultjson['Magnificant'];
55                                                                                         brightness.innerHTML = "Brightness:"+resultjson['Brightness'];
56                                                                                         contrast.innerHTML = "Contrast:"+resultjson['Contrast'];
57                                                                                         forcus.innerHTML = "Forcus:"+resultjson['Forcus'];
58                                                                                         voltage.innerHTML = "Voltage:"+resultjson['Voltage'];
59                                                                                         //   result.innerHTML = ajax.responseText;
60                                                                          }else {
61                                                                                  position1.innerHTML = "HTTP transmission....";
62                                                                         }
63                                                  }
64                                 }
65  }