Skip to content

Commit 0c55856

Browse files
Added result pasting into calculated field
+ minor corrections
1 parent 4862c5a commit 0c55856

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Note: _The order of this list might not match the order these features will be a
6666

6767
_Release date: ???????????????????????_
6868

69-
_Work Time: 6h 40min_
69+
_Work Time: 7h_
7070

7171
-
7272

pages/common.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ function Traction() {
188188

189189
var editor = document.querySelector('#calc');
190190
var property = document.querySelector('#var');
191+
var dataInput;
191192
var textfield = document.querySelector('#expression');
192193
var result = document.querySelector('#result num');
193194
var icons = document.querySelectorAll('#result icon > *');
@@ -198,7 +199,6 @@ var errors = {
198199
syntax: 'Syntax error detected.'
199200
}
200201

201-
202202
function openEditor() {
203203
editor.style.display = 'grid';
204204
}
@@ -215,9 +215,11 @@ function addEquationKeyListeners() {
215215
function openEditorForVariable(event) {
216216
// press '=' to open editor when closed and focus on textfield
217217
if (event.key == '=' && editor.style.display == 'none') {
218+
dataInput = event.target;
218219
property.innerHTML = event.target.parentNode.previousElementSibling.innerHTML;
219-
textfield.value = '';
220+
textfield.value = dataInput.value;
220221
textfield.focus();
222+
result.innerText = '0';
221223
openEditor();
222224
}
223225
}
@@ -275,3 +277,9 @@ function checkErrors(event) {
275277
}
276278
}
277279

280+
// paste result in the field if confirmed
281+
button.addEventListener('click', function() {
282+
dataInput.value = result.innerText;
283+
closeEditor();
284+
dataInput.focus();
285+
});

pages/cylinder.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ <h4>Expression editor</h4>
144144
</span>
145145
</p>
146146
<button style="display: block; margin: auto;"><i class="fi-rr-check"></i>Use result</button>
147-
<!-- <button><i class="fi-rr-cross"></i>Discard</button> -->
148147
</div>
149148
</div>
150149
</div>

0 commit comments

Comments
 (0)