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.

Javascript on Trends Page
#7
Hi,
It works, I've added body.hasClass('usermode') and an extra if to check if we're on initial plan
Perhaps something can be improved...
Code:
  $(function() {
    var body = $('body')
    var timeout = 10 // seconds
    var ini_plan_id = 7 //numero de la pantalla inicial

    if (body.hasClass('trends') || body.hasClass('schedulers')  || body.hasClass('usermode') ){
      var events = ['pointermove', 'keydown', 'click', 'scroll']
      var ticks = 0

      function reset() {
        ticks = 0
      }

      events.forEach((event) => document.addEventListener(event, reset, true))

      setInterval(() => {
        ticks++

        if (ticks >= timeout) {
          if (window.showPlan) {
            if (window.currentPlanId !== ini_plan_id) {
              window.showPlan(ini_plan_id)
            }           
          }
          else {
            window.location = '/scada-vis/'
          }
        }
      }, 1000)
    }
  })
Reply


Messages In This Thread
Javascript on Trends Page - by jmir - 22.01.2026, 06:44
RE: Javascript on Trends Page - by admin - 22.01.2026, 07:04
RE: Javascript on Trends Page - by jmir - 22.01.2026, 07:36
RE: Javascript on Trends Page - by admin - 22.01.2026, 07:49
RE: Javascript on Trends Page - by jmir - 22.01.2026, 12:07
RE: Javascript on Trends Page - by admin - 22.01.2026, 13:58
RE: Javascript on Trends Page - by jmir - 22.01.2026, 14:30

Forum Jump: