www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit dc8c6958554156f23bc54c1be5e623b0eea97a20
parent 691993a6c3a5cecf27ae4afffddfbae6f55e92d0
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun, 25 Jun 2006 07:34:03 +0000

Fixes #11, Observe user pref to turn off automatic scraper updates


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/schema.js | 32++++++++++++++++++++------------
Mchrome/chromeFiles/content/scholar/xpcom/scholar.js | 9+++++++--
2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/schema.js b/chrome/chromeFiles/content/scholar/xpcom/schema.js @@ -50,18 +50,26 @@ Scholar.Schema = new function(){ * since the last check **/ function updateScrapersRemote(force){ - // Determine the earliest local time that we'd query the repository again - var nextCheck = new Date(); - nextCheck.setTime((parseInt(_getDBVersion('lastcheck')) - + SCHOLAR_CONFIG['REPOSITORY_CHECK_INTERVAL']) * 1000); // JS uses ms - var now = new Date(); - - // If enough time hasn't passed and it's not being forced, don't update - if (!force && now < nextCheck){ - Scholar.debug('Not enough time since last update -- not checking repository', 4); - // Set the repository timer to the remaining time - _setRepositoryTimer(Math.round((nextCheck.getTime() - now.getTime()) / 1000)); - return false; + if (!force){ + // Check user preference for automatic updates + if (!Scholar.Prefs.get('automaticScraperUpdates')){ + Scholar.debug('Automatic scraper updating disabled -- not checking repository', 4); + return false; + } + + // Determine the earliest local time that we'd query the repository again + var nextCheck = new Date(); + nextCheck.setTime((parseInt(_getDBVersion('lastcheck')) + + SCHOLAR_CONFIG['REPOSITORY_CHECK_INTERVAL']) * 1000); // JS uses ms + var now = new Date(); + + // If enough time hasn't passed, don't update + if (now < nextCheck){ + Scholar.debug('Not enough time since last update -- not checking repository', 4); + // Set the repository timer to the remaining time + _setRepositoryTimer(Math.round((nextCheck.getTime() - now.getTime()) / 1000)); + return false; + } } // Get the last timestamp we got from the server diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js @@ -369,8 +369,13 @@ Scholar.Prefs = new function(){ // subject is the nsIPrefBranch we're observing (after appropriate QI) // data is the name of the pref that's been changed (relative to subject) switch (data){ - case "pref1": - // pref1 changed + case "automaticScraperUpdates": + if (this.get('automaticScraperUpdates')){ + Scholar.Schema.updateScrapersRemote(); + } + else { + Scholar.Schema.stopRepositoryTimer(); + } break; } }