Files
hexo-theme-butterfly/layout/includes/head/subtitle.pug
2020-03-28 03:20:36 +08:00

117 lines
3.7 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 subtitleEffect = !{subtitleEffect}
fetch('https://api.ooopn.com/ciba/api.php',)
.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['ciba-en'],data.ciba)
var typed = new Typed("#subtitle", {
strings: sub,
startDelay: 300,
typeSpeed: 150,
loop: !{theme.subtitle.loop},
backSpeed: 50
});
}else{
document.getElementById("subtitle").innerHTML = data['ciba-en']
}
})
.catch(function (err) {
console.error(err);
})
else if source == '2'
script.
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);
})
else if source == "3"
script(type="text/javascript" src="http://yijuzhan.com/api/word.php?m=js")
script.
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
}
else if source == '4'
script(type="text/javascript" src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8")
script.
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
}
})
else
- var subtitle = theme.subtitle.sub[0]
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 = '!{subtitle}'
}