feat(templates): 新增绿色主题模版,并设置为默认模版

和文档站点 docs.xxyopen.com 风格保持一致
This commit is contained in:
xiongxiaoyang
2023-10-13 21:21:21 +08:00
parent 00179359bd
commit 255b3f8c4b
575 changed files with 72292 additions and 955 deletions

View File

@ -0,0 +1,201 @@
var needLoginPath = ['/user/favorites.html', '/user/comment.html', '/user/feedback.html',
'/user/feedback_list.html', '/user/read_history.html', '/user/set_name.html',
'/user/set_password.html', '/user/set_sex.html', '/user/setup.html', '/user/userinfo.html',
"/pay/index.html," +
"/author/register.html", "/author/index.html"];
var isLogin = false;
var url = window.location.search;
//key(需要检索的键)
function getSearchString(key) {
var str = url;
str = str.substring(1, str.length); // 获取URL中?之后的字符(去掉第一位的问号)
// 以&分隔字符串获得类似name=xiaoli这样的元素数组
var arr = str.split("&");
for (var i = 0; i < arr.length; i++) {
var tmp_arr = arr[i].split("=");
if (tmp_arr[0] == key) {
return decodeURIComponent(tmp_arr[1]);
}
}
return undefined;
}
var keyword = getSearchString("k");
if (keyword != undefined) {
$("#searchKey").val(keyword);
$("#workDirection").remove();
$("#idGirl").remove();
}
function searchByK(k) {
if (!k) {
window.location.href = '/book/bookclass.html?k=' + encodeURIComponent(document.getElementById("searchKey").value)
} else {
window.location.href = '/book/bookclass.html?k=' + encodeURIComponent(k)
}
}
$("#searchKey").keypress(function (even) {
if (even.which == 13) {
even.stopPropagation();
//enter键按下
searchByK();
}
});
Array.prototype.indexOf = function (val) {
for (var i = 0; i < this.length; i++) {
if (this[i] == val) return i;
}
return -1;
};
jQuery.cookie = function (name, value, options) {
if (typeof value != 'undefined') {
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
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 = $.cookie('Authorization');
if (!token) {
if (needLoginPath.indexOf(window.location.pathname) != -1) {
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
}
$(".user_link").html("<a href=\"/user/login.html\">登录</a><a href=\"/user/register.html\">注册</a>");
} else {
$.ajax({
type: "POST",
url: "/user/refreshToken",
data: {},
dataType: "json",
success: function (data) {
if (data.code == 200) {
$(".user_link").html("<a href=\"/user/userinfo.html\"><i style=\"font-size: 20px;\" class=\"layui-icon \n" +
"\">&#xe66f;" +
"\n" +
"</i></a>");
if ("/user/login.html" == window.location.pathname) {
var orginUrl = getSearchString("originUrl");
window.location.href = orginUrl == undefined || orginUrl.isBlank() ? "/" : orginUrl;
return;
}
isLogin = true;
if (localStorage.getItem("autoLogin") == 1) {
$.cookie('Authorization', data.data.token, {expires: 7, path: '/'});
} else {
$.cookie('Authorization', data.data.token, {path: '/'});
}
} else {
if (needLoginPath.indexOf(window.location.pathname) != -1) {
location.href = '/user/login.html';
}
$(".user_link").html("<a href=\"/user/login.html\">登录</a><a href=\"/user/register.html\">注册</a>");
}
},
error: function () {
layer.alert('网络异常');
}
});
}
function logout() {
$.cookie('Authorization', null, {path: '/'});
location.reload();
}
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);
}
String.prototype.isPhone = function () {
var strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
if (strTemp.test(this)) {
return true;
}
return false;
};
String.prototype.isBlank = function () {
if (this == null || $.trim(this) == "") {
return true;
}
return false;
};
String.prototype.isNickName = function () {
var strTemp = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (strTemp.test(this)) {
return true;
}
return false;
};

File diff suppressed because one or more lines are too long

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();
}