mirror of https://github.com/bra1n/townsquare.git
Merge pull request #262 from alexanderfletcher/dev-3
Add ability to use json from clipboard to upload script
This commit is contained in:
commit
c77dd47397
|
@ -69,6 +69,9 @@
|
|||
<div class="button" @click="promptURL">
|
||||
<font-awesome-icon icon="link" /> Enter URL
|
||||
</div>
|
||||
<div class="button" @click="readFromClipboard">
|
||||
<font-awesome-icon icon="clipboard" /> Use JSON from Clipboard
|
||||
</div>
|
||||
<div class="button" @click="isCustom = false">
|
||||
<font-awesome-icon icon="undo" /> Back
|
||||
</div>
|
||||
|
@ -156,6 +159,15 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
async readFromClipboard() {
|
||||
const text = await navigator.clipboard.readText();
|
||||
try {
|
||||
const roles = JSON.parse(text);
|
||||
this.parseRoles(roles);
|
||||
} catch (e) {
|
||||
alert("Error reading custom script: " + e.message);
|
||||
}
|
||||
},
|
||||
parseRoles(roles) {
|
||||
if (!roles || !roles.length) return;
|
||||
const metaIndex = roles.findIndex(({ id }) => id === "_meta");
|
||||
|
|
|
@ -16,6 +16,7 @@ const faIcons = [
|
|||
"CloudMoon",
|
||||
"Cog",
|
||||
"Copy",
|
||||
"Clipboard",
|
||||
"Dice",
|
||||
"Dragon",
|
||||
"ExchangeAlt",
|
||||
|
|
Loading…
Reference in New Issue