const ICONID = 1;
const DESCRIPTION = 2;
const PATH = 3;
const STARTMONTH = 4;
const STARTDAY = 5;
const ENDMONTH = 6;
const ENDDAY = 7;
const SELECTED = 8;

jOmnis.callbackObject = {
    logos: null,
    logoID: null,
    dataset: null,
    omnisOnLoad: function() {
        this.logos = null;
        this.logoID = 0;
        this.dataset = false;
    },
    omnisSetData: function(logos) {
        this.logos = [];
        if (logos instanceof omnis_list && logos.getRowCount()>0) {
            this.dataset = true;
            for (var i = 0; i < logos.getRowCount(); i++) {
                var logo = {
                    id:             logos.getData(ICONID, i+1),
                    description:    logos.getData(DESCRIPTION, i+1),
                    path:           logos.getData(PATH, i+1),
                    startMonth:     logos.getData(STARTMONTH, i+1),
                    startDay:       logos.getData(STARTDAY, i+1),
                    endMonth:       logos.getData(ENDMONTH, i+1),
                    endDay:         logos.getData(ENDDAY, i+1),
                    selected:       logos.getData(SELECTED, i+1),
                    omnisLine:      i+1};

                if(isLogoValid(logo)){
                    this.logos.push(logo);
                    if(logo.selected){
                        this.logoID = logo.id;
                    }
                }
                
            }
            this.setLogo();
            
        }
    },
    omnisGetCurrentLine: function(){
        var currentLogo = this.logos.find(x => x.id === this.logoID);
        if(currentLogo)
            return currentLogo.omnisLine;
        return 0;
    },
    setLogo: function(){
        if(this.logoID == 0){
            this.logoID = this.logos[Math.floor(Math.random()*this.logos.length)].id;
            jOmnis.sendClickEvent(this.omnisGetCurrentLine());
        }
        document.getElementById("logo").src=this.logos.find(x => x.id === this.logoID)["path"];
    }
};


window.addEventListener("click", function(e) {
    if(e.shiftKey){
        jOmnis.callbackObject.logoID = 0;
        jOmnis.callbackObject.setLogo();
        console.log("hello");
    }

});