import { NetManager } from "../libs/tw/manager/NetManager";
import { DataManager } from "../libs/tw/manager/DataManager";
import { NetName } from "../libs/tw/enum/NetName";
import { Buried } from "../libs/tw/util/Buried";


export class NetBuried {
    private static instance: NetBuried;

    public static get ins(): NetBuried {
        if (!this.instance) {
            this.instance = new NetBuried();
        }
        return this.instance;
    }

    constructor() {}


    exposure = []
	dpm = []
    dcm = []
    
    showLog(i){
        var appId =this.getQueryString(window.location.href, "appId");
        var oaId = this.getQueryString(window.location.href, "activityId");
        this.dpm[i] = `${appId}.110.${i}.1`;
		this.dcm[i] = `202.${oaId}.0.0`;
		this.exposure[i] = Buried.createExposure(this.dpm[i], this.dcm[i]);
        NetManager.ins.showLog(this.exposure[i]);
    }

    clickLog(i){
        var appId = window["CFG"].appId;
        var oaId = window["CFG"].activityId;
        this.dpm[i] = `${appId}.110.${i}.1`;
		this.dcm[i] = `202.${oaId}.0.0`;
		this.exposure[i] = Buried.createExposure(this.dpm[i], this.dcm[i]);
        NetManager.ins.clickLog(this.exposure[i]);
    }

    getQueryString(url, name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }; 
    
  
}