summaryrefslogtreecommitdiff
path: root/rannak/mangud/perenaine/kuulamine/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'rannak/mangud/perenaine/kuulamine/script.js')
-rwxr-xr-xrannak/mangud/perenaine/kuulamine/script.js92
1 files changed, 92 insertions, 0 deletions
diff --git a/rannak/mangud/perenaine/kuulamine/script.js b/rannak/mangud/perenaine/kuulamine/script.js
new file mode 100755
index 0000000..19debea
--- /dev/null
+++ b/rannak/mangud/perenaine/kuulamine/script.js
@@ -0,0 +1,92 @@
+document.addEventListener('DOMContentLoaded', () => {
+ let btn = document.querySelector('.modalButton');
+ btn.click();
+});
+
+
+
+const cells = document.querySelectorAll(".toBeEdited");
+console.log(cells);
+
+for (let i=0;i < cells.length; i++){
+ cells[i].onclick = function(){
+ console.log('Clicked');
+
+ if (this.hasAttribute('data-clicked'))
+ return;
+
+ this.setAttribute('data-clicked', 'yes')
+ this.setAttribute('data-text', this.innerHTML)
+
+ let input = document.createElement('input');
+ input.setAttribute('type', 'text');
+ input.value = this.innerHTML;
+ input.style.width = this.offsetWidth - (this.clientLeft * 2) + 'px';
+ input.style.height = this.offsetHeight - (this.clientTop * 2) + 'px';
+ input.style.border = '0px';
+ input.fontFamily = 'inherit';
+ input.fontSize = 'inherit';
+ input.textAlign = 'inherit';
+ input.style.backgroundColor = 'LightGoldenRodYellow';
+
+
+ // On offclick
+ input.onblur = function(){
+ let td = input.parentElement;
+ let origText = input.parentElement.getAttribute('data-text');
+ let curText = this.value;
+
+ if (origText != curText){
+ td.removeAttribute('data-clicked');
+ td.removeAttribute('data-text');
+ td.innerHTML = curText;
+ td.style.cssText = 'padding: .5rem .5rem';
+ console.log('Sth Change');
+ }
+ else {
+ td.removeAttribute('data-clicked');
+ td.removeAttribute('data-text');
+ td.innerHTML = origText;
+ td.style.cssText = 'padding: .5rem .5rem';
+ }
+
+
+ // Here Check if Done
+ //TODO
+
+
+
+ } // onblur func end
+
+
+ input.onkeypress = function (){
+ if (event.keyCode == 13)
+ this.onblur();
+ }
+
+ this.innerHTML = '';
+ this.style.cssText = 'padding: 0px';
+ this.append(input);
+ this.firstElementChild.select();
+
+
+
+
+
+ } // OnClick Loop
+} //ForLoop
+
+
+
+
+
+
+
+// If Done
+
+function moveOnEnable(){
+ const btn = document.querySelector(".moveOn");
+ btn.disabled = false;
+ btn.onclick = () => location.href = "";
+}
+