Fixed copy to clipboard to work on non-firefox/chrome browsers.

This commit is contained in:
Ylian Saint-Hilaire 2019-06-06 13:34:18 -07:00
parent 7e6d4e6b48
commit 684d266ad1
3 changed files with 9 additions and 7 deletions

View File

@ -285,8 +285,9 @@
else { openTab(null, 'wintab64'); }
}
function copyToClipLinuxInstall() { navigator.clipboard.writeText(linuxInstall); }
function copyToClipLinuxUnInstall() { navigator.clipboard.writeText(linuxUnInstall); }
function copyToClipLinuxInstall() { copyTextToClip(linuxInstall); }
function copyToClipLinuxUnInstall() { copyTextToClip(linuxUnInstall); }
function copyTextToClip(txt) { function selectElementText(e) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(e); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(e); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); } } var e = document.createElement('DIV'); e.textContent = txt; document.body.appendChild(e); selectElementText(e); document.execCommand('copy'); e.remove(); }
</script>
</body>

View File

@ -8773,7 +8773,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
validateAgentInvite();
}
function d2CopyInviteToClip() { navigator.clipboard.writeText(Q('agentInvitationLink').href); }
function d2CopyInviteToClip() { copyTextToClip(Q('agentInvitationLink').href); }
function validateAgentInvite() {
if ((features & 64) && (Q('d2InviteType').value == 1)) {
@ -8882,7 +8882,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
var c = "https://" + servername + portStr + domainUrl + url;
if (addflag == 1) c += Q('aginsType').value;
navigator.clipboard.writeText(c);
copyTextToClip(c);
}
function fileDownload(path, name, appendFlag) {
@ -14172,5 +14172,6 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
function isPrivateIP(a) { return (a.startsWith('10.') || a.startsWith('172.16.') || a.startsWith('192.168.')); }
function u2fSupported() { return (window.u2f && ((navigator.userAgent.indexOf('Chrome/') > 0) || (navigator.userAgent.indexOf('Firefox/') > 0) || (navigator.userAgent.indexOf('Opera/') > 0) || (navigator.userAgent.indexOf('Safari/') > 0))); }
function findOne(arr1, arr2) { if ((arr1 == null) || (arr2 == null)) return false; return arr2.some(function (v) { return arr1.indexOf(v) >= 0; }); };
function copyTextToClip(txt) { function selectElementText(e) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(e); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(e); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); } } var e = document.createElement('DIV'); e.textContent = txt; document.body.appendChild(e); selectElementText(e); document.execCommand('copy'); e.remove(); }
</script></body></html>

View File

@ -2725,7 +2725,7 @@
validateAgentInvite();
}
function d2CopyInviteToClip() { navigator.clipboard.writeText(Q('agentInvitationLink').href); }
function d2CopyInviteToClip() { copyTextToClip(Q('agentInvitationLink').href); }
function validateAgentInvite() {
if ((features & 64) && (Q('d2InviteType').value == 1)) {
@ -2834,7 +2834,7 @@
var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
var c = "https://" + servername + portStr + domainUrl + url;
if (addflag == 1) c += Q('aginsType').value;
navigator.clipboard.writeText(c);
copyTextToClip(c);
}
function fileDownload(path, name, appendFlag) {
@ -5559,7 +5559,6 @@
p13uploadNextFile();
break;
default:
console.log('Unknown onFileUploadStateChange state', state);
break;
}
}
@ -8124,6 +8123,7 @@
function isPrivateIP(a) { return (a.startsWith('10.') || a.startsWith('172.16.') || a.startsWith('192.168.')); }
function u2fSupported() { return (window.u2f && ((navigator.userAgent.indexOf('Chrome/') > 0) || (navigator.userAgent.indexOf('Firefox/') > 0) || (navigator.userAgent.indexOf('Opera/') > 0) || (navigator.userAgent.indexOf('Safari/') > 0))); }
function findOne(arr1, arr2) { if ((arr1 == null) || (arr2 == null)) return false; return arr2.some(function (v) { return arr1.indexOf(v) >= 0; }); };
function copyTextToClip(txt) { function selectElementText(e) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(e); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(e); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); } } var e = document.createElement('DIV'); e.textContent = txt; document.body.appendChild(e); selectElementText(e); document.execCommand('copy'); e.remove(); }
</script>
</body>