[init] initial commit for gitea
This commit is contained in:
38
assets/js/bing.js
Normal file
38
assets/js/bing.js
Normal file
@ -0,0 +1,38 @@
|
||||
const https = require('https')
|
||||
const fs = require('fs')
|
||||
|
||||
const options = {
|
||||
hostname: 'www.bing.com',
|
||||
port: 443,
|
||||
path: '/HPImageArchive.aspx?format=js&idx=0&n=8',
|
||||
method: 'GET'
|
||||
}
|
||||
|
||||
const req = https.request(options, bing_res => {
|
||||
let bing_body = [], bing_data = {};
|
||||
bing_res.on('data', (chunk) => {
|
||||
bing_body.push(chunk);
|
||||
});
|
||||
bing_res.on('end', () => {
|
||||
bing_body = Buffer.concat(bing_body);
|
||||
bing_data = JSON.parse(bing_body.toString());
|
||||
let img_array = bing_data.images;
|
||||
let img_url = [];
|
||||
img_array.forEach(img => {
|
||||
img_url.push(img.url);
|
||||
});
|
||||
var jsonpStr = "getBingImages(" + JSON.stringify(img_url) + ")";
|
||||
fs.writeFile('./assets/json/images.json', jsonpStr, (err) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log("JSON data is saved: " + jsonpStr);
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
req.on('error', error => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.end()
|
2
assets/js/jquery.min.js
vendored
Normal file
2
assets/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
74
assets/js/main.js
Normal file
74
assets/js/main.js
Normal file
@ -0,0 +1,74 @@
|
||||
var iUp = (function () {
|
||||
var t = 0,
|
||||
d = 150,
|
||||
clean = function () {
|
||||
t = 0;
|
||||
},
|
||||
up = function (e) {
|
||||
setTimeout(function () {
|
||||
$(e).addClass("up")
|
||||
}, t);
|
||||
t += d;
|
||||
},
|
||||
down = function (e) {
|
||||
$(e).removeClass("up");
|
||||
},
|
||||
toggle = function (e) {
|
||||
setTimeout(function () {
|
||||
$(e).toggleClass("up")
|
||||
}, t);
|
||||
t += d;
|
||||
};
|
||||
return {
|
||||
clean: clean,
|
||||
up: up,
|
||||
down: down,
|
||||
toggle: toggle
|
||||
}
|
||||
})();
|
||||
|
||||
function getBingImages(imgUrls) {
|
||||
/**
|
||||
* 获取Bing壁纸
|
||||
* 先使用 GitHub Action 每天获取 Bing 壁纸 URL 并更新 images.json 文件
|
||||
* 然后读取 images.json 文件中的数据
|
||||
*/
|
||||
var indexName = "bing-image-index";
|
||||
var index = sessionStorage.getItem(indexName);
|
||||
var $panel = $('#panel');
|
||||
if (isNaN(index) || index == 7) index = 0;
|
||||
else index++;
|
||||
var imgUrl = imgUrls[index];
|
||||
var url = "https://www.bing.com" + imgUrl;
|
||||
$panel.css("background", "url('" + url + "') center center no-repeat #666");
|
||||
$panel.css("background-size", "cover");
|
||||
sessionStorage.setItem(indexName, index);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
// 获取一言数据
|
||||
$.get('https://v1.hitokoto.cn', function (res) {
|
||||
$('#description').html(res.hitokoto + "<br/> -「<strong>" + res.from + "</strong>」")
|
||||
});
|
||||
|
||||
$(".iUp").each(function (i, e) {
|
||||
iUp.up(e);
|
||||
});
|
||||
$(".js-avatar")[0].onload = function () {
|
||||
$(".js-avatar").addClass("show");
|
||||
}
|
||||
});
|
||||
|
||||
$('.btn-mobile-menu__icon').click(function () {
|
||||
if ($('.navigation-wrapper').css('display') == "block") {
|
||||
$('.navigation-wrapper').on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
|
||||
$('.navigation-wrapper').toggleClass('visible animated bounceOutUp');
|
||||
$('.navigation-wrapper').off('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend');
|
||||
});
|
||||
$('.navigation-wrapper').toggleClass('animated bounceInDown animated bounceOutUp');
|
||||
|
||||
} else {
|
||||
$('.navigation-wrapper').toggleClass('visible animated bounceInDown');
|
||||
}
|
||||
$('.btn-mobile-menu__icon').toggleClass('social iconfont icon-list social iconfont icon-angleup animated fadeIn');
|
||||
});
|
Reference in New Issue
Block a user