"use strict";
const translator = require("ks-cheap-translator");
const { translations_url } = require("../../constants");

class WebPage {
    constructor(args) {
        Object.assign(this, args);

        if (!this.id) {
            this.id = "webpage-" + performance.now();
        }

        translator.init({
            translations_url,
            supported_languages: ["fr", "en"],
        }).then(this.refresh_all.bind(this));
    }

    refresh() {
        obj2htm.subRender(this.render(), document.getElementById(this.id), { mode: "replace" })
    }

    refresh_all() {
        obj2htm.renderCycle()
    }
}

module.exports = WebPage;