优化书源调试

pull/371/head
Celeter 4 years ago
parent 581befbab5
commit 440568b58b
  1. 2
      app/src/main/assets/web/index.html
  2. 21
      app/src/main/assets/web/index.js

@ -56,7 +56,7 @@
<div><b>搜索</b></div> <div><b>搜索</b></div>
<div> <div>
<div>搜索地址:</div> <div>搜索地址:</div>
<textarea rows="1" id="searchUrl" class="base" title="searchUrl" <textarea rows="3" id="searchUrl" class="base" title="searchUrl"
placeholder="[域名可省略]/search.php@kw={{key}}"></textarea> placeholder="[域名可省略]/search.php@kw={{key}}"></textarea>
</div> </div>
<div> <div>

@ -18,7 +18,7 @@ function hashParam(key, val) {
} }
} }
// 创建书源规则容器对象 // 创建书源规则容器对象
const RuleJSON = (() => { function Container() {
let ruleJson = {}; let ruleJson = {};
let searchJson = {}; let searchJson = {};
let exploreJson = {}; let exploreJson = {};
@ -60,7 +60,7 @@ const RuleJSON = (() => {
ruleJson.ruleContent = contentJson; ruleJson.ruleContent = contentJson;
return ruleJson; return ruleJson;
})(); }
// 选项卡Tab切换事件处理 // 选项卡Tab切换事件处理
function showTab(tabName) { function showTab(tabName) {
$$('.tabtitle>*').forEach(node => { node.className = node.className.replace(' this', ''); }); $$('.tabtitle>*').forEach(node => { node.className = node.className.replace(' this', ''); });
@ -106,6 +106,7 @@ function HttpPost(url, data) {
} }
// 将书源表单转化为书源对象 // 将书源表单转化为书源对象
function rule2json() { function rule2json() {
let RuleJSON = Container();
// 转换base // 转换base
Object.keys(RuleJSON).forEach(key => { Object.keys(RuleJSON).forEach(key => {
if (!key.startsWith("rule")) { if (!key.startsWith("rule")) {
@ -117,7 +118,8 @@ function rule2json() {
let searchJson = {}; let searchJson = {};
//Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => { //Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => {
Object.keys(RuleJSON.ruleSearch).forEach(key => { Object.keys(RuleJSON.ruleSearch).forEach(key => {
searchJson[key] = $('#' + 'ruleSearch_' + key).value; if ($('#' + 'ruleSearch_' + key).value)
searchJson[key] = $('#' + 'ruleSearch_' + key).value;
}); });
//RuleJSON.ruleSearch = JSON.stringify(searchJson); //RuleJSON.ruleSearch = JSON.stringify(searchJson);
RuleJSON.ruleSearch = searchJson; RuleJSON.ruleSearch = searchJson;
@ -126,7 +128,8 @@ function rule2json() {
let exploreJson = {}; let exploreJson = {};
//Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => { //Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => {
Object.keys(RuleJSON.ruleExplore).forEach(key => { Object.keys(RuleJSON.ruleExplore).forEach(key => {
exploreJson[key] = $('#' + 'ruleExplore_' + key).value; if ($('#' + 'ruleExplore_' + key).value)
exploreJson[key] = $('#' + 'ruleExplore_' + key).value;
}); });
//RuleJSON.ruleExplore = JSON.stringify(exploreJson); //RuleJSON.ruleExplore = JSON.stringify(exploreJson);
RuleJSON.ruleExplore = exploreJson; RuleJSON.ruleExplore = exploreJson;
@ -135,7 +138,8 @@ function rule2json() {
let bookInfoJson = {}; let bookInfoJson = {};
//Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => { //Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => {
Object.keys(RuleJSON.ruleBookInfo).forEach(key => { Object.keys(RuleJSON.ruleBookInfo).forEach(key => {
bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value; if ($('#' + 'ruleBookInfo_' + key).value)
bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value;
}); });
//RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson); //RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson);
RuleJSON.ruleBookInfo = bookInfoJson; RuleJSON.ruleBookInfo = bookInfoJson;
@ -144,7 +148,8 @@ function rule2json() {
let tocJson = {}; let tocJson = {};
//Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => { //Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => {
Object.keys(RuleJSON.ruleToc).forEach(key => { Object.keys(RuleJSON.ruleToc).forEach(key => {
tocJson[key] = $('#' + 'ruleToc_' + key).value; if ($('#' + 'ruleToc_' + key).value)
tocJson[key] = $('#' + 'ruleToc_' + key).value;
}); });
//RuleJSON.ruleToc = JSON.stringify(tocJson); //RuleJSON.ruleToc = JSON.stringify(tocJson);
RuleJSON.ruleToc = tocJson; RuleJSON.ruleToc = tocJson;
@ -153,7 +158,8 @@ function rule2json() {
let contentJson = {}; let contentJson = {};
//Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => { //Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => {
Object.keys(RuleJSON.ruleContent).forEach(key => { Object.keys(RuleJSON.ruleContent).forEach(key => {
contentJson[key] = $('#' + 'ruleContent_' + key).value; if ($('#' + 'ruleContent_' + key).value)
contentJson[key] = $('#' + 'ruleContent_' + key).value;
}); });
//RuleJSON.ruleContent = JSON.stringify(contentJson); //RuleJSON.ruleContent = JSON.stringify(contentJson);
RuleJSON.ruleContent = contentJson; RuleJSON.ruleContent = contentJson;
@ -168,6 +174,7 @@ function rule2json() {
} }
// 将书源对象填充到书源表单 // 将书源对象填充到书源表单
function json2rule(RuleEditor) { function json2rule(RuleEditor) {
let RuleJSON = Container();
// 转换base // 转换base
Object.keys(RuleJSON).forEach(key => { Object.keys(RuleJSON).forEach(key => {
if (!key.startsWith("rule")) { if (!key.startsWith("rule")) {

Loading…
Cancel
Save