OSDN Git Service

index.htmlの表示変更とその他単位などの変更
[vem/WITs.git] / JS / mscontrol.js
1 function mscontrol(command,catchvalue) {
2
3  var ajax=getAjax();
4
5         if(command == "Brightnessset"){
6         var result = document.getElementById("Brightness");
7         }else if (command == "Voltageset") {
8         var result = document.getElementById("Voltage");
9         }else {
10                 var result = document.getElementById("result");
11         }
12
13         if (ajax) {
14                  try{
15                          ajax.onreadystatechange = getData;
16                  }catch(e){
17                         result.innerHTML="Onreadystate change error.";
18                  }
19
20                  try{
21                         ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command)+"&catchvalue="+encodeURIComponent(catchvalue),true);
22                  }catch(e){
23                         result.innerHTML = "ajax open error";
24                  }
25
26                 try {
27                          ajax.send(null);
28                 }catch (e) {
29                         result.innerHTML ="send error";
30                 }
31
32         }else {
33                 result.innerHTML = "you cannot use ajax....";
34         }
35
36         function getData() {
37                         if (ajax.readyState==4) {
38                                         if (ajax.status==200) {
39                                                          result.innerHTML = ajax.responseText;
40                                                  }else {
41                                                          result.innerHTML = "HTTP transmission....";
42                                                 }
43                          }
44         }
45  }