mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-26 18:10:39 +12:00
this fixes #14
This commit is contained in:
parent
77cfb56d94
commit
5e96f44798
|
@ -83,9 +83,11 @@ tr.unused {
|
||||||
|
|
||||||
<h2 data-i18n="statsPageDetailedStats" id="detailed-stats"></h2>
|
<h2 data-i18n="statsPageDetailedStats" id="detailed-stats"></h2>
|
||||||
<div>
|
<div>
|
||||||
|
<select id="selectPageUrlsTemplate" style="display: none;">
|
||||||
|
<option value="all" data-i18n="statsPageDetailedAllPages"></option>
|
||||||
|
<option value="http://chromium-behind-the-scene/" data-i18n="statsPageDetailedBehindTheScenePage"></option>
|
||||||
|
</select>
|
||||||
<select id="selectPageUrls">
|
<select id="selectPageUrls">
|
||||||
<option value="all" data-i18n="statsPageDetailedAllPages"></option>
|
|
||||||
<option id="selectPageUrlTemplate" value="http://chromium-behind-the-scene/" data-i18n="statsPageDetailedBehindTheScenePage"></option>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<h3 data-i18n="statsPageOverview"></h3>
|
<h3 data-i18n="statsPageOverview"></h3>
|
||||||
|
|
|
@ -68,16 +68,7 @@ function renderNumber(value) {
|
||||||
if ( isNaN(value) ) {
|
if ( isNaN(value) ) {
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
// TODO: localization
|
return value.toLocaleString();
|
||||||
if ( +value > 1000 ) {
|
|
||||||
value = value.toString();
|
|
||||||
var i = value.length - 3;
|
|
||||||
while ( i > 0 ) {
|
|
||||||
value = value.slice(0, i) + ',' + value.slice(i);
|
|
||||||
i -= 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -110,13 +101,20 @@ var renderLocalized = function(id, map) {
|
||||||
|
|
||||||
function renderPageUrls() {
|
function renderPageUrls() {
|
||||||
var onResponseReceived = function(r) {
|
var onResponseReceived = function(r) {
|
||||||
var select = $('#selectPageUrls');
|
var i, n;
|
||||||
|
var select = uDom('#selectPageUrls');
|
||||||
// One of the permanent entry will serve as a template
|
|
||||||
var optionTemplate = $('#selectPageUrlTemplate', select);
|
|
||||||
|
|
||||||
// Remove whatever was put there in a previous call
|
// Remove whatever was put there in a previous call
|
||||||
$(optionTemplate).nextAll().remove();
|
uDom('#selectPageUrls > option').remove();
|
||||||
|
var builtinOptions = uDom('#selectPageUrlsTemplate > option');
|
||||||
|
var n = builtinOptions.length;
|
||||||
|
for ( i = 0; i < n; i++ ) {
|
||||||
|
option = builtinOptions.at(i).clone();
|
||||||
|
if ( option.val() === targetUrl ) {
|
||||||
|
option.attr('selected', true);
|
||||||
|
}
|
||||||
|
select.append(option);
|
||||||
|
}
|
||||||
|
|
||||||
var pageURLs = r.pageURLs.sort();
|
var pageURLs = r.pageURLs.sort();
|
||||||
var pageURL, option;
|
var pageURL, option;
|
||||||
|
@ -126,16 +124,18 @@ function renderPageUrls() {
|
||||||
if ( pageURL === r.behindTheSceneURL ) {
|
if ( pageURL === r.behindTheSceneURL ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
option = optionTemplate.clone();
|
option = uDom('<option>');
|
||||||
option.attr('id', '');
|
option.val(pageURL);
|
||||||
option.attr('value', pageURL);
|
|
||||||
option.text(pageURL);
|
option.text(pageURL);
|
||||||
|
if ( pageURL === targetUrl ) {
|
||||||
|
option.attr('selected', true);
|
||||||
|
}
|
||||||
select.append(option);
|
select.append(option);
|
||||||
}
|
}
|
||||||
// Deselect whatever is currently selected
|
// Deselect whatever is currently selected
|
||||||
$('option:selected', select).prop('selected', false);
|
//uDom('#selectPageUrls > option:selected').prop('selected', false);
|
||||||
// Select whatever needs to be selected
|
// Select whatever needs to be selected
|
||||||
$('option[value="'+targetUrl+'"]', select).prop('selected', true);
|
//uDom('#selectPageUrls > option[value="'+targetUrl+'"]').prop('selected', true);
|
||||||
};
|
};
|
||||||
messaging.ask({ what: 'getPageURLs' }, onResponseReceived);
|
messaging.ask({ what: 'getPageURLs' }, onResponseReceived);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,8 @@ var addListToList = function(list, other) {
|
||||||
var addSelectorToList = function(list, selector, context) {
|
var addSelectorToList = function(list, selector, context) {
|
||||||
var p = context || document;
|
var p = context || document;
|
||||||
var r = p.querySelectorAll(selector);
|
var r = p.querySelectorAll(selector);
|
||||||
var i = r.length;
|
var n = r.length;
|
||||||
while ( i-- ) {
|
for ( var i = 0; i < n; i++ ) {
|
||||||
list.nodes.push(r[i]);
|
list.nodes.push(r[i]);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
Loading…
Reference in a new issue