Skip to content

Commit bee61bb

Browse files
committed
Some comment improvements
1 parent 8b37b9f commit bee61bb

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

scripts/vts.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
(function ($) {
77
AblePlayer.prototype.injectVTS = function() {
88

9-
// To add a transcript sorter to a web page: <div id="able-vts"></div>
10-
119
var thisObj, $heading, $instructions, $p1, $p2, $ul, $li1, $li2, $li3,
1210
$fieldset, $legend, i, $radioDiv, radioId, $label, $radio, $saveButton, $savedTable;
1311

@@ -86,13 +84,13 @@
8684
}
8785
$fieldset.append( $fieldWrapper );
8886
$('#able-vts').append($fieldset);
89-
87+
let vtsSave = this.translate( 'vtsSave', 'Generate new .vtt content' );
9088
// Inject a button to generate new files.
9189
$saveButton = $('<button>',{
9290
'type': 'button',
9391
'id': 'able-vts-save',
9492
'value': 'save'
95-
}).text( this.translate( 'vtsSave', 'Generate new .vtt files' ) );
93+
}).text( vtsSave );
9694
$('#able-vts').append($saveButton);
9795

9896
// Inject a table with one row for each cue in the default language
@@ -150,7 +148,7 @@
150148
thisObj.parseVtsOutput($savedTable);
151149
} else {
152150
// cancel saving, and restore the table using edited content
153-
$(this).attr('value','save').text(this.translate( 'vtsSave', 'Generate new .vtt files' ) );
151+
$(this).attr('value','save').text( vtsSave );
154152
$('#able-vts-output').remove();
155153
$('#able-vts-instructions').show();
156154
$('#able-vts > fieldset').show();
@@ -167,8 +165,6 @@
167165

168166
// TODO: Add support for trackDesc
169167
// (to destinguish between tracks for the decribed vs non-described versions)
170-
171-
// Called from tracks.js
172168
var srcFile, vtsCues;
173169

174170
srcFile = this.getFilenameFromPath(src);

scripts/youtube.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,14 @@
183183
}
184184
};
185185

186+
/**
187+
* Get data from the YouTube iFrame API. Pushes data into `this.tracks` and `this.captions`.
188+
* Initiates play to trigger loading the captions module, then stops and collects data.
189+
*
190+
* @returns {Promise} promise
191+
*/
186192
AblePlayer.prototype.getYouTubeCaptionTracks = function () {
187193

188-
// get data via YouTube IFrame Player API, and push data to this.tracks & this.captions
189-
// NOTE: Caption tracks are not available through the IFrame Player API
190-
// until AFTER the video has started playing.
191-
// Therefore, this function plays the video briefly to load the captions module
192-
// then stops the video and collects the data needed to build the cc menu
193-
// This is stupid, but seemingly unavoidable.
194-
// Caption tracks could be obtained through the YouTube Data API
195-
// but this required authors to have a Google API key,
196-
// which would complicate Able Player installation
197-
198194
var deferred = new this.defer();
199195
var promise = deferred.promise();
200196
var thisObj, ytTracks, i, trackLang, trackLabel, isDefaultTrack, apiTriggered = false;
@@ -320,10 +316,10 @@
320316
AblePlayer.prototype.getYouTubeId = function (url) {
321317

322318
// return a YouTube ID, extracted from a full YouTube URL
323-
// Supported URL patterns (with http or https):
324-
// https://youtu.be/xxx
325-
// https://www.youtube.com/watch?v=xxx
326-
// https://www.youtube.com/embed/xxx
319+
// Supported URL patterns:
320+
// http|s://youtu.be/xxx
321+
// http|s://www.youtube.com/watch?v=xxx
322+
// http|s://www.youtube.com/embed/xxx
327323

328324
// in all supported patterns, the id is the last 11 characters
329325
var idStartPos, id;

0 commit comments

Comments
 (0)