前端新增深色主题模版

This commit is contained in:
xiongxiaoyang
2020-12-26 22:16:58 +08:00
parent 5e3962fef4
commit 45c59ecc37
413 changed files with 43337 additions and 1 deletions

View File

@ -0,0 +1,49 @@
Array.prototype.indexOf = function (val) {
for (var i = 0; i < this.length; i++) {
if (this[i] == val) return i;
}
return -1;
};
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
var token = localStorage.getItem("token");
if (token) {
$.get("/user/isLogin", {"token": token}, function (data) {
if (data.code != 1) {//未登录
localStorage.removeItem("token");
}
})
}
function readHistory() {
var books = localStorage.getItem("historyBooks");
var bookIds = "-1929";
if (books) {
bookIds = JSON.parse(localStorage.getItem("historyBooks")).join(",");
}
window.location.href = "/book/search?historyBookIds=" + bookIds;
};
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
}

9597
templates/dark/static/js/jquery-1.9.1.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
/*!
* Lazy Load - JavaScript plugin for lazy loading images
*
* Copyright (c) 2007-2019 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* https://appelsiini.net/projects/lazyload
*
* Version: 2.0.0-rc.2
*
*/
(function (root, factory) {
if (typeof exports === "object") {
module.exports = factory(root);
} else if (typeof define === "function" && define.amd) {
define([], factory);
} else {
root.LazyLoad = factory(root);
}
}) (typeof global !== "undefined" ? global : this.window || this.global, function (root) {
"use strict";
if (typeof define === "function" && define.amd){
root = window;
}
const defaults = {
src: "data-src",
srcset: "data-srcset",
selector: ".lazyload",
root: null,
rootMargin: "0px",
threshold: 0
};
/**
* Merge two or more objects. Returns a new object.
* @private
* @param {Boolean} deep If true, do a deep (or recursive) merge [optional]
* @param {Object} objects The objects to merge together
* @returns {Object} Merged values of defaults and options
*/
const extend = function () {
let extended = {};
let deep = false;
let i = 0;
let length = arguments.length;
/* Check if a deep merge */
if (Object.prototype.toString.call(arguments[0]) === "[object Boolean]") {
deep = arguments[0];
i++;
}
/* Merge the object into the extended object */
let merge = function (obj) {
for (let prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
/* If deep merge and property is an object, merge properties */
if (deep && Object.prototype.toString.call(obj[prop]) === "[object Object]") {
extended[prop] = extend(true, extended[prop], obj[prop]);
} else {
extended[prop] = obj[prop];
}
}
}
};
/* Loop through each object and conduct a merge */
for (; i < length; i++) {
let obj = arguments[i];
merge(obj);
}
return extended;
};
function LazyLoad(images, options) {
this.settings = extend(defaults, options || {});
this.images = images || document.querySelectorAll(this.settings.selector);
this.observer = null;
this.init();
}
LazyLoad.prototype = {
init: function() {
/* Without observers load everything and bail out early. */
if (!root.IntersectionObserver) {
this.loadImages();
return;
}
let self = this;
let observerConfig = {
root: this.settings.root,
rootMargin: this.settings.rootMargin,
threshold: [this.settings.threshold]
};
this.observer = new IntersectionObserver(function(entries) {
Array.prototype.forEach.call(entries, function (entry) {
if (entry.isIntersecting) {
self.observer.unobserve(entry.target);
let src = entry.target.getAttribute(self.settings.src);
let srcset = entry.target.getAttribute(self.settings.srcset);
if ("img" === entry.target.tagName.toLowerCase()) {
if (src) {
entry.target.src = src;
}
if (srcset) {
entry.target.srcset = srcset;
}
} else {
entry.target.style.backgroundImage = "url(" + src + ")";
}
}
});
}, observerConfig);
Array.prototype.forEach.call(this.images, function (image) {
self.observer.observe(image);
});
},
loadAndDestroy: function () {
if (!this.settings) { return; }
this.loadImages();
this.destroy();
},
loadImages: function () {
if (!this.settings) { return; }
let self = this;
Array.prototype.forEach.call(this.images, function (image) {
let src = image.getAttribute(self.settings.src);
let srcset = image.getAttribute(self.settings.srcset);
if ("img" === image.tagName.toLowerCase()) {
if (src) {
image.src = src;
}
if (srcset) {
image.srcset = srcset;
}
} else {
image.style.backgroundImage = "url('" + src + "')";
}
});
},
destroy: function () {
if (!this.settings) { return; }
this.observer.disconnect();
this.settings = null;
}
};
root.lazyload = function(images, options) {
return new LazyLoad(images, options);
};
if (root.jQuery) {
const $ = root.jQuery;
$.fn.lazyload = function (options) {
options = options || {};
options.attribute = options.attribute || "data-src";
new LazyLoad($.makeArray(this), options);
return this;
};
}
return LazyLoad;
});

View File

@ -0,0 +1,197 @@
var checkbg = "#A7A7A7";
var nr_body = document.getElementById("read");//页面body
var huyandiv = document.getElementById("huyandiv");//护眼div
var lightdiv = document.getElementById("lightdiv");//灯光div
var fontfont = document.getElementById("fontfont");//字体div
var fontbig = document.getElementById("fontbig");//大字体div
var fontmiddle = document.getElementById("fontmiddle");//中字体div
var fontsmall = document.getElementById("fontsmall");//小字体div
var nr1 = document.getElementById("chaptercontent");//内容div
//内容页用户设置
function nr_setbg(intype){
var huyandiv = document.getElementById("huyandiv");
var light = document.getElementById("lightdiv");
if(intype == "huyan"){
if(huyandiv.className == "button huyanon"){
document.cookie="light=huyan;path=/";
set("light","huyan");
}
else{
document.cookie="light=no;path=/";
set("light","no");
}
}
if(intype == "light"){
if(light.innerHTML == "关灯"){
document.cookie="light=yes;path=/";
set("light","yes");
}
else{
document.cookie="light=no;path=/";
set("light","no");
}
}
if(intype == "big"){
document.cookie="font=big;path=/";
set("font","big");
}
if(intype == "middle"){
document.cookie="font=middle;path=/";
set("font","middle");
}
if(intype == "small"){
document.cookie="font=small;path=/";
set("font","small");
}
}
//内容页读取设置
function getset(){
var strCookie=document.cookie;
var arrCookie=strCookie.split("; ");
var light;
var font;
for(var i=0;i<arrCookie.length;i++){
var arr=arrCookie[i].split("=");
if("light"==arr[0]){
light=arr[1];
break;
}
}
//light
if(light == "yes"){
set("light","yes");
}
else if(light == "no"){
set("light","no");
}
else if(light == "huyan"){
set("light","huyan");
}
}
//内容页读取设置
function getset1(){
var strCookie=document.cookie;
var arrCookie=strCookie.split("; ");
var light;
var font;
for(var j=0;j<arrCookie.length;j++){
var arr=arrCookie[j].split("=");
if("font"==arr[0]){
font=arr[1];
break;
}
}
//font
if(font == "big"){
set("font","big");
}
else if(font == "middle"){
set("font","middle");
}
else if(font == "small"){
set("font","small");
}
else{
set("font","middle");
}
}
//内容页应用设置
function set(intype,p){
//var nr_title = document.getElementById("top1");//文章标题
//var nr_title = document.getElementById("nr_title");//文章标题
//var shuqian_2 = document.getElementById("shuqian_2");//书签链接
//var pt_prev = document.getElementById("pt_prev1");
//var pt_mulu = document.getElementById("pt_mulu1");
//var pt_next = document.getElementById("pt_next1");
//var pb_prev = document.getElementById("pb_prev1");
//var pb_mulu = document.getElementById("pb_mulu1");
//var pb_next = document.getElementById("pb_next1");
//灯光
if(intype == "light"){
if(p == "yes"){
//关灯
lightdiv.innerHTML = "开灯";
lightdiv.className="button lighton";
nr_body.style.backgroundColor = "#000";
//nr_title.style.color = "#ccc";
nr1.style.color = "#999";
huyandiv.innerHTML = "护眼";
huyandiv.className="button huyanon";
//pt_prev.style.cssText = "background-color:#222;color:#0065B5;";
//pt_mulu.style.cssText = "background-color:#222;color:#0065B5;";
//pt_next.style.cssText = "background-color:#222;color:#0065B5;";
//pb_prev.style.cssText = "background-color:#222;color:#0065B5;";
//pb_mulu.style.cssText = "background-color:#222;color:#0065B5;";
//pb_next.style.cssText = "background-color:#222;color:#0065B5;";
//shuqian_2.style.color = "#999";
}
else if(p == "no"){
//开灯
lightdiv.innerHTML = "关灯";
lightdiv.className="button lightoff";
nr_body.style.backgroundColor = "#fff";
nr1.style.color = "#000";
//nr_title.style.color = "#000";
//pt_prev.style.cssText = "";
//pt_mulu.style.cssText = "";
//pt_next.style.cssText = "";
//pb_prev.style.cssText = "";
//pb_mulu.style.cssText = "";
//pb_next.style.cssText = "";
//shuqian_2.style.color = "#000";
huyandiv.innerHTML = "护眼";
huyandiv.className="button huyanon";
}
else if(p == "huyan"){
//护眼
lightdiv.innerHTML = "关灯";
lightdiv.className="button lightoff";
huyandiv.className="button huyanoff";
nr_body.style.backgroundColor = "#005716";
nr1.style.color = "#000";
//pt_prev.style.cssText = "background-color:#0E7A18;color:#000;";
//pt_mulu.style.cssText = "background-color:#0E7A18;color:#000;";
//pt_next.style.cssText = "background-color:#0E7A18;color:#000;";
//pb_prev.style.cssText = "background-color:#0E7A18;color:#000;";
//pb_mulu.style.cssText = "background-color:#0E7A18;color:#000;";
//pb_next.style.cssText = "background-color:#0E7A18;color:#000;";
shuqian_2.style.color = "#000";
}
}
//字体
if(intype == "font"){
fontsmall.className="sizebg";
if(p == "big"){
fontbig.className="button sizebgon";
nr1.style.fontSize="25px";
fontmiddle.className="sizebg";
fontsmall.className="sizebg";
}
if(p == "middle"){
fontmiddle.className="button sizebgon";
nr1.style.fontSize = "20px";
fontbig.className="sizebg";
fontsmall.className="sizebg";
}
if(p == "small"){
fontsmall.className="button sizebgon";
nr1.style.fontSize = "14px";
fontbig.className="sizebg";
fontmiddle.className="sizebg";
}
}
}

View File

@ -0,0 +1,107 @@
window.onload=function(){
// AddToFavorites(false);
}
function AddToFavorites(isTip)
{
if(GetCookie("isCollect") && !isTip){
return
}
else {
SetCookie("isCollect","1");
var title = document.title;
var url = location.href;
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, '');
else if (window.opera && window.print) // Opera
{
var elem = document.createElement('a');
elem.setAttribute('href', url);
elem.setAttribute('title', title);
elem.setAttribute('rel', 'sidebar'); // required to work in opera 7+
elem.click();
}
else if (navigator.userAgent.indexOf('UCBrowser') > -1) {//UC
window.location.href = "ext:add_favorite";
}
else if (document.all) // IE
window.external.AddFavorite(url, title);
else {
if(isTip){
alert("该浏览器不支持自动收藏请点击Ctrl+D手动收藏");
}
}
}
}
function SetCookie(name, value) {
var key = '';
var Days = 365;
var exp = new Date();
var domain = "";
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
if (key == null || key == "") {
document.cookie = name + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/;domain=" + domain + ";";
}
else {
var nameValue = GetCookie(name);
if (nameValue == "") {
document.cookie = name + "=" + key + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/;domain=" + domain + ";";
}
else {
var keyValue = getCookie(name, key);
if (keyValue != "") {
nameValue = nameValue.replace(key + "=" + keyValue, key + "=" + encodeURI(value));
document.cookie = name + "=" + nameValue + ";expires=" + exp.toGMTString() + ";path=/;domain=" + domain + ";";
}
else {
document.cookie = name + "=" + nameValue + "&" + key + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/;" + domain + ";";
}
}
}
}
function GetCookie(name) {
var nameValue = "";
var key = "";
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)) {
nameValue = decodeURI(arr[2]);
}
if (key != null && key != "") {
reg = new RegExp("(^| |&)" + key + "=([^(;|&|=)]*)(&|$)");
if (arr = nameValue.match(reg)) {
return decodeURI(arr[2]);
}
else return "";
}
else {
return nameValue;
}
}
function DelCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=GetCookie(name);
if(cval!=null)
document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}