/* 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 */ (function ($) { AblePlayer.prototype.injectVTS = function() { // To add a transcript sorter to a web page: // Add
to the web page // Define all variables var thisObj, tracks, $heading; var $instructions, $p1, $p2, $ul, $li1, $li2, $li3; var $fieldset, $legend, i, $radioDiv, radioId, $label, $radio; var $saveButton, $savedTable; thisObj = this; if ($('#able-vts').length) { // Page includes a container for a VTS instance // Are they qualifying tracks? if (this.vtsTracks.length) { // Yes - there are! // Build an array of unique languages this.langs = []; this.getAllLangs(this.vtsTracks); // Set the default VTS language this.vtsLang = this.lang; // Inject a heading $heading = $('

').text('Video Transcript Sorter'); // TODO: Localize; 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('Use the Video Transcript Sorter to perform any of the following tasks:'); $ul = $('

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

    ').text('When finished editing, click the "Save Changes" button. This will auto-generate new content for all relevant timed text files (chapters, descriptions, captions, and/or subtitles), which can be copied and pasted into separate WebVTT files for use by Able Player.'); $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('Select a language'); // TODO: Localize this $fieldset.append($legend) for (i in this.langs) { radioId = 'vts-lang-radio-' + this.langs[i]; $radioDiv = $('
    ',{ // uncomment the following if label is native name // 'lang': this.langs[i] }); $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 = $('