You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

55 lines
1.8 KiB
Plaintext

<div class="container has-text-centered">
<p class="title">
Wasm Base91 Converter
</p>
<div vg-if="c.TextToB91">
<textarea vg-content='c.PlainText' @keyup="c.ToB91(event)" placeholder="Plaintext" rows="4" cols="50"></textarea>
<div style="margin-bottom: 0.5rem;"></div>
<textarea vg-content='c.B91String' placeholder="Base91" rows="4" cols="50"></textarea>
</div>
<div vg-if="c.B91ToText">
<textarea vg-content='c.B91String' @keyup="c.ToString(event)" placeholder="Base91" rows="4" cols="50"></textarea>
<div style="margin-bottom: 0.5rem;"></div>
<textarea vg-content='c.PlainText' placeholder="Plaintext" rows="4" cols="50"></textarea>
</div>
<a class="button is-light" @click="c.Swap(event)" style="margin-top: 0.5rem;">
<span class="iconify" data-icon="heroicons-solid:refresh"></span>&nbsp;Swap
</a>
</div>
<script type="application/x-go">
import (
"ekyu.moe/base91"
)
type Base91 struct {
B91String string `vugu:"data"`
PlainText string `vugu:"data"`
TextToB91 bool `vugu:"data"`
B91ToText bool `vugu:"data"`
}
func (c *Base91) Init() {
c.TextToB91 = true
}
func (c *Base91) ToB91(event vugu.DOMEvent) {
plaintext := event.PropString("target", "value")
b91String := base91.EncodeToString([]byte(plaintext))
c.PlainText = plaintext
c.B91String = b91String
}
func (c *Base91) ToString(event vugu.DOMEvent) {
b91String := event.PropString("target", "value")
plain := base91.DecodeString(b91String)
c.PlainText = string(plain)
c.B91String = b91String
}
func (c *Base91) Swap(event vugu.DOMEvent) {
c.TextToB91, c.B91ToText = !c.TextToB91, !c.B91ToText
}
</script>