|
21 | 21 | .fresh { |
22 | 22 | color:#000; |
23 | 23 | } |
| 24 | + |
| 25 | + .notready { |
| 26 | + color:#000; |
| 27 | + } |
24 | 28 | </style> |
25 | 29 | </head> |
26 | 30 | <body> |
|
102 | 106 | if (!(v in values) || values[v] === "") { |
103 | 107 | $('#text').bind('mousedown', preventSelection); |
104 | 108 | $('#text').prop('readonly', true); |
| 109 | + buttonNotReady(); |
105 | 110 | } |
106 | 111 |
|
107 | 112 | // fuck JavaScript |
|
163 | 168 | window.copyText = () => { |
164 | 169 | const copy_button = document.getElementById("button"); |
165 | 170 | // 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 | + } |
173 | 183 | } |
174 | 184 |
|
175 | 185 | window.refreshButton = () => { |
176 | 186 | copy_button.innerHTML = 'Copy Text'; |
177 | 187 | copy_button.className = 'fresh'; |
178 | 188 | } |
| 189 | + |
| 190 | + window.buttonNotReady = () => { |
| 191 | + copy_button.innerHTML = 'Not all fields are filled'; |
| 192 | + copy_button.className = 'notready'; |
| 193 | + } |
179 | 194 | })(); |
180 | 195 |
|
181 | 196 |
|
|
0 commit comments