Make logs unselectable to force people clicking the damn share button >_>

This commit is contained in:
Alexandre Aubin 2021-09-24 20:24:58 +02:00
parent 127ceefa02
commit 81b00d3ac7
3 changed files with 39 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

@ -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,19 @@
<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">
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>
</p>
</view-base>
</template>