"use strict";
import {util} from "../../util/util.js";
import {httpUtil} from "../../util/httpUtil.js";
import {fullMap} from "../../fullMap.js";
import {khcToastr} from "../alert/khcToastr.js";
import {config} from "../../config.js";

class iframe{
    constructor(data) {
        this.eleID = util.getUUID();
        this.objID = util.getUUID() + 'div';
        this.parentObjID = data.parentObjID;
        this.code=data.iframeCode.code;
        this.iframeCode=data.iframeCode;
        this.iframeURL = this.code.iframeURL;
        this.iframeHeight=this.code.iframeHeight;
    }
    init(){
        return new Promise((resolve, reject) => {
            let that=this;
            that.componentMap = new Map();//存储组件信息
            let col=that.iframeCode.code.col;
            // 检查是否成功获取了元素
            let htmlTemplate=`
                <div id="${that.objID}" class="col-${!util.isNull(col)?col*2:'12'} col-xl-${!util.isNull(col)?col:'12'} mb-3">
                    <div>
                        <iframe id="${that.eleID}" width="100%" height="100%" frameBorder="0" style="height: ${util.isNull(that.iframeHeight)?'92vh':`${that.iframeHeight}px`}"></iframe>
                    </div>
                </div>`;
            document.getElementById(that.parentObjID).insertAdjacentHTML("beforeEnd", htmlTemplate);
            document.getElementById(that.eleID).src=that.iframeURL
            resolve();
        })
    }
    render(){
        let that=this;
        that.init().then(()=>{
        })
    }
}
export {iframe}