Browse Source

thsi fixes #170

pull/2/head
gorhill 10 years ago
parent
commit
186c649984
  1. 2
      src/css/hosts-files.css
  2. 15
      src/js/hosts-files.js
  3. 7
      src/js/start.js
  4. 6
      src/js/storage.js

2
src/css/hosts-files.css

@ -118,7 +118,7 @@ body[dir="rtl"] #externalListsDiv {
font-size: smaller; font-size: smaller;
width: 100%; width: 100%;
height: 12em; height: 12em;
white-space: nowrap;
white-space: pre;
} }
body #busyOverlay { body #busyOverlay {
background-color: transparent; background-color: transparent;

15
src/js/hosts-files.js

@ -72,6 +72,7 @@ var renderHostsFiles = function() {
var listStatsTemplate = vAPI.i18n('hostsFilesPerFileStats'); var listStatsTemplate = vAPI.i18n('hostsFilesPerFileStats');
var lastUpdateString = vAPI.i18n('hostsFilesLastUpdate'); var lastUpdateString = vAPI.i18n('hostsFilesLastUpdate');
var renderElapsedTimeToString = vAPI.i18n.renderElapsedTimeToString; var renderElapsedTimeToString = vAPI.i18n.renderElapsedTimeToString;
var reExternalHostFile = /^https?:/;
// Assemble a pretty blacklist name if possible // Assemble a pretty blacklist name if possible
var listNameFromListKey = function(listKey) { var listNameFromListKey = function(listKey) {
@ -154,16 +155,16 @@ var renderHostsFiles = function() {
var availableLists = details.available; var availableLists = details.available;
var listKeys = Object.keys(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) { 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); return ta.localeCompare(tb);
} }
if ( ta === '' && tb === '' ) {
return a.localeCompare(b);
}
if ( tb === '' ) {
if ( reExternalHostFile.test(tb) ) {
return -1; return -1;
} }
return 1; return 1;

7
src/js/start.js

@ -125,9 +125,12 @@ var onHostsFilesLoaded = function() {
µm.assets.remoteFetchBarrier -= 1; µm.assets.remoteFetchBarrier -= 1;
}; };
var onPSLReady = function() {
var onUserSettingsLoaded = function() {
µm.loadHostsFiles(onHostsFilesLoaded); µm.loadHostsFiles(onHostsFilesLoaded);
µm.loadUserSettings();
};
var onPSLReady = function() {
µm.loadUserSettings(onUserSettingsLoaded);
µm.loadMatrix(); µm.loadMatrix();
// rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the // rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the

6
src/js/storage.js

@ -108,7 +108,7 @@
if ( availableEntry === undefined ) { if ( availableEntry === undefined ) {
continue; continue;
} }
storedEntry = lists[oldLocation];
storedEntry = lists[oldLocation] || {};
availableEntry.off = storedEntry.off || false; availableEntry.off = storedEntry.off || false;
µm.assets.setHomeURL(newLocation, availableEntry.homeURL); µm.assets.setHomeURL(newLocation, availableEntry.homeURL);
if ( storedEntry.entryCount !== undefined ) { if ( storedEntry.entryCount !== undefined ) {
@ -118,7 +118,7 @@
availableEntry.entryUsedCount = storedEntry.entryUsedCount; availableEntry.entryUsedCount = storedEntry.entryUsedCount;
} }
// This may happen if the list name was pulled from the list content // 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; availableEntry.title = storedEntry.title;
} }
} }
@ -177,7 +177,7 @@
continue; continue;
} }
availableHostsFiles[location] = { availableHostsFiles[location] = {
title: '',
title: location,
external: true external: true
}; };
} }

Loading…
Cancel
Save