This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Backround image change
#1
Hi, is it possible to change background image of room if one or more lights are switch to on?
Reply
#2
Here's a working example that should be added to Custom JavaScript. Change tag, plan_id and img variables as needed.
Code:
$(function() {
  if (typeof grp != 'object') {
    return;
  }

  var tag = 'light';
  var plan_id = 1;

  function check() {
    var objs = grp.tag(tag);
    var res = false;
    
    $.each(objs, function(id, obj) {
      res = res || obj.value;
    });

    if (currentPlanId == plan_id) {
      var img;

      if (res) {
        img = '/scada/resources/img/light.png';
      }
      else {
        img = '/scada/resources/img/dark.png';
      }

      img = 'url(' + img + ')';

      $E.planBg
        .css('background-image', img)
        .data('background-image', img);
    }
  }

  grp.taglisten(tag, check);
  $E.body.on('showplan', check);
});
Reply


Forum Jump: