Преглед изворни кода

Remove parentheses if weight == 1

missionfloyd пре 2 година
родитељ
комит
27d02597c7
1 измењених фајлова са 8 додато и 2 уклоњено
  1. 8 2
      javascript/edit-attention.js

+ 8 - 2
javascript/edit-attention.js

@@ -99,7 +99,13 @@ function keyupEditAttention(event){
 	weight = parseFloat(weight.toPrecision(12));
 	if(String(weight).length == 1) weight += ".0"
 
-	text = text.slice(0, selectionEnd + 1) + weight + text.slice(selectionEnd + 1 + end - 1);
+    if (closeCharacter == ')' && weight == 1) {
+        text = text.slice(0, selectionStart - 1) + text.slice(selectionStart, selectionEnd) + text.slice(selectionEnd + 5);
+        selectionStart--;
+        selectionEnd--;
+    } else {
+        text = text.slice(0, selectionEnd + 1) + weight + text.slice(selectionEnd + 1 + end - 1);
+    }
 
 	target.focus();
 	target.value = text;
@@ -111,4 +117,4 @@ function keyupEditAttention(event){
 
 addEventListener('keydown', (event) => {
     keyupEditAttention(event);
-});
+});