2022-03-21 08:42:56 +00:00
|
|
|
|
/*
|
|
|
|
|
作者:D.Young
|
|
|
|
|
主页:https://yyv.me/
|
|
|
|
|
github:https://github.com/5iux/sou
|
|
|
|
|
日期:2019-07-26
|
|
|
|
|
版权所有,请勿删除
|
|
|
|
|
========================================
|
|
|
|
|
由 yeetime 修改
|
|
|
|
|
github:https://github.com/yeetime/sou2
|
|
|
|
|
日期:2019-12-13
|
|
|
|
|
========================================
|
|
|
|
|
由 imsyy 二次修改
|
|
|
|
|
github:https://github.com/imsyy/sou2
|
|
|
|
|
日期:2022-03-10
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 默认搜索引擎列表
|
|
|
|
|
var se_list_preinstall = {
|
|
|
|
|
'1': {
|
|
|
|
|
id: 1,
|
|
|
|
|
title: "百度",
|
|
|
|
|
url: "https://www.baidu.com/s",
|
|
|
|
|
name: "wd",
|
|
|
|
|
icon: "iconfont icon-baidu",
|
|
|
|
|
},
|
|
|
|
|
'2': {
|
|
|
|
|
id: 2,
|
|
|
|
|
title: "必应",
|
|
|
|
|
url: "https://cn.bing.com/search",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-bing",
|
|
|
|
|
},
|
|
|
|
|
'3': {
|
|
|
|
|
id: 3,
|
|
|
|
|
title: "谷歌",
|
|
|
|
|
url: "https://www.google.com/search",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-google",
|
|
|
|
|
},
|
|
|
|
|
'4': {
|
|
|
|
|
id: 4,
|
|
|
|
|
title: "搜狗",
|
|
|
|
|
url: "https://www.sogou.com/web",
|
|
|
|
|
name: "query",
|
|
|
|
|
icon: "iconfont icon-sougousousuo",
|
|
|
|
|
},
|
|
|
|
|
'5': {
|
|
|
|
|
id: 5,
|
|
|
|
|
title: "360",
|
|
|
|
|
url: "https://www.so.com/s",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-360sousuo",
|
|
|
|
|
},
|
|
|
|
|
'6': {
|
|
|
|
|
id: 6,
|
|
|
|
|
title: "微博",
|
|
|
|
|
url: "https://s.weibo.com/weibo",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-xinlangweibo",
|
|
|
|
|
},
|
|
|
|
|
'7': {
|
|
|
|
|
id: 7,
|
|
|
|
|
title: "知乎",
|
|
|
|
|
url: "https://www.zhihu.com/search",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-zhihu",
|
|
|
|
|
},
|
|
|
|
|
'8': {
|
|
|
|
|
id: 8,
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/search",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-github",
|
|
|
|
|
},
|
|
|
|
|
'9': {
|
|
|
|
|
id: 9,
|
|
|
|
|
title: "BiliBili",
|
|
|
|
|
url: "https://search.bilibili.com/all",
|
|
|
|
|
name: "keyword",
|
|
|
|
|
icon: "iconfont icon-bilibilidonghua",
|
|
|
|
|
},
|
|
|
|
|
'10': {
|
|
|
|
|
id: 10,
|
|
|
|
|
title: "淘宝",
|
|
|
|
|
url: "https://s.taobao.com/search",
|
|
|
|
|
name: "q",
|
|
|
|
|
icon: "iconfont icon-taobao",
|
|
|
|
|
},
|
|
|
|
|
'11': {
|
|
|
|
|
id: 11,
|
|
|
|
|
title: "京东",
|
|
|
|
|
url: "https://search.jd.com/Search",
|
|
|
|
|
name: "keyword",
|
|
|
|
|
icon: "iconfont icon-jingdong",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 默认快捷方式
|
|
|
|
|
var quick_list_preinstall = {
|
|
|
|
|
'1': {
|
|
|
|
|
title: "哔哩哔哩",
|
|
|
|
|
url: "https://www.bilibili.com/",
|
|
|
|
|
explain: "哔哩哔哩 (゜-゜)つロ 干杯~",
|
|
|
|
|
},
|
|
|
|
|
'2': {
|
|
|
|
|
title: "GitHub",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
},
|
|
|
|
|
'3': {
|
|
|
|
|
title: "V2EX",
|
|
|
|
|
url: "https://www.v2ex.com/",
|
|
|
|
|
explain: "V2EX",
|
|
|
|
|
},
|
|
|
|
|
'4': {
|
|
|
|
|
title: "Steam",
|
|
|
|
|
url: "https://store.steampowered.com/",
|
|
|
|
|
explain: "Steam",
|
|
|
|
|
},
|
|
|
|
|
'5': {
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
},
|
|
|
|
|
'6': {
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
},
|
|
|
|
|
'7': {
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
},
|
|
|
|
|
'8': {
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
},
|
|
|
|
|
'9': {
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
},
|
|
|
|
|
'10': {
|
|
|
|
|
title: "Github",
|
|
|
|
|
url: "https://github.com/",
|
|
|
|
|
explain: "GitHub",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取搜索引擎列表
|
|
|
|
|
function getSeList() {
|
|
|
|
|
var se_list_local = Cookies.get('se_list');
|
|
|
|
|
if (se_list_local !== "{}" && se_list_local) {
|
|
|
|
|
return JSON.parse(se_list_local);
|
|
|
|
|
} else {
|
|
|
|
|
setSeList(se_list_preinstall);
|
|
|
|
|
return se_list_preinstall;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置搜索引擎列表
|
|
|
|
|
function setSeList(se_list) {
|
|
|
|
|
if (se_list) {
|
|
|
|
|
Cookies.set('se_list', se_list, {
|
|
|
|
|
expires: 36500
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获得默认搜索引擎
|
|
|
|
|
function getSeDefault() {
|
|
|
|
|
var se_default = Cookies.get('se_default');
|
|
|
|
|
return se_default ? se_default : "1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//背景图片
|
|
|
|
|
var bg_img_preinstall = {
|
|
|
|
|
"type": "2", // 1:使用主题默认的背景图片 2:关闭背景图片 3:使用自定义的背景图片
|
|
|
|
|
"path": "", //自定义图片
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取背景图片
|
|
|
|
|
function getBgImg() {
|
|
|
|
|
var bg_img_local = Cookies.get('bg_img');
|
|
|
|
|
if (bg_img_local && bg_img_local !== "{}") {
|
|
|
|
|
return JSON.parse(bg_img_local);
|
|
|
|
|
} else {
|
|
|
|
|
setBgImg(bg_img_preinstall);
|
|
|
|
|
return bg_img_preinstall;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置背景图片
|
|
|
|
|
function setBgImg(bg_img) {
|
|
|
|
|
if (bg_img) {
|
|
|
|
|
Cookies.set('bg_img', bg_img, {
|
|
|
|
|
expires: 36500
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置-壁纸
|
|
|
|
|
//$('#bg').attr('src','https://api.dujin.org/bing/1920.php')
|
|
|
|
|
function setBgImgInit() {
|
|
|
|
|
var bg_img = getBgImg();
|
|
|
|
|
$("input[name='wallpaper-type'][value=" + bg_img["type"] + "]").click();
|
|
|
|
|
if (bg_img["type"] === "5") {
|
|
|
|
|
$("#wallpaper-url").val(bg_img["path"]);
|
|
|
|
|
$("#wallpaper-button").fadeIn(100);
|
|
|
|
|
$("#wallpaper_url").fadeIn(100);
|
|
|
|
|
} else {
|
|
|
|
|
$("#wallpaper_url").fadeOut(300);
|
|
|
|
|
$("#wallpaper-button").fadeOut(300);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (bg_img["type"]) {
|
|
|
|
|
case "1":
|
|
|
|
|
var pictures = new Array();
|
|
|
|
|
pictures[0] = './img/background1.webp';
|
|
|
|
|
pictures[1] = './img/background2.webp';
|
|
|
|
|
pictures[2] = './img/background3.webp';
|
|
|
|
|
pictures[3] = './img/background4.webp';
|
|
|
|
|
pictures[4] = './img/background5.webp';
|
|
|
|
|
pictures[5] = './img/background6.webp';
|
|
|
|
|
pictures[6] = './img/background7.webp';
|
|
|
|
|
pictures[7] = './img/background8.webp';
|
|
|
|
|
pictures[8] = './img/background9.webp';
|
|
|
|
|
pictures[9] = './img/background10.webp';
|
2022-03-22 12:29:15 +00:00
|
|
|
|
var rd = Math.floor(Math.random() * 10);
|
2022-03-21 08:42:56 +00:00
|
|
|
|
$('#bg').attr('src', pictures[rd]) //随机默认壁纸
|
|
|
|
|
break;
|
|
|
|
|
case "2":
|
|
|
|
|
$('#bg').attr('src', 'https://api.dujin.org/bing/1920.php') //必应每日
|
|
|
|
|
break;
|
|
|
|
|
case "3":
|
|
|
|
|
$('#bg').attr('src', 'https://api.ixiaowai.cn/gqapi/gqapi.php') //随机风景
|
|
|
|
|
break;
|
|
|
|
|
case "4":
|
|
|
|
|
$('#bg').attr('src', 'https://api.ixiaowai.cn/api/api.php') //随机二次元
|
|
|
|
|
break;
|
|
|
|
|
case "5":
|
|
|
|
|
$('#bg').attr('src', bg_img["path"]) //自定义
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 搜索框高亮
|
|
|
|
|
function focusWd() {
|
|
|
|
|
//输入框
|
|
|
|
|
$(".all-search").css({
|
|
|
|
|
"background-color": 'var(--main-text-form-hover-color)',
|
|
|
|
|
"transition": "ease 0.4s",
|
|
|
|
|
"transform": "translateY(-140%)"
|
|
|
|
|
});
|
|
|
|
|
//背景模糊
|
|
|
|
|
$('#bg').css({
|
|
|
|
|
"transform": "scale(1.08)",
|
|
|
|
|
"filter": "blur(10px)",
|
|
|
|
|
"transition": "ease 0.3s",
|
|
|
|
|
});
|
|
|
|
|
//搜索引擎按钮
|
|
|
|
|
$('#icon-se').css({
|
|
|
|
|
"color": 'var(--main-text-form-color)',
|
|
|
|
|
"transition": "ease 0.5s"
|
|
|
|
|
});
|
|
|
|
|
//搜索按钮
|
|
|
|
|
$('#icon-sou').css({
|
|
|
|
|
"color": "var(--main-text-form-color)",
|
|
|
|
|
"transition": "ease 0.5s"
|
|
|
|
|
});
|
|
|
|
|
//时间上移
|
|
|
|
|
$(".tool-all").css({
|
|
|
|
|
"transform": "translateY(-140%)"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 搜索框取消高亮
|
|
|
|
|
function blurWd() {
|
|
|
|
|
//输入框
|
|
|
|
|
$(".all-search").css({
|
|
|
|
|
"background-color": "",
|
|
|
|
|
"transition": "ease 0.4s",
|
|
|
|
|
"transform": ""
|
|
|
|
|
});
|
|
|
|
|
//背景模糊
|
|
|
|
|
$('#bg').css({
|
|
|
|
|
"transform": "scale(1)",
|
|
|
|
|
"filter": "blur(0px)",
|
|
|
|
|
"transition": "ease 0.3s",
|
|
|
|
|
});
|
|
|
|
|
//搜索引擎按钮
|
|
|
|
|
$('#icon-se').css({
|
|
|
|
|
"color": "var(--main-text-color)",
|
|
|
|
|
"transition": "ease 0.5s"
|
|
|
|
|
});
|
|
|
|
|
//搜索按钮
|
|
|
|
|
$('#icon-sou').css({
|
|
|
|
|
"color": 'var(--main-text-color)',
|
|
|
|
|
"transition": "ease 0.5s"
|
|
|
|
|
});
|
|
|
|
|
//隐藏输入
|
|
|
|
|
$(".wd").val("");
|
|
|
|
|
//时间下移
|
|
|
|
|
$(".tool-all").css({
|
|
|
|
|
"transform": "translateY(-120%)"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关键字提示
|
|
|
|
|
function keywordReminder() {
|
|
|
|
|
var keyword = $(".wd").val();
|
|
|
|
|
if (keyword != "") {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: 'https://suggestion.baidu.com/su?wd=' + keyword,
|
|
|
|
|
dataType: 'jsonp',
|
|
|
|
|
jsonp: 'cb', //回调函数的参数名(键值)key
|
|
|
|
|
success: function (data) {
|
|
|
|
|
//获取宽度
|
|
|
|
|
$("#keywords").css("width", $('.sou').width());
|
|
|
|
|
$("#keywords").empty().show();
|
|
|
|
|
$.each(data.s, function (i, val) {
|
|
|
|
|
$('#keywords').append("<div class=\"keyword\" data-id=\"" + (i + 1) + "\">" + "<i class='iconfont icon-sousuo'></i>" + val + "</div>");
|
|
|
|
|
});
|
|
|
|
|
$("#keywords").attr("data-length", data.s["length"]);
|
|
|
|
|
},
|
|
|
|
|
error: function () {
|
|
|
|
|
$("#keywords").empty().show();
|
|
|
|
|
$("#keywords").hide();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
$("#keywords").empty().show();
|
|
|
|
|
$("#keywords").hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 搜索框数据加载
|
|
|
|
|
function searchData() {
|
|
|
|
|
var se_default = getSeDefault();
|
|
|
|
|
var se_list = getSeList();
|
|
|
|
|
var defaultSe = se_list[se_default];
|
|
|
|
|
if (defaultSe) {
|
|
|
|
|
$(".search").attr("action", defaultSe["url"]);
|
|
|
|
|
$("#icon-se").attr("class", defaultSe["icon"]);
|
|
|
|
|
$(".wd").attr("name", defaultSe["name"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断窗口大小,添加输入框自动完成
|
|
|
|
|
// var wid = $("body").width();
|
|
|
|
|
// if (wid < 640) {
|
|
|
|
|
// $(".wd").attr('autocomplete', 'off');
|
|
|
|
|
// } else {
|
|
|
|
|
// $(".wd").focus();
|
|
|
|
|
// focusWd();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 搜索引擎列表加载
|
|
|
|
|
function seList() {
|
|
|
|
|
var html = "";
|
|
|
|
|
var se_list = getSeList();
|
|
|
|
|
for (var i in se_list) {
|
|
|
|
|
//html += "<div class='se-li' data-url='" + se_list[i]["url"] + "' data-name='" + se_list[i]["name"] + "' data-img='" + se_list[i]["img"] + "'><img src='" + se_list[i]["img"] + "'>" + se_list[i]["title"] + "</div>";
|
|
|
|
|
html += "<div class='se-li' data-url='" + se_list[i]["url"] + "' data-name='" + se_list[i]["name"] + "' data-icon='" + se_list[i]["icon"] + "'><a class='se-li-text'><i id='icon-sou-list' class=' " + se_list[i]["icon"] + " '></i><span>" + se_list[i]["title"] + "</span></a></div>";
|
|
|
|
|
}
|
|
|
|
|
$(".search-engine-list").html(html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置-搜索引擎列表加载
|
|
|
|
|
function setSeInit() {
|
|
|
|
|
var se_default = getSeDefault();
|
|
|
|
|
var se_list = getSeList();
|
|
|
|
|
var html = "";
|
|
|
|
|
for (var i in se_list) {
|
|
|
|
|
var tr = "<div class='se_list_div'><div class='se_list_num'>" + i + "</div>";
|
|
|
|
|
if (i === se_default) {
|
|
|
|
|
tr = "<div class='se_list_div'><div class='se_list_num'>\
|
|
|
|
|
<i class='iconfont icon-home'></i></div>";
|
|
|
|
|
}
|
|
|
|
|
tr += "<div class='se_list_name'>" + se_list[i]["title"] + "</div>\
|
|
|
|
|
<div class='se_list_button'>\
|
|
|
|
|
<button class='set_se_default' value='" + i + "' style='border-radius: 8px 0px 0px 8px;'>\
|
|
|
|
|
<i class='iconfont icon-home'></i></button>\
|
|
|
|
|
<button class='edit_se' value='" + i + "'>\
|
|
|
|
|
<i class='iconfont icon-xiugai'></i></button>\
|
|
|
|
|
<button class='delete_se' value='" + i + "' style='border-radius: 0px 8px 8px 0px;'>\
|
|
|
|
|
<i class='iconfont icon-delete'></i></button></div>\
|
|
|
|
|
</div>";
|
|
|
|
|
html += tr;
|
|
|
|
|
}
|
|
|
|
|
$(".se_list_table").html(html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取快捷方式列表
|
|
|
|
|
function getQuickList() {
|
|
|
|
|
var quick_list_local = Cookies.get('quick_list');
|
|
|
|
|
if (quick_list_local !== "{}" && quick_list_local) {
|
|
|
|
|
return JSON.parse(quick_list_local);
|
|
|
|
|
} else {
|
|
|
|
|
setQuickList(quick_list_preinstall);
|
|
|
|
|
return quick_list_preinstall;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置快捷方式列表
|
|
|
|
|
function setQuickList(quick_list) {
|
|
|
|
|
if (quick_list) {
|
|
|
|
|
Cookies.set('quick_list', quick_list, {
|
|
|
|
|
expires: 36500
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 快捷方式数据加载
|
|
|
|
|
function quickData() {
|
|
|
|
|
var html = "";
|
|
|
|
|
var quick_list = getQuickList();
|
|
|
|
|
for (var i in quick_list) {
|
|
|
|
|
html += "<div class='quick' title='" + quick_list[i]['explain'] + "'>\
|
|
|
|
|
<a href='" + quick_list[i]['url'] + "' target='_blank'>\
|
|
|
|
|
" + quick_list[i]['title'] + "\
|
|
|
|
|
</a>\
|
|
|
|
|
</div>";
|
|
|
|
|
}
|
|
|
|
|
$(".quick-all").html(html + "<div class='quick'><a id='set-quick'>\
|
|
|
|
|
<i class='iconfont icon-tianjia-'></i></a></div>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置-快捷方式加载
|
|
|
|
|
function setQuickInit() {
|
|
|
|
|
var quick_list = getQuickList();
|
|
|
|
|
var html = "";
|
|
|
|
|
for (var i in quick_list) {
|
|
|
|
|
tr = "<div class='quick_list_div'>\
|
|
|
|
|
<div class='quick_list_div_num'>" + i + "</div>\
|
|
|
|
|
<div class='quick_list_div_name'>" + quick_list[i]['title'] + "</div>\
|
|
|
|
|
<div class='quick_list_div_button'>\
|
|
|
|
|
<button class='edit_quick' value='" + i + "' style='border-radius: 8px 0px 0px 8px;'>\
|
|
|
|
|
<i class='iconfont icon-xiugai'></i></button>\
|
|
|
|
|
<button class='delete_quick' value='" + i + "' style='border-radius: 0px 8px 8px 0px;'>\
|
|
|
|
|
<i class='iconfont icon-delete'></i></button>\
|
|
|
|
|
</div>\
|
|
|
|
|
</div>\
|
|
|
|
|
</div>";
|
|
|
|
|
html += tr;
|
|
|
|
|
}
|
|
|
|
|
$(".quick_list_table").html(html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下載文本为文件
|
|
|
|
|
* @param filename 文件名
|
|
|
|
|
* @param text 内容
|
|
|
|
|
*/
|
|
|
|
|
function download(filename, text) {
|
|
|
|
|
var element = document.createElement('a');
|
|
|
|
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
|
|
|
|
|
element.setAttribute('download', filename);
|
|
|
|
|
|
|
|
|
|
element.style.display = 'none';
|
|
|
|
|
document.body.appendChild(element);
|
|
|
|
|
|
|
|
|
|
element.click();
|
|
|
|
|
|
|
|
|
|
document.body.removeChild(element);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开设置
|
|
|
|
|
function openSet() {
|
|
|
|
|
$("#menu").addClass('on');
|
|
|
|
|
|
|
|
|
|
openBox();
|
|
|
|
|
|
|
|
|
|
//更改设置图标
|
|
|
|
|
$("#icon-menu").attr("class", "iconfont icon-home");
|
|
|
|
|
|
|
|
|
|
//隐藏书签打开设置
|
|
|
|
|
$(".mark").css({
|
|
|
|
|
"display": "none",
|
|
|
|
|
});
|
|
|
|
|
$(".set").css({
|
|
|
|
|
"display": "flex",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭设置
|
|
|
|
|
function closeSet() {
|
|
|
|
|
$("#menu").removeClass('on');
|
|
|
|
|
|
|
|
|
|
closeBox();
|
|
|
|
|
|
|
|
|
|
//更改设置图标
|
|
|
|
|
$("#icon-menu").attr("class", "iconfont icon-shezhi");
|
|
|
|
|
|
|
|
|
|
//隐藏设置
|
|
|
|
|
$(".set").css({
|
|
|
|
|
"display": "none",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 刷新主页数据
|
|
|
|
|
seList();
|
|
|
|
|
quickData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 书签显示
|
|
|
|
|
function openBox() {
|
|
|
|
|
$("#content").addClass('box');
|
|
|
|
|
$(".mark").css({
|
|
|
|
|
"display": "flex",
|
|
|
|
|
});
|
|
|
|
|
//时间上移
|
|
|
|
|
$(".tool-all").css({
|
|
|
|
|
"transform": 'translateY(-160%)'
|
|
|
|
|
});
|
|
|
|
|
//背景模糊
|
|
|
|
|
$('#bg').css({
|
|
|
|
|
"transform": 'scale(1.08)',
|
|
|
|
|
"filter": "blur(10px)",
|
|
|
|
|
"transition": "ease 0.3s",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 书签关闭
|
|
|
|
|
function closeBox() {
|
|
|
|
|
$("#content").removeClass('box');
|
|
|
|
|
$(".mark").css({
|
|
|
|
|
"display": "none",
|
|
|
|
|
});
|
|
|
|
|
//时间下移
|
|
|
|
|
$(".tool-all").css({
|
|
|
|
|
"transform": 'translateY(-110%)'
|
|
|
|
|
});
|
|
|
|
|
//背景模糊
|
|
|
|
|
$('#bg').css({
|
|
|
|
|
"transform": 'scale(1)',
|
|
|
|
|
"filter": "blur(0px)",
|
|
|
|
|
"transition": "ease 0.3s",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//显示设置搜索引擎列表
|
|
|
|
|
function showSe() {
|
|
|
|
|
$(".se_list").show();
|
|
|
|
|
$(".se_add_preinstall").show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//隐藏设置搜索引擎列表
|
|
|
|
|
function hideSe() {
|
|
|
|
|
$(".se_list").hide();
|
|
|
|
|
$(".se_add_preinstall").hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//显示设置快捷方式列表
|
|
|
|
|
function showQuick() {
|
|
|
|
|
$(".quick_list").show();
|
|
|
|
|
$(".se_add_preinstalls").show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//隐藏设置快捷方式列表
|
|
|
|
|
function hideQuick() {
|
|
|
|
|
$(".quick_list").hide();
|
|
|
|
|
$(".se_add_preinstalls").hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
// 搜索框数据加载
|
|
|
|
|
searchData();
|
|
|
|
|
|
|
|
|
|
// 搜索引擎列表加载
|
|
|
|
|
seList();
|
|
|
|
|
|
|
|
|
|
// 快捷方式数据加载
|
|
|
|
|
quickData();
|
|
|
|
|
|
|
|
|
|
// 壁纸数据加载
|
|
|
|
|
setBgImgInit();
|
|
|
|
|
|
|
|
|
|
// 点击事件
|
|
|
|
|
$(document).on('click', function (e) {
|
|
|
|
|
// 选择搜索引擎点击
|
|
|
|
|
if ($(".search-engine").is(":hidden") && $(".se").is(e.target) || $(".search-engine").is(":hidden") && $("#icon-se").is(e.target)) {
|
|
|
|
|
if ($(".se").is(e.target) || $("#icon-se").is(e.target)) {
|
|
|
|
|
//获取宽度
|
|
|
|
|
$(".search-engine").css("width", $('.sou').width() - 30);
|
|
|
|
|
//出现动画
|
|
|
|
|
$(".search-engine").slideDown(160);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$(".search-engine").is(e.target) && $(".search-engine").has(e.target).length === 0) {
|
|
|
|
|
$(".search-engine").slideUp(160);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动提示隐藏
|
|
|
|
|
if (!$(".sou").is(e.target) && $(".sou").has(e.target).length === 0) {
|
|
|
|
|
$("#keywords").hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 时间点击
|
|
|
|
|
$("#time_text").click(function () {
|
|
|
|
|
if ($("#content").attr("class") === "box") {
|
|
|
|
|
closeBox();
|
|
|
|
|
closeSet();
|
|
|
|
|
} else {
|
|
|
|
|
openBox();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 搜索引擎列表点击
|
|
|
|
|
$(".search-engine-list").on("click", ".se-li", function () {
|
|
|
|
|
var url = $(this).attr('data-url');
|
|
|
|
|
var name = $(this).attr('data-name');
|
|
|
|
|
var icon = $(this).attr('data-icon');
|
|
|
|
|
$(".search").attr("action", url);
|
|
|
|
|
$(".wd").attr("name", name);
|
|
|
|
|
$("#icon-se").attr("class", icon);
|
|
|
|
|
$(".search-engine").slideUp(160);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 搜索框获得焦点事件
|
|
|
|
|
$(".wd").focus(function () {
|
|
|
|
|
focusWd();
|
|
|
|
|
keywordReminder();
|
|
|
|
|
$(".search-engine").slideUp(160);
|
|
|
|
|
});
|
|
|
|
|
|
2022-03-22 15:23:57 +00:00
|
|
|
|
$("#s-button").focus(function () {
|
|
|
|
|
focusWd();
|
|
|
|
|
keywordReminder();
|
|
|
|
|
$(".search-engine").slideUp(160);
|
|
|
|
|
});
|
|
|
|
|
|
2022-03-21 08:42:56 +00:00
|
|
|
|
// 搜索框失去焦点事件
|
|
|
|
|
$(".wd").blur(function () {
|
|
|
|
|
blurWd();
|
|
|
|
|
});
|
|
|
|
|
|
2022-03-22 15:23:57 +00:00
|
|
|
|
$("#s-button").blur(function () {
|
|
|
|
|
blurWd();
|
|
|
|
|
});
|
|
|
|
|
|
2022-03-21 08:42:56 +00:00
|
|
|
|
// 自动提示( 调用百度 api )
|
|
|
|
|
$('.wd').keyup(function (event) {
|
|
|
|
|
var key = event.keyCode;
|
|
|
|
|
// 屏蔽上下键
|
|
|
|
|
var shieldKey = [38, 40];
|
|
|
|
|
if (shieldKey.includes(key)) return;
|
|
|
|
|
keywordReminder();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 点击自动提示的关键字
|
|
|
|
|
$("#keywords").on("click", "div", function () {
|
|
|
|
|
var wd = $(this).text();
|
|
|
|
|
$(".wd").val(wd);
|
|
|
|
|
$(".search").submit();
|
|
|
|
|
//隐藏输入
|
|
|
|
|
$(".wd").val("");
|
|
|
|
|
$("#keywords").hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 自动提示键盘方向键选择操作
|
|
|
|
|
// $(".wd").keydown(function (event) { //上下键获取焦点
|
|
|
|
|
// var key = event.keyCode;
|
|
|
|
|
// if ($.trim($(this).val()).length === 0) return;
|
|
|
|
|
|
|
|
|
|
// var id = $(".keyword-active").attr("data-id");
|
|
|
|
|
// if (id === undefined) id = 0;
|
|
|
|
|
|
|
|
|
|
// if (key === 38) {
|
|
|
|
|
// /*向上按钮*/
|
|
|
|
|
// id--;
|
|
|
|
|
// } else if (key === 40) {
|
|
|
|
|
// /*向下按钮*/
|
|
|
|
|
// id++;
|
|
|
|
|
// } else {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// var length = $("#keywords").attr("data-length");
|
|
|
|
|
// if (id > length) id = 1;
|
|
|
|
|
// if (id < 1) id = length;
|
|
|
|
|
|
|
|
|
|
// $(".keyword[data-id=" + id + "]").addClass("keyword-active").siblings().removeClass("keyword-active");
|
|
|
|
|
// $(".wd").val($(".keyword[data-id=" + id + "]").text());
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// 菜单点击
|
|
|
|
|
$("#menu").click(function (event) {
|
|
|
|
|
if ($(this).attr("class") === "on") {
|
|
|
|
|
closeSet();
|
|
|
|
|
} else {
|
|
|
|
|
openSet();
|
|
|
|
|
|
|
|
|
|
// 设置内容加载
|
|
|
|
|
setSeInit(); //搜索引擎设置
|
|
|
|
|
setQuickInit(); //快捷方式设置
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 快捷方式添加按钮点击
|
2022-03-22 12:29:15 +00:00
|
|
|
|
$("#set-quick").click(function () {
|
|
|
|
|
openSet();
|
2022-03-21 08:42:56 +00:00
|
|
|
|
|
2022-03-22 12:29:15 +00:00
|
|
|
|
// 设置内容加载
|
|
|
|
|
setSeInit(); //搜索引擎设置
|
|
|
|
|
setQuickInit(); //快捷方式设置
|
2022-03-21 08:42:56 +00:00
|
|
|
|
|
2022-03-22 12:29:15 +00:00
|
|
|
|
//添加快捷方式
|
|
|
|
|
$("#set-quick-menu").trigger('click');
|
|
|
|
|
$(".set_quick_list_add").trigger('click');
|
2022-03-21 08:42:56 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 修改默认搜索引擎
|
|
|
|
|
$(".se_list_table").on("click", ".set_se_default", function () {
|
|
|
|
|
var name = $(this).val();
|
|
|
|
|
Cookies.set('se_default', name, {
|
|
|
|
|
expires: 36500
|
|
|
|
|
});
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '是否设置为默认搜索引擎?',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
setSeInit();
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '设置成功'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 搜索引擎添加
|
|
|
|
|
$(".set_se_list_add").click(function () {
|
|
|
|
|
$(".se_add_content input").val("");
|
|
|
|
|
|
|
|
|
|
hideSe();
|
|
|
|
|
$(".se_add_content").show();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 搜索引擎保存
|
|
|
|
|
$(".se_add_save").click(function () {
|
|
|
|
|
var key_inhere = $(".se_add_content input[name='key_inhere']").val();
|
|
|
|
|
var key = $(".se_add_content input[name='key']").val();
|
|
|
|
|
var title = $(".se_add_content input[name='title']").val();
|
|
|
|
|
var url = $(".se_add_content input[name='url']").val();
|
|
|
|
|
var name = $(".se_add_content input[name='name']").val();
|
|
|
|
|
//var icon = $(".se_add_content input[name='icon']").val();
|
|
|
|
|
var icon = "iconfont icon-wangluo";
|
|
|
|
|
|
|
|
|
|
var num = /^\+?[1-9][0-9]*$/;
|
|
|
|
|
if (!num.test(key)) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '序号 ' + key + ' 不是正整数'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var se_list = getSeList();
|
|
|
|
|
|
|
|
|
|
if (se_list[key]) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '搜索引擎 ' + key + ' 已有数据,是否覆盖?',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
se_list[key] = {
|
|
|
|
|
title: title,
|
|
|
|
|
url: url,
|
|
|
|
|
name: name,
|
|
|
|
|
icon: icon,
|
|
|
|
|
};
|
|
|
|
|
setSeList(se_list);
|
|
|
|
|
setSeInit();
|
|
|
|
|
$(".se_add_content").hide();
|
|
|
|
|
//显示列表
|
|
|
|
|
showSe();
|
|
|
|
|
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '覆盖成功'
|
|
|
|
|
});
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (key_inhere && key !== key_inhere) {
|
|
|
|
|
delete se_list[key_inhere];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
se_list[key] = {
|
|
|
|
|
title: title,
|
|
|
|
|
url: url,
|
|
|
|
|
name: name,
|
|
|
|
|
icon: icon,
|
|
|
|
|
};
|
|
|
|
|
setSeList(se_list);
|
|
|
|
|
setSeInit();
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '添加成功'
|
|
|
|
|
});
|
|
|
|
|
$(".se_add_content").hide();
|
|
|
|
|
showSe();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 关闭表单
|
|
|
|
|
$(".se_add_cancel").click(function () {
|
|
|
|
|
$(".se_add_content").hide();
|
|
|
|
|
|
|
|
|
|
//显示列表
|
|
|
|
|
showSe();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 搜索引擎修改
|
|
|
|
|
$(".se_list").on("click", ".edit_se", function () {
|
|
|
|
|
|
|
|
|
|
var se_list = getSeList();
|
|
|
|
|
var key = $(this).val();
|
|
|
|
|
$(".se_add_content input[name='key_inhere']").val(key);
|
|
|
|
|
$(".se_add_content input[name='key']").val(key);
|
|
|
|
|
$(".se_add_content input[name='title']").val(se_list[key]["title"]);
|
|
|
|
|
$(".se_add_content input[name='url']").val(se_list[key]["url"]);
|
|
|
|
|
$(".se_add_content input[name='name']").val(se_list[key]["name"]);
|
|
|
|
|
// $(".se_add_content input[name='icon']").val("iconfont icon-Earth");
|
|
|
|
|
|
|
|
|
|
//隐藏列表
|
|
|
|
|
hideSe();
|
|
|
|
|
|
|
|
|
|
$(".se_add_content").show();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 搜索引擎删除
|
|
|
|
|
$(".se_list").on("click", ".delete_se", function () {
|
|
|
|
|
var se_default = getSeDefault();
|
|
|
|
|
var key = $(this).val();
|
|
|
|
|
if (key == se_default) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '默认搜索引擎不可删除'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '搜索引擎 ' + key + ' 是否删除?',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
var se_list = getSeList();
|
|
|
|
|
delete se_list[key];
|
|
|
|
|
setSeList(se_list);
|
|
|
|
|
setSeInit();
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '删除成功'
|
|
|
|
|
});
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 恢复预设搜索引擎
|
|
|
|
|
$(".set_se_list_preinstall").click(function () {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '现有搜索引擎数据将被清空',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
setSeList(se_list_preinstall);
|
|
|
|
|
Cookies.set('se_default', 1, {
|
|
|
|
|
expires: 36500
|
|
|
|
|
});
|
|
|
|
|
setSeInit();
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '重置成功'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 设置-快捷方式添加
|
|
|
|
|
$(".set_quick_list_add").click(function () {
|
|
|
|
|
$(".quick_add_content input").val("");
|
|
|
|
|
$(".quick_add_content").show();
|
|
|
|
|
|
|
|
|
|
//隐藏列表
|
|
|
|
|
hideQuick();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 设置-快捷方式保存
|
|
|
|
|
$(".quick_add_save").click(function () {
|
|
|
|
|
var key_inhere = $(".quick_add_content input[name='key_inhere']").val();
|
|
|
|
|
var key = $(".quick_add_content input[name='key']").val();
|
|
|
|
|
var title = $(".quick_add_content input[name='title']").val();
|
|
|
|
|
var url = $(".quick_add_content input[name='url']").val();
|
|
|
|
|
var img = $(".quick_add_content input[name='img']").val();
|
|
|
|
|
|
|
|
|
|
var num = /^\+?[1-9][0-9]*$/;
|
|
|
|
|
if (!num.test(key)) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '快捷方式 ' + key + ' 不是正整数'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var quick_list = getQuickList();
|
|
|
|
|
|
|
|
|
|
if (quick_list[key]) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '快捷方式 " + key + " 已有数据,是否覆盖?',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
quick_list[key] = {
|
|
|
|
|
title: title,
|
|
|
|
|
url: url,
|
|
|
|
|
img: img,
|
|
|
|
|
};
|
|
|
|
|
setQuickList(quick_list);
|
|
|
|
|
setQuickInit();
|
|
|
|
|
$(".quick_add_content").hide();
|
|
|
|
|
//显示列表
|
|
|
|
|
showQuick();
|
|
|
|
|
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '覆盖成功'
|
|
|
|
|
});
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (key_inhere && key != key_inhere) {
|
|
|
|
|
delete quick_list[key_inhere];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quick_list[key] = {
|
|
|
|
|
title: title,
|
|
|
|
|
url: url,
|
|
|
|
|
img: img,
|
|
|
|
|
};
|
|
|
|
|
setQuickList(quick_list);
|
|
|
|
|
setQuickInit();
|
|
|
|
|
$(".quick_add_content").hide();
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '添加成功'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//显示列表
|
|
|
|
|
showQuick();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 设置-快捷方式关闭添加表单
|
|
|
|
|
$(".quick_add_cancel").click(function () {
|
|
|
|
|
$(".quick_add_content").hide();
|
|
|
|
|
|
|
|
|
|
//显示列表
|
|
|
|
|
showQuick();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//恢复预设快捷方式
|
|
|
|
|
$(".set_quick_list_preinstall").click(function () {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '快捷方式数据将被清空',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
setQuickList(quick_list_preinstall);
|
|
|
|
|
setQuickInit();
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '重置成功'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 快捷方式修改
|
|
|
|
|
$(".quick_list").on("click", ".edit_quick", function () {
|
|
|
|
|
|
|
|
|
|
var quick_list = getQuickList();
|
|
|
|
|
var key = $(this).val();
|
|
|
|
|
$(".quick_add_content input[name='key_inhere']").val(key);
|
|
|
|
|
$(".quick_add_content input[name='key']").val(key);
|
|
|
|
|
$(".quick_add_content input[name='title']").val(quick_list[key]["title"]);
|
|
|
|
|
$(".quick_add_content input[name='url']").val(quick_list[key]["url"]);
|
|
|
|
|
$(".quick_add_content input[name='img']").val(quick_list[key]["img"]);
|
|
|
|
|
|
|
|
|
|
//隐藏列表
|
|
|
|
|
hideQuick();
|
|
|
|
|
|
|
|
|
|
$(".quick_add_content").show();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 快捷方式删除
|
|
|
|
|
$(".quick_list").on("click", ".delete_quick", function () {
|
|
|
|
|
|
|
|
|
|
var key = $(this).val();
|
|
|
|
|
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '快捷方式 ' + key + ' 是否删除?',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
var quick_list = getQuickList();
|
|
|
|
|
delete quick_list[key];
|
|
|
|
|
setQuickList(quick_list);
|
|
|
|
|
setQuickInit();
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '删除成功'
|
|
|
|
|
});
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 壁纸设置
|
|
|
|
|
$("#wallpaper").on("click", ".set-wallpaper", function () {
|
|
|
|
|
var type = $(this).val();
|
|
|
|
|
var bg_img = getBgImg();
|
|
|
|
|
bg_img["type"] = type;
|
|
|
|
|
|
|
|
|
|
if (type === "1") {
|
|
|
|
|
$('#wallpaper_text').html("显示默认壁纸,刷新页面以生效");
|
|
|
|
|
setBgImg(bg_img);
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '壁纸设置成功,刷新生效',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === "2") {
|
|
|
|
|
$('#wallpaper_text').html("显示必应每日一图,每天更新,刷新页面以生效 | API @ 缙哥哥");
|
|
|
|
|
setBgImg(bg_img);
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '壁纸设置成功,刷新生效',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === "3") {
|
|
|
|
|
$('#wallpaper_text').html("显示随机风景图,每次刷新后更换,刷新页面以生效 | API @ 小歪");
|
|
|
|
|
setBgImg(bg_img);
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '壁纸设置成功,刷新生效',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === "4") {
|
|
|
|
|
$('#wallpaper_text').html("显示随机二次元图,每次刷新后更换,刷新页面以生效 | API @ 小歪");
|
|
|
|
|
setBgImg(bg_img);
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '壁纸设置成功,刷新生效',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === "5") {
|
|
|
|
|
$('#wallpaper_text').html("自定义壁纸地址,请输入正确地址,点击保存且刷新页面以生效");
|
|
|
|
|
$("#wallpaper_url").fadeIn(100);
|
|
|
|
|
$("#wallpaper-button").fadeIn(100);
|
|
|
|
|
$("#wallpaper-url").val(bg_img["path"]);
|
|
|
|
|
} else {
|
|
|
|
|
$("#wallpaper_url").fadeOut(300);
|
|
|
|
|
$("#wallpaper-button").fadeOut(300);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 自定义壁纸设置保存
|
|
|
|
|
$(".wallpaper_save").click(function () {
|
|
|
|
|
var url = $("#wallpaper-url").val();
|
|
|
|
|
var reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;
|
|
|
|
|
if (!reg.test(url)) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '请输入正确的链接',
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
var bg_img = getBgImg();
|
|
|
|
|
bg_img["type"] = "5";
|
|
|
|
|
bg_img["path"] = url;
|
|
|
|
|
setBgImg(bg_img);
|
|
|
|
|
iziToast.show({
|
|
|
|
|
message: '自定义壁纸设置成功,刷新生效',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 我的数据导出
|
|
|
|
|
$("#my_data_out").click(function () {
|
|
|
|
|
var cookies = Cookies.get();
|
|
|
|
|
var json = JSON.stringify(cookies);
|
|
|
|
|
download("Snavigation-back-up-" + $.now() + ".json", json);
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '已导出备份文件至下载目录'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 我的数据导入 点击触发文件选择
|
|
|
|
|
$("#my_data_in").click(function () {
|
|
|
|
|
$("#my_data_file").click();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 选择文件后读取文件内容
|
|
|
|
|
$("#my_data_file").change(function () {
|
|
|
|
|
var selectedFile = document.getElementById('my_data_file').files[0];
|
|
|
|
|
//var name = selectedFile.name;//读取选中文件的文件名
|
|
|
|
|
//var size = selectedFile.size;//读取选中文件的大小
|
|
|
|
|
//console.log("文件名:"+name+" 大小:"+size);
|
|
|
|
|
|
|
|
|
|
var reader = new FileReader(); //这是核心,读取操作就是由它完成.
|
|
|
|
|
reader.readAsText(selectedFile); //读取文件的内容,也可以读取文件的URL
|
|
|
|
|
reader.onload = function () {
|
|
|
|
|
//当读取完成后回调这个函数,然后此时文件的内容存储到了result中,直接操作即可
|
|
|
|
|
//console.log(this.result);
|
|
|
|
|
|
|
|
|
|
// json 格式校验
|
|
|
|
|
var mydata;
|
|
|
|
|
try {
|
|
|
|
|
mydata = JSON.parse(this.result);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '数据解析异常'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (typeof mydata != 'object') {
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '数据格式错误'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
message: '当前数据将会被覆盖!是否继续导入?',
|
|
|
|
|
buttons: [
|
|
|
|
|
['<button>确认</button>', function (instance, toast) {
|
|
|
|
|
for (var key in mydata) {
|
|
|
|
|
Cookies.set(key, mydata[key], {
|
|
|
|
|
expires: 36500
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
iziToast.show({
|
|
|
|
|
timeout: 2000,
|
|
|
|
|
message: '导入成功'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, true],
|
|
|
|
|
['<button>取消</button>', function (instance, toast) {
|
|
|
|
|
instance.hide({
|
|
|
|
|
transitionOut: 'flipOutX',
|
|
|
|
|
}, toast, 'buttonName');
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
window.location.reload()
|
|
|
|
|
}, 1000);
|
|
|
|
|
}]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|