import Tagify from '@yaireo/tagify';
import '@yaireo/tagify/dist/tagify.css';

const taginput = document.querySelector("#subtitles");
const episode_id = document.getElementById('e_id').value;

// Get Tags from API
window.axios.get('/admin/subtitles/' + episode_id).then(function (response) {
    if (response.status != 200) {
        return;
    }

    var tagify = new Tagify(taginput, {
        whitelist: response.data.subs,
        dropdown: {
            classname: "color-blue",
            enabled: 0,              // show the dropdown immediately on focus
            maxItems: 10,
            position: "text",         // place the dropdown near the typed text
            closeOnSelect: false,          // keep the dropdown open after selecting a suggestion
            highlightFirst: true
        }
    });

    tagify.addTags(response.data.episodesubs);
}).catch(function (error) {
    console.log(error);
});

