Fix jshint warnings
Since nobody ran jshint on our js code, there are some warnings, including at least one bug. Change-Id: Ied755e8a38b3b34273f3e5d40bcbeb502b3b9783
This commit is contained in:
parent
339a8d3450
commit
feb8f4ac4a
@ -131,29 +131,26 @@ horizon.Capacity = {
|
||||
// Draw the initial d3 bars
|
||||
_initialCreation: function(bars) {
|
||||
var scope = this;
|
||||
|
||||
$(bars).each(function(index, element) {
|
||||
var progress_element = $(element);
|
||||
|
||||
var capacity_limit = parseInt(progress_element.attr('data-capacity-limit'), 10);
|
||||
var capacity_used = parseInt(progress_element.attr('data-capacity-used'), 10);
|
||||
var average_used = parseInt(progress_element.attr('data-average-capacity-used'), 10);
|
||||
var percentage_used = 0;
|
||||
var average_percentage = 0;
|
||||
var _used_px = 0;
|
||||
|
||||
if (!isNaN(capacity_limit) && !isNaN(average_used)) {
|
||||
var average_percentage = ((average_used / capacity_limit) * 100);
|
||||
} else {
|
||||
var average_percentage = 0;
|
||||
average_percentage = ((average_used / capacity_limit) * 100);
|
||||
}
|
||||
|
||||
if (!isNaN(capacity_limit) && !isNaN(capacity_used)) {
|
||||
var percentage_used = Math.round((capacity_used / capacity_limit) * 100);
|
||||
var used_px = progress_element.width() / 100 * percentage_used;
|
||||
|
||||
} else { // If NaN percentage_used is 0
|
||||
var percentage_used = 0;
|
||||
var used_px = 0;
|
||||
percentage_used = Math.round((capacity_used / capacity_limit) * 100);
|
||||
_used_px = progress_element.width() / 100 * percentage_used;
|
||||
}
|
||||
|
||||
scope.drawUsed($(element).attr('id'), percentage_used, used_px, average_percentage);
|
||||
scope.drawUsed($(element).attr('id'), percentage_used, _used_px, average_percentage);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ horizon.d3_circles_chart = {
|
||||
}
|
||||
|
||||
this.time = jquery_element.data('time');
|
||||
this.data = []
|
||||
this.data = [];
|
||||
|
||||
this.refresh = refresh;
|
||||
function refresh(){
|
||||
@ -130,7 +130,7 @@ horizon.d3_circles_chart = {
|
||||
self.bind_commands();
|
||||
},
|
||||
refresh: function(html_element){
|
||||
var chart = new this.CirclesChart(this, html_element)
|
||||
var chart = new this.CirclesChart(this, html_element);
|
||||
// FIXME save chart objects somewhere so I can use them again when
|
||||
// e.g. I am swithing tabs, or if I want to update them
|
||||
// via web sockets
|
||||
@ -143,7 +143,7 @@ horizon.d3_circles_chart = {
|
||||
// library
|
||||
var width = size + 4,
|
||||
height = size + 4,
|
||||
round = size / 2;
|
||||
round = size / 2,
|
||||
center_x = width / 2,
|
||||
center_y = height / 2;
|
||||
|
||||
@ -171,27 +171,30 @@ horizon.d3_circles_chart = {
|
||||
.attr("cx", center_x)
|
||||
.attr("cy", center_y)
|
||||
.attr("stroke", "#cecece")
|
||||
.attr("stroke-width", function(d) {
|
||||
.attr("stroke-width", function (d) {
|
||||
return 1;
|
||||
})
|
||||
.style("fill", function(d) {
|
||||
if (d.color){
|
||||
.style("fill", function (d) {
|
||||
if (d.color) {
|
||||
return d.color;
|
||||
} else if (settings.scale == "linear_color_scale"){
|
||||
return self.linear_color_scale(d.percentage, settings.domain, settings.range)
|
||||
|
||||
} else if (settings.scale == "linear_color_scale") {
|
||||
return self.linear_color_scale(d.percentage, settings.domain, settings.range);
|
||||
}
|
||||
})
|
||||
.on("mouseover", function(d){
|
||||
.on("mouseover", function (d) {
|
||||
if (d.tooltip) {
|
||||
tooltip.html(d.tooltip);
|
||||
} else {
|
||||
tooltip.html(d.name + "<br/>" + d.status);
|
||||
}
|
||||
tooltip.style("visibility", "visible");})
|
||||
.on("mousemove", function(d){tooltip.style("top", (event.pageY-10)+"px").style("left",(event.pageX+10)+"px");})
|
||||
.on("mouseout", function(d){tooltip.style("visibility", "hidden");});
|
||||
;
|
||||
tooltip.style("visibility", "visible");
|
||||
})
|
||||
.on("mousemove", function (d) {
|
||||
tooltip.style("top", (event.pageY-10)+"px").style("left",(event.pageX+10)+"px");
|
||||
})
|
||||
.on("mouseout", function (d) {
|
||||
tooltip.style("visibility", "hidden");
|
||||
});
|
||||
|
||||
/*
|
||||
// or just d3 title element
|
||||
@ -210,15 +213,15 @@ horizon.d3_circles_chart = {
|
||||
var change_time_command_selector = 'select[data-circles-chart-command="change_time"]';
|
||||
var change_url_command_selector = '[data-circles-chart-command="change_url"]';
|
||||
var self = this;
|
||||
bind_change_time = function(){
|
||||
bind_change_time = function () {
|
||||
$(change_time_command_selector).each(function() {
|
||||
$(this).change(function(){
|
||||
$(this).change(function () {
|
||||
var invoker = $(this);
|
||||
var command = new self.Command.ChangeTime(self, invoker);
|
||||
command.execute();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
bind_change_url = function(){
|
||||
$(change_url_command_selector + ' a').click(function (e) {
|
||||
// Bootstrap tabs functionality
|
||||
@ -229,8 +232,8 @@ horizon.d3_circles_chart = {
|
||||
var invoker = $(this);
|
||||
var command = new self.Command.ChangeUrl(self, invoker);
|
||||
command.execute();
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
bind_change_time();
|
||||
bind_change_url();
|
||||
},
|
||||
@ -248,7 +251,7 @@ horizon.d3_circles_chart = {
|
||||
// change time of the chart
|
||||
$(this).data('time', self.new_time);
|
||||
// refresh the chart
|
||||
chart_class.refresh(this)
|
||||
chart_class.refresh(this);
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -265,12 +268,12 @@ horizon.d3_circles_chart = {
|
||||
// change time of the chart
|
||||
$(this).data('url', self.new_url);
|
||||
// refresh the chart
|
||||
chart_class.refresh(this)
|
||||
chart_class.refresh(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* init the graphs */
|
||||
horizon.addInitFunction(function () {
|
||||
|
@ -429,6 +429,7 @@ horizon.d3_single_bar_chart = {
|
||||
.attr("height", base_component.h)
|
||||
.style("background-color", "white")
|
||||
.append("g");
|
||||
var used_component;
|
||||
|
||||
// append Unused resources Bar
|
||||
this.append_unused(bar, base_component, tooltip_free);
|
||||
@ -444,19 +445,19 @@ horizon.d3_single_bar_chart = {
|
||||
tooltip_used = this.append_tooltip(tooltip_used, "");
|
||||
|
||||
// append used so it will be shown as multiple values in one chart
|
||||
var used_component = new this.UsedComponent(base_component);
|
||||
used_component = new this.UsedComponent(base_component);
|
||||
used_component.append(bar, tooltip_used);
|
||||
|
||||
// append Used resources to Bar
|
||||
base_component.total_used_perc += base_component.percentage_used_value();
|
||||
};
|
||||
}
|
||||
|
||||
// append Text to Bar
|
||||
this.append_text(bar, base_component, tooltip_free);
|
||||
|
||||
} else {
|
||||
// used is show as one value it the chart
|
||||
var used_component = new this.UsedComponent(base_component);
|
||||
used_component = new this.UsedComponent(base_component);
|
||||
used_component.append(bar, tooltip_used);
|
||||
|
||||
// append average value to Bar
|
||||
@ -465,7 +466,7 @@ horizon.d3_single_bar_chart = {
|
||||
}
|
||||
// append border of whole Bar
|
||||
this.append_border(bar);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ tuskar.formset_table = (function () {
|
||||
button.click(function () {
|
||||
module.add_row(table, prefix, empty_row_html);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// if the formset is not empty and has no errors,
|
||||
// delete the empty extra rows from the end
|
||||
@ -67,17 +67,17 @@ tuskar.formset_table = (function () {
|
||||
var total_forms = +$('#id_' + prefix + '-TOTAL_FORMS').val();
|
||||
|
||||
if (table.find('tbody tr').length > 1 &&
|
||||
table.find('tbody td.error').length == 0 &&
|
||||
table.find('tbody td.error').length === 0 &&
|
||||
total_forms > initial_forms) {
|
||||
table.find('tbody tr').each(function (index) {
|
||||
if (index >= initial_forms) {
|
||||
$(this).remove();
|
||||
};
|
||||
}
|
||||
});
|
||||
module.reenumerate_rows(table, prefix);
|
||||
$('#id_' + prefix + '-INITIAL_FORMS').val(
|
||||
$('#id_' + prefix + '-TOTAL_FORMS').val());
|
||||
};
|
||||
}
|
||||
|
||||
// enable tooltips
|
||||
table.find('td.error[title]').tooltip();
|
||||
|
@ -24,7 +24,7 @@ horizon.addInitFunction(function () {
|
||||
equal(input.attr('checked'), undefined);
|
||||
tuskar.formset_table.replace_delete(row);
|
||||
var x = input.next('a');
|
||||
tuskar.formset_table.delete_row.call(x)
|
||||
tuskar.formset_table.delete_row.call(x);
|
||||
equal(row.css("display"), 'none');
|
||||
equal(input.attr('checked'), 'checked');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user