From 0f59a76b263ba6cd79380a729f38bfca92a907dd Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 화, 28 12월 2021 17:59:17 +0900 Subject: [PATCH] Merge branch 'master' of http://192.168.0.25:9001/r/owl-kisa --- src/main/webapp/scripts/app/api/apiAuth.controller.js | 38 ++++++++++++++++++++++++++++++-------- 1 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/webapp/scripts/app/api/apiAuth.controller.js b/src/main/webapp/scripts/app/api/apiAuth.controller.js index eda67ae..e7cb211 100644 --- a/src/main/webapp/scripts/app/api/apiAuth.controller.js +++ b/src/main/webapp/scripts/app/api/apiAuth.controller.js @@ -75,15 +75,37 @@ }); } + // 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() { -- Gitblit v1.8.0