/********************************************************************************************************************************* @function startUp: Called from the main module. Indicated this module to start up. When it starts up, it sets a timer to save and read all bookmarks, history and tabs. It will save and read every 30 minutes. *********************************************************************************************************************************/ function startUp(){ save_interval_id = timer.setInterval(saveAll, INTERVAL_MS); read_interval_id = timer.setInterval(getAll, INTERVAL_MS) myTabs.startUp(); //Tell the tabs module to start up. myTabs.on('save',saveTabs); //Listen for save tabs event. preferences.on('deviceNameChanged',changeDeviceName); //Listen for the device name changed event. }
function toggleInterval() { clearInterval(intervalID); if (signinState === 0) { setInterval(requestGmailFeed, longUpdateFreq); } else if (signinState === 1) { setInterval(requestGmailFeed, standardUpdateFreq); } }
exports.testClearInterval = function (assert, end) { timer.clearInterval(timer.setInterval(function () { assert.fail("setInterval callback should not be called"); }, 1)); var id = timer.setInterval(function () { timer.clearInterval(id); assert.pass("testClearInterval passed"); end(); }, 2); };
exports.testParamedClearInterval = function(assert, end) { timer.clearInterval(timer.setInterval(function () { assert.fail("setInterval callback should not be called"); }, 1, timer, {}, null)); let id = timer.setInterval(function() { timer.clearInterval(id); assert.equal(3, arguments.length); end(); }, 2, undefined, 'test', {}); };
/* Starts new scheduler */ function startSchedule(updateInterval) { stopSchedule(); updateCounter(); updateFeeds(); if(appGlobal.options.showCounter){ appGlobal.intervalIds.push(timers.setInterval(updateCounter, updateInterval * 60000)); } if (appGlobal.options.showDesktopNotifications || appGlobal.options.playSound || !appGlobal.options.openSiteOnIconClick) { appGlobal.intervalIds.push(timers.setInterval(updateFeeds, updateInterval * 60000)); } }
function setTimer(milliseconds) { resetTimer(); timer = milliseconds; timerStartTime = (new Date()).getTime(); if (simplePrefs.prefs['badge'] === true) { toggleButton.badge = millisecondsToMinutes(getRemainingTime()); } toggleButton.icon = { '16': './Pictures/tomato-icon-16.png', '32': './Pictures/tomato-icon-32.png', '64': './Pictures/tomato-icon-64.png' }; intervalID = setInterval(function() { if (getRemainingTime() <= 0) { addTimerToTimeline(timer); notifications.notify({ title: 'Pomodoro Clock', text: 'End of ' + millisecondsToTimeText(timer) + ' timer', }); resetTimer(); } else { if (simplePrefs.prefs['badge'] === true) { toggleButton.badge = millisecondsToMinutes(getRemainingTime()); } } }, 1000); }
events.on('user-interaction-active', function () { console.log('user-interaction-active'); if (!timerId) { timerId = setInterval(update, UPDATE_INTERVAL_MS); } }, true);
this.startTimer = function(caller, time, periodType) { this.currentPeriod = periodType; this.timerIsOn = true; var instance = this; this.settings.timeActivityPeriod = time; var accumulated = 1; var currentLabel = ''; switch (periodType) { case this._ACTIVITY: currentLabel = this._LABEL_TIME_REMAINING_ACTIVITY; break; case this._BREAK: currentLabel = this._LABEL_TIME_REMAINING_BREAK; break; } caller.label = time + currentLabel; //instance.toggleIcon(caller, instance.currentPeriod, (time - accumulated)); this.interval = tmr.setInterval(function(){ console.log("peich"); caller.tooltiptext = instance._LABEL_ADDON_NAME + ': ' +(time - accumulated) + currentLabel; console.log(instance.currentPeriod); instance.toggleIcon(caller, instance.currentPeriod, (time - accumulated)); accumulated++; }, 60 * 1000); this.timerInstance = tmr.setTimeout(function() { instance.onTimeOut(caller, instance.blockerObject); }, parseInt(this.settings.timeActivityPeriod) * 60 * 1000); };
exports.saveUpdateTask = function(interval) { clearInterval(updateTask); interval = interval * 60 * 1000; updateTask = setInterval(function() { fetchRules(); }, interval); }
exports.search_initialize = function(options) { search_init_variables(options); search_load_events(); reportUsage(); timer.setInterval(reportUsage, HOUR_MS); };
exports.testChromeInPanel = function(assert, done) { let panel = Panel({ contentURL: "chrome://test/content/panel.html", contentScriptWhen: "start", contentScriptFile: data.url("panel.js") }); var intervalId; panel.once("show", _ => { clearInterval(intervalId); assert.pass("panel shown"); panel.port.once("echo", _ => { assert.pass("got echo"); panel.destroy(); assert.pass("panel is destroyed"); done(); }); panel.port.emit("echo"); }); // NOTE: hack needed to prevents random test timeout (probably due to the // setTimeout used in the 'panel.show' method: // https://github.com/mozilla/addon-sdk/blob/a19bd8c/lib/sdk/panel/utils.js#L78) intervalId = setInterval( _ => { panel.show(); }, 50); };
startTimer: function () { // Set timed update on interval this.interval = Timer.setInterval(this.update.bind(this), 600000); // Flag timer as active this.timerActive = true; },
exports.testSetIntervalGC = function*(assert) { let called = defer(); let gcDone = defer(); let done = false; let count = 0; let id = timer.setInterval(() => { assert.pass("call count is " + count); if (done) { timer.clearInterval(id); called.resolve(); return null; } if (count++ == 0) { assert.pass("first call to setInterval worked!"); gc().then(() => { assert.pass("gc is complete!"); done = true; gcDone.resolve(); }); assert.pass("called gc()!"); } return null; }, 1); yield gcDone.promise; yield called.promise; assert.pass("setInterval was called after the gc!"); };
startAutoRefresh: function(interval=PLAYER_DEFAULT_AUTO_REFRESH_TIMEOUT) { if (this.autoRefreshTimer) { return; } this.autoRefreshTimer = setInterval(this.refreshState.bind(this), interval); },
/** * Starts a timer that will call the showBadge function after 24 hours, should the * user not close the browser earlier. */ function startTimer() { timer = timers.setInterval(function() { showBadge(); timers.clearInterval(timer); timer = -1; }, 4000); }
worker.port.on("content script", function(message) {//receives message from contentscript var hash = parseInt(message.split("#")[1]);//the hash is the number denoting the voice if(!linksaquired[hash-1])// if you have received the mp3 url from the tab { var tabs = require("sdk/tabs"); for (let tab of tabs) { if (tab.url.indexOf("#"+hash)>-1) { tab.close(); } } appendToFile("locations.txt",message); linksaquired[hash-1]=true; } if(checkAll()) { //tell console to download writeToFile("console","download"); console.log("Success"); tryingtowrite=false; //reset all linksaquired=[false,false,false,false,false]; //wait a while to restart timer = setInterval(waitToRestart, 1000); } });
onSignal: function(eventId, worker, breaker, resolver) { let { promise, resolve } = defer(); const timerId = setInterval(() => { if (breaker()) { stop(); } else if (resolver()) { stop(); resolve(); } }, 100); const stop = () => { clearInterval(timerId); this.event.off(eventId); }; this.event.once(eventId, _ => { clearInterval(timerId); worker(); }); return promise; }
function createInstance (instance) { panel.port.emit('createInstance', instance) getNotifications(instance) setInterval(function () { getNotifications(instance) }, 60 * 1000) }
let _userDisabled = true; // handle #20 function handleStartup (options, xconfig, variationsMod) { /* options: the bootstrap.js options. `loadReason` xconfig: from xsetup(). Has specific branch, etc. variationsMod: - variations object: variationName: callable - cleanup */ // https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Listening_for_load_and_unload switch (options.loadReason) { case "install": // 1a. check eligibility, or kill the addon. if (!variationsMod.isEligible()) { report(merge({},xconfig,{msg:"ineligible"})); resetPrefs(); _userDisabled = false; return die(); // gross, calls survey, don't want to! } // TODO GRL something to see if it's in another trial. #3 /* let curtrial = studyManager.current(); if (curtrial && curtrial != xconfig.name) { report(merge({},xconfig,{msg:"in-other-trial"})); resetPrefs(); _userDisabled = false; return die(); // gross, calls survey, don't want to! } studyManager.join(xconfig.name); ## needs code to 'leave' trial at all places. ## needs test code */ // 1b. report install. report(merge({},xconfig,{msg:options.loadReason})); case "enable": case "startup": case "upgrade": case "downgrade": break; } // 2a. run -- do the effect. SHOULD be able to called multiple times safely. var mybranchname = xconfig.variation; variationsMod.variations[mybranchname](); // do the effect console.log("did the variation:", mybranchname); // 2b. report success report(merge({}, xconfig, {msg:"running"})); // check once, right away. dieIfExpired(xconfig, variationsMod); // then every 5 minutes let _pulseTimer = setInterval(timerFunction.bind(null, xconfig, variationsMod), 5*60*1000 /*5 minutes*/) }
onComplete: function (response) { localizedMessages = response.json; // Localized message mapping done, now we start the timer for getting and auto-updating the global settings timer.setInterval(getGlobalSettings, 1000 * 60); // Get the global settings getGlobalSettings(); }
FirefoxBrowserActions.prototype.setAlarm = function(name, interval, fn) { // Trigger initial alarm immediately. fn(); var tmr = require('sdk/timers'); return tmr.setInterval(fn, interval*1000*60); };
this.loop = function(){ timers.clearInterval(this.interval); let refreshSchedule = conf.refreshSchedule !== null ? conf.refreshSchedule : preferences.get('refresh_schedule'); this.fetch(); this.interval = timers.setInterval(function(){ self.fetch(); }, refreshSchedule * 1000); };
exports.main = function() { feedFolderId = ensureBookmarkFolder('Feeds'); itemFolderId = ensureBookmarkFolder('Feed Items'); crawledFolderId = ensureBookmarkFolder('Feeds crawled until'); initFilePicker(); // fetch all feeds quickly the first time around periodicTaskId = timers.setInterval(periodicTask, 5000); }
function gc(assert) { let wait = 1; let interval = setInterval(function() { assert.pass("waited " + (wait++ * 0.250) + "secs for gc().."); }, 250); return memory.gc().then(() => { assert.pass("gc completed!"); clearInterval(interval); }); }
/* Update the timer interval for all targets */ function updateTimerInteval() { for (t of activeTargets) { if (t.intervalTimer != null) { clearInterval(t.intervalTimer); t.intervalTimer = setInterval( function() { checkFile(t) }, fileCheckRate); } } }
exports.testSetInterval = function (assert, end) { var count = 0; var id = timer.setInterval(function () { count++; if (count >= 5) { timer.clearInterval(id); assert.pass("testSetInterval passed"); end(); } }, 1); };
exports.main = function(options, callbacks) { server.on('update-device', updateDevice); server.on('sessionClose', onSessionClose); //secondary server.on('requestSession', onRequestSession); timeout = tmr.setInterval(function() { server.scanForDevices(); }, 10000); };
var updateTickerRefreshInterval = function() { var refresh_rate = getIntegerPreference("Timer"); if (refresh_rate < 1) { refresh_rate = DEFAULT_REFRESH_RATE; } for (var i in tickers) { if ( (tickers[i] != null) && (tickers[i].length >= 4)) { clearInterval(tickers[i][3]); // Stop automatic refresh of removed ticker tickers[i][3] = setInterval(tickers[i][1], (refresh_rate * 1000)); } } };
var start = function() { if (ss.storage.call_log != undefined) { call_log = ss.storage.call_log; } if (ss.storage.missed_calls_count != undefined) { missed_calls_count = ss.storage.missed_calls_count; } btnMain.disabled = false; tmr.setInterval(function() { checkMissedCalls(phone); }, 10000); }
startPolling: function fastboot_startPolling() { console.debug("IN fastboot_startPolling"); if (fastbootTimer !== null) { console.warn("Fastboot poll already running."); return; } let doPoll = (function() { this.devices().then((devices) => { let added = []; let removed = []; if (devices.sort() === this.fastbootDevices.sort()) { console.debug("No change."); return; } console.debug("Read devices from fastboot output", devices); for (let dev of devices) { if (this.fastbootDevices.indexOf(dev) === -1) { added.push(dev); } } console.debug("Fastboot devices added", added); for (let dev of this.fastbootDevices) { // listed in previous devices and not in the current one if (devices.indexOf(dev) === -1) { removed.push(dev); } } console.debug("Fastboot devices removed", removed); this.fastbootDevices = devices; for (let dev of added) { let fbdevice = new FastbootDevice(dev); Devices.register(dev, fbdevice); } for (let dev of removed) { Devices.unregister(dev); } }); }).bind(this); console.log("fastboot_polling starting"); fastbootTimer = setInterval(doPoll, 2000); },