code review

This commit is contained in:
gorhill 2014-08-20 10:26:57 -04:00
parent 5275c73380
commit e5573eb985
3 changed files with 16 additions and 12 deletions

View File

@ -29,6 +29,7 @@
var userListName = chrome.i18n.getMessage('1pPageName'); var userListName = chrome.i18n.getMessage('1pPageName');
var listDetails = {}; var listDetails = {};
var cosmeticSwitch = true;
var externalLists = ''; var externalLists = '';
var cacheWasPurged = false; var cacheWasPurged = false;
var needUpdate = false; var needUpdate = false;
@ -67,18 +68,11 @@ var renderNumber = function(value) {
// TODO: get rid of background page dependencies // TODO: get rid of background page dependencies
var renderBlacklists = function() { var renderBlacklists = function() {
// empty list first
var µb = getµb(); var µb = getµb();
uDom('#listsOfBlockedHostsPrompt').text(
chrome.i18n.getMessage('3pListsOfBlockedHostsPrompt')
.replace('{{netFilterCount}}', renderNumber(µb.abpFilters.getFilterCount()))
.replace('{{cosmeticFilterCount}}', renderNumber(µb.abpHideFilters.getFilterCount()))
);
// Assemble a pretty blacklist name if possible // Assemble a pretty blacklist name if possible
var htmlFromListName = function(blacklistTitle, blacklistHref) { var htmlFromListName = function(blacklistTitle, blacklistHref) {
if ( blacklistHref === µb.userFiltersPath ) { if ( blacklistHref === listDetails.userFiltersPath ) {
return userListName; return userListName;
} }
if ( !blacklistTitle ) { if ( !blacklistTitle ) {
@ -197,6 +191,7 @@ var renderBlacklists = function() {
var onListsReceived = function(details) { var onListsReceived = function(details) {
listDetails = details; listDetails = details;
cosmeticSwitch = details.cosmetic;
needUpdate = false; needUpdate = false;
var lists = details.available; var lists = details.available;
@ -226,6 +221,11 @@ var renderBlacklists = function() {
delete groups[groupKey]; delete groups[groupKey];
} }
uDom('#listsOfBlockedHostsPrompt').text(
chrome.i18n.getMessage('3pListsOfBlockedHostsPrompt')
.replace('{{netFilterCount}}', renderNumber(details.netFilterCount))
.replace('{{cosmeticFilterCount}}', renderNumber(details.cosmeticFilterCount))
);
uDom('#lists .listDetails').remove(); uDom('#lists .listDetails').remove();
uDom('#lists').html(html.join('')); uDom('#lists').html(html.join(''));
uDom('#autoUpdate').prop('checked', listDetails.autoUpdate === true); uDom('#autoUpdate').prop('checked', listDetails.autoUpdate === true);
@ -242,7 +242,7 @@ var renderBlacklists = function() {
// Return whether selection of lists changed. // Return whether selection of lists changed.
var listsSelectionChanged = function() { var listsSelectionChanged = function() {
if ( listDetails.cosmetic !== getµb().userSettings.parseAllABPHideFilters ) { if ( listDetails.cosmetic !== cosmeticSwitch ) {
return true; return true;
} }
if ( cacheWasPurged ) { if ( cacheWasPurged ) {
@ -393,7 +393,7 @@ var autoUpdateCheckboxChanged = function() {
/******************************************************************************/ /******************************************************************************/
var abpHideFiltersCheckboxChanged = function() { var cosmeticSwitchChanged = function() {
listDetails.cosmetic = this.checked; listDetails.cosmetic = this.checked;
updateApplyButtons(); updateApplyButtons();
}; };
@ -435,7 +435,7 @@ var externalListsApplyHandler = function() {
uDom.onLoad(function() { uDom.onLoad(function() {
// Handle user interaction // Handle user interaction
uDom('#autoUpdate').on('change', autoUpdateCheckboxChanged); uDom('#autoUpdate').on('change', autoUpdateCheckboxChanged);
uDom('#parseCosmeticFilters').on('change', abpHideFiltersCheckboxChanged); uDom('#parseCosmeticFilters').on('change', cosmeticSwitchChanged);
uDom('#buttonApply').on('click', buttonApplyHandler); uDom('#buttonApply').on('click', buttonApplyHandler);
uDom('#buttonUpdate').on('click', buttonUpdateHandler); uDom('#buttonUpdate').on('click', buttonUpdateHandler);
uDom('#lists').on('change', '.listDetails > input', onListCheckboxChanged); uDom('#lists').on('change', '.listDetails > input', onListCheckboxChanged);

View File

@ -1000,7 +1000,8 @@ exports.metadata = function(callback) {
entryOut.homeURL = path; entryOut.homeURL = path;
} }
} }
getRepoMetadata(onRepoMetaReady); // Always ask for most up-to-date version
getRepoMetadata(onRepoMetaReady, true);
}; };
cachedAssetsManager.entries(onCacheMetaReady); cachedAssetsManager.entries(onCacheMetaReady);

View File

@ -250,7 +250,10 @@ var getLists = function(callback) {
available: null, available: null,
current: µb.remoteBlacklists, current: µb.remoteBlacklists,
cosmetic: µb.userSettings.parseAllABPHideFilters, cosmetic: µb.userSettings.parseAllABPHideFilters,
netFilterCount: µb.abpFilters.getFilterCount(),
cosmeticFilterCount: µb.abpHideFilters.getFilterCount(),
autoUpdate: µb.userSettings.autoUpdate, autoUpdate: µb.userSettings.autoUpdate,
userFiltersPath: µb.userFiltersPath,
cache: null cache: null
}; };
var onMetadataReady = function(entries) { var onMetadataReady = function(entries) {