Skip to content

Commit

Permalink
cleaning up old stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 10, 2015
1 parent 35ac2cc commit 67417c5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 82 deletions.
1 change: 0 additions & 1 deletion src/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<script src="js/vapi-common.js"></script>
<script src="js/vapi-background.js"></script>
<script src="js/background.js"></script>
<script src="js/xal.js"></script>
<script src="js/async.js"></script>
<script src="js/utils.js"></script>
<script src="js/uritools.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/js/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ AsyncJobManager.prototype.restartTimer = function() {
// TODO: Maybe use chrome.alarms() API when the next job is at more than
// one minute in the future... From reading about it, chrome.alarms() is
// smarter in that it will fire the event only when the browser is not
// too busy. (through XAL to abstract API specificities)
// too busy.
if ( when < this.timerWhen ) {
clearTimeout(this.timerId);
this.timerWhen = when;
Expand Down
20 changes: 10 additions & 10 deletions src/js/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ var backupUserData = function(callback) {

µb.restoreBackupSettings.lastBackupFile = filename;
µb.restoreBackupSettings.lastBackupTime = Date.now();
µb.XAL.keyvalSetMany(µb.restoreBackupSettings);
µb.keyvalSetMany(µb.restoreBackupSettings);

getLocalData(callback);
};
Expand All @@ -1135,20 +1135,20 @@ var restoreUserData = function(request) {

var onAllRemoved = function() {
// Be sure to adjust `countdown` if adding/removing anything below
µb.XAL.keyvalSetOne('version', userData.version);
µb.keyvalSetOne('version', userData.version);
µBlock.saveLocalSettings(true);
µb.XAL.keyvalSetMany(userData.userSettings, onCountdown);
µb.XAL.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
µb.XAL.keyvalSetOne('netWhitelist', userData.netWhitelist || '', onCountdown);
µb.keyvalSetMany(userData.userSettings, onCountdown);
µb.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
µb.keyvalSetOne('netWhitelist', userData.netWhitelist || '', onCountdown);

// With versions 0.9.2.4-, dynamic rules were saved within the
// `userSettings` object. No longer the case.
var s = userData.dynamicFilteringString || userData.userSettings.dynamicFilteringString || '';
µb.XAL.keyvalSetOne('dynamicFilteringString', s, onCountdown);
µb.keyvalSetOne('dynamicFilteringString', s, onCountdown);

µb.XAL.keyvalSetOne('hostnameSwitchesString', userData.hostnameSwitchesString || '', onCountdown);
µb.keyvalSetOne('hostnameSwitchesString', userData.hostnameSwitchesString || '', onCountdown);
µb.assets.put('assets/user/filters.txt', userData.userFilters, onCountdown);
µb.XAL.keyvalSetMany({
µb.keyvalSetMany({
lastRestoreFile: request.file || '',
lastRestoreTime: Date.now(),
lastBackupFile: '',
Expand All @@ -1162,13 +1162,13 @@ var restoreUserData = function(request) {

// If we are going to restore all, might as well wipe out clean local
// storage
µb.XAL.keyvalRemoveAll(onAllRemoved);
vAPI.storage.clear(onAllRemoved);
};

/******************************************************************************/

var resetUserData = function() {
µb.XAL.keyvalRemoveAll();
vAPI.storage.clear();

// Keep global counts, people can become quite attached to numbers
µb.saveLocalSettings(true);
Expand Down
2 changes: 1 addition & 1 deletion src/js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ var onUserSettingsReady = function(fetched) {

// Remove obsolete setting
delete userSettings.logRequests;
µb.XAL.keyvalRemoveOne('logRequests');
vAPI.storage.remove('logRequests');
};

/******************************************************************************/
Expand Down
18 changes: 16 additions & 2 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@

/******************************************************************************/

µBlock.keyvalSetOne = function(key, val, callback) {
var bin = {};
bin[key] = val;
vAPI.storage.set(bin, callback || this.noopFunc);
};

/******************************************************************************/

µBlock.keyvalSetMany = function(dict, callback) {
vAPI.storage.set(dict, callback || this.noopFunc);
};

/******************************************************************************/

µBlock.saveLocalSettings = function(force) {
if ( force ) {
this.localSettingsModifyTime = Date.now();
Expand Down Expand Up @@ -70,13 +84,13 @@
/******************************************************************************/

µBlock.savePermanentFirewallRules = function() {
this.XAL.keyvalSetOne('dynamicFilteringString', this.permanentFirewall.toString());
this.keyvalSetOne('dynamicFilteringString', this.permanentFirewall.toString());
};

/******************************************************************************/

µBlock.saveHostnameSwitches = function() {
this.XAL.keyvalSetOne('hostnameSwitchesString', this.hnSwitches.toString());
this.keyvalSetOne('hostnameSwitchesString', this.hnSwitches.toString());
};

/******************************************************************************/
Expand Down
67 changes: 0 additions & 67 deletions src/js/xal.js

This file was deleted.

0 comments on commit 67417c5

Please sign in to comment.