Skip to content

Commit 040d807

Browse files
author
pickles
committed
update copy button
1 parent 6951a7a commit 040d807

1 file changed

Lines changed: 17 additions & 24 deletions

File tree

www/index.html.tmpl

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,35 +157,28 @@
157157
updateText();
158158
updatePage();
159159
});
160-
})();
161160

162-
function copyText() {
163-
const copy_button = document.getElementById("button");
164-
// Copy text to clipboard onclick.
165-
if (!(v in values) || values[v] === "") {
166-
copy_button.innerHTML = 'Not all fields are filled';
167-
}
168-
else {
169-
const copyText = document.getElementById("text");
170-
const title = document.getElementById("title");
171-
navigator.clipboard.writeText(copyText.value);
172-
173-
// Button text change from "Copy Text" to "Copied", and text turns grey.
174-
copy_button.innerHTML = 'Copied';
175-
copy_button.className = 'copied';
176-
}
177-
}
161+
const copy_button = document.getElementById("button");
162+
163+
window.copyText = () => {
164+
const copy_button = document.getElementById("button");
165+
// Copy text to clipboard onclick.
166+
const copyText = document.getElementById("text");
167+
const title = document.getElementById("title");
168+
navigator.clipboard.writeText(copyText.value);
178169

179-
function refreshButton() {
180-
const copy_button = document.getElementById("button");
181-
if (!(v in values) || values[v] === "") {
182-
copy_button.innerHTML = 'Not all fields are filled';
170+
// Button text change from "Copy Text" to "Copied", and text turns grey.
171+
copy_button.innerHTML = 'Copied';
172+
copy_button.className = 'copied';
183173
}
184-
else {
174+
175+
window.refreshButton = () => {
185176
copy_button.innerHTML = 'Copy Text';
177+
copy_button.className = 'fresh';
186178
}
187-
copy_button.className = 'fresh';
188-
}
179+
})();
180+
181+
189182
</script>
190183
</body>
191184
</html>

0 commit comments

Comments
 (0)