Copy to clipboard button

This commit is contained in:
Natsumi
2021-05-25 19:06:04 +12:00
parent 9aad0a453f
commit 0310f1ca2c
2 changed files with 51 additions and 3 deletions

View File

@@ -682,7 +682,7 @@ speechSynthesis.getVoices();
};
Vue.component('launch', {
template: '<el-button @click="confirm" size="mini" icon="el-icon-link" circle></el-button>',
template: '<el-button @click="confirm" size="mini" icon="el-icon-info" circle></el-button>',
props: {
location: String
},
@@ -9668,6 +9668,51 @@ speechSynthesis.getVoices();
D.visible = false;
};
// App: Copy To Clipboard
$app.methods.copyToClipboard = function (text) {
var textArea = document.createElement("textarea");
textArea.id = 'copy_to_clipboard';
textArea.value = text;
textArea.style.top = '0';
textArea.style.left = '0';
textArea.style.position = 'fixed';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
document.execCommand('copy');
document.getElementById('copy_to_clipboard').remove();
};
$app.methods.copyInstanceUrl = function (url) {
this.copyToClipboard(url);
this.$message({
message: 'Instance URL copied to clipboard',
type: 'success'
});
this.launchDialog.visible = false;
this.newInstanceDialog.visible = false;
};
$app.methods.copyLocation = function (location) {
var L = API.parseLocation(location);
var url = getLaunchURL(L.worldId, L.instanceId);
this.copyToClipboard(url);
this.$message({
message: 'Instance URL copied to clipboard',
type: 'success'
});
};
$app.methods.copyLocationCheck = function (location) {
if ((location === '') ||
(location === 'offline') ||
(location === 'private')) {
return false;
}
return true;
};
// App: VRCPlus Icons
API.$on('LOGIN', function () {