class Changelog { constructor() { this.el = $('#changelog'); this.page = 1; this.compile = wpj.template.compile('#changelogTemplate'); const me = this; let query = this.el.data('deploytime') ? '?time=' + this.el.data('deploytime') : '?'; me.fetchData(query); this.el.on('click', '[data-nav]', function() { me.changeSlide($(this).data('nav')); }); this.el.on('click', '[data-loader]', function() { me.page++; me.fetchData(query + '&page=' + me.page); }); this.el.on('click', 'a[href*="http"]', function() { window.open($(this).attr('href')); }); } changeSlide(dir) { if (dir === 'next') { this.page++; } else if (dir === 'prev') { this.page--; } else if (typeof dir === 'number') { this.page = dir; } this.el.find('[data-slide]').removeClass('active'); this.el.find(`[data-slide=${this.page}]`).addClass('active'); this.el.find('[data-nav="prev"]').prop('disabled', this.page === 1); this.el.find('[data-nav="next"]').prop('disabled', this.page === this.el.find('[data-slide]').length); } fetchData(query) { fetch('https://klient.wpj.cz/changelog/json/' + query) .then(response => response.json()) .then(data => { var $wrapper = $('[data-infopanel-wrapper]'); data.filter(item => (item.type === 'Infopanel - chyba' || item.type === 'Infopanel - zpráva')).forEach(item => { var infopanel = '