diff --git a/js/beestat/thermostat_group.js b/js/beestat/home_comparisons.js similarity index 78% rename from js/beestat/thermostat_group.js rename to js/beestat/home_comparisons.js index 6da69eb..2dbc9ab 100644 --- a/js/beestat/thermostat_group.js +++ b/js/beestat/home_comparisons.js @@ -1,176 +1,151 @@ -/** - * Fire off an API call to get the temperature profile using the currently - * defined settings. Updates the cache with the response which fires off the - * event for anything bound to that data. - * - * TODO: This can probably be refactored a bit. The API call is now gone - * because it's no longer possible to generate these on the fly as of 1.4. - * - * @param {Function} callback Optional callback to fire when the API call - * completes. - */ -beestat.generate_temperature_profile = function(callback) { - var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; - var thermostat_group = beestat.cache.thermostat_group[ - thermostat.thermostat_group_id - ]; - - beestat.cache.set( - 'data.comparison_temperature_profile', - thermostat_group.temperature_profile - ); - - if (callback !== undefined) { - callback(); - } -}; - -/** - * Fire off an API call to get the comparison scores using the currently - * defined settings. Updates the cache with the response which fires off the - * vent for anything bound to that data. - * - * Note that this fires off a batch API call for heat, cool, and resist - * scores. So if you *only* had the resist card on the dashboard you would - * still get all three. I think the most common use case is showing all three - * scores, so the layer loader will be able to optimize away the duplicate - * requests and do one multi API call instead of three distinct API calls. - * - * @param {Function} callback Optional callback to fire when the API call - * completes. - */ -beestat.get_comparison_scores = function(callback) { - var types = [ - 'heat', - 'cool', - 'resist' - ]; - - var api = new beestat.api(); - types.forEach(function(type) { - beestat.cache.delete('data.comparison_scores_' + type); - api.add_call( - 'thermostat_group', - 'get_scores', - { - 'type': type, - 'attributes': beestat.get_comparison_attributes(type) - }, - type - ); - }); - - api.set_callback(function(data) { - types.forEach(function(type) { - beestat.cache.set('data.comparison_scores_' + type, data[type]); - }); - - if (callback !== undefined) { - callback(); - } - }); - - api.send(); -}; - -/** - * Based on the comparison settings chosen in the GUI, get the proper broken - * out comparison attributes needed to make an API call. - * - * @param {string} type heat|cool|resist - * - * @return {Object} The comparison attributes. - */ -beestat.get_comparison_attributes = function(type) { - var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; - var thermostat_group = - beestat.cache.thermostat_group[thermostat.thermostat_group_id]; - - var attributes = {}; - - if (beestat.setting('comparison_property_type') === 'similar') { - // Match structure type exactly. - if (thermostat_group.property_structure_type !== null) { - attributes.property_structure_type = - thermostat_group.property_structure_type; - } - - // Always a 10 year age delta on both sides. - if (thermostat_group.property_age !== null) { - var property_age_delta = 10; - var min_property_age = Math.max( - 0, - thermostat_group.property_age - property_age_delta - ); - var max_property_age = thermostat_group.property_age + property_age_delta; - attributes.property_age = { - 'operator': 'between', - 'value': [ - min_property_age, - max_property_age - ] - }; - } - - // Always a 1000sqft size delta on both sides (total 2000 sqft). - if (thermostat_group.property_square_feet !== null) { - var property_square_feet_delta = 1000; - var min_property_square_feet = Math.max( - 0, - thermostat_group.property_square_feet - property_square_feet_delta - ); - var max_property_square_feet = - thermostat_group.property_square_feet + - property_square_feet_delta; - attributes.property_square_feet = { - 'operator': 'between', - 'value': [ - min_property_square_feet, - max_property_square_feet - ] - }; - } - - /* - * If 0 or 1 stories, then 1 story, else just more than one story. - * Apartments ignore this. - */ - if ( - thermostat_group.property_stories !== null && - thermostat_group.property_structure_type !== 'apartment' - ) { - if (thermostat_group.property_stories < 2) { - attributes.property_stories = thermostat_group.property_stories; - } else { - attributes.property_stories = { - 'operator': '>=', - 'value': thermostat_group.property_stories - }; - } - } - } else if (beestat.setting('comparison_property_type') === 'same_structure') { - // Match structure type exactly. - if (thermostat_group.property_structure_type !== null) { - attributes.property_structure_type = - thermostat_group.property_structure_type; - } - } - - if ( - thermostat_group.address_latitude !== null && - thermostat_group.address_longitude !== null && - beestat.setting('comparison_region') !== 'global' - ) { - attributes.address_latitude = thermostat_group.address_latitude; - attributes.address_longitude = thermostat_group.address_longitude; - attributes.address_radius = 250; - } - - if (type === 'heat') { - attributes.system_type_heat = thermostat_group.system_type_heat; - } else if (type === 'cool') { - attributes.system_type_cool = thermostat_group.system_type_cool; - } - - return attributes; -}; +beestat.home_comparisons = {}; + +/** + * Fire off an API call to get the comparison scores using the currently + * defined settings. Updates the cache with the response which fires off the + * vent for anything bound to that data. + * + * Note that this fires off a batch API call for heat, cool, and resist + * scores. So if you *only* had the resist card on the dashboard you would + * still get all three. I think the most common use case is showing all three + * scores, so the layer loader will be able to optimize away the duplicate + * requests and do one multi API call instead of three distinct API calls. + * + * @param {Function} callback Optional callback to fire when the API call + * completes. + */ +beestat.home_comparisons.get_comparison_scores = function(callback) { + var types = [ + 'heat', + 'cool', + 'resist' + ]; + + var api = new beestat.api(); + types.forEach(function(type) { + beestat.cache.delete('data.comparison_scores_' + type); + api.add_call( + 'thermostat_group', + 'get_scores', + { + 'type': type, + 'attributes': beestat.home_comparisons.get_comparison_attributes(type) + }, + type + ); + }); + + api.set_callback(function(data) { + types.forEach(function(type) { + beestat.cache.set('data.comparison_scores_' + type, data[type]); + }); + + if (callback !== undefined) { + callback(); + } + }); + + api.send(); +}; + +/** + * Based on the comparison settings chosen in the GUI, get the proper broken + * out comparison attributes needed to make an API call. + * + * @param {string} type heat|cool|resist + * + * @return {Object} The comparison attributes. + */ +beestat.home_comparisons.get_comparison_attributes = function(type) { + var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; + var thermostat_group = + beestat.cache.thermostat_group[thermostat.thermostat_group_id]; + + var attributes = {}; + + if (beestat.setting('comparison_property_type') === 'similar') { + // Match structure type exactly. + if (thermostat_group.property_structure_type !== null) { + attributes.property_structure_type = + thermostat_group.property_structure_type; + } + + // Always a 10 year age delta on both sides. + if (thermostat_group.property_age !== null) { + var property_age_delta = 10; + var min_property_age = Math.max( + 0, + thermostat_group.property_age - property_age_delta + ); + var max_property_age = thermostat_group.property_age + property_age_delta; + attributes.property_age = { + 'operator': 'between', + 'value': [ + min_property_age, + max_property_age + ] + }; + } + + // Always a 1000sqft size delta on both sides (total 2000 sqft). + if (thermostat_group.property_square_feet !== null) { + var property_square_feet_delta = 1000; + var min_property_square_feet = Math.max( + 0, + thermostat_group.property_square_feet - property_square_feet_delta + ); + var max_property_square_feet = + thermostat_group.property_square_feet + + property_square_feet_delta; + attributes.property_square_feet = { + 'operator': 'between', + 'value': [ + min_property_square_feet, + max_property_square_feet + ] + }; + } + + /* + * If 0 or 1 stories, then 1 story, else just more than one story. + * Apartments ignore this. + */ + if ( + thermostat_group.property_stories !== null && + thermostat_group.property_structure_type !== 'apartment' + ) { + if (thermostat_group.property_stories < 2) { + attributes.property_stories = thermostat_group.property_stories; + } else { + attributes.property_stories = { + 'operator': '>=', + 'value': thermostat_group.property_stories + }; + } + } + } else if (beestat.setting('comparison_property_type') === 'same_structure') { + // Match structure type exactly. + if (thermostat_group.property_structure_type !== null) { + attributes.property_structure_type = + thermostat_group.property_structure_type; + } + } + + if ( + thermostat_group.address_latitude !== null && + thermostat_group.address_longitude !== null && + beestat.setting('comparison_region') !== 'global' + ) { + attributes.address_latitude = thermostat_group.address_latitude; + attributes.address_longitude = thermostat_group.address_longitude; + attributes.address_radius = 250; + } + + if (type === 'heat') { + attributes.system_type_heat = thermostat_group.system_type_heat; + } else if (type === 'cool') { + attributes.system_type_cool = thermostat_group.system_type_cool; + } + + return attributes; +}; diff --git a/js/component/card/comparison_settings.js b/js/component/card/comparison_settings.js index eadccf1..09dd313 100644 --- a/js/component/card/comparison_settings.js +++ b/js/component/card/comparison_settings.js @@ -127,7 +127,7 @@ beestat.component.card.comparison_settings.prototype.decorate_region_ = function // Open up the loading window. self.show_loading_('Calculating Score for ' + region + ' region'); - beestat.get_comparison_scores(function() { + beestat.home_comparisons.get_comparison_scores(function() { // Rerender to get rid of the loader. self.rerender(); }); @@ -200,7 +200,7 @@ beestat.component.card.comparison_settings.prototype.decorate_property_ = functi // Open up the loading window. self.show_loading_('Calculating Score for ' + property_type.text); - beestat.get_comparison_scores(function() { + beestat.home_comparisons.get_comparison_scores(function() { // Rerender to get rid of the loader. self.rerender(); }); diff --git a/js/component/card/score.js b/js/component/card/score.js index 1d4d4f8..7044e67 100644 --- a/js/component/card/score.js +++ b/js/component/card/score.js @@ -14,17 +14,13 @@ beestat.component.card.score = function() { }, 10); beestat.dispatcher.addEventListener( - [ - 'cache.data.comparison_temperature_profile', - 'cache.data.comparison_scores_' + this.type_ - ], + 'cache.data.comparison_scores_' + this.type_, data_change_function ); beestat.component.card.apply(this, arguments); - this.layer_.register_loader(beestat.generate_temperature_profile); - this.layer_.register_loader(beestat.get_comparison_scores); + this.layer_.register_loader(beestat.home_comparisons.get_comparison_scores); }; beestat.extend(beestat.component.card.score, beestat.component.card); @@ -34,28 +30,12 @@ beestat.extend(beestat.component.card.score, beestat.component.card); * @param {rocket.Elements} parent */ beestat.component.card.score.prototype.decorate_contents_ = function(parent) { - // this.view_detail_ = true; - - if (this.view_detail_ === true) { - this.decorate_detail_(parent); - } else { - this.decorate_score_(parent); - } -}; - -/** - * Decorate the score with the circle. - * - * @param {rocket.Elements} parent - */ -beestat.component.card.score.prototype.decorate_score_ = function(parent) { var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; var thermostat_group = beestat.cache.thermostat_group[ thermostat.thermostat_group_id ]; if ( - beestat.cache.data.comparison_temperature_profile === undefined || beestat.cache.data['comparison_scores_' + this.type_] === undefined ) { // Height buffer so the cards don't resize after they load. @@ -67,11 +47,10 @@ beestat.component.card.score.prototype.decorate_score_ = function(parent) { var percentile; if ( thermostat_group.temperature_profile[this.type_] !== undefined && - beestat.cache.data['comparison_scores_' + this.type_].length > 2 && - beestat.cache.data.comparison_temperature_profile[this.type_] !== null + beestat.cache.data['comparison_scores_' + this.type_].length > 2 ) { percentile = this.get_percentile_( - beestat.cache.data.comparison_temperature_profile[this.type_].score, + thermostat_group.temperature_profile[this.type_].score, beestat.cache.data['comparison_scores_' + this.type_] ); } else { @@ -190,364 +169,6 @@ beestat.component.card.score.prototype.decorate_score_ = function(parent) { } }, 100); } -}; - -/** - * Decorate the detail bell curve. - * - * @param {rocket.Elements} parent - */ -beestat.component.card.score.prototype.decorate_detail_ = function(parent) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // var self = this; - - this.chart_ = new beestat.component.chart(); - this.chart_.options.chart.height = 166; - - // if ( - // beestat.cache.data.comparison_temperature_profile === undefined - // ) { - // this.chart_.render(parent); - // this.show_loading_('Calculating'); - // } else { - // var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; - - // var x_categories = []; - // var trendlines = {}; - // var raw = {}; - - // Global x range. -/* var x_min = Infinity; - var x_max = -Infinity; - - var y_min = Infinity; - var y_max = -Infinity; - for (var type in beestat.cache.data.comparison_temperature_profile) { - var profile = beestat.cache.data.comparison_temperature_profile[type]; - - if (profile !== null) { - // Convert the data to Celsius if necessary - var deltas_converted = {}; - for (var key in profile.deltas) { - deltas_converted[beestat.temperature({'temperature': key})] = - beestat.temperature({ - 'temperature': profile.deltas[key], - 'delta': true, - 'round': 3 - }); - } - - profile.deltas = deltas_converted; - var linear_trendline = this.get_linear_trendline_(profile.deltas); - - var min_max_keys = Object.keys(profile.deltas); - - // This specific trendline x range. - var this_x_min = Math.min.apply(null, min_max_keys); - var this_x_max = Math.max.apply(null, min_max_keys); - - // Global x range. - x_min = Math.min(x_min, this_x_min); - x_max = Math.max(x_max, this_x_max); - - trendlines[type] = []; - raw[type] = []; - - * - * Data is stored internally as °F with 1 value per degree. That data - * gets converted to °C which then requires additional precision - * (increment). - * - * The additional precision introduces floating point error, so - * convert the x value to a fixed string. - * - * The string then needs converted to a number for highcharts, so - * later on use parseFloat to get back to that. - * - * Stupid Celsius. - - var increment; - var fixed; - if (thermostat.temperature_unit === '°F') { - increment = 1; - fixed = 0; - } else { - increment = 0.1; - fixed = 1; - } - for (var x = this_x_min; x <= this_x_max; x += increment) { - var x_fixed = x.toFixed(fixed); - var y = (linear_trendline.slope * x_fixed) + - linear_trendline.intercept; - - trendlines[type].push([ - parseFloat(x_fixed), - y - ]); - if (profile.deltas[x_fixed] !== undefined) { - raw[type].push([ - parseFloat(x_fixed), - profile.deltas[x_fixed] - ]); - y_min = Math.min(y_min, profile.deltas[x_fixed]); - y_max = Math.max(y_max, profile.deltas[x_fixed]); - } - } - } - } - - // Set y_min and y_max to be equal but opposite so the graph is always - // centered. - var absolute_y_max = Math.max(Math.abs(y_min), Math.abs(y_max)); - y_min = absolute_y_max * -1; - y_max = absolute_y_max;*/ - - // y_min = -5; - // y_max = 5; - // x_min = Math.min(x_min, 0); - // x_max = Math.max(x_max, 100); - - // Chart - // this.chart_.options.exporting.chartOptions.title.text = this.get_title_(); - // this.chart_.options.exporting.chartOptions.subtitle.text = this.get_subtitle_(); - - // this.chart_.options.chart.backgroundColor = beestat.style.color.bluegray.base; - // this.chart_.options.exporting.filename = this.get_title_(); - this.chart_.options.chart.zoomType = null; - // this.chart_.options.plotOptions.series.connectNulls = true; - this.chart_.options.legend = {'enabled': false}; - -/* this.chart_.options.xAxis = { - 'lineWidth': 0, - 'tickLength': 0, - 'tickInterval': 5, - 'gridLineWidth': 1, - 'gridLineColor': beestat.style.color.bluegray.light, - 'gridLineDashStyle': 'longdash', - 'labels': { - 'style': {'color': beestat.style.color.gray.base}, - 'formatter': function() { - return this.value + thermostat.temperature_unit; - } - } - };*/ - - - this.chart_.options.xAxis = { - 'title': { 'text': null }, - 'plotLines': [ - { - 'color': 'white', - 'width': 2, - 'value': beestat.cache.data.comparison_temperature_profile[this.type_].score - - } - ] - // alignTicks: false - }; - this.chart_.options.yAxis = { - 'title': { 'text': null } - }; - -/* this.chart_.options.yAxis = [ - { - 'alignTicks': false, - 'gridLineColor': beestat.style.color.bluegray.light, - 'gridLineDashStyle': 'longdash', - 'title': {'text': null}, - 'labels': { - 'style': {'color': beestat.style.color.gray.base}, - 'formatter': function() { - return this.value + thermostat.temperature_unit; - } - }, - 'min': y_min, - 'max': y_max, - 'plotLines': [ - { - 'color': beestat.style.color.bluegray.light, - 'dashStyle': 'solid', - 'width': 3, - 'value': 0, - 'zIndex': 1 - } - ] - } - ];*/ - -/* this.chart_.options.tooltip = { - 'shared': true, - 'useHTML': true, - 'borderWidth': 0, - 'shadow': false, - 'backgroundColor': null, - 'followPointer': true, - 'crosshairs': { - 'width': 1, - 'zIndex': 100, - 'color': beestat.style.color.gray.light, - 'dashStyle': 'shortDot', - 'snap': false - }, - 'positioner': function(tooltip_width, tooltip_height, point) { - return beestat.component.chart.tooltip_positioner( - self.chart_.get_chart(), - tooltip_width, - tooltip_height, - point - ); - }, - 'formatter': function() { - var sections = []; - var section = []; - this.points.forEach(function(point) { - var series = point.series; - - var value = beestat.temperature({ - 'temperature': point.y, - 'units': true, - 'convert': false, - 'delta': true, - 'type': 'string' - }) + ' / hour'; - - // if (series.name.indexOf('Raw') === -1) { - section.push({ - 'label': series.name, - 'value': value, - 'color': series.color - }); - // } - }); - sections.push(section); - - return beestat.component.chart.tooltip_formatter( - 'Outdoor Temp: ' + - beestat.temperature({ - 'temperature': this.x, - 'round': 0, - 'units': true, - 'convert': false - }), - sections - ); - } - };*/ - - // beestat.cache.data['comparison_scores_' + this.type_] = [ 0.4, 0.6, 0.6, 0.7, 0.8, 0.8, 0.8, 0.9, 0.9, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 1.4, 1.4, 1.5, 1.5, 1.5, 1.5, 1.5, 1.6, 1.7, 1.8, 1.9, 2.3, 2.6, 2.7, 3.3, 3.3, 3.6, 5.9] - - - console.log(beestat.cache.data['comparison_scores_' + this.type_]); - - var color = this.type_ === 'resist' ? beestat.style.color.gray.base : beestat.series['compressor_' + this.type_ + '_1'].color; - - this.chart_.options.series = [ - - - { - // 'data': trendlines.heat, - // 'name': 'Indoor Heat Δ', - // 'color': beestat.series.compressor_heat_1.color, - // 'marker': { - // 'enabled': false, - // 'states': {'hover': {'enabled': false}} - // }, - 'type': 'bellcurve', - 'baseSeries': 1, - 'color': color, - - // Histogram - // 'type': 'histogram', - // 'binWidth': 0.1, - // 'borderWidth': 0, - - // 'data': beestat.cache.data['comparison_scores_' + this.type_] - // 'lineWidth': 2, - // 'states': {'hover': {'lineWidthPlus': 0}} - }, -{ - 'data': beestat.cache.data['comparison_scores_' + this.type_], - 'visible': false - }, - - ]; - - console.log(parent); - // return; - - // Trendline data - // this.chart_.options.series.push({ - // 'data': trendlines.heat, - // 'name': 'Indoor Heat Δ', - // 'color': beestat.series.compressor_heat_1.color, - // 'marker': { - // 'enabled': false, - // 'states': {'hover': {'enabled': false}} - // }, - // 'type': 'bellcurve', - // 'data': beestat.cache.data['comparison_scores_' + this.type_] - // 'lineWidth': 2, - // 'states': {'hover': {'lineWidthPlus': 0}} - // }); - - console.log('render chart'); - this.chart_.render(parent); - // } - - - - - - - - - - - - - - - - - - - - - }; /** @@ -580,14 +201,6 @@ beestat.component.card.score.prototype.decorate_top_right_ = function(parent) { var menu = (new beestat.component.menu()).render(parent); - // menu.add_menu_item(new beestat.component.menu_item() - // .set_text('View Detail') - // .set_icon('chart_bell_curve') - // .set_callback(function() { - // self.view_detail_ = true; - // self.rerender(); - // })); - menu.add_menu_item(new beestat.component.menu_item() .set_text('Help') .set_icon('help_circle') @@ -602,28 +215,19 @@ beestat.component.card.score.prototype.decorate_top_right_ = function(parent) { * @return {string} The subtitle. */ beestat.component.card.score.prototype.get_subtitle_ = function() { - if (this.view_detail_ === true) { - if ( - // beestat.cache.data['comparison_scores_' + this.type_] !== undefined && - // beestat.cache.data['comparison_scores_' + this.type_].length > 2 && - beestat.cache.data.comparison_temperature_profile !== undefined && - beestat.cache.data.comparison_temperature_profile[this.type_] !== null - ) { - return 'Your raw score: ' + beestat.cache.data.comparison_temperature_profile[this.type_].score; - } + var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; + var thermostat_group = beestat.cache.thermostat_group[ + thermostat.thermostat_group_id + ]; - return 'N/A'; - } else { - if ( - beestat.cache.data['comparison_scores_' + this.type_] !== undefined && - beestat.cache.data['comparison_scores_' + this.type_].length > 2 && - beestat.cache.data.comparison_temperature_profile !== undefined && - beestat.cache.data.comparison_temperature_profile[this.type_] !== null - ) { - return 'Comparing to ' + Number(beestat.cache.data['comparison_scores_' + this.type_].length).toLocaleString() + ' Homes'; - } - - return 'N/A'; + if ( + beestat.cache.data['comparison_scores_' + this.type_] !== undefined && + beestat.cache.data['comparison_scores_' + this.type_].length > 2 && + thermostat_group.temperature_profile[this.type_] !== null + ) { + return 'Comparing to ' + Number(beestat.cache.data['comparison_scores_' + this.type_].length).toLocaleString() + ' Homes'; } + return 'N/A'; + }; diff --git a/js/component/card/temperature_profiles.js b/js/component/card/temperature_profiles.js index db6f2d4..5a9ddfb 100644 --- a/js/component/card/temperature_profiles.js +++ b/js/component/card/temperature_profiles.js @@ -2,15 +2,7 @@ * Temperature profiles. */ beestat.component.card.temperature_profiles = function() { - var self = this; - - beestat.dispatcher.addEventListener('cache.data.comparison_temperature_profile', function() { - self.rerender(); - }); - beestat.component.card.apply(this, arguments); - - this.layer_.register_loader(beestat.generate_temperature_profile); }; beestat.extend(beestat.component.card.temperature_profiles, beestat.component.card); @@ -22,17 +14,20 @@ beestat.extend(beestat.component.card.temperature_profiles, beestat.component.ca beestat.component.card.temperature_profiles.prototype.decorate_contents_ = function(parent) { var self = this; + var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; + var thermostat_group = beestat.cache.thermostat_group[ + thermostat.thermostat_group_id + ]; + this.chart_ = new beestat.component.chart(); this.chart_.options.chart.height = 300; if ( - beestat.cache.data.comparison_temperature_profile === undefined + thermostat_group.temperature_profile === null ) { this.chart_.render(parent); this.show_loading_('Calculating'); } else { - var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; - // var x_categories = []; var trendlines = {}; var raw = {}; @@ -43,10 +38,10 @@ beestat.component.card.temperature_profiles.prototype.decorate_contents_ = funct var y_min = Infinity; var y_max = -Infinity; - for (var type in beestat.cache.data.comparison_temperature_profile) { + for (var type in thermostat_group.temperature_profile) { // Cloned because I mutate this data for temperature conversions. var profile = beestat.clone( - beestat.cache.data.comparison_temperature_profile[type] + thermostat_group.temperature_profile[type] ); if (profile !== null) { diff --git a/js/component/modal/change_system_type.js b/js/component/modal/change_system_type.js index 1ff7826..974e21a 100644 --- a/js/component/modal/change_system_type.js +++ b/js/component/modal/change_system_type.js @@ -148,7 +148,7 @@ beestat.component.modal.change_system_type.prototype.get_buttons_ = function() { // Re-run comparison scores as they are invalid for the new system // type. - beestat.get_comparison_scores(); + beestat.home_comparisons.get_comparison_scores(); // Close the modal. self.dispose(); diff --git a/js/component/modal/help_score.js b/js/component/modal/help_score.js index 0516025..7902707 100644 --- a/js/component/modal/help_score.js +++ b/js/component/modal/help_score.js @@ -35,7 +35,7 @@ beestat.component.modal.help_score.prototype.decorate_contents_ = function(paren var strings = []; - var comparison_attributes = beestat.get_comparison_attributes(this.type_); + var comparison_attributes = beestat.home_comparisons.get_comparison_attributes(this.type_); if (comparison_attributes.system_type_heat !== undefined) { strings.push('Heat Type: ' + this.get_comparison_string_(comparison_attributes.system_type_heat)); diff --git a/js/js.php b/js/js.php index 6f606c3..23a771a 100755 --- a/js/js.php +++ b/js/js.php @@ -28,7 +28,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; - echo '' . PHP_EOL; + echo '' . PHP_EOL; echo '' . PHP_EOL; echo '' . PHP_EOL; diff --git a/js/layer.js b/js/layer.js index e107c6d..f58c2e4 100644 --- a/js/layer.js +++ b/js/layer.js @@ -30,7 +30,11 @@ beestat.layer.prototype.decorate_ = function(parent) { /** * Register a loader. Components do this. If the same function reference is - * passed by multiple components, the duplicates will be removed. + * passed by multiple components, the duplicates will be removed. The loader + * was added so that I could have multiple cards on the same layer that need + * the same data. Each card adds a loader and when the layer loads it runs + * these functions. This way a layer can get the data one time instead of each + * component firing off a duplicate API call. * * @param {Function} loader A function to call when all of the components have * been added to the layer.