Skip to content

Commit

Permalink
Fix some linter errors, use blob URL for download
Browse files Browse the repository at this point in the history
Signed-off-by: Knut Ahlers <[email protected]>
  • Loading branch information
Luzifer committed Sep 23, 2023
1 parent 69c2b09 commit b8fd877
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/langs/langs.tpl.js
2 changes: 0 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
Expand Down Expand Up @@ -64,4 +63,3 @@
></script>
</body>
</html>

26 changes: 20 additions & 6 deletions src/app.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/no-v-html -->
<template>
<div id="app">
<b-navbar
Expand Down Expand Up @@ -76,7 +77,10 @@
v-html="$t('title-explanation')"
/>
<ul>
<li v-for="explanation in $t('items-explanation')">
<li
v-for="(explanation, idx) in $t('items-explanation')"
:key="`idx${idx}`"
>
{{ explanation }}
</li>
</ul>
Expand Down Expand Up @@ -255,7 +259,7 @@
<i class="fas fa-fw fa-clipboard" />
</b-button>
<b-button
:href="`data:text/plain;charset=UTF-8,${encodeURIComponent(secret)}`"
:href="secretContentBlobURL"
download
title="Download Secret as Text File"
>
Expand Down Expand Up @@ -305,6 +309,8 @@
</template>

<script>
/* global maxSecretExpire */
import crypto from './crypto.js'
import qrcode from 'qrcode'
Expand Down Expand Up @@ -351,10 +357,11 @@ export default {
explanationShown: false,
mode: 'create',
secret: '',
secretContentBlobURL: '',
secretContentQRDataURL: '',
secretExpiry: null,
secretId: '',
secretQRDataURL: '',
secretContentQRDataURL: '',
securePassword: '',
selectedExpiry: null,
showError: false,
Expand Down Expand Up @@ -443,7 +450,7 @@ export default {
window.setTimeout(() => this.$refs.secretUrl.focus(), 100)
})
})
.catch(err => {
.catch(() => {
// Network error
this.error = this.$t('alert-something-went-wrong')
this.showError = true
Expand Down Expand Up @@ -533,7 +540,7 @@ export default {
})
})
})
.catch(err => {
.catch(() => {
// Network error
this.error = this.$t('alert-something-went-wrong')
this.showError = true
Expand All @@ -558,6 +565,11 @@ export default {
},
secret(to) {
if (this.secretContentBlobURL) {
window.URL.revokeObjectURL(this.secretContentBlobURL)
}
this.secretContentBlobURL = window.URL.createObjectURL(new Blob([to], { type: 'text/plain' }))
if (this.customize.disableQRSupport || !to) {
return
}
Expand All @@ -566,7 +578,9 @@ export default {
.then(url => {
this.secretContentQRDataURL = url
})
.catch(() => this.secretContentQRDataURL = null)
.catch(() => {
this.secretContentQRDataURL = null
})
},
secretUrl(to) {
Expand Down
4 changes: 1 addition & 3 deletions src/langs/langs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/langs/langs.tpl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Auto-Generated, do not edit!

const switchFormal = (formal, informal) => {
return window.useFormalLanguage ? formal : informal
}
const switchFormal = (formal, informal) => window.useFormalLanguage ? formal : informal

export default {
{{- range $lang, $translation := .Translations -}}
Expand Down
7 changes: 5 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable sort-imports */
/* global version */
import Vue from 'vue'
import VueI18n from 'vue-i18n'

Expand All @@ -16,15 +18,16 @@ const cookieSet = Object.fromEntries(document.cookie.split('; ')
.map(el => decodeURIComponent(el))))

const i18n = new VueI18n({
locale: cookieSet.lang || navigator?.language || 'en',
fallbackLocale: 'en',
locale: cookieSet.lang || navigator?.language || 'en',
messages,
})

new Vue({
el: '#app',
components: { app },
data: { version },
el: '#app',
i18n,
name: 'OTSAppInterface',
render: createElement => createElement('app'),
})

0 comments on commit b8fd877

Please sign in to comment.