Merge remote-tracking branch 'origin/master'

pull/132/head
kunfei 5 years ago
commit f769b087a6
  1. 1
      app/src/main/assets/updateLog.md
  2. 314
      app/src/main/assets/web/index.html
  3. 157
      app/src/main/assets/web/index.js

@ -6,6 +6,7 @@
* 修复翻页动画 * 修复翻页动画
* 修复主题模式跟随 * 修复主题模式跟随
* 修复滚动翻页切换章节时跳动 * 修复滚动翻页切换章节时跳动
* 适配阅读3.0的web做源
**2020/03/04** **2020/03/04**
* 修复仿真翻页动画 * 修复仿真翻页动画

@ -3,218 +3,281 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>书源编辑器v3.8</title> <title>阅读3.0书源编辑器_V4.0</title>
<link rel="stylesheet" type="text/css" href="/index.css"/> <link rel="icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="index.css" />
</head> </head>
<body> <body>
<div class="editor"> <div class="editor">
<div class="setbox"> <div class="setbox">
<div class="rules"> <div class="rules">
<div><b>书源基础信息</b></div> <div><b>基本</b></div>
<div> <div>
<div>书源名称:</div> <div>源URL :</div>
<textarea rows="1" id="bookSourceName" placeholder="书源名称(bookSourceName) | 会显示在书源列表"></textarea> <textarea rows="1" id="bookSourceUrl" class="base" title="bookSourceUrl"
placeholder="<必填>通常填写网站主页,例: https://www.qidian.com"></textarea>
</div> </div>
<div> <div>
<div>书源分组:</div> <div>源类型 :</div>
<textarea rows="1" id="bookSourceGroup" placeholder="书源分组(bookSourceGroup) | 描述书源的特征信息"></textarea> <textarea rows="1" id="bookSourceType" class="base" title="bookSourceType"
placeholder="&lt;必填&gt;0:文本 1:音频"></textarea>
</div> </div>
<div> <div>
<div>名:</div> <div>源名 :</div>
<textarea rows="1" id="bookSourceUrl" <textarea rows="1" id="bookSourceName" class="base" title="bookSourceName"
placeholder="书源URL(bookSourceUrl) | 通常填写网站主页(标头不可省略),例: https://www.qidian.com"></textarea> placeholder="&lt;必填&gt;会显示在书源列表"></textarea>
</div> </div>
<div> <div>
<div>登录网页:</div> <div>源分组 :</div>
<textarea rows="1" id="loginUrl" placeholder="登录URL(loginUrl) | 填写网站登录网址,仅在需要登录的书源有用"></textarea> <textarea rows="1" id="bookSourceGroup" class="base" title="bookSourceGroup"
placeholder="&lt;选填&gt;描述书源的特征信息"></textarea>
</div> </div>
<div><b>书籍发现规则</b></div>
<div> <div>
<div>发现菜单:</div> <div>登录地址:</div>
<textarea rows="5" id="ruleFindUrl" <textarea rows="1" id="loginUrl" class="base" title="loginUrl"
placeholder="发现分类菜单规则(ruleFindUrl),将显示在发现菜单&#10;每行一条发现分类(网址域名可省略):&#10;名称1::网址(Url)1&#10;名称2::网址(Url)2&#10;..."></textarea> placeholder="&lt;选填&gt;填写网站登录网址,仅在需要登录的书源有用"></textarea>
</div> </div>
<div> <div>
<div>结果列表:</div> <div>链接验证:</div>
<textarea rows="1" id="ruleFindList" <textarea rows="1" id="bookUrlPattern" class="base" title="bookUrlPattern"
placeholder="发现页列表规则(ruleFindList) | 选择书籍节点 (规则结果为List&lt;Element&gt;)"></textarea> placeholder="&lt;选填&gt;当详情页URL与源URL的域名不一致时有效,用于添加网址"></textarea>
</div> </div>
<div> <div>
<div>书籍名称:</div> <div>请求头 :</div>
<textarea rows="1" id="ruleFindName" <textarea rows="3" id="header" class="base" title="header" placeholder="&lt;选填&gt;客户端标识"></textarea>
placeholder="发现页书名规则(ruleFindName) | 选择节点书名 (规则结果为String)"></textarea>
</div> </div>
<p></p>
<div><b>搜索</b></div>
<div> <div>
<div>书籍作者:</div> <div>搜索地址:</div>
<textarea rows="1" id="ruleFindAuthor" <textarea rows="1" id="searchUrl" class="base" title="searchUrl"
placeholder="发现页作者规则(ruleFindAuthor) | 选择节点作者 (规则结果为String)"></textarea> placeholder="[域名可省略]/search.php@kw={{key}}"></textarea>
</div> </div>
<div> <div>
<div>书籍分类:</div> <div>列表规则:</div>
<textarea rows="1" id="ruleFindKind" <textarea rows="3" id="ruleSearch_bookList" class="ruleSearch" title="bookList"
placeholder="发现页分类规则(ruleFindKind) | 选择节点分类信息 (规则结果为List&lt;String&gt;)"></textarea> placeholder="选择书籍节点 (规则结果为List&lt;Element&gt;)"></textarea>
</div>
<div>
<div>书名规则:</div>
<textarea rows="1" id="ruleSearch_name" class="ruleSearch" title="name"
placeholder="选择节点书名 (规则结果为String)"></textarea>
</div>
<div>
<div>作者规则:</div>
<textarea rows="1" id="ruleSearch_author" class="ruleSearch" title="author"
placeholder="选择节点作者 (规则结果为String)"></textarea>
</div>
<div>
<div>分类规则:</div>
<textarea rows="1" id="ruleSearch_kind" class="ruleSearch" title="kind"
placeholder="选择节点分类信息 (规则结果为String)"></textarea>
</div>
<div>
<div>字数规则:</div>
<textarea rows="1" id="ruleSearch_wordCount" class="ruleSearch" title="wordCount"
placeholder="选择节点字数信息 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>最新章节:</div> <div>最新章节:</div>
<textarea rows="1" id="ruleFindLastChapter" <textarea rows="1" id="ruleSearch_lastChapter" class="ruleSearch" title="lastChapter"
placeholder="发现页最新章节规则(ruleFindLastChapter) | 选择节点最新章节 (规则结果为String)"></textarea> placeholder="选择节点最新章节 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>简介内容:</div> <div>简介规则:</div>
<textarea rows="1" id="ruleFindIntroduce" <textarea rows="1" id="ruleSearch_intro" class="ruleSearch" title="intro"
placeholder="发现页简介规则(ruleFindIntroduce) | 选择节点书籍简介 (规则结果为String)"></textarea> placeholder="选择节点书籍简介 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>封面链接:</div> <div>封面规则:</div>
<textarea rows="1" id="ruleFindCoverUrl" <textarea rows="1" id="ruleSearch_coverUrl" class="ruleSearch" title="coverUrl"
placeholder="发现页封面规则(ruleFindCoverUrl) | 选择节点书籍封面 (规则结果为Url)"></textarea> placeholder="选择节点书籍封面 (规则结果为String类型的url)"></textarea>
</div> </div>
<div> <div>
<div>详情链接:</div> <div>详情地址:</div>
<textarea rows="1" id="ruleFindNoteUrl" <textarea rows="1" id="ruleSearch_bookUrl" class="ruleSearch" title="bookUrl"
placeholder="发现页详情规则(ruleFindNoteUrl) | 选择书籍详情页网址 (规则结果为Url)"></textarea> placeholder="选择书籍详情页网址 (规则结果为String类型的url)"></textarea>
</div> </div>
<div><b>书籍搜索规则</b></div> <p></p>
<div><b>发现</b></div>
<div> <div>
<div>搜索网址:</div> <div>发现地址:</div>
<textarea rows="1" id="ruleSearchUrl" <textarea rows="6" id="exploreUrl" class="base" title="exploreUrl"
placeholder="搜索网址(ruleSearchUrl) | [域名可省略]/search.php@kw=searchKey|char=utf-8"></textarea> placeholder="内容能显示在发现菜单&#10;每行一条发现分类(网址域名可省略),例:&#10;名称1::网址(Url)1&#10;名称2::网址(Url)2&#10;..."></textarea>
</div> </div>
<div> <div>
<div>结果验证:</div> <div>列表规则:</div>
<textarea rows="1" id="ruleBookUrlPattern" <textarea rows="1" id="ruleExplore_bookList" class="ruleExplore" title="bookList"
placeholder="搜索页URL验证(ruleBookUrlPattern) | 正则验证URL是否为详情页,成功则跳过搜索页解析"></textarea> placeholder="选择书籍节点 (规则结果为List&lt;Element&gt;)"></textarea>
</div> </div>
<div> <div>
<div>结果列表:</div> <div>书名规则:</div>
<textarea rows="1" id="ruleSearchList" <textarea rows="1" id="ruleExplore_name" class="ruleExplore" title="name"
placeholder="搜索页列表规则(ruleSearchList) | 选择书籍节点 (规则结果为List&lt;Element&gt;)"></textarea> placeholder="选择节点书名 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>书籍名称:</div> <div>作者规则:</div>
<textarea rows="1" id="ruleSearchName" <textarea rows="1" id="ruleExplore_author" class="ruleExplore" title="author"
placeholder="搜索页书名规则(ruleSearchName) | 选择节点书名 (规则结果为String)"></textarea> placeholder="选择节点作者 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>书籍作者:</div> <div>分类规则:</div>
<textarea rows="1" id="ruleSearchAuthor" <textarea rows="1" id="ruleExplore_kind" class="ruleExplore" title="kind"
placeholder="搜索页作者规则(ruleSearchAuthor) | 选择节点作者 (规则结果为String)"></textarea> placeholder="选择节点分类信息 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>书籍分类:</div> <div>字数规则:</div>
<textarea rows="1" id="ruleSearchKind" <textarea rows="1" id="ruleExplore_wordCount" class="ruleExplore" title="wordCount"
placeholder="搜索页分类规则(ruleSearchKind) | 选择节点分类信息 (规则结果为List&lt;String&gt;)"></textarea> placeholder="选择节点字数信息 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>最新章节:</div> <div>最新章节:</div>
<textarea rows="1" id="ruleSearchLastChapter" <textarea rows="1" id="ruleExplore_lastChapter" class="ruleExplore" title="lastChapter"
placeholder="搜索页最新章节规则(ruleSearchLastChapter) | 选择节点最新章节 (规则结果为String)"></textarea> placeholder="选择节点最新章节 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>简介内容:</div> <div>简介规则:</div>
<textarea rows="1" id="ruleSearchIntroduce" <textarea rows="1" id="ruleExplore_intro" class="ruleExplore" title="intro"
placeholder="搜索页简介规则(ruleSearchIntroduce) | 选择节点书籍简介 (规则结果为String)"></textarea> placeholder="选择节点书籍简介 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>封面链接:</div> <div>封面规则:</div>
<textarea rows="1" id="ruleSearchCoverUrl" <textarea rows="1" id="ruleExplore_coverUrl" class="ruleExplore" title="coverUrl"
placeholder="搜索页封面规则(ruleSearchCoverUrl) | 选择节点书籍封面 (规则结果为Url)"></textarea> placeholder="选择节点书籍封面 (规则结果为String类型的url)"></textarea>
</div> </div>
<div> <div>
<div>详情链接:</div> <div>详情地址:</div>
<textarea rows="1" id="ruleSearchNoteUrl" <textarea rows="1" id="ruleExplore_bookUrl" class="ruleExplore" title="bookUrl"
placeholder="搜索页详情规则(ruleSearchNoteUrl) | 选择书籍详情页网址 (规则结果为Url)"></textarea> placeholder="选择书籍详情页网址 (规则结果为String类型的url)"></textarea>
</div> </div>
<div><b>书籍详情规则</b></div> <p></p>
<div><b>详情</b></div>
<div> <div>
<div>页面处理:</div> <div>预处理 :</div>
<textarea rows="1" id="ruleBookInfoInit" <textarea rows="3" id="ruleBookInfo_init" class="ruleBookInfo" title="init"
placeholder="详情页信息预处理(ruleBookInfoInit) | 用于加速详情信息检索"></textarea> placeholder="用于加速详情信息检索,只支持AllInOne规则"></textarea>
</div> </div>
<div> <div>
<div>籍名称:</div> <div>名规则:</div>
<textarea rows="1" id="ruleBookName" <textarea rows="1" id="ruleBookInfo_name" class="ruleBookInfo" title="name"
placeholder="书名规则(ruleBookName) | 选择详情页书名 (规则结果为String)"></textarea> placeholder="选择节点书名 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>书籍作者:</div> <div>作者规则:</div>
<textarea rows="1" id="ruleBookAuthor" <textarea rows="1" id="ruleBookInfo_author" class="ruleBookInfo" title="author"
placeholder="作者规则(ruleBookAuthor) | 选择详情页作者 (规则结果为String)"></textarea> placeholder="选择节点作者 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>书籍分类:</div> <div>分类规则:</div>
<textarea rows="1" id="ruleBookKind" <textarea rows="1" id="ruleBookInfo_kind" class="ruleBookInfo" title="kind"
placeholder="分类规则(ruleBookKind) | 选择详情页分类信息 (规则结果为List&lt;String&gt;)"></textarea> placeholder="选择节点分类信息 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>最新章节:</div> <div>字数规则:</div>
<textarea rows="1" id="ruleBookLastChapter" <textarea rows="1" id="ruleBookInfo_wordCount" class="ruleBookInfo" title="wordCount"
placeholder="最新章节规则(ruleBookLastChapter) | 选择详情页最新章节 (规则结果为String)"></textarea> placeholder="选择节点字数信息 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>简介内容:</div> <div>最新章节:</div>
<textarea rows="1" id="ruleIntroduce" <textarea rows="1" id="ruleBookInfo_lastChapter" class="ruleBookInfo" title="lastChapter"
placeholder="简介规则(ruleIntroduce) | 选择详情页书籍简介 (规则结果为String)"></textarea> placeholder="选择节点最新章节 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>封面链接:</div> <div>简介规则:</div>
<textarea rows="1" id="ruleCoverUrl" placeholder="封面规则(ruleCoverUrl) | 选择详情页书籍封面 (规则结果为Url)"></textarea> <textarea rows="1" id="ruleBookInfo_intro" class="ruleBookInfo" title="intro"
placeholder="选择节点书籍简介 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>目录链接:</div> <div>封面规则:</div>
<textarea rows="1" id="ruleChapterUrl" <textarea rows="1" id="ruleBookInfo_coverUrl" class="ruleBookInfo" title="coverUrl"
placeholder="目录URL规则(ruleChapterUrl) | 选择目录页网址 (规则结果为Url, 与详情页相同时可省略)"></textarea> placeholder="选择节点书籍封面 (规则结果为String类型的url)"></textarea>
</div> </div>
<div><b>目录列表规则</b></div>
<div> <div>
<div>目录翻页:</div> <div>目录地址:</div>
<textarea rows="1" id="ruleChapterUrlNext" <textarea rows="1" id="ruleBookInfo_tocUrl" class="ruleBookInfo" title="tocUrl"
placeholder="目录下一页规则(ruleChapterUrlNext) | 选择目录下一页链接 (规则结果为List&lt;Url&gt;)"></textarea> placeholder="选择书籍详情页网址 (规则结果为String类型的url, 与详情页相同时可省略)"></textarea>
</div> </div>
<p></p>
<div><b>目录</b></div>
<div> <div>
<div>目录列表:</div> <div>列表规则:</div>
<textarea rows="1" id="ruleChapterList" <textarea rows="3" id="ruleToc_chapterList" class="ruleToc" title="chapterList"
placeholder="目录列表规则(ruleChapterList) | 选择目录列表的章节节点 (规则结果为List&lt;Element&gt;)"></textarea> placeholder="选择目录列表的章节节点 (规则结果为List&lt;Element&gt;)"></textarea>
</div> </div>
<div> <div>
<div>章节名称:</div> <div>章节名称:</div>
<textarea rows="1" id="ruleChapterName" <textarea rows="1" id="ruleToc_chapterName" class="ruleToc" title="chapterName"
placeholder="章节名称规则(ruleChapterName) | 选择章节名称 (规则结果为String)"></textarea> placeholder="选择章节名称 (规则结果为String)"></textarea>
</div>
<div>
<div>章节地址:</div>
<textarea rows="1" id="ruleToc_chapterUrl" class="ruleToc" title="chapterUrl"
placeholder="选择章节链接 (规则结果为String类型的Url)"></textarea>
</div> </div>
<div> <div>
<div>章节链接:</div> <div>收费标识:</div>
<textarea rows="1" id="ruleContentUrl" <textarea rows="1" id="ruleToc_isVip" class="ruleToc" title="isVip"
placeholder="章节URL规则(ruleContentUrl) | 选择章节链接 (规则结果为Url)"></textarea> placeholder="章节是否为VIP章节 (规则结果为Bool)"></textarea>
</div> </div>
<div><b>正文阅读规则</b></div>
<div> <div>
<div>章节正文:</div> <div>章节信息:</div>
<textarea rows="1" id="ruleBookContent" <textarea rows="1" id="ruleToc_updateTime" class="ruleToc" title="updateTime"
placeholder="正文规则(ruleBookContent) | 选择正文内容 (规则结果为String)"></textarea> placeholder="选择章节信息 (规则结果为String)"></textarea>
</div> </div>
<div> <div>
<div>正文翻页:</div> <div>翻页规则:</div>
<textarea rows="1" id="ruleContentUrlNext" <textarea rows="1" id="ruleToc_nextTocUrl" class="ruleToc" title="nextTocUrl"
placeholder="正文翻页URL规则(ruleContentUrlNext) | 选择下一分页(不是下一章)链接 (规则结果为Url)"></textarea> placeholder="选择目录下一页链接 (规则结果为List&lt;String&gt;或String)"></textarea>
</div> </div>
<p></p>
<div><b>正文</b></div>
<div>
<div>正文规则:</div>
<textarea rows="1" id="ruleContent_content" class="ruleContent" title="content"
placeholder="选择正文内容 (规则结果为String)"></textarea>
</div>
<div>
<div>翻页规则:</div>
<textarea rows="1" id="ruleContent_nextContentUrl" class="ruleContent" title="nextContentUrl"
placeholder="选择下一分页(不是下一章)链接 (规则结果为String类型的Url)"></textarea>
</div>
<div>
<div>脚本注入:</div>
<textarea rows="3" id="ruleContent_webJs" class="ruleContent" title="webJs"
placeholder="注入javascript,用于模拟鼠标点击等,无返回结果"></textarea>
</div>
<div>
<div>资源正则:</div>
<textarea rows="1" id="ruleContent_sourceRegex" class="ruleContent" title="sourceRegex"
placeholder="匹配资源的url特征,用于嗅探"></textarea>
</div>
<p></p>
<div><b>其它规则</b></div> <div><b>其它规则</b></div>
<div> <div>
<div>浏览标识:</div> <div>启用搜索:</div>
<textarea rows="1" id="httpUserAgent" <textarea rows="1" id="enabled" class="base" title="enabled"
placeholder="浏览器UA(HttpUserAgent) | 浏览器标识:User-Agent (可选)"></textarea> placeholder="启用: true 关闭: false (可选,默认true)"></textarea>
</div> </div>
<div> <div>
<div>排序编号:</div> <div>启用发现:</div>
<textarea rows="1" id="serialNumber" placeholder="整数: 0~N (可选,默认0) | 数字越小越靠前"></textarea> <textarea rows="1" id="enabledExplore" class="base" title="enabledExplore"
placeholder="启用: true 关闭: false (可选,默认true)"></textarea>
</div> </div>
<div> <div>
<div>搜索权重:</div> <div>搜索权重:</div>
<textarea rows="1" id="weight" placeholder="整数: 0~N (可选,默认0) | 数字越大越靠前"></textarea> <textarea rows="1" id="weight" class="base" title="weight"
placeholder="整数: 0~N (可选,默认0) | 数字越大越靠前"></textarea>
</div>
<div>
<div>排序编号:</div>
<textarea rows="1" id="customOrder" class="base" title="customOrder"
placeholder="整数: 0~N (可选,默认0) | 数字越小越靠前"></textarea>
</div> </div>
<div> <div>
<div>是否启用:</div> <div>更新时间:</div>
<textarea rows="1" id="enable" placeholder="默认启用=true,手动启用=false (可选,默认true)"></textarea> <textarea rows="1" id="lastUpdateTime" class="base" title="lastUpdateTime"
placeholder="整数: 0~N (可选,默认0) | 暂未使用"></textarea>
</div> </div>
</div> </div>
</div> </div>
@ -266,10 +329,11 @@
</div> </div>
<div class="tabbody"> <div class="tabbody">
<div class="tab1 this"> <div class="tab1 this">
<textarea class="context" id="RuleJsonString" placeholder="这里输出序列化的JSON数据,可直接导入'阅读'APP"></textarea> <textarea class="context" id="RuleJsonString"
placeholder="这里输出序列化的JSON数据,可直接导入'阅读'APP"></textarea>
</div> </div>
<div class="tab2"> <div class="tab2">
<input type="text" class="inputbox" id="DebugKey" placeholder="我的"> <input type="text" class="inputbox" id="DebugKey" placeholder="输入搜索关键字,默认搜「我的">
<textarea class="context" id="DebugConsole" placeholder="这里用于输出调试信息"></textarea> <textarea class="context" id="DebugConsole" placeholder="这里用于输出调试信息"></textarea>
</div> </div>
<div class="tab3"> <div class="tab3">
@ -283,7 +347,7 @@
</div> </div>
<div class="tab4"> <div class="tab4">
<div class="context link"> <div class="context link">
<a target="_blank" href="https://gedoor.github.io/MyBookshelf/sourcerule.html">官方书源教程</a> <a target="_blank" href="https://celeter.github.io">制作教程</a>
<a target="_blank" href="https://zhuanlan.zhihu.com/p/29436838">Xpath基础教程</a> <a target="_blank" href="https://zhuanlan.zhihu.com/p/29436838">Xpath基础教程</a>
<a target="_blank" href="https://zhuanlan.zhihu.com/p/32187820">Xpath高级教程</a> <a target="_blank" href="https://zhuanlan.zhihu.com/p/32187820">Xpath高级教程</a>
<a target="_blank" href="https://www.w3cschool.cn/regex_rmjc/?">正则表达式教程</a> <a target="_blank" href="https://www.w3cschool.cn/regex_rmjc/?">正则表达式教程</a>
@ -294,14 +358,14 @@
<br>(?i) 前缀表示忽略大小写 <br>(?i) 前缀表示忽略大小写
</div> </div>
<a target="_blank" href="https://www.beta.browxy.com/">代码在线运行工具</a> <a target="_blank" href="https://www.beta.browxy.com/">代码在线运行工具</a>
<a target="_blank" href="/bookshelf.html">阅读书架(测试)</a> <a target="_blank" href="bookshelf.html">阅读书架(测试)</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript" src="/index.js"></script> <script type="text/javascript" src="index.js"></script>
</body> </body>
</html> </html>

