diff options
| author | Henry Jameson <me@hjkos.com> | 2021-04-13 00:08:17 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2021-04-13 00:08:17 +0300 |
| commit | 09ef284af7e0c9312cf9968deefe8fe701387689 (patch) | |
| tree | 29d03f7f7054056036bdaabb617b76d63a906c54 | |
| parent | 87903fbf6dd8fbc47fe5a49b901aa295e07529e8 (diff) | |
better label, better error handling
| -rw-r--r-- | src/components/flash/flash.js | 13 | ||||
| -rw-r--r-- | src/components/flash/flash.vue | 28 | ||||
| -rw-r--r-- | src/i18n/en.json | 4 |
3 files changed, 37 insertions, 8 deletions
diff --git a/src/components/flash/flash.js b/src/components/flash/flash.js index 74ea3400..d03384c7 100644 --- a/src/components/flash/flash.js +++ b/src/components/flash/flash.js @@ -1,9 +1,13 @@ import RuffleService from '../../services/ruffle_service/ruffle_service.js' import { library } from '@fortawesome/fontawesome-svg-core' -import { faStop } from '@fortawesome/free-solid-svg-icons' +import { + faStop, + faExclamationTriangle +} from '@fortawesome/free-solid-svg-icons' library.add( - faStop + faStop, + faExclamationTriangle ) const Flash = { @@ -17,7 +21,7 @@ const Flash = { }, methods: { openPlayer () { - if (this.player) return // prevent double-loading + if (this.player) return // prevent double-loading, or re-loading on failure this.player = 'hidden' RuffleService.getRuffle().then((ruffle) => { const player = ruffle.newest().createPlayer() @@ -30,6 +34,9 @@ const Flash = { player.style.height = '100%' player.load(this.src).then(() => { this.player = true + }).catch((e) => { + console.error('Error loading ruffle', e) + this.player = 'error' }) this.ruffleInstance = player }) diff --git a/src/components/flash/flash.vue b/src/components/flash/flash.vue index fb8981e1..d20d037b 100644 --- a/src/components/flash/flash.vue +++ b/src/components/flash/flash.vue @@ -1,13 +1,13 @@ <template> <div class="Flash"> <div - v-if="player" + v-if="player === true || player === 'hidden'" ref="container" class="player" :class="{ hidden: player === 'hidden' }" /> <button - v-if="player === false || player === 'hidden'" + v-if="player !== true" class="button-unstyled placeholder" @click="openPlayer" > @@ -18,10 +18,22 @@ {{ $t('general.loading') }} </span> <span + v-if="player === 'error'" + class="label" + > + {{ $t('general.flash_fail') }} + </span> + <span v-else class="label" > - {{ $t('general.flash_content') }} + <p> + {{ $t('general.flash_content') }} + </p> + <p> + <FAIcon icon="exclamation-triangle" /> + {{ $t('general.flash_security') }} + </p> </span> </button> <button @@ -52,6 +64,14 @@ top: 0; } + .label { + text-align: center; + flex: 1 1 0; + line-height: 1.2; + white-space: normal; + word-wrap: normal; + } + .hidden { display: none; visibility: 'hidden'; @@ -59,7 +79,7 @@ .placeholder { height: 100%; - width: 100%; + flex: 1; display: flex; align-items: center; justify-content: center; diff --git a/src/i18n/en.json b/src/i18n/en.json index 90cbbf0f..61d88cb3 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -80,7 +80,9 @@ "admin": "Admin", "moderator": "Moderator" }, - "flash_content": "Click to show Flash content using Ruffle (Experimental)" + "flash_content": "Click to show Flash content using Ruffle (Experimental, may not work).", + "flash_security": "Note that this can be potentially dangerous since Flash content is still arbitrary code, it might leak your cookies.", + "flash_fail": "Failed to load flash content, see console for details." }, "image_cropper": { "crop_picture": "Crop picture", |
