mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
131 lines
4.4 KiB
Plaintext
131 lines
4.4 KiB
Plaintext
if theme.subtitle.enable
|
|
- var source = theme.subtitle.source
|
|
- var subtitleEffect = theme.subtitle.effect
|
|
|
|
if subtitleEffect
|
|
script(src=url_for(theme.CDN.typed))
|
|
|
|
if source == '1'
|
|
script.
|
|
var subtitleType = function () {
|
|
var subtitleEffect = !{ subtitleEffect }
|
|
fetch('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',)
|
|
.then(function (res) {
|
|
return res.json()
|
|
})
|
|
.then(function (data) {
|
|
if (subtitleEffect) {
|
|
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(',')
|
|
var both = sub.unshift(data.text)
|
|
var typed = new Typed('#subtitle', {
|
|
strings: sub,
|
|
startDelay: 300,
|
|
typeSpeed: 150,
|
|
loop: !{theme.subtitle.loop},
|
|
backSpeed: 50,
|
|
})
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = data.text
|
|
}
|
|
})
|
|
.catch(function (err) {
|
|
console.error(err)
|
|
})
|
|
}
|
|
window.addEventListener('load', subtitleType)
|
|
|
|
else if source == '2'
|
|
script.
|
|
var subtitleType = function () {
|
|
var subtitleEffect = !{ subtitleEffect }
|
|
fetch('https://v1.hitokoto.cn')
|
|
.then(function (res) {
|
|
return res.json()
|
|
})
|
|
.then(function (data) {
|
|
if (subtitleEffect) {
|
|
var from = '出自 ' + data.from
|
|
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(',')
|
|
var both = sub.unshift(data.hitokoto, from)
|
|
var typed = new Typed('#subtitle', {
|
|
strings: sub,
|
|
startDelay: 300,
|
|
typeSpeed: 150,
|
|
loop: !{theme.subtitle.loop},
|
|
backSpeed: 50,
|
|
})
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = data.hitokoto
|
|
}
|
|
})
|
|
.catch(function (err) {
|
|
console.error(err)
|
|
})
|
|
}
|
|
window.addEventListener('load', subtitleType)
|
|
|
|
else if source == '3'
|
|
script.
|
|
var subtitleType = function () {
|
|
loadScript('http://yijuzhan.com/api/word.php?m=js', function () {
|
|
var subtitleEffect = !{ subtitleEffect }
|
|
var con = str[0]
|
|
if (subtitleEffect) {
|
|
var from = '出自 ' + str[1]
|
|
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(',')
|
|
var both = sub.unshift(con, from)
|
|
var typed = new Typed('#subtitle', {
|
|
strings: sub,
|
|
startDelay: 300,
|
|
typeSpeed: 150,
|
|
loop: !{theme.subtitle.loop},
|
|
backSpeed: 50,
|
|
})
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = con
|
|
}
|
|
})
|
|
}
|
|
window.addEventListener('load', subtitleType)
|
|
|
|
else if source == '4'
|
|
script.
|
|
var subtitleType = function () {
|
|
loadScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () {
|
|
var subtitleEffect = !{ subtitleEffect }
|
|
jinrishici.load(function (result) {
|
|
if (subtitleEffect) {
|
|
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(',')
|
|
var content = result.data.content
|
|
var both = sub.unshift(content)
|
|
var typed = new Typed('#subtitle', {
|
|
strings: sub,
|
|
startDelay: 300,
|
|
typeSpeed: 150,
|
|
loop: !{theme.subtitle.loop},
|
|
backSpeed: 50,
|
|
})
|
|
} else {
|
|
document.getElementById('subtitle').innerHTML = result.data.content
|
|
}
|
|
})
|
|
}
|
|
)
|
|
}
|
|
window.addEventListener('load', subtitleType)
|
|
|
|
else
|
|
script.
|
|
var subtitleEffect = !{subtitleEffect}
|
|
if (subtitleEffect) {
|
|
var typed = new Typed("#subtitle", {
|
|
strings: '!{theme.subtitle.sub}'.split(","),
|
|
startDelay: 300,
|
|
typeSpeed: 150,
|
|
loop: !{theme.subtitle.loop},
|
|
backSpeed: 50
|
|
})
|
|
} else {
|
|
document.getElementById("subtitle").innerHTML = '!{theme.subtitle.sub[0]}'
|
|
}
|