diff --git a/wp-hyperaudio/hyperaudio-admin.php b/wp-hyperaudio/hyperaudio-admin.php index 99128ae..50c1a58 100644 --- a/wp-hyperaudio/hyperaudio-admin.php +++ b/wp-hyperaudio/hyperaudio-admin.php @@ -15,6 +15,7 @@ function hyperaudio_load_admin_script($hook) return; } + wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), false, '1.0.0', false); wp_enqueue_script( 'converter', plugin_dir_url( __FILE__ ) . '/js/converter.js', array( 'jquery' ), '1.0.0', true ); } @@ -143,6 +144,21 @@ function hyperaudio_options_page() padding: 4px; } + .sub-holder { + font-size: 80%; + padding-top: 16px; + display: none; + } + + .sub-btn { + margin-right: 16px; + } + + .sub-download { + padding-right: 16px; + display: none; + } + @@ -266,13 +282,18 @@ function hyperaudio_options_page()
-
- +
+ + Download WebVTT ⬇ + Download SRT ⬇ +
+ + + + - - - + \ No newline at end of file diff --git a/wp-hyperaudio/js/converter.js b/wp-hyperaudio/js/converter.js index 4a8fd14..f7aabed 100644 --- a/wp-hyperaudio/js/converter.js +++ b/wp-hyperaudio/js/converter.js @@ -55,6 +55,27 @@ $(document).ready(function() { function renderTranscript() { $('#rtranscript').html($('#htranscript').val()); + + //document.getElementById("gen-subs").addEventListener("click", genSubs); + $('#gen-subs').click(genSubs); + //document.getElementById("generate-captions").style.display = 'inline'; + $('#generate-captions').show(); + + function genSubs(){ + var cap1 = caption(); + var subs = cap1.init("rtranscript", null, null, null); + //console.log(subs.vtt); + //console.log(subs.srt); + //var downloadLinkVtt = document.getElementById("download-vtt"); + //downloadLinkVtt.setAttribute("href", 'data:text/vtt,'+encodeURIComponent(subs.vtt)); + //downloadLinkVtt.style.display = 'inline'; + $('#download-vtt').attr("href", 'data:text/vtt,'+encodeURIComponent(subs.vtt)).show(); + + //var downloadLinkSrt = document.getElementById("download-srt"); + //downloadLinkSrt.setAttribute("href", 'data:text/vtt,'+encodeURIComponent(subs.srt)); + //downloadLinkSrt.style.display = 'inline'; + $('#download-srt').attr("href", 'data:text/vtt,'+encodeURIComponent(subs.srt)).show(); + }; } String.prototype.replaceAll = function(search, replacement) {