mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
30 lines
947 B
JavaScript
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();
|
|
};
|
|
})();
|