From fc867937a36e5e7752e99303243c56f682d98414 Mon Sep 17 00:00:00 2001 From: Nikhil Mehta Date: Mon, 30 May 2022 14:14:19 +0530 Subject: [PATCH] feat(labels): added ability to add labels to text section --- pages/diff.vue | 3 - pages/index.vue | 86 ++++++++++------ pages/v1/diff.vue | 248 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 304 insertions(+), 33 deletions(-) create mode 100644 pages/v1/diff.vue diff --git a/pages/diff.vue b/pages/diff.vue index 3c4985d..86fd050 100644 --- a/pages/diff.vue +++ b/pages/diff.vue @@ -100,9 +100,6 @@ export default { copied: false, } }, - asyncData() { - return { name: 'World' } - }, mounted() { const _diff = this.$route.hash const gunzip = pako.ungzip(Buffer.from(undoUrlSafeBase64(_diff), 'base64')) diff --git a/pages/index.vue b/pages/index.vue index 21d081d..445429d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -12,25 +12,47 @@ -
-
- - -
- + +
+
+ + +
+
+ +
+
+
+
@@ -49,14 +71,12 @@ export default Vue.extend({ methods: { checkForm(e: Event) { e.preventDefault() - const lhsTextArea: HTMLTextAreaElement = document.getElementById( - 'lhs' - ) as HTMLTextAreaElement - const lhs: string = lhsTextArea?.value || '' - const rhsTextArea: HTMLTextAreaElement = document.getElementById( - 'rhs' - ) as HTMLTextAreaElement - const rhs: string = rhsTextArea?.value || '' + const formData = new FormData(e.currentTarget as HTMLFormElement) + // const formDataJson = Object.fromEntries(formData.entries()) + const lhs = formData.get('lhs') + const rhs = formData.get('rhs') + const lhsLabel = formData.get('lhsLabel') + const rhsLabel = formData.get('rhsLabel') if (!lhs || !rhs) { this.$store.commit('toast/show', { show: true, @@ -84,11 +104,17 @@ export default Vue.extend({ const originalLhs = lhs const originalRhs = rhs const diff = dmp.diff_main(originalLhs, originalRhs) - const gzip = Buffer.from(pako.gzip(JSON.stringify(diff))).toString( - 'base64' - ) + const gzip = Buffer.from( + pako.gzip( + JSON.stringify({ + diff, + lhsLabel, + rhsLabel, + }) + ) + ).toString('base64') this.$router.push({ - path: '/diff', + path: '/v1/diff', hash: `#${doUrlSafeBase64(gzip)}`, }) }, diff --git a/pages/v1/diff.vue b/pages/v1/diff.vue new file mode 100644 index 0000000..2b5ea67 --- /dev/null +++ b/pages/v1/diff.vue @@ -0,0 +1,248 @@ + + + + +