<commit_before>let $ = selector => document.querySelector(selector);

function modify({ type, title, year, info }) {
    let object = { title, year, ...info };

    $('#example').setAttribute('type', type);

    $('#movie').removeAttribute('active');
    $('#tv-show').removeAttribute('active');

    $(`#${ type }`).setAttribute('active', true);

    let element;
    for(let key in object)
        if(element = $(`#${ key }`))
            element.innerHTML = object[key] || "";

    $('#body').setAttribute('style', `background-image: url("${ type }.poster.jpg")`);
    $('#poster').setAttribute('src', `${ type }.poster.jpg`);

    let { imdb, tmdb, tvdb } = object,
        ids = { imdb, tmdb, tvdb };

    for(let id in ids)
        $(`#${ id }`).setAttribute('href', (
            ids[id]?
                id == 'imdb'?
                    `https://www.imdb.com/videoembed/${ object[id.toUpperCase()] }/`:
                id == 'tmdb'?
                    `https://www.youtube.com/embed/${ object[id.toUpperCase()] }`:
                `https://www.youtube.com/embed/${ object[id.toUpperCase()] }`:
            'blank.html'
        ));
}

function as(type) {
    open('blank.html', 'frame');

    return modify({
        "movie": {
            'type':  "movie",
            'title': "Being <NAME>",
            'year':  1999,
            'info': {
                'rating':       "R",
                'runtime':      "1:53",
                'genre':        "Comedy, Drama, Fantasy",
                'release-date': "December 3, 1999 (USA)",

                'imdb': "tt0120601",
                'IMDB': "vi3568894233",
                'tmdb': 492,
                'TMDB': "HdVvjvW_OEo",
                'tvdb': null,
                'TVDB': null,
            },
        },

        "tv-show": {
            'type': "tv-show",
            'title': "Love, Death & Robots",
            'year':  2019,
            'info': {
                'rating':       "TV-MA",
                'runtime':      "0:15",
                'genre':        "Animation, Comedy, Fantasy, Horror, Science-Fiction",
                'release-date': "May 15, 2019 (USA)",

                'imdb': "tt9561862",
                'IMDB': "vi1035648281",
                'tmdb': 86831,
                'TMDB': "wUFwunMKa4E",
                'tvdb': 357888,
                'TVDB': "wUFwunMKa4E",
            },
        },
    }[type]);
}

document.querySelectorAll('#movie, #tv-show').forEach(element => {
    element.onmouseup = event => {
        let self = event.target;

        as(self.id);
    };
});

document.querySelectorAll('[target="frame"]').forEach(element => {
    let body = document.body,
        frame = $('#frame'),
        loading = $('#loading');

    element.onmouseup = event =>
        loading.setAttribute('loading', true);

    frame.onload = frame.onerror = event =><commit_msg>Update index.js<commit_after>let $ = selector => document.querySelector(selector);

function modify({ type, title, year, info }) {
    let object = { title, year, ...info };

    $('#example').setAttribute('type', type);

    $('#movie').removeAttribute('active');
    $('#tv-show').removeAttribute('active');

    $(`#${ type }`).setAttribute('active', true);

    let element;
    for(let key in object)
        if(element = $(`#${ key }`))
            element.innerHTML = object[key] || "";

    $('#body').setAttribute('style', `background-image: url("${ type }.poster.jpg")`);
    $('#poster').setAttribute('src', `${ type }.poster.jpg`);

    let { imdb, tmdb, tvdb } = object,
        ids = { imdb, tmdb, tvdb };

    for(let id in ids)
        $(`#${ id }`).setAttribute('href', (
            ids[id]?
                id == 'imdb'?
                    `https://www.imdb.com/videoembed/${ object[id.toUpperCase()] }/`:
                id == 'tmdb'?
                    `https://www.youtube.com/embed/${ object[id.toUpperCase()] }`:
                `https://www.youtube.com/embed/${ object[id.toUpperCase()] }`:
            'blank.html'
        ));
}

function as(type) {
    open('blank.html', 'frame');

    return modify({
        "movie": {
            'type':  "movie",
            'title': "Being <NAME>",
            'year':  1999,
            'info': {
                'rating':       "R",
                'runtime':      "1:53",
                'genre':        "Comedy, Drama, Fantasy",
                'release-date': "December 3, 1999 (USA)",

                'imdb': "tt0120601",
                'IMDB': "vi3568894233",
                'tmdb': 492,
                'TMDB': "HdVvjvW_OEo",
                'tvdb': null,
                'TVDB': null,
            },
        },

        "tv-show": {
            'type': "tv-show",
            'title': "Love, Death & Robots",
            'year':  2019,
            'info': {
                'rating':       "TV-MA",
                'runtime':      "0:15",
                'genre':        "Animation, Comedy, Fantasy, Horror, Science-Fiction",
                'release-date': "May 15, 2019 (USA)",

                'imdb': "tt9561862",
                'IMDB': "vi1035648281",
                'tmdb': 86831,
                'TMDB': "wUFwunMKa4E",
                'tvdb': 357888,
                'TVDB': "wUFwunMKa4E",
            },
        },
    }[type]);
}

document.querySelectorAll('#movie, #tv-show').forEach(element => {
    element.onmouseup = event => {
        let self = event.target;

        location.hash = '#' + self.id;
    };
});

document.querySelectorAll('[target="frame"]').forEach(element => {
    let body = document.body,
        frame = $('#frame'),
        loading = $('#loading');

    element.onmouseup = event =>
        loading.setAttribute('loading', true);

    frame.onload = frame.onerror = event =>
{'fraction_non_alphanumeric': 0.19088072122052704, 'fraction_numerical': 0.026005547850208043, 'mean_word_length': 1.6414835164835164, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, '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': '1521219', 'n_tokens_mistral': 1933, 'n_tokens_neox': 1764, 'n_words': 336}