$(function() { $('.title').data("loading", false); $('.title').click(function() { var $this = $(this); if ($(this).data("loading")) { return; } $(this).data("loading", true); var $parent = $(this).parent(); var $container = $parent.find('.srtContainer'); if ($container.length > 0) { // alert("hi"); $(this).data("loading", false); $container.is(":visible") ? $container.hide() : $container.show(); return; } var name = $parent.attr("data-name"); var srtFilename = "srt/" + name + ".srt"; var audioFilename = "wav/" + name + ".wav"; $.get(srtFilename, {}, function(srt) { $this.data("loading", false); var txt = srtToTxt(srt, 'tc'); var $txtContainer = $('
').addClass("srtContainer").data("srt", srt).hide() var $audio = $('').attr("src", audioFilename).attr("controls", "controls").appendTo($txtContainer); var $btnsContainer = $('').addClass("btnsContainer").appendTo($txtContainer); var $padmaBtn = $('').addClass("padmaBtn").text("View on pad.ma").appendTo($btnsContainer); var $srtBtn = $('').addClass("srtBtn").text("View SRT").data("fmt", "srt").appendTo($btnsContainer); var $tcBtn = $('').addClass("srtBtn").text("View Time-coded Text").data("fmt", "tc").appendTo($btnsContainer); var $txtBtn = $('').addClass("srtBtn").text("View Plain Text").data("fmt", "txt").appendTo($btnsContainer); var $srt = $('').addClass('srt').html(txt.replace(/\n/g, "