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 button = uDom(hash);
var url = button.attr('data-dashboard-panel-url'); var url = button.attr('data-dashboard-panel-url');
uDom('iframe').nodeAt(0).src = url; uDom('iframe').nodeAt(0).src = url;
uDom('.tabButton').toArray().forEach(function(tab){ uDom('.tabButton').forEach(function(button){
var button = uDom(tab);
button.toggleClass('selected', button.attr('data-dashboard-panel-url') === url); button.toggleClass('selected', button.attr('data-dashboard-panel-url') === url);
}); });
} }

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

@ -109,12 +109,12 @@ uDom.onLoad(function() {
// `data-range` allows to add/remove bool properties without // `data-range` allows to add/remove bool properties without
// changing code. // changing code.
uDom('input[data-range="bool"]').toArray().forEach(function(elem) { uDom('input[data-range="bool"]').forEach(function(elem) {
elem.checked = userSettings[elem.id] === true; elem.prop('checked', userSettings[elem.attr('id')] === true);
}); });
uDom('input[name="displayTextSize"]').toArray().forEach(function(elem) { uDom('input[name="displayTextSize"]').forEach(function(elem) {
elem.checked = elem.value === userSettings.displayTextSize; elem.prop('checked', elem.val() === userSettings.displayTextSize);
}); });
uDom('#smart-auto-reload').val(userSettings.smartAutoReload); uDom('#smart-auto-reload').val(userSettings.smartAutoReload);
uDom('#subframe-color').val(userSettings.subframeColor); 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) { DOMList.prototype.subset = function(i, l) {
var r = new DOMList(); var r = new DOMList();
var n = l !== undefined ? l : this.nodes.length; 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() { DOMList.prototype.remove = function() {
var cn, p; var cn, p;
var i = this.nodes.length; var i = this.nodes.length;

Loading…
Cancel
Save