"use strict" class Message{ constructor(type){ let set = settings.messages[type]; this.getFullHTML(set); } static Won(){return "won";} static Lost(){return "lost";} static New(){return "newGame";} static Credits(){return "credits";} getFullHTML(set){ let self = this; this.html = set.html; this.styles = set.styles; this.buttons = []; for (let b of set.buttons){ let htmlButton = $(""); htmlButton.text(b.text); htmlButton.css(b.styles); htmlButton.click(function(){self.buttonClicked(b);}); this.buttons.push(htmlButton); } } buttonClicked(setButton){ eval(setButton.onclick); this.destroy(this); } display(){ let pane = $("
"); pane.css(this.styles); pane.append(this.html); for (let b of this.buttons) pane.append(b); pane.attr("id", "message"); $("#messageWrapper").append(pane); $("#messageWrapper").show(); } destroy(obj){ $("#messageWrapper").hide(); $("#messageWrapper").html(""); obj = null; } } function prepareCredits(){ credits = credits.credits; let htmlCredits = $("
"); htmlCredits.attr("id", "creditsTableWrapper"); let table = ""; table += ""; for (let prop in credits[0]){ table += ""; } table += ""; for (let c of credits){ let section = ""; for (let prop in c){ let link = {open: "", close: ""}; if (prop === "link"){ link.open = ""; link.close = ""; } section += ""; } section += ""; table += section; } table += "
" + prop.capitalize() + "
" + link.open + c[prop] + link.close + "
"; htmlCredits.append($(table)); settings.messages.credits.html = htmlCredits; }