diff --git a/views/window.js b/views/window.js index 64b0c45..8f9e1f0 100644 --- a/views/window.js +++ b/views/window.js @@ -21,8 +21,9 @@ button.onclick = function() { const searchPress = function(e) { e = e || window.event; if (e.keyCode == 13) { + e.preventDefault(); document.getElementById("btn-search").click(); - setSourceText(getSourceText().trim()); + setSourceText(removeLineBreak(getSourceText())); return false; } return true; @@ -69,11 +70,11 @@ closeBtn.onclick = function() { }; function getSourceText() { - return window.document.getElementById("translated-text").value; + return window.document.getElementById("text").value; } function setSourceText(text) { - window.document.getElementById("translated-text").value = text; + window.document.getElementById("text").value = text; return text; } @@ -91,3 +92,7 @@ function setTextFontSize(text, elementId) { } return text.length; } + +function removeLineBreak(str) { + return str.replace(/(\r\n|\n|\r)/gm, ""); +}