Merge pull request #400 from YunoHost/unselectable-logs

Make logs unselectable to force people clicking the damn share button >_>
This commit is contained in:
Alexandre Aubin 2021-09-29 18:22:35 +02:00 committed by GitHub
commit ced352f04f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 10 deletions

View file

@ -125,17 +125,31 @@ export default {
},
mounted () {
// Konamicode ;P
const konamiCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a']
let step = 0
// Unlock copypasta on log view
const copypastaCode = ['ArrowDown', 'ArrowDown', 'ArrowUp', 'ArrowUp']
let copypastastep = 0
document.addEventListener('keydown', ({ key }) => {
if (key === konamiCode[step++]) {
if (step === konamiCode.length) {
this.$store.commit('SET_SPINNER', 'nyancat')
step = 0
if (key === copypastaCode[copypastastep++]) {
if (copypastastep === copypastaCode.length) {
document.getElementsByClassName("unselectable").forEach((element) => element.classList.remove("unselectable"))
copypastastep = 0
}
} else {
step = 0
copypastastep = 0
}
})
// Konamicode ;P
const konamiCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a']
let konamistep = 0
document.addEventListener('keydown', ({ key }) => {
if (key === konamiCode[konamistep++]) {
if (konamistep === konamiCode.length) {
this.$store.commit('SET_SPINNER', 'nyancat')
konamistep = 0
}
} else {
konamistep = 0
}
})

View file

@ -466,6 +466,7 @@
"system_upgrade_all_applications_btn": "Upgrade all applications",
"system_upgrade_all_packages_btn": "Upgrade all packages",
"tcp": "TCP",
"text_selection_is_disabled": "Text selection is disabled. If you want to share this log, please share the *full* log with the 'Share with Yunopaste' button.<br/><small>Or if you really really want to select text, press these keys: ↓↓↑↑.</small>",
"tip_about_user_email": "Users are created with an associated email address (and XMPP account) with the format username@domain.tld. Additional email aliases and email forwards can later be added by the admin and the user.",
"tools": "Tools",
"tools_adminpw": "Change administration password",

View file

@ -175,3 +175,11 @@ code {
background-color: $light;
overflow: auto;
}
.unselectable {
-webkit-user-select: none;
-webkit-touch-callout: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

View file

@ -50,12 +50,15 @@
<icon iname="plus" /> {{ $t('logs_more') }}
</b-button>
<pre class="log"><code v-html="logs" /></pre>
<pre class="log unselectable"><code v-html="logs" /></pre>
<b-button @click="shareLogs" variant="success" class="w-100 rounded-0">
<icon iname="cloud-upload" /> {{ $t('logs_share_with_yunopaste') }}
</b-button>
</card>
<p class="w-100 px-5 py-2 mb-0" v-html="$t('text_selection_is_disabled')" />
</view-base>
</template>