From 68fdb8a9b68fc14d5f54c9f66e40fd047915b268 Mon Sep 17 00:00:00 2001 From: sanj Date: Sun, 18 Jul 2010 02:02:20 +0530 Subject: [PATCH] added optional callback after subtitles have been loaded --- jquery.srt.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jquery.srt.js b/jquery.srt.js index d046015..e696050 100644 --- a/jquery.srt.js +++ b/jquery.srt.js @@ -65,7 +65,7 @@ } } } - + opts.subtitlesLoaded(subtitles); var currentSubtitle = -1; var ival = setInterval(function() { @@ -80,7 +80,7 @@ } if(subtitle > 0) { if(subtitle != currentSubtitle) { - opts.showSubtitle(subtitles[subtitle].t, subtitleElement); + opts.showSubtitle(subtitles[subtitle], subtitleElement); // subtitleElement.html(subtitles[subtitle].t); currentSubtitle=subtitle; } else if(subtitles[subtitle].o < currentTime) { @@ -91,10 +91,12 @@ }, opts.interval); } - function showSubtitle(txt, elem) { - elem.html(txt); +//default function to show subtitle + function showSubtitle(sub, elem) { + elem.html(sub.t); } +//default function to hide subtitle function hideSubtitle(elem) { elem.html(''); } @@ -106,7 +108,8 @@ 'id': that.attr('data-video'), 'url': that.attr('data-srt'), 'showSubtitle': showSubtitle, - 'hideSubtitle': hideSubtitle + 'hideSubtitle': hideSubtitle, + 'subtitlesLoaded': $.noop }, o); this.each(function() { var subtitleElement = $(this);