<commit_before>/**
 * Moovie: an advanced HTML5 video player for MooTools.
 * @copyright 2010 <NAME>
 * @license MIT
 */
import { WebSRT } from './websrt.js';
import { WebVTT } from 'vtt.js';

/**
 * Loads and parses the track based on the filetype.
 * @type {Class}
 */
const Loader = new Class({
    initialize: function (url, srclang, onCue) {
        this.url = url;
        this.srclang = srclang;
        this.onCue = onCue;
        this.readyState = 0;
        this.sendRequest();
    },

    sendRequest: function () {
        // @todo sort out crossorigin attribute/property as well...
        const request = new Request({
            url: this.url,

            onProgress: () => {
                this.readyState = 1;
            },

            onSuccess: (data) => {
                const parser = this.getParser(this.url.split('.').pop());

                parser.oncue = (cue) => {
                    this.onCue(cue);
                };

                parser.onparsingerror = () => {
                    this.readyState = 3;
                };

                parser.onflush = () => {
                    this.readyState = 2;
                };

                parser.parse(data);
                parser.flush();
                this.readyState = 1;
            },

            onError: () => {
                this.readyState = 3;
            }
        });

        request.send();
    },

    getParser: function (ext) {
        if (ext === 'srt') {
            return new WebSRT.Parser();
        } else if (ext === 'vtt') {
            return new WebVTT.Parser(window, WebVTT.StringDecoder());
        }

        throw new Error(`Unsupported file type: ${ext}`);<commit_msg>fix: Remove use event handlers<commit_after>/**
 * Moovie: an advanced HTML5 video player for MooTools.
 * @copyright 2010 <NAME>
 * @license MIT
 */
import { WebSRT } from './websrt.js';
import { WebVTT } from 'vtt.js';

/**
 * Loads and parses the track based on the filetype.
 * @type {Class}
 */
const Loader = new Class({
    initialize: function (url, srclang, onCue) {
        this.url = url;
        this.srclang = srclang;
        this.onCue = onCue;
        this.sendRequest();
    },

    sendRequest: function () {
        // @todo sort out crossorigin attribute/property as well...
        const request = new Request({
            url: this.url,

            onSuccess: (data) => {
                const parser = this.getParser(this.url.split('.').pop());

                parser.oncue = (cue) => {
                    this.onCue(cue);
                };

                parser.parse(data);
                parser.flush();
            }
        });

        request.send();
    },

    getParser: function (ext) {
        if (ext === 'srt') {
            return new WebSRT.Parser();
        } else if (ext === 'vtt') {
            return new WebVTT.Parser(window, WebVTT.StringDecoder());
        }

        throw new Error(`Unsupported file type: ${ext}`);
{'fraction_non_alphanumeric': 0.13766408616627399, 'fraction_numerical': 0.005385392123864019, 'mean_word_length': 1.5037910699241785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, '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': '6307461', 'n_tokens_mistral': 910, 'n_tokens_neox': 849, 'n_words': 215}