import Find from './Find/Find.js'; const ROOT_OBJECT = 'root'; const STANDARD = 0; const NO_MODULE = 1; class App extends Find.createApp() { constructor(name) { const root = Find.search(name); super(root); } init() { this.select('com.find.minify'); this.setMeta(); this.setTitle(); this.setForms(); this.render(); this.attachEvents(); } setMeta() { this.meta([ Find.css('bulma.min.css'), Find.content(''), Find.content(''), Find.content('') ]); } setTitle() { this.title('Минификатор Find.js на Find.js'); } setForms() { this.add([ Find.content( `

Минификация Find.js  

Минифицируйте Find.js прямо сейчас! Или же скачайте no-module версию:
` ) ]); } mwait(t, x) { const root = this.component(); const title = root.id('title'); root.id("hand_error").text(''); if (t === true) { title.text('Минификация Find.js в процессе...'); } else { if (typeof t === "string") { title.text(t); if (arguments.length > 1) { root.id("hand_error").text(x); } } else { title.text('Минификация Find.js'); } } } attachEvents() { const root = this.component(); root.id('minify').attach('click', () => { this.mwait(true); this.minifyFind(STANDARD); }); root.id('no-module').attach('click', () => { this.mwait(true); this.minifyFind(NO_MODULE); }); } async minifyFind(mode) { try { let response = await fetch('Find/Find.js'); if (response.ok) { let code = await response.text(); let name = 'find.min.js'; if (mode == NO_MODULE) { code = code.replace('export default class Find', 'class Find'); name = 'nomodule-' + name; } let minif = await Terser.minify(code, { sourceMap: false }); this.uploadFile(name, 'application/javascript', minif.code); this.mwait(false); } else { this.mwait('Ошибка HTTP', response.status); } } catch (err) { this.mwait('Ошибка: ', err); } } uploadFile(filename, mime, content) { const blob = new Blob([content], { type: mime }); const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = filename; link.click(); URL.revokeObjectURL(link.href); } } const app = new App(ROOT_OBJECT); app.init();