piskel/dev/js/service/performance/PerformanceReportService.js

30 lines
947 B
JavaScript
Raw Normal View History

2017-05-22 10:56:42 +03:00
(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();
};
})();