| | |
| | | }); |
| | | } |
| | | |
| | | // navigator.clipboard 는 브라우저 보안이나 활성화 여부에 따라 사용이 안될때가 있음 |
| | | function copyToClipboard(textToCopy) { |
| | | // navigator clipboard api needs a secure context (https) |
| | | if (navigator.clipboard && window.isSecureContext) { |
| | | // navigator clipboard api method' |
| | | return navigator.clipboard.writeText(textToCopy); |
| | | } else { |
| | | // text area method |
| | | let textArea = document.createElement("textarea"); |
| | | textArea.value = textToCopy; |
| | | // make the textarea out of viewport |
| | | textArea.style.position = "fixed"; |
| | | textArea.style.left = "-999999px"; |
| | | textArea.style.top = "-999999px"; |
| | | document.body.appendChild(textArea); |
| | | textArea.focus(); |
| | | textArea.select(); |
| | | return new Promise((res, rej) => { |
| | | // here the magic happens |
| | | document.execCommand('copy') ? res() : rej(); |
| | | textArea.remove(); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | function copyToken() { |
| | | var copyText = document.getElementById("apiApplicationForm2"); |
| | | |
| | | copyText.select(); |
| | | copyText.setSelectionRange(0, 99999); |
| | | |
| | | navigator.clipboard.writeText(copyText.value); |
| | | |
| | | SweetAlert.swal($filter("translate")("api.successToApiTokenCopy")); // "api 토큰 생성 성공" |
| | | copyToClipboard($scope.vm.form.token) |
| | | .then(() => |
| | | SweetAlert.swal($filter("translate")("api.successToApiTokenCopy")) |
| | | ) |
| | | .catch(() => SweetAlert.error($filter("translate")("api.failedToApiTokenCopy"))) |
| | | } |
| | | |
| | | function find() { |