Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Remove: line break to press Enter
Browse files Browse the repository at this point in the history
  • Loading branch information
the6thm0nth committed May 20, 2018
1 parent 1e34d0d commit 2f776cd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions views/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -91,3 +92,7 @@ function setTextFontSize(text, elementId) {
}
return text.length;
}

function removeLineBreak(str) {
return str.replace(/(\r\n|\n|\r)/gm, "");
}

0 comments on commit 2f776cd

Please sign in to comment.