优化书源调试

pull/371/head
Celeter 4 years ago
parent 581befbab5
commit 440568b58b
  1. 2
      app/src/main/assets/web/index.html
  2. 11
      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,6 +118,7 @@ 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 => {
if ($('#' + 'ruleSearch_' + key).value)
searchJson[key] = $('#' + 'ruleSearch_' + key).value; searchJson[key] = $('#' + 'ruleSearch_' + key).value;
}); });
//RuleJSON.ruleSearch = JSON.stringify(searchJson); //RuleJSON.ruleSearch = JSON.stringify(searchJson);
@ -126,6 +128,7 @@ 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 => {
if ($('#' + 'ruleExplore_' + key).value)
exploreJson[key] = $('#' + 'ruleExplore_' + key).value; exploreJson[key] = $('#' + 'ruleExplore_' + key).value;
}); });
//RuleJSON.ruleExplore = JSON.stringify(exploreJson); //RuleJSON.ruleExplore = JSON.stringify(exploreJson);
@ -135,6 +138,7 @@ 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 => {
if ($('#' + 'ruleBookInfo_' + key).value)
bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value; bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value;
}); });
//RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson); //RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson);
@ -144,6 +148,7 @@ 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 => {
if ($('#' + 'ruleToc_' + key).value)
tocJson[key] = $('#' + 'ruleToc_' + key).value; tocJson[key] = $('#' + 'ruleToc_' + key).value;
}); });
//RuleJSON.ruleToc = JSON.stringify(tocJson); //RuleJSON.ruleToc = JSON.stringify(tocJson);
@ -153,6 +158,7 @@ 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 => {
if ($('#' + 'ruleContent_' + key).value)
contentJson[key] = $('#' + 'ruleContent_' + key).value; contentJson[key] = $('#' + 'ruleContent_' + key).value;
}); });
//RuleJSON.ruleContent = JSON.stringify(contentJson); //RuleJSON.ruleContent = JSON.stringify(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