FANDOM


(function() {
    /*značky*/
    function CutieMark(elem) { //konstruktor
        this.cutieMark = elem;
    }
    CutieMark.prototype.hide = function() { //schování
        this.cutieMark.style.display = 'none';
    };
    CutieMark.prototype.show = function() { //zobrazování
        this.cutieMark.style.display = 'inline-block';
    };
    /*skupina značek*/
    function CutieGroup(infobox) {
        //určování značek
        var cutieMarksEl = infobox.getElementsByClassName('ib1_cm');
        this.cutieMarks = [];
        for (var i = 0; i < cutieMarksEl.length; i++) {
            this.cutieMarks[i] = new CutieMark(cutieMarksEl[i]);
        }
        //určování tlačítek
        var buttonsEl = infobox.getElementsByClassName('ib1_cmButton');
        if (buttonsEl.length > 0) {
            this.nextButton = buttonsEl[1];
            this.nextButton.addEventListener("click", this.next.bind(this));
            this.prevButton = buttonsEl[0];
            this.prevButton.addEventListener("click", this.prev.bind(this));
        }
        this.MAX_MARK = this.cutieMarks.length - 1;
        this.curentMark = 0;
    }
    CutieGroup.prototype.next = function() {
        this.cutieMarks[this.curentMark].hide();
        if (this.curentMark < this.MAX_MARK) {
            this.curentMark++;
        } else {
            this.curentMark = 0;
        }
        this.cutieMarks[this.curentMark].show();
    };
    CutieGroup.prototype.prev = function() {
        this.cutieMarks[this.curentMark].hide();
        if (this.curentMark !== 0) {
            this.curentMark--;
        } else {
            this.curentMark = this.MAX_MARK;
        }
        this.cutieMarks[this.curentMark].show();
    };
    /*infobox*/
    function Infobox(elem) { //konstruktor
        this.infobox = elem;
        this.name = this.infobox.dataset.name;
        this.bgColor = this.infobox.dataset.bgcolor;
        this.fontColor = this.infobox.dataset.fontcolor;
        this.cm = new CutieGroup(this.infobox);
    }
    Infobox.prototype.hide = function() { //schování
        this.infobox.style.display = 'none';
    };
    Infobox.prototype.show = function() { //zobrazování
        this.infobox.style.display = 'block';
    };
    /*Blok infoboxů*/
    function InfoboxBlock(elem) {//konstruktor
        this.infoboxBlock = elem;
        //určování infoboxů
        this.infoboxes = [];
        var infoboxesEl = this.infoboxBlock.getElementsByClassName('ib1_infoboxCharacter');
        for (var i = 0; infoboxesEl[i]; i++) {
            this.infoboxes[i] = new Infobox(infoboxesEl[i]);
        }
        //určování parametrů slidera
        this.IB_NUM = this.infoboxes.length;
        this.activeInfobox = 0;
        this.nextInfobox = 1;
        this.prevInfobox = this.IB_NUM;
        //určování řídicích tlačítek
        var controlButtonsEl = this.infoboxBlock.getElementsByClassName('ib1_cb_block');
        this.nextButton, this.prevButton, this.switchButton;
        if (this.IB_NUM > 2) {
            this.prevButton = controlButtonsEl[0].firstChild;
            this.prevButton.addEventListener("click", this.prev.bind(this));
            this.nextButton = controlButtonsEl[0].lastChild;
            this.nextButton.addEventListener("click", this.next.bind(this));
        } else if (this.IB_NUM > 1) {
            this.switchButton = controlButtonsEl[0].firstChild;
            this.switchButton.addEventListener("click", this.ibSwitch.bind(this));
        }
    }
    InfoboxBlock.prototype.next = function() { //napřed
            this.infoboxes[this.activeInfobox].hide();
            this.infoboxes[this.nextInfobox].show();
            this.prevInfobox = this.activeInfobox;
            this.activeInfobox = this.nextInfobox;
            if (this.nextInfobox == this.IB_NUM - 1) {
                this.nextInfobox = 0;
            } else {
                this.nextInfobox++;
            }
            this.updateButton(this.nextButton, this.nextInfobox);
            this.updateButton(this.prevButton, this.prevInfobox);
        };
        InfoboxBlock.prototype.prev = function() { //nazpět
            this.infoboxes[this.activeInfobox].hide();
            this.infoboxes[this.prevInfobox].show();
            this.nextInfobox = this.activeInfobox;
            this.activeInfobox = this.prevInfobox;
            if (this.prevInfobox == 0) {
                this.prevInfobox = this.IB_NUM - 1;
            } else {
                this.prevInfobox--;
            }
            this.updateButton(this.nextButton, this.nextInfobox);
            this.updateButton(this.prevButton, this.prevInfobox);
        };
        InfoboxBlock.prototype.ibSwitch = function() { //varianta pro 2 ib
            this.infoboxes[this.activeInfobox].hide();
            this.updateButton(this.switchButton, this.activeInfobox);
            this.activeInfobox = Math.abs(this.activeInfobox - 1);
            this.infoboxes[this.activeInfobox].show();
        };
        InfoboxBlock.prototype.updateButton = function(elem, number) { //obnovování tlačítek
            elem.innerHTML = this.infoboxes[number].name;
            elem.style.backgroundColor = this.infoboxes[number].bgColor;
            elem.style.color = this.infoboxes[number].fontColor;
        };
    /*Stránka*/
    // určování bloků infoboxů
    var ibBlocks = [];
    var ibBlocksEl = document.getElementsByClassName('ib1_ibBlock');
    for (var i = 0; ibBlocksEl[i]; i++) {
        ibBlocks[i] = new InfoboxBlock(ibBlocksEl[i]);
    }
})();

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

V síti Wikia

Náhodná Wiki