| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- var oSw_btn
- function show_heat_img(oHeatsw, status){
- if (status) {
- oHeatsw.src = "img/switch_off.png";
- } else {
- oHeatsw.src = "img/switch_on.png";
- }
- }
- function set_heat_switch(oHeatsw, status){
-
- if (oHeatsw.src.match('on')) {
- oHeatsw.src = "img/switch_off.png";
- } else {
- oHeatsw.src = "img/switch_on.png";
- }
- }
- var url = window.location.href
- console.log("当前页面地址:" + url)
- function get_status(root_url, oHeatsw){
- console.log("get_status :" + url)
- var url_staus = root_url + 'status';
- var request = new XMLHttpRequest();
- request.open('GET', url_staus);
- // 等待获取成功 onreadystatechange
- request.onreadystatechange = function(){
- if (request.readyState == 4 && request.status == 200){
- var res_status = JSON.parse(request.responseText)
- show_heat_img(oHeatsw, res_status['heat']['status']);
- }
- }
- request.send(null)
- }
- function my_function() {
- // window.alert('onload1');
- oLisw = document.getElementById("lisw");
- oHeatsw = document.getElementById("heatsw");
- get_status(url, oHeatsw)
- oHeatsw.onclick = function() {
- };
- };
- window.onload = my_function
|