From 186c64998432fb7a37bf8e660284ef05741d758d Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 8 May 2015 09:02:12 -0400 Subject: [PATCH] thsi fixes #170 --- src/css/hosts-files.css | 2 +- src/js/hosts-files.js | 15 ++++++++------- src/js/start.js | 7 +++++-- src/js/storage.js | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/css/hosts-files.css b/src/css/hosts-files.css index da5b114..43d085d 100644 --- a/src/css/hosts-files.css +++ b/src/css/hosts-files.css @@ -118,7 +118,7 @@ body[dir="rtl"] #externalListsDiv { font-size: smaller; width: 100%; height: 12em; - white-space: nowrap; + white-space: pre; } body #busyOverlay { background-color: transparent; diff --git a/src/js/hosts-files.js b/src/js/hosts-files.js index 01e8930..37612a6 100644 --- a/src/js/hosts-files.js +++ b/src/js/hosts-files.js @@ -72,6 +72,7 @@ var renderHostsFiles = function() { var listStatsTemplate = vAPI.i18n('hostsFilesPerFileStats'); var lastUpdateString = vAPI.i18n('hostsFilesLastUpdate'); var renderElapsedTimeToString = vAPI.i18n.renderElapsedTimeToString; + var reExternalHostFile = /^https?:/; // Assemble a pretty blacklist name if possible var listNameFromListKey = function(listKey) { @@ -154,16 +155,16 @@ var renderHostsFiles = function() { var availableLists = details.available; var listKeys = Object.keys(details.available); + + // Sort works this way: + // - Send /^https?:/ items at the end (custom hosts file URL) listKeys.sort(function(a, b) { - var ta = availableLists[a].title || ''; - var tb = availableLists[b].title || ''; - if ( ta !== '' && tb !== '' ) { + var ta = availableLists[a].title || a; + var tb = availableLists[b].title || b; + if ( reExternalHostFile.test(ta) === reExternalHostFile.test(tb) ) { return ta.localeCompare(tb); } - if ( ta === '' && tb === '' ) { - return a.localeCompare(b); - } - if ( tb === '' ) { + if ( reExternalHostFile.test(tb) ) { return -1; } return 1; diff --git a/src/js/start.js b/src/js/start.js index 2521b5a..1ae8536 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -125,9 +125,12 @@ var onHostsFilesLoaded = function() { µm.assets.remoteFetchBarrier -= 1; }; -var onPSLReady = function() { +var onUserSettingsLoaded = function() { µm.loadHostsFiles(onHostsFilesLoaded); - µm.loadUserSettings(); +}; + +var onPSLReady = function() { + µm.loadUserSettings(onUserSettingsLoaded); µm.loadMatrix(); // rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the diff --git a/src/js/storage.js b/src/js/storage.js index e140456..7d097fe 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -108,7 +108,7 @@ if ( availableEntry === undefined ) { continue; } - storedEntry = lists[oldLocation]; + storedEntry = lists[oldLocation] || {}; availableEntry.off = storedEntry.off || false; µm.assets.setHomeURL(newLocation, availableEntry.homeURL); if ( storedEntry.entryCount !== undefined ) { @@ -118,7 +118,7 @@ availableEntry.entryUsedCount = storedEntry.entryUsedCount; } // This may happen if the list name was pulled from the list content - if ( availableEntry.title === '' && storedEntry.title !== '' ) { + if ( availableEntry.title === '' && storedEntry.title !== undefined ) { availableEntry.title = storedEntry.title; } } @@ -177,7 +177,7 @@ continue; } availableHostsFiles[location] = { - title: '', + title: location, external: true }; }