| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- var iUp = (function () {
- var time = 0,
- duration = 150,
- clean = function () {
- time = 0;
- },
- up = function (element) {
- setTimeout(function () {
- element.classList.add("up");
- }, time);
- time += duration;
- },
- down = function (element) {
- element.classList.remove("up");
- },
- toggle = function (element) {
- setTimeout(function () {
- element.classList.toggle("up");
- }, time);
- time += duration;
- };
- 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 = document.querySelector('#panel');
- if (isNaN(index) || index == 7) index = 0;
- else index++;
- var imgUrl = imgUrls[index];
- var url = "https://www.cn.bing.com" + imgUrl;
- panel.style.background = "url('" + url + "') center center no-repeat #666";
- panel.style.backgroundSize = "cover";
- sessionStorage.setItem(indexName, index);
- }
- function decryptEmail(encoded) {
- var address = atob(encoded);
- window.location.href = "mailto:" + address;
- }
- document.addEventListener('DOMContentLoaded', function () {
- // 获取一言数据
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function () {
- if (this.readyState == 4 && this.status == 200) {
- var res = JSON.parse(this.responseText);
- document.getElementById('description').innerHTML = res.hitokoto + "<br/> -「<strong>" + res.from + "</strong>」";
- }
- };
- xhr.open("GET", "https://v1.hitokoto.cn", true);
- xhr.send();
- var iUpElements = document.querySelectorAll(".iUp");
- iUpElements.forEach(function (element) {
- iUp.up(element);
- });
- var avatarElement = document.querySelector(".js-avatar");
- avatarElement.addEventListener('load', function () {
- avatarElement.classList.add("show");
- });
- });
- var btnMobileMenu = document.querySelector('.btn-mobile-menu__icon');
- var navigationWrapper = document.querySelector('.navigation-wrapper');
- btnMobileMenu.addEventListener('click', function () {
- if (navigationWrapper.style.display == "block") {
- navigationWrapper.addEventListener('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
- navigationWrapper.classList.toggle('visible');
- navigationWrapper.classList.toggle('animated');
- navigationWrapper.classList.toggle('bounceOutUp');
- navigationWrapper.removeEventListener('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', arguments.callee);
- });
- navigationWrapper.classList.toggle('animated');
- navigationWrapper.classList.toggle('bounceInDown');
- navigationWrapper.classList.toggle('animated');
- navigationWrapper.classList.toggle('bounceOutUp');
- } else {
- navigationWrapper.classList.toggle('visible');
- navigationWrapper.classList.toggle('animated');
- navigationWrapper.classList.toggle('bounceInDown');
- }
- btnMobileMenu.classList.toggle('social');
- btnMobileMenu.classList.toggle('iconfont');
- btnMobileMenu.classList.toggle('icon-list');
- btnMobileMenu.classList.toggle('social');
- btnMobileMenu.classList.toggle('iconfont');
- btnMobileMenu.classList.toggle('icon-angleup');
- btnMobileMenu.classList.toggle('animated');
- btnMobileMenu.classList.toggle('fadeIn');
- });
|