Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would suggest you to have a global array / object of timer ids such that whenever you create a new timer, you push it in and vice versa.</p> <p>My take:</p> <pre><code>timers = {}; function slide_out(event) { clicked_element = document.getElementById(event.srcElement.id); var re_clicked = new RegExp(clicked_element.className, "g"); if (clicked_element.className == "options-bar slide-out") { BACKGROUND.setTimers("positive", clicked_element.id); clicked_element.className = clicked_element.className.replace(re_clicked, ''); clicked_element.className += "options-bar slide-out open"; } else { clicked_element.className = clicked_element.className.replace(re_clicked, ''); clicked_element.className += "options-bar slide-out"; BACKGROUND.setTimers("negitive", clicked_element.id); } function setTimers(status, elementId) { var timerGetContent = null; if (status == "login") { tray_count = 0; timerGetContent = null; timerGetContent = setInterval(getContent, 4000); timers[elementId] = timerGetContent; alert("inside login"); } else if (status == "negitive") { tray_count--; if (tray_count == 0 &amp;&amp; timers[elementId] == undefined) { timerGetContent = setInterval(getRecentContent, 4000); timers[elementId] = timerGetContent; alert("inside negitive"); } } else if (status == "positive") { tray_count++; clearInterval(timers[elementId]); delete timers[elementId]; timerGetContent = null; alert("inside positive") } } </code></pre> <p>I am sorry if I messed up indentation</p> <p>Cheers</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload