code review

pull/2/head
gorhill 10 years ago
parent 4dd3b09ae4
commit 4b4dc3c0db

@ -27,8 +27,7 @@ var loadDashboardPanel = function(hash) {
var button = uDom(hash);
var url = button.attr('data-dashboard-panel-url');
uDom('iframe').nodeAt(0).src = url;
uDom('.tabButton').toArray().forEach(function(tab){
var button = uDom(tab);
uDom('.tabButton').forEach(function(button){
button.toggleClass('selected', button.attr('data-dashboard-panel-url') === url);
});
}

@ -314,8 +314,7 @@ function changeFilterHandler() {
// Initialize request filters as per user settings:
// https://github.com/gorhill/httpswitchboard/issues/49
var statsFilters = cachedUserSettings.statsFilters;
uDom('input[id^="show-"][type="checkbox"]').toArray().forEach(function(elem) {
var input = uDom(elem);
uDom('input[id^="show-"][type="checkbox"]').forEach(function(input) {
statsFilters[input.attr('id')] = !!input.prop('checked');
});
changeUserSettings('statsFilters', statsFilters);
@ -396,8 +395,7 @@ uDom.onLoad(function(){
// init ui as per user settings
uDom('#max-logged-requests').val(userSettings.maxLoggedRequests);
var statsFilters = userSettings.statsFilters;
uDom('input[id^="show-"][type="checkbox"]').toArray().forEach(function(elem) {
var input = uDom(elem);
uDom('input[id^="show-"][type="checkbox"]').forEach(function(input) {
var filter = statsFilters[input.attr('id')];
input.prop('checked', filter === undefined || filter === true);
});

@ -109,12 +109,12 @@ uDom.onLoad(function() {
// `data-range` allows to add/remove bool properties without
// changing code.
uDom('input[data-range="bool"]').toArray().forEach(function(elem) {
elem.checked = userSettings[elem.id] === true;
uDom('input[data-range="bool"]').forEach(function(elem) {
elem.prop('checked', userSettings[elem.attr('id')] === true);
});
uDom('input[name="displayTextSize"]').toArray().forEach(function(elem) {
elem.checked = elem.value === userSettings.displayTextSize;
uDom('input[name="displayTextSize"]').forEach(function(elem) {
elem.prop('checked', elem.val() === userSettings.displayTextSize);
});
uDom('#smart-auto-reload').val(userSettings.smartAutoReload);
uDom('#subframe-color').val(userSettings.subframeColor);

@ -228,6 +228,14 @@ DOMList.prototype.toArray = function() {
/******************************************************************************/
DOMList.prototype.forEach = function(fn) {
for ( var i = 0; i < this.nodes.length; i++ ) {
fn(this.at(i), i);
}
};
/******************************************************************************/
DOMList.prototype.subset = function(i, l) {
var r = new DOMList();
var n = l !== undefined ? l : this.nodes.length;
@ -355,16 +363,6 @@ DOMList.prototype.contents = function() {
/******************************************************************************/
DOMList.prototype.forEach = function(callback) {
var n = this.nodes.length;
for ( var i = 0; i < n; i++ ) {
callback.bind(this.nodes[i]).call();
}
return this;
};
/******************************************************************************/
DOMList.prototype.remove = function() {
var cn, p;
var i = this.nodes.length;

Loading…
Cancel
Save