diff --git a/capture.png b/capture.png index 02b035c..c843fac 100644 Binary files a/capture.png and b/capture.png differ diff --git a/custom/script.js b/custom/script.js index 7c35aac..61047f0 100644 --- a/custom/script.js +++ b/custom/script.js @@ -37,22 +37,28 @@ $(document).ready(function(){ } }); - // click button remake - $("#btn-remake").click(function(){ + // change input-lyric + $("#input-lyric").on("input", function(){ var input = $("#input-lyric").val(); - if(input != "") { - var output = handleRemakeLyric(input); + var output = handleRemakeLyric(input); - setTimeout(function(){ - $("#output-lyric").val(output); - }, 200); + setTimeout(function(){ + $("#output-lyric").val(output); + }, 200); + }); - toastr.success('Remake done'); - }else{ - toastr.error('Input is null'); + // scroll input-lyric + $("#input-lyric").on("scroll", function(){ + if($("#sync-chk").is(":checked")){ + syncScroll(); } }); + // click sync checkbox + $("#sync-chk").click(function(){ + syncScroll(); + }); + function handleRemakeLyric(input) { var lines = input.split('\n'); var realLength = lines.length; @@ -114,4 +120,9 @@ $(document).ready(function(){ } return strVal.substring(0, strVal.length - 1); } + + function syncScroll() { + var scrollPos = $("#input-lyric").scrollTop(); + $("#output-lyric").scrollTop(scrollPos); + } }); \ No newline at end of file diff --git a/index.html b/index.html index 59640cb..669305a 100644 --- a/index.html +++ b/index.html @@ -29,9 +29,6 @@