Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to set time interval for a specific function?
    text
    copied!<p>Presently I have set time interval in such a way that every 1 seconds,a function is executed.The problem is that,i am displaying notification through this function.There are notification buttons in notification.When I click on the notification action button,mulitple windows are being open.I found out that it is because I have set Timer.But in my extension , timer is necessary in order to check the output of a server file everytime.Anyone please help me.Is there any other way to deal this problem Here is my background.js</p> <pre><code> var myNotificationID = null; var oldChromeVersion = !chrome.runtime; setInterval(function() { updateIcon(); }, 1000); function onInit() { updateIcon(); if (!oldChromeVersion) { chrome.alarms.create('watchdog',{periodInMinutes:5,delayInMinutes: 0}); } } function onAlarm(alarm) { if (alarm &amp;&amp; alarm.name == 'watchdog') { onWatchdog(); } else { updateIcon(); } } function onWatchdog() { chrome.alarms.get('refresh', function(alarm) { if (alarm) { console.log('Refresh alarm exists. Yay.'); } else { updateIcon(); } }); } if (oldChromeVersion) { updateIcon(); onInit(); } else { chrome.runtime.onInstalled.addListener(onInit); chrome.alarms.onAlarm.addListener(onAlarm); } function updateIcon(){ if(//something) //something else{ chrome.notifications.create( 'id1',{ type: 'basic', iconUrl: '/calpine_not_logged_in.png', title: 'Warning : Attendance', message: 'Please mark your Attendance !', buttons: [{ title: 'Mark', iconUrl: '/tick.jpg' },{ title: 'Ignore', iconUrl: '/cross.jpg'}], priority: 0}, function(id) { myNotificationID = id;} ); chrome.notifications.onButtonClicked.addListener(function(notifId, btnIdx) { if (notifId === myNotificationID) { if (btnIdx === 0) { window.open("http://www.calpinemate.com/"); } else if (btnIdx === 1) { notification.close(); } } }); chrome.notifications.onClosed.addListener(function() { notification.close(); }); } } } }); } } </code></pre> <p>onInit();</p> <p>Here i found out that,when i remove the delayInminutes and laso the set timeineterval it opens only one tab,as i want.But both of them are necessary to do continuous checking of a server file.because whole my operation is based on the server file output.Is there any way to cope with this problem.Is there any way to set time interval for only that function? </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