Skip to content

Commit

Permalink
Merge pull request #1886 from Mister-King/master
Browse files Browse the repository at this point in the history
Vaidation to prevent AJAX call if `<track>` source does not exist
  • Loading branch information
Ron666 committed Oct 21, 2016
2 parents 4568ae8 + af28daa commit d2f0701
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions src/js/mep-feature-tracks.js
Expand Up @@ -239,37 +239,39 @@
};


$.ajax({
url: track.src,
dataType: "text",
success: function(d) {

// parse the loaded file
if (typeof d == "string" && (/<tt\s+xml/ig).exec(d)) {
track.entries = mejs.TrackFormatParser.dfxp.parse(d);
} else {
track.entries = mejs.TrackFormatParser.webvtt.parse(d);
}
if (track.src !== undefined || track.src !== "") {
$.ajax({
url: track.src,
dataType: "text",
success: function(d) {

// parse the loaded file
if (typeof d == "string" && (/<tt\s+xml/ig).exec(d)) {
track.entries = mejs.TrackFormatParser.dfxp.parse(d);
} else {
track.entries = mejs.TrackFormatParser.webvtt.parse(d);
}

after();
after();

if (track.kind == 'chapters') {
t.media.addEventListener('play', function() {
if (t.media.duration > 0) {
t.displayChapters(track);
}
}, false);
}
if (track.kind == 'chapters') {
t.media.addEventListener('play', function() {
if (t.media.duration > 0) {
t.displayChapters(track);
}
}, false);
}

if (track.kind == 'slides') {
t.setupSlides(track);
if (track.kind == 'slides') {
t.setupSlides(track);
}
},
error: function() {
t.removeTrackButton(track.srclang);
t.loadNextTrack();
}
},
error: function() {
t.removeTrackButton(track.srclang);
t.loadNextTrack();
}
});
});
}
},

enableTrackButton: function(lang, label) {
Expand Down

0 comments on commit d2f0701

Please sign in to comment.