asciibird/src/Dashboard.vue

680 lines
20 KiB
Vue
Raw Normal View History

<template>
<div id="app">
2021-04-24 00:42:33 +00:00
<NewAscii />
2021-04-17 01:58:45 +00:00
2021-04-17 01:36:44 +00:00
<context-menu :display="showContextMenu" ref="menu">
<ul>
2021-04-24 00:20:11 +00:00
<li
2021-04-24 00:42:33 +00:00
@click="$store.commit('openModal', 'new-ascii')"
2021-04-24 00:20:11 +00:00
class="ml-1"
@contextmenu.prevent
>
New ASCII
</li>
2021-04-17 01:36:44 +00:00
<li @click="clearCache()" class="ml-1">Clear and Refresh</li>
<li @click="startImport('mirc')" class="ml-1">Import mIRC</li>
<li
2021-04-24 00:20:11 +00:00
@click="exportMirc('file')"
class="ml-1"
v-if="this.$store.getters.asciibirdMeta.length"
>
Export mIRC to File
</li>
<li
2021-04-17 01:36:44 +00:00
class="ml-1"
2021-06-19 00:26:23 +00:00
@click="exportMirc('clipboard')"
2021-04-17 01:36:44 +00:00
v-if="this.$store.getters.asciibirdMeta.length"
>
2021-04-24 00:20:11 +00:00
Export mIRC to Clipboard
2021-04-17 01:36:44 +00:00
</li>
<li
@click="exportAsciibirdState()"
class="ml-1"
v-if="this.$store.getters.asciibirdMeta.length"
>
Save Asciibird State
</li>
<li @click="startImport('asb')" class="ml-1">Load Asciibird State</li>
</ul>
</context-menu>
<span
@mouseup.right="openContextMenu"
@contextmenu.prevent
style="width: 100%; height: 100%; position: absolute; z-index: -1"
></span>
<input
type="file"
style="display: none"
ref="asciiInput"
@change="onImport()"
/>
<template v-if="this.$store.getters.asciibirdMeta.length">
2021-01-16 03:03:14 +00:00
<t-button
2021-03-31 23:29:55 +00:00
v-for="(value, key) in this.$store.getters.asciibirdMeta"
2021-01-16 03:03:14 +00:00
v-bind:key="key"
class="ml-1"
@click="changeTab(key, value)"
2021-01-30 02:33:11 +00:00
:disabled="false"
2021-01-16 03:03:14 +00:00
>
{{ value.title }}
2021-01-09 01:57:48 +00:00
</t-button>
2021-04-17 01:36:44 +00:00
<Toolbar :canvas-x="canvasX" :canvas-y="canvasY" />
<DebugPanel :canvas-x="canvasX" :canvas-y="canvasY" />
<Editor @coordsupdate="updateCoords" />
2021-03-29 08:44:42 +00:00
2021-03-30 08:36:53 +00:00
<CharPicker v-if="$store.getters.getToolbarState.isChoosingChar" />
<ColourPicker
v-if="
$store.getters.getToolbarState.isChoosingFg ||
$store.getters.getToolbarState.isChoosingBg
"
/>
2021-04-17 01:36:44 +00:00
</template>
<template v-else>
<div style="left: 35%; top: 15%; position: absolute; z-index: -2">
<h1 style="font-size: 72px; text-align: center">ASCIIBIRD</h1>
<h1 style="font-size: 13px; text-align: center">
Right click to start
</h1>
</div>
</template>
</div>
</template>
<style>
2021-04-03 03:13:03 +00:00
/* html {
cursor: url('assets/mouse-pointer-solid.svg'), auto;
2021-04-03 03:13:03 +00:00
} */
</style>
<script>
2021-04-17 01:36:44 +00:00
import Toolbar from "./components/Toolbar.vue";
import DebugPanel from "./components/DebugPanel.vue";
import Editor from "./views/Editor.vue";
2021-05-29 00:28:30 +00:00
2021-04-17 01:36:44 +00:00
import CharPicker from "./components/parts/CharPicker.vue";
import ColourPicker from "./components/parts/ColourPicker.vue";
import ContextMenu from "./components/parts/ContextMenu.vue";
2021-04-24 00:20:11 +00:00
import NewAscii from "./components/modals/NewAscii.vue";
2021-06-19 00:26:23 +00:00
import LZString from "lz-string";
export default {
async created() {
2021-03-31 23:29:55 +00:00
// Load from irc watch if present in the URL bar
const asciiUrlCdn = new URL(location.href).searchParams.get("ascii");
if (asciiUrlCdn) {
const res = await fetch(`https://ascii.jewbird.live/${asciiUrlCdn}`, {
method: "GET",
headers: {
Accept: "text/plain",
},
});
const asciiData = await res.text();
console.log({ asciiData, asciiUrlCdn });
this.mircAsciiImport(asciiData, asciiUrlCdn);
2021-05-29 00:28:30 +00:00
// window.location.href = "/";
}
const asciiUrl = new URL(location.href).searchParams.get("ircwatch");
2021-04-24 00:20:11 +00:00
if (asciiUrl) {
2021-05-29 00:28:30 +00:00
const res = await fetch(`https://irc.watch/ascii/txt/${asciiUrl}`, {
2021-04-24 00:20:11 +00:00
method: "GET",
headers: {
Accept: "text/plain",
},
});
const asciiData = await res.text();
console.log({ asciiData, asciiUrl });
this.mircAsciiImport(asciiData, asciiUrl);
2021-05-29 00:28:30 +00:00
// window.location.href = "/";
2021-04-24 00:20:11 +00:00
}
},
2021-03-31 23:29:55 +00:00
components: {
2021-04-17 01:36:44 +00:00
Toolbar,
DebugPanel,
Editor,
CharPicker,
ColourPicker,
2021-04-24 00:20:11 +00:00
ContextMenu,
NewAscii,
2021-03-31 23:29:55 +00:00
},
2021-04-17 01:36:44 +00:00
name: "Dashboard",
data: () => ({
2021-04-24 00:20:11 +00:00
showNewAsciiModal: false,
currentTab: 1,
2021-03-29 05:10:31 +00:00
canvasX: null,
canvasY: null,
2021-04-02 02:07:49 +00:00
dashboardX: 0,
dashboardY: 0,
importType: null,
2021-04-17 01:36:44 +00:00
showContextMenu: false,
}),
computed: {
2021-04-03 03:13:03 +00:00
currentTool() {
2021-04-17 01:36:44 +00:00
return (
this.$store.getters.getToolbarIcons[
this.$store.getters.getCurrentTool
] ?? null
);
2021-04-03 03:13:03 +00:00
},
icon() {
2021-04-17 01:36:44 +00:00
return [
this.currentTool.fa ?? "fas",
this.currentTool.icon ?? "mouse-pointer",
];
2021-04-03 03:13:03 +00:00
},
},
methods: {
2021-04-17 01:36:44 +00:00
openContextMenu(e) {
2021-06-19 01:34:31 +00:00
e.preventDefault();
2021-04-17 01:36:44 +00:00
this.$refs.menu.open(e);
},
2021-03-29 05:10:31 +00:00
updateCoords(value) {
2021-03-30 08:36:53 +00:00
this.canvasX = value.x;
this.canvasY = value.y;
2021-03-29 05:10:31 +00:00
},
async onImport() {
2021-01-23 02:50:32 +00:00
const { files } = this.$refs.asciiInput;
const filename = files[0].name;
2021-01-16 03:03:14 +00:00
const fileReader = new FileReader();
2021-04-03 03:13:03 +00:00
const _importType = this.importType;
2021-04-17 01:36:44 +00:00
fileReader.addEventListener("load", () => {
2021-04-03 03:13:03 +00:00
switch (_importType) {
2021-04-17 01:36:44 +00:00
case "asb":
2021-04-03 03:13:03 +00:00
this.importAsciibirdState(fileReader.result, filename);
break;
2021-04-17 01:36:44 +00:00
case "mirc":
2021-04-03 03:13:03 +00:00
this.mircAsciiImport(fileReader.result, filename);
break;
}
});
// This will fire the file reader 'load' event
const asciiImport = fileReader.readAsText(files[0]);
},
startImport(type) {
2021-03-31 23:29:55 +00:00
// For ANSI we'll need to add back in the
// type cariable here
2021-04-03 03:13:03 +00:00
this.importType = type;
console.log(this.importType);
this.$refs.asciiInput.click();
},
// We can maybe try something different to import ANSI
// asniImport(contents, filename) {
// let ansiArray = contents.split("\n");
// let ansiWidth = 0;
// this.finalAscii = {
// width: false, // defined in: switch (curChar) case "\n":
// height: contents.split("\r\n").length,
// title: filename,
// key: this.$store.getters.nextTabValue,
// blockWidth: 8 * this.$store.getters.blockSizeMultiplier,
// blockHeight: 13 * this.$store.getters.blockSizeMultiplier,
// blocks: this.create2DArray(contents.split("\r\n").length),
// };
// for (let i = 0; i <= ansiArray.length - 1; i++) {
// if (ansiWidth > 0 && this.finalAscii.width === false) {
// this.finalAscii.width = ansiWidth;
// }
// ansiWidth = 0;
// for (let j = 0; j <= ansiArray[i].length - 1; j++) {
// let ansiParse = Anser.ansiToJson(ansiArray[i]);
// for (let l = 0; l <= ansiParse.length - 1; l++) {
// var contentArray = ansiParse[l].content.split("");
// var curBlock = {
2021-03-29 05:10:31 +00:00
// fg: this.mircColours.indexOf(`rgb(${ansiParse[l].fg})`),
// bg: this.mircColours.indexOf(`rgb(${ansiParse[l].bg})`),
// char: null,
// };
// // If we had no matches in our mIRC RGB lookup, then we have to try match
// // the ASNI colours to the best mIRC colour
// if (curBlock.fg === -1) {
// switch (ansiParse[l].fg) {
// case "187, 187, 0": // orangeish yellow
// curBlock.fg = 8;
// break;
// case "187, 0, 0": // red
// curBlock.fg = 4;
// break;
// }
// }
// if (curBlock.bg === -1) {
// switch (ansiParse[l].bg) {
// case "187, 187, 0": // orangeish yellow
// curBlock.bg = 8;
// break;
// case "187, 0, 0": // red
// curBlock.bg = 4;
// break;
// }
// }
// for (let k = 0; k <= contentArray.length - 1; k++) {
// if (contentArray[k] === "\r") {
// continue;
// }
2021-03-29 05:10:31 +00:00
// this.mircColours.indexOf(`rgb(${ansiParse[l].fg})`);
// curBlock.char = contentArray[k];
// this.finalAscii.blocks[i][ansiWidth] = JSON.parse(
// JSON.stringify(curBlock)
// );
// ansiWidth++;
// }
// }
// }
// }
// this.$store.commit("newAsciibirdMeta", this.finalAscii);
// },
2021-04-17 01:58:45 +00:00
onTriggeredEventHandler(payload) {
console.log(`You have pressed CMD (CTRL) + ${payload.keyString}`);
},
mircAsciiImport(contents, filename) {
2021-03-31 23:29:55 +00:00
const MIRC_MAX_COLOURS = this.$store.getters.mircColours.length;
2021-03-29 05:10:31 +00:00
// The current state of the Colours
let curBlock = {
fg: null,
bg: null,
char: null,
};
// set asciiImport as the entire file contents as a string
2021-06-19 00:26:23 +00:00
const asciiImport = contents
.split("\u0003\u0003")
.join("\u0003")
2021-06-19 06:55:23 +00:00
.split("\u000F").join("")
2021-06-26 00:19:52 +00:00
.split("\u0003\n").join("\n")
.split("\u0002\u0003").join("\u0003");
// This will end up in the asciibirdMeta
2021-03-31 23:29:55 +00:00
const finalAscii = {
width: false, // defined in: switch (curChar) case "\n":
2021-04-17 01:36:44 +00:00
height: asciiImport.split("\n").length,
title: filename,
key: this.$store.getters.nextTabValue,
blockWidth: 8 * this.$store.getters.blockSizeMultiplier,
blockHeight: 13 * this.$store.getters.blockSizeMultiplier,
2021-04-17 01:36:44 +00:00
blocks: this.create2DArray(asciiImport.split("\n").length),
2021-05-15 01:52:20 +00:00
history: [],
redo: [],
2021-04-24 00:20:11 +00:00
x: 8 * 35, // the dragable ascii canvas x
y: 13 * 2, // the dragable ascii canvas y
};
// Turn the entire ascii string into an array
2021-04-17 01:36:44 +00:00
let asciiStringArray = asciiImport.split("");
2021-06-19 06:55:23 +00:00
let linesArray = asciiImport.split("\n");
// The proper X and Y value of the block inside the ASCII
let asciiX = 0;
let asciiY = 0;
2021-03-30 08:36:53 +00:00
// used to determine colours
let colourChar1 = null;
let colourChar2 = null;
2021-03-31 23:29:55 +00:00
let parsedColour = null;
2021-03-30 08:36:53 +00:00
// This variable just counts the amount of colour and char codes to minus
// to get the real width
2021-03-31 23:29:55 +00:00
let widthOfColCodes = 0;
2021-06-19 00:26:23 +00:00
2021-06-19 06:55:23 +00:00
// Better for colourful asciis
let maxWidthLoop = 0;
// Used before the loop, better for plain text
let maxWidthFound = 0;
for(let i = 0; i < linesArray.length; i++) {
if (linesArray[i].length > maxWidthFound) {
maxWidthFound = linesArray[i].length;
2021-06-19 00:26:23 +00:00
}
}
2021-03-20 00:39:17 +00:00
while (asciiStringArray.length) {
2021-03-31 23:29:55 +00:00
const curChar = asciiStringArray[0];
// Defining a small finite state machine
// to detect the colour code
switch (curChar) {
2021-04-17 01:36:44 +00:00
case "\n":
// Reset the colours here on a new line
2021-06-19 01:34:31 +00:00
curBlock = {
fg: null,
bg: null,
char: null,
};
2021-06-19 06:55:23 +00:00
if (linesArray[asciiY] && linesArray[asciiY].length > maxWidthLoop) {
maxWidthLoop = linesArray[asciiY].length;
}
2021-03-31 23:29:55 +00:00
// the Y value of the ascii
asciiY++;
2021-06-19 01:34:31 +00:00
// Calculate widths mirc asciis vs plain text
2021-06-19 00:26:23 +00:00
if (!finalAscii.width && widthOfColCodes > 0) {
2021-04-17 01:36:44 +00:00
finalAscii.width =
2021-06-19 06:55:23 +00:00
maxWidthLoop - widthOfColCodes; // minus \n for the proper width
2021-06-26 00:19:52 +00:00
}
if (!finalAscii.width && widthOfColCodes === 0) {
2021-06-19 01:34:31 +00:00
// Plain text
2021-06-19 00:26:23 +00:00
finalAscii.width =
2021-06-19 06:55:23 +00:00
maxWidthFound; // minus \n for the proper width
}
// Resets the X value
asciiX = 0;
asciiStringArray.shift();
2021-06-19 06:55:23 +00:00
widthOfColCodes = 0;
break;
2021-04-17 01:36:44 +00:00
case "\u0003":
2021-03-31 23:29:55 +00:00
// Remove the colour char
asciiStringArray.shift();
2021-03-31 23:29:55 +00:00
widthOfColCodes++;
2021-03-31 23:29:55 +00:00
// Attempt to work out bg
2021-03-30 08:36:53 +00:00
colourChar1 = `${asciiStringArray[0]}`;
colourChar2 = `${asciiStringArray[1]}`;
parsedColour = parseInt(`${colourChar1}${colourChar2}`);
2021-03-31 23:29:55 +00:00
// Work out the 01, 02 double digit codes
if (parseInt(colourChar1) === 0 && parseInt(colourChar2) >= 0) {
asciiStringArray.shift();
}
2021-03-29 05:10:31 +00:00
if (isNaN(parsedColour)) {
2021-03-30 08:36:53 +00:00
curBlock.bg = parseInt(colourChar1);
2021-03-31 23:29:55 +00:00
widthOfColCodes += 1;
2021-03-27 04:54:44 +00:00
asciiStringArray.shift();
2021-03-31 23:29:55 +00:00
} else if (parsedColour <= MIRC_MAX_COLOURS && parsedColour >= 0) {
2021-03-29 05:10:31 +00:00
curBlock.fg = parseInt(parsedColour);
2021-03-31 23:29:55 +00:00
widthOfColCodes += parsedColour.toString().length;
2021-03-27 04:54:44 +00:00
asciiStringArray = asciiStringArray.slice(
2021-03-29 05:10:31 +00:00
parsedColour.toString().length,
2021-04-17 01:36:44 +00:00
asciiStringArray.length
2021-03-27 04:54:44 +00:00
);
}
// No background colour
2021-04-17 01:36:44 +00:00
if (asciiStringArray[0] !== ",") {
break;
} else {
2021-03-20 09:59:32 +00:00
// Remove , from array
2021-04-17 01:36:44 +00:00
widthOfColCodes += 1;
asciiStringArray.shift();
}
2021-02-20 02:16:45 +00:00
2021-03-31 23:29:55 +00:00
// Attempt to work out bg
2021-03-30 08:36:53 +00:00
colourChar1 = `${asciiStringArray[0]}`;
colourChar2 = `${asciiStringArray[1]}`;
parsedColour = parseInt(`${colourChar1}${colourChar2}`);
2021-03-20 09:59:32 +00:00
if (
2021-04-17 01:36:44 +00:00
!isNaN(colourChar1) &&
!isNaN(colourChar2) &&
parseInt(colourChar2) > parseInt(colourChar1) &&
!isNaN(parsedColour) &&
parseInt(parsedColour) < 10
) {
2021-03-30 08:36:53 +00:00
parsedColour = parseInt(colourChar2);
2021-04-17 01:36:44 +00:00
widthOfColCodes += 1;
asciiStringArray.shift();
}
if (
parseInt(colourChar2) === parseInt(colourChar1) &&
parseInt(parsedColour) < 10
) {
parsedColour = parseInt(colourChar1);
asciiStringArray.shift();
2021-04-17 01:36:44 +00:00
asciiStringArray.shift();
widthOfColCodes += 2;
curBlock.bg = parseInt(colourChar1);
break;
}
2021-03-29 05:10:31 +00:00
if (isNaN(parsedColour)) {
2021-03-30 08:36:53 +00:00
curBlock.bg = parseInt(colourChar1);
2021-03-31 23:29:55 +00:00
widthOfColCodes += 1;
asciiStringArray.shift();
2021-03-31 23:29:55 +00:00
} else if (parsedColour <= MIRC_MAX_COLOURS && parsedColour >= 0) {
2021-03-29 05:10:31 +00:00
curBlock.bg = parseInt(parsedColour);
2021-03-31 23:29:55 +00:00
widthOfColCodes += parsedColour.toString().length;
2021-02-20 02:16:45 +00:00
asciiStringArray = asciiStringArray.slice(
2021-03-29 05:10:31 +00:00
parsedColour.toString().length,
2021-04-17 01:36:44 +00:00
asciiStringArray.length
);
2021-02-20 02:16:45 +00:00
break;
}
break;
default:
curBlock.char = curChar;
asciiStringArray.shift();
asciiX++;
2021-03-31 23:29:55 +00:00
finalAscii.blocks[asciiY][asciiX - 1] = { ...curBlock };
break;
} // End Switch
} // End loop charPos
2021-03-31 23:29:55 +00:00
// Store the ASCII
2021-06-19 00:26:23 +00:00
finalAscii.blocks = LZString.compressToUTF16(
JSON.stringify(finalAscii.blocks)
);
finalAscii.history.push(finalAscii.blocks);
2021-04-17 01:36:44 +00:00
this.$store.commit("newAsciibirdMeta", finalAscii);
2021-03-27 02:07:33 +00:00
2021-03-31 23:29:55 +00:00
// To show the ASCII after importing we get the last key
// from the asciiBirdMeta array
const keys = this.$store.getters.asciibirdMeta
2021-03-27 04:54:44 +00:00
.map((v, k) => k)
.filter((i) => i !== undefined);
2021-03-27 02:07:33 +00:00
2021-03-31 23:29:55 +00:00
// Set the current tab and pop the array for the last value
2021-03-27 02:07:33 +00:00
this.currentTab = keys.pop();
2021-04-17 01:36:44 +00:00
this.$store.commit("changeTab", this.currentTab);
2021-03-31 23:29:55 +00:00
// Update the browsers title to the ASCII filename
document.title = `asciibird - ${this.$store.getters.currentAscii.title}`;
2021-01-16 03:03:14 +00:00
},
importAsciibirdState(fileContents) {
2021-06-19 00:26:23 +00:00
let contents = JSON.parse(
LZString.decompressFromEncodedURIComponent(fileContents)
);
this.$store.commit("changeState", { ...contents });
},
exportAsciibirdState() {
let output;
try {
2021-06-19 00:26:23 +00:00
output = LZString.compressToEncodedURIComponent(
JSON.stringify(this.$store.getters.getState)
);
// Default timestamp for filename
2021-04-03 03:13:03 +00:00
const today = new Date();
const y = today.getFullYear();
const m = today.getMonth() + 1; // JavaScript months are 0-based.
const d = today.getDate();
const h = today.getHours();
const mi = today.getMinutes();
const s = today.getSeconds();
2021-04-17 01:36:44 +00:00
this.downloadToFile(
output,
`asciibird-${y}-${m}-${d}-${h}-${mi}-${s}.asb`,
"application/gzip"
2021-04-17 01:36:44 +00:00
);
} catch (err) {
console.log(err);
}
},
2021-04-24 00:20:11 +00:00
exportMirc(type) {
2021-03-31 23:29:55 +00:00
const { currentAscii } = this.$store.getters;
2021-06-19 00:26:23 +00:00
let blocks = this.$store.getters.currentAsciiBlocks;
2021-03-31 23:29:55 +00:00
const output = [];
let curBlock = null;
let prevBlock = { bg: -1, fg: -1 };
2021-06-26 00:19:52 +00:00
for (let y = 0; y <= blocks.length - 1; y++) {
2021-06-26 00:19:52 +00:00
if (y >= currentAscii.height) {
continue;
}
for (let x = 0; x <= blocks[y].length - 1; x++) {
2021-06-26 00:19:52 +00:00
if (x >= currentAscii.width) {
continue;
}
curBlock = blocks[y][x];
2021-03-31 23:29:55 +00:00
// If we have a difference between our previous block
// we'll put a colour codes and continue as normal
2021-03-31 00:46:33 +00:00
if (curBlock.bg !== prevBlock.bg || curBlock.fg !== prevBlock.fg) {
Object.assign(curBlock, blocks[y][x]);
2021-04-17 01:36:44 +00:00
const zeroPad = (num, places) => String(num).padStart(places, "0");
output.push(
`\u0003${zeroPad(
curBlock.fg ?? this.$store.getters.getOptions.defaultFg,
2
)},${zeroPad(
curBlock.bg ?? this.$store.getters.getOptions.defaultBg,
2
)}`
);
2021-03-30 08:36:53 +00:00
}
2021-03-31 23:29:55 +00:00
// null .chars will end up as space
2021-04-17 01:36:44 +00:00
output.push(curBlock.char ?? " ");
prevBlock = blocks[y][x];
2021-03-30 08:36:53 +00:00
}
2021-03-31 23:29:55 +00:00
// We can never have a -1 colour code so we'll always
// write one at the start of each line
2021-03-31 00:46:33 +00:00
prevBlock = { bg: -1, fg: -1 };
2021-03-31 23:29:55 +00:00
// New line except for the very last line
if (y < blocks.length - 1) {
2021-04-17 01:36:44 +00:00
output.push("\n");
}
2021-03-30 08:36:53 +00:00
}
// Download to a txt file
// Check if txt already exists and append it
2021-04-17 01:36:44 +00:00
const filename =
currentAscii.title.slice(currentAscii.title.length - 3) === "txt"
? currentAscii.title
: `${currentAscii.title}.txt`;
2021-04-24 00:20:11 +00:00
switch (type) {
case "clipboard":
2021-06-19 00:26:23 +00:00
this.$copyText(output.join("")).then(
function (e) {
alert("Copied");
console.log(e);
},
function (e) {
alert("Can not copy");
console.log(e);
}
);
2021-04-24 00:20:11 +00:00
break;
default:
case "file":
this.downloadToFile(output.join(""), filename, "text/plain");
break;
}
},
downloadToFile(content, filename, contentType) {
2021-03-30 08:36:53 +00:00
const downloadToFile = (content, filename, contentType) => {
2021-04-17 01:36:44 +00:00
const a = document.createElement("a");
2021-03-30 08:36:53 +00:00
const file = new Blob([content], { type: contentType });
a.href = URL.createObjectURL(file);
a.download = filename;
a.click();
URL.revokeObjectURL(a.href);
};
2021-04-03 03:13:03 +00:00
return downloadToFile(content, filename, contentType);
2021-03-30 08:36:53 +00:00
},
changeTab(key, value) {
// Update the tab index in vuex store
2021-03-13 03:30:58 +00:00
this.currentTab = key;
2021-04-17 01:36:44 +00:00
this.$store.commit("changeTab", key);
},
2021-01-30 02:33:11 +00:00
clearCache() {
localStorage.clear();
2021-04-17 01:36:44 +00:00
window.location.href = "/";
2021-01-30 02:33:11 +00:00
},
create2DArray(rows) {
const arr = [];
for (let i = 0; i < rows; i++) {
arr[i] = [];
}
return arr;
},
2021-04-02 02:07:49 +00:00
captureMouse(event) {
2021-04-03 03:13:03 +00:00
// clientX/Y gives the coordinates relative to the viewport in CSS pixels.
// console.log("viewport", event.clientX);
// console.log("viewport", event.clientY);
2021-04-02 02:07:49 +00:00
2021-04-03 03:13:03 +00:00
// // pageX/Y gives the coordinates relative to the <html> element in CSS pixels.
// console.log("element", event.pageX);
// console.log("element", event.pageY);
2021-04-02 02:07:49 +00:00
2021-04-03 03:13:03 +00:00
this.dashboardX = event.pageX;
this.dashboardY = event.pageY;
2021-04-02 02:07:49 +00:00
2021-04-03 03:13:03 +00:00
// // screenX/Y gives the coordinates relative to the screen in device pixels.
// console.log("screen", event.screenX);
// console.log("screen", event.screenY);
},
},
};
</script>