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 59ae4933ba
commit d541aa82f9
3 changed files with 9 additions and 7 deletions

View File

@ -285,8 +285,9 @@
else { openTab(null, 'wintab64'); } else { openTab(null, 'wintab64'); }
} }
function copyToClipLinuxInstall() { navigator.clipboard.writeText(linuxInstall); } function copyToClipLinuxInstall() { copyTextToClip(linuxInstall); }
function copyToClipLinuxUnInstall() { navigator.clipboard.writeText(linuxUnInstall); } 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> </script>
</body> </body>

View File

@ -8773,7 +8773,7 @@ var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this
validateAgentInvite(); validateAgentInvite();
} }
function d2CopyInviteToClip() { navigator.clipboard.writeText(Q('agentInvitationLink').href); } function d2CopyInviteToClip() { copyTextToClip(Q('agentInvitationLink').href); }
function validateAgentInvite() { function validateAgentInvite() {
if ((features & 64) && (Q('d2InviteType').value == 1)) { 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 portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
var c = "https://" + servername + portStr + domainUrl + url; var c = "https://" + servername + portStr + domainUrl + url;
if (addflag == 1) c += Q('aginsType').value; if (addflag == 1) c += Q('aginsType').value;
navigator.clipboard.writeText(c); copyTextToClip(c);
} }
function fileDownload(path, name, appendFlag) { 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 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 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 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> </script></body></html>

View File

@ -2725,7 +2725,7 @@
validateAgentInvite(); validateAgentInvite();
} }
function d2CopyInviteToClip() { navigator.clipboard.writeText(Q('agentInvitationLink').href); } function d2CopyInviteToClip() { copyTextToClip(Q('agentInvitationLink').href); }
function validateAgentInvite() { function validateAgentInvite() {
if ((features & 64) && (Q('d2InviteType').value == 1)) { if ((features & 64) && (Q('d2InviteType').value == 1)) {
@ -2834,7 +2834,7 @@
var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port); var portStr = (serverinfo.port == 443) ? '' : (":" + serverinfo.port);
var c = "https://" + servername + portStr + domainUrl + url; var c = "https://" + servername + portStr + domainUrl + url;
if (addflag == 1) c += Q('aginsType').value; if (addflag == 1) c += Q('aginsType').value;
navigator.clipboard.writeText(c); copyTextToClip(c);
} }
function fileDownload(path, name, appendFlag) { function fileDownload(path, name, appendFlag) {
@ -5559,7 +5559,6 @@
p13uploadNextFile(); p13uploadNextFile();
break; break;
default: default:
console.log('Unknown onFileUploadStateChange state', state);
break; break;
} }
} }
@ -8124,6 +8123,7 @@
function isPrivateIP(a) { return (a.startsWith('10.') || a.startsWith('172.16.') || a.startsWith('192.168.')); } 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 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 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> </script>
</body> </body>