bookdetail.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0" />
  6. <link rel="shortcut icon" href="favicon.ico" />
  7. <link rel="bookmark" href="favicon.ico" type="image/x-icon" />
  8. <title>2023年中国航油-管理年鉴</title>
  9. <link rel="stylesheet" href="css/mui.min.css">
  10. <link rel="stylesheet" href="css/reset.css" />
  11. <link rel="stylesheet" href="css/main.css" />
  12. <style>
  13. .m-artical-action-mid {
  14. position: fixed;
  15. width: 100%;
  16. height: 40%;
  17. top: 30%;
  18. z-index: 9998;
  19. }
  20. #muluList {
  21. /*避免导航边框和列表背景边框重叠,看起来像两条边框似得;*/
  22. margin-top: -1px;
  23. }
  24. .highChapter {
  25. color: red !important;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div>
  31. <!-- 中间点击层 -->
  32. <div class="m-artical-action">
  33. <div class="m-artical-action-mid" id="action_mid"></div>
  34. </div>
  35. <!-- 顶部导航 -->
  36. <div class="nav-top colorStyle bgStyle" id="nav_top" style="display: none;">
  37. <div class="nav_container">
  38. <div class="nav_return nav_back_book" id="nav_icon"></div>
  39. <div class="nav_text nav_back_book" id="nav_text">返回首页</div>
  40. </div>
  41. </div>
  42. <!-- 主体内容 -->
  43. <header id="header" class="top_mulu_box colorStyle bgStyle">
  44. <div class="top_left" style="cursor: pointer;">
  45. <div class="top_left_icon" id="topLeftIcon"></div>
  46. <div class="top_left_text" id="topMulu">目录</div>
  47. </div>
  48. <div class="top_center">
  49. <div class="top_center_text" id="ChapterTitle"></div>
  50. </div>
  51. <div class="top_right"></div>
  52. </header>
  53. <div class="container">
  54. <div class="Content">
  55. <!-- 内容动态加载 -->
  56. </div>
  57. <div class="page_btn">
  58. <button class="btn-prev colorStyle bgStyle" id="btn_prev">上一章</button>
  59. <button class="btn-next colorStyle bgStyle" id="btn_next">下一章</button>
  60. </div>
  61. </div>
  62. <!-- 底部导航栏 -->
  63. <div class="nav-bottom colorStyle bgStyle" id="nav_bottom" style="display: none;">
  64. <div class="btn-mulu">
  65. <div class="mulu">
  66. <div class="bottom-icon" id="icon_mulu"> </div>
  67. <div class="text_mulu">目录</div>
  68. </div>
  69. </div>
  70. <div class="btn_Aa">
  71. <div class="Aa">
  72. <div class="bottom-icon" id="icon_Aa"> </div>
  73. <div class="text_Aa">字号</div>
  74. </div>
  75. </div>
  76. <div class="btn-extra">
  77. <div class="extra">
  78. <div class="bottom-icon" id="icon_extra"> </div>
  79. <div class="text_extra">其他</div>
  80. </div>
  81. </div>
  82. <!-- 其他功能栏 -->
  83. <div class="extraPop colorStyle bgStyle" id="extra_Pop" style="display: none;">
  84. <div class="fontItem">
  85. <span class="fontItemTitle">背景</span>
  86. <div class="fontItemCons" id="bk-list">
  87. <div class="bk-item" id="mb">
  88. <div class="bk-container" style="background-color: rgb(247, 238, 229);"></div>
  89. <span>米白</span>
  90. </div>
  91. <div class="bk-item" id="zz">
  92. <div class="bk-container" style="background-color: rgb(233, 223, 199);"></div>
  93. <span>纸张</span>
  94. </div>
  95. <div class="bk-item" id="qh">
  96. <div class="bk-container" style="background-color: rgb(164, 164, 164);"></div>
  97. <span>浅灰</span>
  98. </div>
  99. <div class="bk-item" id="hy">
  100. <div class="bk-container" style="background-color: rgb(205, 239, 206);"></div>
  101. <span>护眼</span>
  102. </div>
  103. <div class="bk-item" id="hl">
  104. <div class="bk-container" style="background-color: rgb(40, 53, 72);"></div>
  105. <span>海蓝</span>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <!-- 字号功能栏 -->
  111. <div class="fontPop colorStyle bgStyle" id="font_Pop" style="display: none;">
  112. <div class="fontItem">
  113. <span class="fontItemTitle">字号</span>
  114. <div class="fontItemCons">
  115. 小<input style="width: 80%; margin: 0 auto;" type="range" id="slider" name="slider" min="16"
  116. max="24" step="1">大
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <!-- 目录 -->
  122. <div class="muluBox colorStyle" id="mulu_Box" style="display: none;">
  123. <div class="muluMask" id="mulu_Mask"></div>
  124. <div class="muluCons bgStyle" id="mulu_Cons">
  125. <div class="muluTitle">
  126. <div>共<span id="ChapterTotal"></span>章</div>
  127. </div>
  128. <div class="mui-content">
  129. <ul id="muluList" class="mui-table-view mui-table-view-chevron">
  130. <!-- 目录动态加载 -->
  131. </ul>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <script src="js/mui.min.js"></script>
  137. <script type="text/javascript" src="js/jquery.min.js"></script>
  138. <script type="text/javascript" src="js/jquery.jsonp.js"></script>
  139. <script type="text/javascript" src="js/jquery.base64.js"></script>
  140. <script>
  141. //移动设备的高度
  142. let deviceHeight = document.documentElement.clientHeight;
  143. // $('.container').css('height', deviceHeight+'px')
  144. //
  145. var Dom = {
  146. font_Pop: $("#font_Pop"),
  147. extra_Pop: $("#extra_Pop"),
  148. nav_top: $("#nav_top"),
  149. nav_bottom: $("#nav_bottom"),
  150. icon_Aa: $("#icon_Aa"),
  151. icon_extra: $("#icon_extra"),
  152. body: $("body"),
  153. win: $(window),
  154. slider: $("#slider"),
  155. icon_mulu: $("#icon_mulu"),
  156. mulu_Box: $("#mulu_Box"),
  157. mulu_Dialog: $("#mulu_Dialog"),
  158. mulu_Mask: $("mulu_Mask"),
  159. mulu_Cons: $("#mulu_Cons"),
  160. muluList: $("#muluList"),
  161. bkList: $("#bk-list"),
  162. header: $("#header"),
  163. ChapterDialog: $("#ChapterDialog")
  164. }
  165. var Util = (function() { //封装的本地存储和json数据解析
  166. var prefix = 'function_reader_';
  167. var StorageGetter = function(key) {
  168. return localStorage.getItem(prefix + key);
  169. }
  170. var StorageSetter = function(key, val) {
  171. return localStorage.setItem(prefix + key, val);
  172. }
  173. //通过url来获取加密信息,并解密
  174. var getJsonp = function(url, callback) {
  175. return $.jsonp({
  176. url: url,
  177. cache: true,
  178. callback: 'duokan_fiction_chapter',
  179. success: function(result) {
  180. //获取加密信息,解码、转json
  181. var data = $.base64.decode(result);
  182. var json = decodeURIComponent(escape(data));
  183. callback(json);
  184. }
  185. })
  186. }
  187. return {
  188. getJsonp: getJsonp,
  189. StorageGetter: StorageGetter,
  190. StorageSetter: StorageSetter
  191. }
  192. })();
  193. /***** 存储记录 *****/
  194. //背景颜色
  195. var bgColor = Util.StorageGetter("bgColor") || "rgb(233, 223, 199)"; //默认”纸张“背景颜色
  196. //字体颜色
  197. var fontColor = bgColor === 'rgb(40, 53, 72)' ? "#f8f8f8" : "#000000"; //默认黑色
  198. //字号大小
  199. let size = Util.StorageGetter("font_size") ? parseInt(Util.StorageGetter("font_size")) : 18;
  200. var fontSize = size / 16;
  201. //数据层的初始化
  202. var RootContainer = $('.Content');
  203. var readerUIFrame = ReaderBaseFrame(RootContainer);
  204. var readerMuluFrame = ReaderMuluFrame(Dom.muluList)
  205. var File_id = 0;
  206. var Chapter_id = 0;
  207. var ChapterTotal = 0;
  208. var ChapterList = [];
  209. var readerm = ReaderModel();
  210. readerm.init(function(data, mulu) {
  211. readerUIFrame(data);
  212. ChapterList = mulu;
  213. readerMuluFrame(mulu);
  214. $("#ChapterTitle").text(data.ct);
  215. setHtmlStyle()
  216. });
  217. //业务事件的初始化
  218. EventHandler();
  219. function ReaderBaseFrame(container) { //UI渲染层
  220. function ParseChapterData(jsonData) { //生成要展示的 html文本
  221. let jsonObj = jsonData;
  222. let size = Util.StorageGetter("font_size");
  223. size = size ? parseInt(size) : 18;
  224. fontSize = size / 16;
  225. let fontSizeAdd6 = (size + 6) / 16;
  226. let fontSizeAdd2 = (size + 2) / 16;
  227. let html = "";
  228. if (!!jsonObj.introduction && jsonObj.introduction.length > 0) {
  229. html += "<br/><br/><br/>";
  230. for (let i = 0; i < jsonObj.introduction.length; i++) {
  231. html += `<p class="colorStyle" style="font-size:${fontSize}">${jsonObj.introduction[i]}</p>`;
  232. }
  233. }
  234. html += `<br/><br/><br/><h4 style=font-size:${fontSizeAdd6};color:${fontColor}">${jsonObj.t}</h4>`;
  235. if (jsonObj.textType === 'table') {
  236. html +=
  237. '<table class="table" width="100%" cellpadding="0" cellspacing="0" style="table-layout: fixed;">';
  238. if (!!jsonObj.tableTitle) {
  239. html += `<caption class="caption">${jsonObj.tableTitle}</caption>`;
  240. }
  241. if (jsonObj.tableHead.length) {
  242. html += `<thead class="thead"><tr class="tr">`;
  243. jsonObj.tableHead.map((item, index) => {
  244. html += `<th class="th">${item}</th>`;
  245. })
  246. html += `</tr></thead>`;
  247. }
  248. if (jsonObj.tableBody.length) {
  249. html += `<tbody class="tbody">`
  250. jsonObj.tableBody.map(item => {
  251. html += `<tr class="tr">`;
  252. item.length && item.map((liDom, index) => {
  253. html += `<td class="td">${liDom}</td>`;
  254. })
  255. html += "</tr>"
  256. })
  257. html += `</tbody>`
  258. }
  259. html += `</table>`;
  260. } else {
  261. for (let i = 0; i < jsonObj.p.length; i++) {
  262. if (Chapter_id == 0) {
  263. html += "<div>" + jsonObj.p[i] + "</div>";
  264. } else {
  265. if (/^##.*/.test(jsonObj.p[i])) {
  266. html +=
  267. `<h6 class="colorStyle" style="line-height: 2.0625rem; padding: 1.25rem 0 0.3125rem; font-weight: bold; font-size:${fontSize}rem;color:${fontColor}">${jsonObj.p[i].replace('##', '')}</h6>`;
  268. } else if (/^#.*/.test(jsonObj.p[i])) {
  269. html +=
  270. `<h5 class="colorStyle" style="line-height: 2.1875rem; padding: 0.625rem 0; font-weight: bold; font-size:${fontSizeAdd2}rem;color:${fontColor}">${jsonObj.p[i].replace('#', '')}</h5>`;
  271. } else if (/^\<img.*/.test(jsonObj.p[i])) {
  272. html +=
  273. `<div style="margin-bottom:1.25rem;">${jsonObj.p[i]}</div>`;
  274. } else {
  275. html +=
  276. `<p class="colorStyle" style="font-size:${fontSize}rem;color:${fontColor}">${jsonObj.p[i]}</p>`;
  277. }
  278. }
  279. }
  280. }
  281. html = html.replace("##", )
  282. return html;
  283. }
  284. return function(data) { //返回 渲染后的结果data:解密后的json数据
  285. container.html(ParseChapterData(data));
  286. }
  287. }
  288. function ReaderMuluFrame(container) { //目录UI渲染层
  289. function ParseChapterMuluData(jsonData) { //生成要展示的 html文本
  290. let mulu = '';
  291. for (let i = 0; i < jsonData.length; i++) {
  292. let jsonObj = jsonData[i];
  293. if (jsonObj.children) {
  294. mulu +=
  295. `<li class="mui-table-view-cell mui-collapse parentLi"><a class="mui-navigate-right list-li-a" data-cid="${jsonObj.chapter_id}" data-fid="${jsonObj.file_id}" href="#">${jsonObj.title}</a><ul class="mui-table-view mui-table-view-chevron">`;
  296. for (let k = 0; k < jsonObj.children.length; k++) {
  297. mulu += `<li class="mui-table-view-cell"><a class="mui-navigate-right list-li-a" data-cid="${jsonObj.children[k].chapter_id}" data-fid="${jsonObj.children[k].file_id}" href="#">
  298. ${jsonObj.children[k].title}</a></li>`;
  299. }
  300. mulu += '</ul></li>';
  301. } else {
  302. mulu += `<li class="mui-table-view-cell parentLi"><a class="mui-navigate-right list-li-a" data-cid="${jsonObj.chapter_id}" data-cid="${jsonObj.file_id}" href="#">${jsonObj.title}
  303. </a></li>`;
  304. }
  305. }
  306. mulu = mulu.replace("##", );
  307. return mulu;
  308. }
  309. return function(data) { //返回 渲染后的结果data:解密后的json数据
  310. container.html(ParseChapterMuluData(data));
  311. }
  312. }
  313. function ReaderModel() { //数据交互层
  314. //todo 获取章节信息
  315. var init = function(Uicallback) { //初始化 信息
  316. getFictionInfo(function(mulu) {
  317. getCurChaptInfo(Chapter_id, function(data) {
  318. //todo
  319. Uicallback && Uicallback(data, mulu);
  320. })
  321. })
  322. };
  323. var getFictionInfo = function(callback) { //获取所有章节摘要信息
  324. $.get('data/chapter.json', function(data) {
  325. //todo 获取章节信息之后的回调
  326. Chapter_id = parseInt(Util.StorageGetter("ChapterId"));
  327. File_id = parseInt(Util.StorageGetter("FileId"));
  328. //选择是否从头阅读
  329. if (Chapter_id !== 0) {
  330. if (confirm('您要继续上次的阅读么?')) {} else {
  331. Chapter_id = 0;
  332. }
  333. }
  334. let list = data.chapters;
  335. for (let i = 0; i < list.length; i++) {
  336. if (!isFinite(Chapter_id) && list[i].type !== 'file') {
  337. Chapter_id = list[i].chapter_id;
  338. File_id = list[i].file_id;
  339. }
  340. if (list[i].children) {
  341. ChapterTotal += list[i].children.length;
  342. if (!isFinite(Chapter_id)) {
  343. Chapter_id = list[i].children[0].chapter_id;
  344. File_id = list[i].children[0].file_id;
  345. }
  346. }
  347. }
  348. callback && callback(list);
  349. }, 'json');
  350. };
  351. var getCurChaptInfo = function(Chapter_id, callback) { //获取当前Chapter_id章节详细信息
  352. // $.get('data/data' + Chapter_id + '.json', function(data,status) {
  353. // //todo 获取详细信息之后的回调
  354. // console.log(status,'status')
  355. // if (data.result == 0) {
  356. // // var url=data.jsonp;
  357. // // Util.getJsonp(url,function(data){
  358. // callback && callback(data);
  359. // $("#ChapterTitle").text(data.ct);
  360. // // });//通过url来获取加密信息,并解密
  361. // }
  362. // }, 'json');
  363. $.getJSON('data/data' + Chapter_id + '.json')
  364. .done(function(data) {
  365. // 请求成功,文件存在
  366. // console.log("文件存在", data);
  367. if (data.result == 0) {
  368. callback && callback(data);
  369. }
  370. })
  371. .fail(function(jqXHR, textStatus, errorThrown) {
  372. // console.log("文件不存在",jqXHR);
  373. callback && callback({
  374. p: [],
  375. t: "",
  376. result: 0
  377. });
  378. // 请求出错,文件不存在
  379. // if (jqXHR.status === 404) {
  380. // console.log("文件不存在");
  381. // } else {
  382. // console.log("请求出错");
  383. // }
  384. });
  385. };
  386. var prveChapter = function() { //上一页
  387. Chapter_id = parseInt(Chapter_id);
  388. if (Chapter_id == 0) {
  389. return;
  390. }
  391. Chapter_id -= 1;
  392. //调用方法获取 Chapter_id章节信息
  393. getCurChaptInfo(Chapter_id, function(data) {
  394. readerUIFrame(data); //渲染html数据
  395. });
  396. Util.StorageSetter("ChapterId", Chapter_id);
  397. //
  398. updateFileId()
  399. };
  400. var nextChapter = function() { //下一页
  401. Chapter_id = parseInt(Chapter_id);
  402. if (Chapter_id == ChapterTotal) {
  403. return;
  404. }
  405. Chapter_id += 1;
  406. //调用方法获取 Chapter_id章节信息
  407. getCurChaptInfo(Chapter_id, function(data) {
  408. readerUIFrame(data);
  409. });
  410. Util.StorageSetter("ChapterId", Chapter_id);
  411. //
  412. updateFileId()
  413. };
  414. var jumpChapter = function() { //跳页
  415. Chapter_id = parseInt(Chapter_id);
  416. File_id = parseInt(File_id);
  417. //调用方法获取 Chapter_id章节信息
  418. getCurChaptInfo(Chapter_id, function(data) {
  419. //console.log(data);
  420. readerUIFrame(data); //渲染html数据
  421. });
  422. Util.StorageSetter("ChapterId", Chapter_id);
  423. Util.StorageSetter("FileId", File_id);
  424. updateFileId()
  425. };
  426. var updateFileId = function() { //更新目录一级 file_id
  427. for (let item of ChapterList) {
  428. if (item.type === 'file') {
  429. let obj = item.children.find(child => child.chapter_id == Chapter_id)
  430. if (obj) {
  431. File_id = obj.file_id;
  432. $("#ChapterTitle").text(obj.cTitle);
  433. break;
  434. }
  435. } else {
  436. if (Chapter_id === item.chapter_id) {
  437. File_id = item.file_id;
  438. $("#ChapterTitle").text(item.cTitle);
  439. break;
  440. }
  441. Util.StorageSetter("FileId", File_id);
  442. }
  443. }
  444. }
  445. return {
  446. init: init,
  447. prveChapter: prveChapter,
  448. nextChapter: nextChapter,
  449. jumpChapter: jumpChapter,
  450. }
  451. }
  452. function EventHandler() { //业务事件处理层
  453. //点击主体中间事件
  454. $("#action_mid").click(function() {
  455. if (Dom.nav_top.css('display') == "none") {
  456. actNavDialog(true)
  457. } else {
  458. actAllDialog(false)
  459. }
  460. });
  461. //点击返回事件
  462. $(".nav_back_book").click(function() {
  463. Chapter_id = parseInt(Chapter_id);
  464. if (Chapter_id == 0) {
  465. return;
  466. }
  467. if (Dom.nav_top.css('display') == "none") {
  468. return;
  469. }
  470. Chapter_id = 0;
  471. readerm.jumpChapter();
  472. });
  473. //点击目录事件--顶部浮窗
  474. $("#topMulu").click(function() {
  475. muluShow("top")
  476. });
  477. //点击目录事件--底部导航
  478. $("#icon_mulu").click(function() {
  479. muluShow()
  480. });
  481. var muluShow = function(type) {
  482. Dom.icon_extra.removeClass("act");
  483. if (Dom.mulu_Box.css('display') == 'none') {
  484. $('body,html').addClass('notScroll');
  485. Dom.mulu_Box.show();
  486. if (type === 'top') {
  487. Dom.mulu_Box.css("bottom", 0)
  488. } else {
  489. Dom.mulu_Box.css("bottom", 70)
  490. }
  491. Dom.nav_top.hide();
  492. Dom.mulu_Mask.show();
  493. Dom.mulu_Cons.show();
  494. //章节总数赋值
  495. $('#ChapterTotal').text(ChapterTotal)
  496. //给当前选中章节高亮
  497. let optDom = $(".parentLi")[File_id];
  498. $(optDom).addClass("mui-active");
  499. $($(optDom).find("a")).each((i, aNode) => {
  500. if ($(aNode).data('cid') == Chapter_id) {
  501. $(aNode).addClass("highChapter")
  502. } else {
  503. $(aNode).removeClass("highChapter")
  504. }
  505. })
  506. } else {
  507. muluUpdateActive();
  508. actMuluDialog(false);
  509. }
  510. $("#muluList,#muluList .mui-table-view,.list-li-a,.mui-table-view-cell>a:not(.mui-btn).mui-active").css(
  511. 'background-color', bgColor);
  512. actFontDialog(false)
  513. actExtraDialog(false);
  514. }
  515. //点击目录列表进行指定跳转
  516. Dom.muluList.on("click", function(e) {
  517. let cid = $(e.target).data('cid');
  518. if (cid === undefined || cid === null || cid === "") {
  519. return
  520. }
  521. Chapter_id = cid;
  522. File_id = $(e.target).data('fid');
  523. let cSpan = $(e.target).parent().parent("ul").prev();
  524. let cTitle = cSpan[0] ? cSpan[0].text : e.target.text;
  525. $("#ChapterTitle").text(cTitle);
  526. muluUpdateActive();
  527. readerm.jumpChapter();
  528. actAllDialog(false)
  529. window.scrollTo(0, 0);
  530. })
  531. // 点击弹窗内容以外的地方关闭弹窗
  532. $("#mulu_Mask").on('click', function(e) {
  533. // if ($(e.target).closest('#mui-content').length > 0) {
  534. // console.log('弹出框内部被点击了');
  535. // } else {
  536. // console.log('弹出框以外的部分被点击了');
  537. // 关闭弹框
  538. actAllDialog(false)
  539. // }
  540. });
  541. //点击字号事件
  542. $(".btn_Aa").click(function() {
  543. Dom.icon_extra.removeClass("act");
  544. if (Dom.font_Pop.css('display') == 'none') {
  545. Dom.font_Pop.show();
  546. Dom.slider.val(fontSize);
  547. } else {
  548. Dom.font_Pop.hide();
  549. }
  550. actMuluDialog(false);
  551. actExtraDialog(false);
  552. });
  553. //滚动条事件
  554. Dom.win.scroll(function() {
  555. actAllDialog(false)
  556. })
  557. //点击字体大小事件
  558. Dom.slider.change(function() {
  559. let NowFontSize = Number($(this).val());
  560. if (NowFontSize > 24 || NowFontSize < 16) {
  561. return;
  562. }
  563. $("p").css('font-size', NowFontSize / 16 + 'rem');
  564. $("h6").css('font-size', NowFontSize / 16 + 'rem');
  565. $("h4").css('font-size', (NowFontSize + 6) / 16 + 'rem');
  566. $("h5").css('font-size', (NowFontSize + 2) / 16 + 'rem');
  567. Util.StorageSetter("font_size", NowFontSize);
  568. });
  569. //点击其他事件
  570. $(".btn-extra").click(function() {
  571. Dom.icon_extra.addClass("act");
  572. if (Dom.extra_Pop.css('display') == 'none') {
  573. Dom.extra_Pop.show();
  574. if (bgColor) {
  575. $(".bk-item").each((i, liDom) => {
  576. let nodeSpan = $($(liDom).find(".bk-container"));
  577. nodeSpan.removeClass("bk-container-current")
  578. let itembg = nodeSpan[0].style.backgroundColor;
  579. if (itembg === bgColor) {
  580. nodeSpan.addClass("bk-container-current")
  581. }
  582. })
  583. }
  584. } else {
  585. Dom.extra_Pop.hide();
  586. }
  587. actMuluDialog(false);
  588. actFontDialog(false);
  589. });
  590. //点击背景颜色切换
  591. Dom.bkList.on("click", function(e) {
  592. if (!$(e.target).hasClass("bk-container")) {
  593. return
  594. }
  595. bgColor = $(e.target)[0].style.backgroundColor;
  596. updateBgColor($(e.target), "bgCheck")
  597. })
  598. //更新颜色设置的选中效果
  599. var updateBgColor = function(target, type) {
  600. $(target).addClass("bk-container-current");
  601. let optDom = $(target).parent(".bk-item").siblings();
  602. $(optDom).each((i, liDom) => {
  603. $($(liDom).find(".bk-container")).removeClass("bk-container-current")
  604. })
  605. let isDark = bgColor === 'rgb(40, 53, 72)';
  606. fontColor = isDark ? "#f8f8f8" : "#000000";
  607. setHtmlStyle();
  608. Util.StorageSetter("bgColor", bgColor);
  609. //更新图标
  610. Dom.icon_extra.removeClass().addClass(
  611. `bottom-icon act ${isDark ? "dark-icon-extra" : "light-icon-extra"}`);
  612. Dom.icon_Aa.removeClass().addClass(`bottom-icon ${isDark ? "dark-icon-Aa" : "light-icon-Aa"}`);
  613. Dom.icon_mulu.removeClass().addClass(`bottom-icon ${isDark ? "dark-icon-mulu" : "light-icon-mulu"}`);
  614. }
  615. $("#btn_prev").click(function() {
  616. window.scrollTo(0, 0);
  617. readerm.prveChapter();
  618. });
  619. $("#btn_next").click(function() {
  620. window.scrollTo(0, 0);
  621. readerm.nextChapter();
  622. });
  623. }
  624. //设置文本样式
  625. function setHtmlStyle() {
  626. Dom.body.css({
  627. 'background-color': bgColor,
  628. 'color': fontColor
  629. });
  630. $(".bgStyle").css('background-color', bgColor);
  631. $(".colorStyle").css('color', fontColor);
  632. let isDark = bgColor === 'rgb(40, 53, 72)';
  633. $("#topLeftIcon").removeClass().addClass(`top_left_icon ${isDark ? "dark-icon-mulu" : "light-icon-mulu"}`);
  634. $("#nav_icon").removeClass().addClass(`nav_return nav_back_book ${isDark ? "dark-icon-navleft" : "light-icon-navleft"}`);
  635. }
  636. //整体弹窗 展示控制
  637. function actAllDialog(flag) {
  638. actLightDialog(flag);
  639. actFontDialog(flag);
  640. actMuluDialog(flag);
  641. actNavDialog(flag);
  642. actExtraDialog(flag);
  643. }
  644. //光亮设置 展示控制
  645. function actLightDialog(flag) {
  646. //展示
  647. if (flag) {
  648. return
  649. }
  650. //隐藏
  651. }
  652. //字号设置 展示控制
  653. function actFontDialog(flag) {
  654. //展示
  655. if (flag) {
  656. let iconClass = bgColor === 'rgb(40, 53, 72)' ? "dark-icon-Aa" : "light-icon-Aa";
  657. Dom.icon_Aa.addClass(iconClass);
  658. return
  659. }
  660. //隐藏
  661. Dom.font_Pop.hide();
  662. }
  663. //目录设置 展示控制
  664. function actMuluDialog(flag) {
  665. //展示
  666. if (flag) {
  667. let iconClass = bgColor === 'rgb(40, 53, 72)' ? "dark-icon-mulu" : "light-icon-mulu";
  668. Dom.icon_mulu.addClass(iconClass);
  669. return
  670. }
  671. //隐藏
  672. Dom.mulu_Box.hide();
  673. Dom.mulu_Mask.hide();
  674. Dom.mulu_Cons.hide();
  675. $('body,html').removeClass('notScroll');
  676. }
  677. //其他设置 展示控制
  678. function actExtraDialog(flag) {
  679. //展示
  680. if (flag) {
  681. return
  682. }
  683. //隐藏
  684. Dom.extra_Pop.hide();
  685. }
  686. //顶部导航+底部导航 展示控制
  687. function actNavDialog(flag) {
  688. //展示
  689. if (flag) {
  690. Dom.nav_top.show();
  691. Dom.nav_bottom.show();
  692. let isDark = bgColor === 'rgb(40, 53, 72)';
  693. Dom.icon_extra.addClass(`${isDark ? "dark-icon-extra" : "light-icon-extra"}`);
  694. Dom.icon_Aa.addClass(`${isDark ? "dark-icon-Aa" : "light-icon-Aa"}`);
  695. Dom.icon_mulu.addClass(`${isDark ? "dark-icon-mulu" : "light-icon-mulu"}`);
  696. return
  697. }
  698. //隐藏
  699. Dom.nav_top.hide();
  700. Dom.nav_bottom.hide();
  701. Dom.icon_extra.removeClass().addClass("bottom-icon");
  702. Dom.icon_Aa.removeClass().addClass("bottom-icon");
  703. Dom.icon_mulu.removeClass().addClass("bottom-icon");
  704. }
  705. //给当前选中章节高亮,去掉其他
  706. function muluUpdateActive() {
  707. $(".parentLi").each((i, liDom) => {
  708. $($(liDom).find("a")).each((i, aNode) => {
  709. if ($(aNode).data('fid') == File_id) {
  710. $(liDom).addClass("mui-active")
  711. } else {
  712. $(liDom).removeClass("mui-active")
  713. }
  714. if ($(aNode).data('cid') == Chapter_id) {
  715. $(aNode).addClass("highChapter")
  716. } else {
  717. $(aNode).removeClass("highChapter")
  718. }
  719. })
  720. })
  721. }
  722. </script>
  723. </body>
  724. </html>