[add] initial commit

This commit is contained in:
2022-09-30 21:05:45 -05:00
commit 366ae365ab
27 changed files with 10348 additions and 0 deletions

57
src/components/Gelvin.vue Normal file
View 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>

View 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>

View 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>