Page 68 - MDP2020-2
P. 68

|    인천전자마이스터고등학교  ·············································································································
            62


                                                     let  show  =  document.querySelector("#show");
                                                     if(data=="ok"){
                                                             result.innerHTML="<h1></h1>"
                                                             /*UV4L  Webrtc  영상  삽입*/
                                                             show.innerHTML  =  `<div><img  style="-webkit-user-select:
                             none;margin:  auto;"
                     src="http://0.0.0.0:8080/stream/video.mjpeg"></div>`;
                                                     }else{
                                                             show.innerHTML  =  "<h1>error</h1>";
                                                     }
                                             });
                                     }function  hangup(){                                                                    //통화해제
                                             fetch("/house/led/off")
                                             .then(response=>  {  console.log(response);  return  response.text()})
                                             .then(data=>  {
                                                     console.log(data);
                                                     let  result  =  document.querySelector("#result");
                                                     if(data=="ok"){
                                                             show.innerHTML="<h1></h1>"
                                                             result.innerHTML  =  "<h1>연결이  끊겼습니다</h1>";
                                                             setTimeout(function()  {                                  //3초  후에  실행
                                                             result.innerHTML  =  "<h1></h1>"
                                                             },  3000);
                                                     }else{
                                                             result.innerHTML  =  "<h1>error</h1>";
                                                     }
                                             });
                                     }
               function  door(){                                                                        //문  열기
                                             fetch("/house/led/open")
                                             .then(response=>  {  console.log(response);  return  response.text()})
                                             .then(data=>  {
                                                     console.log(data);
                                                     let  result  =  document.querySelector("#result");
                                                     if(data=="ok"){
                                                             sleep(7000);                                                        //7초  딜레이
                                                             door_d();                                                              //PIR센서  감지
                                                             door_c();
                                                                   }else{
                                                             result.innerHTML  =  "<h1>error</h1>";
                                                     }
                                             });
                                     }
             function  door_c(){                                                                    //문  닫기
                                             fetch("/house/led/open/c")
                                             .then(response=>  {  console.log(response);  return  response.text()})
                                             .then(data=>  {
                                                     console.log(data);
                                                     let  result  =  document.querySelector("#result");
                                                     if(data=="fail"){
                                                             result.innerHTML  =  "<h1>에러가  발생하였습니다</h1>"
                                                     }
                                             });
                                     }

                                     function  door_d(){                                                                    //PIR센서  감지
                                             fetch("/house/led/open/d")
                                             .then(response=>  {  console.log(response);  return  response.text()})
                                             .then(data=>  {
                                                     console.log(data);
                                                     let  result  =  document.querySelector("#result");
   63   64   65   66   67   68   69   70   71   72   73