@ -20,11 +20,40 @@ function hashParam(key, val) {
// 创建书源规则容器对象 // 创建书源规则容器对象
const RuleJSON = (() => { const RuleJSON = (() => {
let ruleJson = {}; let ruleJson = {};
$$('.rules textarea').forEach(item => ruleJson[item.id] = ''); let searchJson = {};
// for (let item of $$('.rules textarea')) ruleJson[item.id] = ''; let exploreJson = {};
ruleJson.serialNumber = 0; let bookInfoJson = {};
let tocJson = {};
let contentJson = {};
// 基本以及其他
$$('.rules .base').forEach(item => ruleJson[item.title] = '');
ruleJson.lastUpdateTime = 0;
ruleJson.customOrder = 0;
ruleJson.weight = 0; ruleJson.weight = 0;
ruleJson.enable = true; ruleJson.enabled = true;
ruleJson.enabledExplore = true;
// 搜索规则
$$('.rules .ruleSearch').forEach(item => searchJson[item.title] = '');
ruleJson.ruleSearch = JSON.stringify(searchJson);
// 发现规则
$$('.rules .ruleExplore').forEach(item => exploreJson[item.title] = '');
ruleJson.ruleExplore = JSON.stringify(exploreJson);
// 详情页规则
$$('.rules .ruleBookInfo').forEach(item => bookInfoJson[item.title] = '');
ruleJson.ruleBookInfo = JSON.stringify(bookInfoJson);
// 目录规则
$$('.rules .ruleToc').forEach(item => tocJson[item.title] = '');
ruleJson.ruleToc = JSON.stringify(tocJson);
// 正文规则
$$('.rules .ruleContent').forEach(item => contentJson[item.title] = '');
ruleJson.ruleContent = JSON.stringify(contentJson);
return ruleJson; return ruleJson;
})(); })();
// 选项卡Tab切换事件处理 // 选项卡Tab切换事件处理
@ -72,15 +101,113 @@ function HttpPost(url, data) {
} }
// 将书源表单转化为书源对象 // 将书源表单转化为书源对象
function rule2json() { function rule2json() {
Object.keys(RuleJSON).forEach((key) => RuleJSON[key] = $('#' + key).value); // 转换base
RuleJSON.serialNumber = RuleJSON.serialNumber == '' ? 0 : parseInt(RuleJSON.serialNumber); Object.keys(RuleJSON).forEach(key => {
if (!key.startsWith("rule")) {
RuleJSON[key] = $('#' + key).value;
}
});
// 转换搜索规则
let searchJson = {};
Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => {
searchJson[key] = $('#' + 'ruleSearch_' + key).value;
});
RuleJSON.ruleSearch = JSON.stringify(searchJson);
// 转换发现规则
let exploreJson = {};
Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => {
exploreJson[key] = $('#' + 'ruleExplore_' + key).value;
});
RuleJSON.ruleExplore = JSON.stringify(exploreJson);
// 转换详情页规则
let bookInfoJson = {};
Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => {
bookInfoJson[key] = $('#' + 'ruleBookInfo_' + key).value;
});
RuleJSON.ruleBookInfo = JSON.stringify(bookInfoJson);
// 转换目录规则
let tocJson = {};
Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => {
tocJson[key] = $('#' + 'ruleToc_' + key).value;
});
RuleJSON.ruleToc = JSON.stringify(tocJson);
// 转换正文规则
let contentJson = {};
Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => {
contentJson[key] = $('#' + 'ruleContent_' + key).value;
});
RuleJSON.ruleContent = JSON.stringify(contentJson);
RuleJSON.lastUpdateTime = RuleJSON.lastUpdateTime == '' ? 0 : parseInt(RuleJSON.lastUpdateTime);
RuleJSON.customOrder = RuleJSON.customOrder == '' ? 0 : parseInt(RuleJSON.customOrder);
RuleJSON.weight = RuleJSON.weight == '' ? 0 : parseInt(RuleJSON.weight); RuleJSON.weight = RuleJSON.weight == '' ? 0 : parseInt(RuleJSON.weight);
RuleJSON.enable = RuleJSON.enable == '' || RuleJSON.enable.toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true'; RuleJSON.bookSourceType == RuleJSON.bookSourceType == '' ? 0 : parseInt(RuleJSON.weight);
RuleJSON.enabled = RuleJSON.enabled == '' || String(RuleJSON.enabled).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
RuleJSON.enabledExplore = RuleJSON.enabledExplore == '' || String(RuleJSON.enabledExplore).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
return RuleJSON; return RuleJSON;
} }
// 将书源对象填充到书源表单 // 将书源对象填充到书源表单
function json2rule(RuleEditor) { function json2rule(RuleEditor) {
Object.keys(RuleJSON).forEach((key) => $("#" + key).value = RuleEditor[key] ? RuleEditor[key] : ''); // 转换base
Object.keys(RuleJSON).forEach(key => {
if (!key.startsWith("rule")) {
let val = RuleEditor[key];
if (typeof val == "number") {
$("#" + key).value = val ? String(val) : '0';
}
else if (typeof val == "boolean") {
$("#" + key).value = val ? String(val) : 'false';
}
else {
$("#" + key).value = val ? String(val) : '';
}
}
});
// 转换搜索规则
if (RuleEditor.ruleSearch) {
let searchJson = JSON.parse(RuleEditor.ruleSearch);
Object.keys(JSON.parse(RuleJSON.ruleSearch)).forEach(key => {
$('#' + 'ruleSearch_' + key).value = searchJson[key] ? searchJson[key] : '';
});
}
// 转换发现规则
if (RuleEditor.ruleExplore) {
let exploreJson = JSON.parse(RuleEditor.ruleExplore);
Object.keys(JSON.parse(RuleJSON.ruleExplore)).forEach(key => {
$('#' + 'ruleExplore_' + key).value = exploreJson[key] ? exploreJson[key] : '';
});
}
// 转换详情页规则
if (RuleEditor.ruleBookInfo) {
let bookInfoJson = JSON.parse(RuleEditor.ruleBookInfo);
Object.keys(JSON.parse(RuleJSON.ruleBookInfo)).forEach(key => {
$('#' + 'ruleBookInfo_' + key).value = bookInfoJson[key] ? bookInfoJson[key] : '';
});
}
// 转换目录规则
if (RuleEditor.ruleToc) {
let tocJson = JSON.parse(RuleEditor.ruleToc);
Object.keys(JSON.parse(RuleJSON.ruleToc)).forEach(key => {
$('#' + 'ruleToc_' + key).value = tocJson[key] ? tocJson[key] : '';
});
}
// 转换正文规则
if (RuleEditor.ruleContent) {
let contentJson = JSON.parse(RuleEditor.ruleContent);
Object.keys(JSON.parse(RuleJSON.ruleContent)).forEach(key => {
$('#' + 'ruleContent_' + key).value = contentJson[key] ? contentJson[key] : '';
});
}
} }
// 记录操作过程 // 记录操作过程
var course = { "old": [], "now": {}, "new": [] }; var course = { "old": [], "now": {}, "new": [] };
@ -153,16 +280,16 @@ $('.menu').addEventListener('click', e => {
}); });
failMsg = '\n推送失败的书源将用红色字体标注!'; failMsg = '\n推送失败的书源将用红色字体标注!';
} }
alert(`批量推送书源到「阅读APP」\n共计: ${RuleSources.length}\n成功: ${okData.length}\n失败: ${RuleSources.length - okData.length}${failMsg}`); alert(`批量推送书源到「阅读3.0APP」\n共计: ${RuleSources.length}\n成功: ${okData.length}\n失败: ${RuleSources.length - okData.length}${failMsg}`);
} }
else { else {
alert(`批量推送书源到「阅读APP」成功!\n共计: ${RuleSources.length}`); alert(`批量推送书源到「阅读3.0APP」成功!\n共计: ${RuleSources.length}`);
} }
} }
else { else {
alert(`批量推送书源失败!\nErrorMsg: ${json.errorMsg}`); alert(`批量推送书源失败!\nErrorMsg: ${json.errorMsg}`);
} }
}).catch(err => { alert(`批量推送书源失败,无法连接到「阅读APP」!\n${err}`); }); }).catch(err => { alert(`批量推送书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
thisNode.setAttribute('class', ''); thisNode.setAttribute('class', '');
})(); })();
return; return;
@ -181,7 +308,7 @@ $('.menu').addEventListener('click', e => {
else { else {
alert(`批量拉取书源失败!\nErrorMsg: ${json.errorMsg}`); alert(`批量拉取书源失败!\nErrorMsg: ${json.errorMsg}`);
} }
}).catch(err => { alert(`批量拉取书源失败,无法连接到「阅读APP」!\n${err}`); }); }).catch(err => { alert(`批量拉取书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
thisNode.setAttribute('class', ''); thisNode.setAttribute('class', '');
})(); })();
return; return;
@ -244,9 +371,9 @@ $('.menu').addEventListener('click', e => {
(async () => { (async () => {
let saveRule = [rule2json()]; let saveRule = [rule2json()];
await HttpPost(`/saveSources`, saveRule).then(json => { await HttpPost(`/saveSources`, saveRule).then(json => {
alert(json.isSuccess ? `书源《${saveRule[0].bookSourceName}》已成功保存到「阅读APP」` : `书源《${saveRule[0].bookSourceName}》保存失败!\nErrorMsg: ${json.errorMsg}`); alert(json.isSuccess ? `书源《${saveRule[0].bookSourceName}》已成功保存到「阅读3.0APP」` : `书源《${saveRule[0].bookSourceName}》保存失败!\nErrorMsg: ${json.errorMsg}`);
setRule(saveRule[0]); setRule(saveRule[0]);
}).catch(err => { alert(`保存书源失败,无法连接到「阅读APP」!\n${err}`); }); }).catch(err => { alert(`保存书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
thisNode.setAttribute('class', ''); thisNode.setAttribute('class', '');
})(); })();
return; return;
@ -348,7 +475,7 @@ $('.tab3>.titlebar').addEventListener('click', e => {
console.log(deleteSources); console.log(deleteSources);
console.log(`以上书源已删除!`) console.log(`以上书源已删除!`)
} }
}).catch(err => { alert(`删除书源失败,无法连接到「阅读APP」!\n${err}`); }); }).catch(err => { alert(`删除书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
} }
break; break;
case 'ClrAll': case 'ClrAll':

Loading…
Cancel
Save