Skip to content

Commit 5c2aa3f

Browse files
author
pickles
committed
add a not ready state
1 parent 040d807 commit 5c2aa3f

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

www/index.html.tmpl

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
.fresh {
2222
color:#000;
2323
}
24+
25+
.notready {
26+
color:#000;
27+
}
2428
</style>
2529
</head>
2630
<body>
@@ -102,6 +106,7 @@
102106
if (!(v in values) || values[v] === "") {
103107
$('#text').bind('mousedown', preventSelection);
104108
$('#text').prop('readonly', true);
109+
buttonNotReady();
105110
}
106111

107112
// fuck JavaScript
@@ -163,19 +168,29 @@
163168
window.copyText = () => {
164169
const copy_button = document.getElementById("button");
165170
// Copy text to clipboard onclick.
166-
const copyText = document.getElementById("text");
167-
const title = document.getElementById("title");
168-
navigator.clipboard.writeText(copyText.value);
169-
170-
// Button text change from "Copy Text" to "Copied", and text turns grey.
171-
copy_button.innerHTML = 'Copied';
172-
copy_button.className = 'copied';
171+
if (copy_button.className == 'notready') {
172+
buttonNotReady();
173+
}
174+
else {
175+
const copyText = document.getElementById("text");
176+
const title = document.getElementById("title");
177+
navigator.clipboard.writeText(copyText.value);
178+
179+
// Button text change from "Copy Text" to "Copied", and text turns grey.
180+
copy_button.innerHTML = 'Copied';
181+
copy_button.className = 'copied';
182+
}
173183
}
174184

175185
window.refreshButton = () => {
176186
copy_button.innerHTML = 'Copy Text';
177187
copy_button.className = 'fresh';
178188
}
189+
190+
window.buttonNotReady = () => {
191+
copy_button.innerHTML = 'Not all fields are filled';
192+
copy_button.className = 'notready';
193+
}
179194
})();
180195

181196

0 commit comments

Comments
 (0)