[add] initial commit
This commit is contained in:
57
src/components/Gelvin.vue
Normal file
57
src/components/Gelvin.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<a
|
||||
class="link icon-text"
|
||||
href="#"
|
||||
@click="toggle_locale()"
|
||||
>
|
||||
<span class="icon highlight">
|
||||
<font-awesome-icon icon="fa-solid fa-temperature-three-quarters" />
|
||||
</span><span style="font-size: 1em">{{ temperature }}</span>
|
||||
<slot />
|
||||
</a>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Gelvin',
|
||||
props: {
|
||||
addr: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
id: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fetcher: null,
|
||||
value: NaN,
|
||||
celsius: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
temperature() {
|
||||
return this.celsius ?
|
||||
this.value.toFixed(2).toLocaleString() + "°C" :
|
||||
(this.value * 9/5 + 32).toFixed(2).toLocaleString() + "°F" ;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetch_temp();
|
||||
this.fetcher = setInterval(this.fetch_temp, 30000)
|
||||
},
|
||||
methods: {
|
||||
fetch_temp() {
|
||||
fetch(this.addr + "/gelvin/measurements/" + this.id)
|
||||
.then(response => response.json())
|
||||
.then(json => this.value = json.value);
|
||||
},
|
||||
toggle_locale() {
|
||||
this.celsius = ! this.celsius;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
25
src/components/HashList.vue
Normal file
25
src/components/HashList.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div class="hash-list">
|
||||
<div
|
||||
v-for="(item, index) in items"
|
||||
:key="index"
|
||||
class="content is-small"
|
||||
>
|
||||
<span class="highlight">#</span> {{ item }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'HashList',
|
||||
props: {
|
||||
items: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
49
src/components/XorLink.vue
Normal file
49
src/components/XorLink.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<a
|
||||
class="link icon-text"
|
||||
href="#"
|
||||
@click="attachUrl()"
|
||||
>
|
||||
<span
|
||||
v-if="icon"
|
||||
class="icon highlight"
|
||||
><font-awesome-icon :icon="icon" /></span>{{ text }}
|
||||
<slot />
|
||||
</a>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'XorLink',
|
||||
props: {
|
||||
addr: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
otp: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
xorArray(a, b) {
|
||||
return a.length < b.length ? null : a.map((c, i) => {
|
||||
return c ^ b[i];
|
||||
})
|
||||
},
|
||||
attachUrl() {
|
||||
window.location.href = String.fromCharCode(...this.xorArray(this.addr, this.otp));
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user