tilde/js/app.js

118 lines
3.2 KiB
JavaScript
Executable File

var vm = new Vue({
el: '#app',
data: {
links: [
{
"text": "blog",
"href": "blog/",
"icon": "rss"
},
{
"text": "keybase",
"href": "https://keybase.io/bharris",
"icon": "key"
},
{
"text": "github",
"href": "https://github.com/benharri",
"icon": "github"
},
{
"text": "gitea",
"href": "https://git.tilde.team/ben",
"icon": "code-fork"
},
{
"text": "stack overflow",
"href": "https://stackoverflow.com/users/6352706/ben-harris",
"icon": "stack-overflow"
},
{
"text": "my git guide",
"href": "https://benharri.github.io/learngit/",
"icon": "git"
},
{
"text": "my personal site",
"href": "https://benharr.is",
"icon": "globe"
},
{
"text": "my discord bot",
"href": "https://bot.benharr.is",
"icon": "comments-o"
},
{
"text": "software design pattern book",
"href": "patterns/",
"icon": "book"
},
{
"text": "win solitaire",
"href": "soli/",
"icon": "gamepad"
},
{
"text": "tildebook",
"href": "https://tilde.zone/@ben",
"icon": "share-square"
},
{
"text": "tilde irc",
"href": "https://irc.tilde.team",
"icon": "comments"
}
],
text: 'type here',
output: '',
font: 'standard',
fonts: [],
yesno: '',
yesnoimg: '',
tagline: '',
numtags: 0
},
created: function () {
axios.get(
'api/?fonts'
).then(function (response) {
vm.fonts = response.data
})
axios.get(
'api/?count'
).then(function (response) {
vm.numtags = response.data
vm.getnewtagline()
})
this.updateOutput()
},
methods: {
updateOutput: function () {
axios.get(
'api/?text=' + this.text + '&font=' + this.font
).then(function (response) {
vm.output = response.data
})
},
getyesno: function () {
axios.get(
'https://yesno.wtf/api'
).then(function (response) {
response = response.data
vm.yesno = response.answer
vm.yesnoimg = response.image
})
},
getnewtagline: function () {
axios.get(
'api/?key=' + Math.floor(Math.random() * vm.numtags)
).then(function (response) {
vm.tagline = response.data
})
},
faclass: function (icon) {
return "fa fa-" + icon
}
}
})