piskel/dev/js/service/performance/PerformanceReportService.js
2017-05-22 09:56:42 +02:00

30 lines
947 B
JavaScript

(function () {
var ns = $.namespace('pskl.service.performance');
ns.PerformanceReportService = function (piskelController, currentColorsService) {
this.piskelController = piskelController;
this.currentColorsService = currentColorsService;
this.currentReport = null;
};
ns.PerformanceReportService.prototype.init = function () {
$.subscribe(Events.HISTORY_STATE_SAVED, this.createReport_.bind(this));
};
ns.PerformanceReportService.prototype.createReport_ = function () {
var report = new ns.PerformanceReport(
this.piskelController.getPiskel(),
this.currentColorsService.getCurrentColors().length);
if (!report.equals(this.currentReport)) {
$.publish(Events.PERFORMANCE_REPORT_CHANGED, [report]);
this.currentReport = report;
}
};
ns.PerformanceReportService.prototype.hasProblem = function () {
return this.currentReport && this.currentReport.hasProblem();
};
})();