main.js 440 B

123456789101112131415161718192021222324252627
  1. $(document).ready(function(){
  2. function refreshDoor(){
  3. $('div[id^="state"]').each(function(e,elem){
  4. var id = $(elem).attr('id').replace('state','');
  5. $.ajax({
  6. type: "GET",
  7. url: "action.php?action=door_get_state&engine="+id
  8. }).done(function( msg ) {
  9. $('img',elem).attr('src','plugins/door/img/'+(msg==1?'open':'close')+'.png');
  10. });
  11. });
  12. }
  13. refreshDoor();
  14. setInterval(function(){
  15. refreshDoor();
  16. },2000);
  17. });