import { NetManager } from './../../libs/tw/manager/NetManager';
import { DataManager } from './../../libs/tw/manager/DataManager';
import { HtmlTextParser } from "./HtmlTextParser";
import Panel from "../views/Panel";

export default class RulePanel extends Panel {
    public labContent: eui.Label;
    public scroller: eui.Scroller;
    start() {
        if (window['ruleTxt']) {
            this.labContent.textFlow = (new HtmlTextParser).parser(window['ruleTxt']);
        } else {
            if (!DataManager.ins.getRuleData) {
                NetManager.ins.getRule(() => {
                    // DataManager
                    this.addRule();
                });
            }
            else {
                this.addRule();
            }
        }
    }

    group: eui.Group;
    private addRule() {
        const text = DataManager.ins.getRuleData.ruleText;
        this.labContent.textFlow = (new HtmlTextParser).parser(DataManager.ins.getRuleData.ruleText);
    }

    get skinKey() { return 'Rule' }
}