<commit_before>// Pure Javascript Slider with Animations - https://codepen.io/gabrieleromanato/pen/pIfoD by <NAME>
export class Slider {
    root: Element;
    links: NodeListOf<Element>;
    wrapper: HTMLElement;
    selectedIndex: number;

    constructor(webPart: Element, selctor: string) {
        this.root = webPart.querySelector(selctor);
        this.init();
    }

    init() : void {
        this.links = this.root.parentElement.querySelectorAll(".slider-nav a");
        this.wrapper = <HTMLElement>this.root.querySelector(".slider-wrapper");
        for (let i = 0; i < this.links.length; ++i) {
            let link = this.links[i];
            this.initSlide(link);
            if(this.links.length > 0) {
                (<HTMLElement>this.links[0]).click();
            }
        }
    }

    initSlide(element: Element) : void {
        element.addEventListener("click", (event) => {
            event.preventDefault();
            let a = <Element>event.target;
            this.setCurrentLink(a);
            let index = parseInt(a.getAttribute("data-slide"), 10) + 1;
            let currentSlide = <HTMLElement>this.root.querySelector(".slide:nth-child(" + index + ")");

            this.wrapper.style.left = "-" + currentSlide.offsetLeft + "px";
            this.animate(currentSlide);

        }, false);
    }

    getSelectedIndex() : number {
        return this.selectedIndex;
    }

    animate(slide: HTMLElement) : void {
        let parent = slide.parentElement;
        let caption = slide.querySelector(".caption");
        let captions = parent.querySelectorAll(".caption");<commit_msg>added the ability to pass in the selected index<commit_after>// Pure Javascript Slider with Animations - https://codepen.io/gabrieleromanato/pen/pIfoD by <NAME>
export class Slider {
    root: Element;
    links: NodeListOf<Element>;
    wrapper: HTMLElement;
    selectedIndex: number;

    constructor(webPart: Element, selctor: string, index: number) {
        this.root = webPart.querySelector(selctor);
        this.init(index);
    }

    init(index: number) : void {
        this.links = this.root.parentElement.querySelectorAll(".slider-nav a");
        this.wrapper = <HTMLElement>this.root.querySelector(".slider-wrapper");
        for (let i = 0; i < this.links.length; ++i) {
            let link = this.links[i];
            this.initSlide(link);
        }
        if(index < 0) {
            index = this.links.length + index;
        }
        if(this.links.length > index) {
            (<HTMLElement>this.links[index]).click();
        }
    }

    initSlide(element: Element) : void {
        element.addEventListener("click", (event) => {
            event.preventDefault();
            let a = <Element>event.target;
            this.setCurrentLink(a);
            let index = parseInt(a.getAttribute("data-slide"), 10) + 1;
            let currentSlide = <HTMLElement>this.root.querySelector(".slide:nth-child(" + index + ")");

            this.wrapper.style.left = "-" + currentSlide.offsetLeft + "px";
            this.animate(currentSlide);

        }, false);
    }

    getSelectedIndex() : number {
        return this.selectedIndex;
    }

    animate(slide: HTMLElement) : void {
        let parent = slide.parentElement;
        let caption = slide.querySelector(".caption");
        let captions = parent.querySelectorAll(".caption");
{'fraction_non_alphanumeric': 0.13606847697756788, 'fraction_numerical': 0.003246753246753247, 'mean_word_length': 2.3488142292490117, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5068997', 'n_tokens_mistral': 994, 'n_tokens_neox': 986, 'n_words': 191}