See More

/* Video Transcript Sorter (VTS) * Used to synchronize time stamps from WebVTT resources * so they appear in the proper sequence within an auto-generated interactive transcript */ import $ from 'jquery'; function addVtsFunctions(AblePlayer) { AblePlayer.prototype.injectVTS = function() { var thisObj, $heading, $instructions, $p1, $p2, $ul, $li1, $li2, $li3, $fieldset, $legend, i, $radioDiv, radioId, $label, $radio, $saveButton, $savedTable; thisObj = this; if ( null !== document.getElementById( 'able-vts' ) ) { // Are they qualifying tracks? if (this.vtsTracks.length) { // Build an array of unique languages this.langs = []; this.getAllLangs(this.vtsTracks); // Set the default VTS language this.vtsLang = this.lang; // Inject a heading let heading = this.translate( 'vtsHeading', 'Video Transcript Sorter' ); $heading = $('

').text( heading ); // TODO: intelligently assign proper heading level $('#able-vts').append($heading); // Inject an empty div for writing messages this.$vtsAlert = $('
',{ 'id': 'able-vts-alert', 'aria-live': 'polite', 'aria-atomic': 'true' }) $('#able-vts').append(this.$vtsAlert); // Inject instructions (TODO: Localize) $instructions = $('
',{ 'id': 'able-vts-instructions' }); $p1 = $('

').text( this.translate( 'vtsInstructions1', 'Use the Video Transcript Sorter to modify text tracks:' ) ); $ul = $('

    '); $li1 = $('
  • ').text( this.translate( 'vtsInstructions2', 'Reorder chapters, descriptions, captions, and/or subtitles so they appear in the proper sequence in Able Player\'s auto-generated transcript.' ) ); $li2 = $('
  • ').text( this.translate( 'vtsInstructions3', 'Modify content or start/end times (all are directly editable within the table).' ) ); $li3 = $('
  • ').text( this.translate( 'vtsInstructions4', 'Add new content, such as chapters or descriptions.' ) ); $p2 = $('

    ').text( this.translate( 'vtsInstructions5', 'After editing, click the "Save Changes" button to generate new content for all relevant timed text files. The new text can be copied and pasted into new WebVTT files.' ) ); $ul.append($li1,$li2,$li3); $instructions.append($p1,$ul,$p2); $('#able-vts').append($instructions); // Inject a fieldset with radio buttons for each language $fieldset = $('

    '); $legend = $('').text( this.translate( 'vtsSelectLanguage', 'Select a language' ) ); $fieldset.append($legend); let $fieldWrapper = $( '
    ' ); for (i in this.langs) { radioId = 'vts-lang-radio-' + this.langs[i]; $radioDiv = $('
    '); $radio = $('', { 'type': 'radio', 'name': 'vts-lang', 'id': radioId, 'value': this.langs[i] }).on('click',function() { thisObj.vtsLang = $(this).val(); thisObj.showVtsAlert('Loading ' + thisObj.getLanguageName(thisObj.vtsLang) + ' tracks'); thisObj.injectVtsTable('update',thisObj.vtsLang); }); if (this.langs[i] == this.lang) { // this is the default language. $radio.prop('checked',true); } $label = $('