123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705 |
- <html>
- <head>
- <link href="Css/sweetalert2.min.css" rel="stylesheet" />
- <style type="text/css">
- /************ init world ************/
- html, body {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 100%;
- overflow: hidden;
- }
- /************ util ************/
- .fill-parent {
- width: 100% !important;
- height: 100% !important;
- }
- .fill-parent-fixed {
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- }
- .fill-parent-zoom {
- max-width: 100%;
- max-height: 100%;
- }
- .scrollable {
- overflow: scroll;
- }
- .scrollable-v {
- overflow-y: scroll;
- }
- .raw-text {
- white-space: pre-wrap;
- }
- /************ objects ************/
- .tile-list {
- display: flex;
- flex-wrap: wrap;
- align-content: flex-start;
- }
- .tile-list .list-view-item {
- border: solid 1px gray;
- margin-right: 13px;
- margin-left: 10px;
- margin-top: 5px;
- width: 200px;
- height: 240px;
- text-align: center;
- position: relative;
- overflow: hidden;
- }
- .tile-list .list-view-icon {
- height: 100%;
- width: 100%;
- object-fit: cover;
- object-position: top;
- }
- .tile-list .list-view-label {
- display: block;
- position: absolute;
- bottom: 0;
- color: rgb(255, 255, 255);
- background-color: rgba(0, 0, 0, 0.5);
- width: 100%;
- white-space: pre-wrap;
- }
- .progressBar {
- background-color: black;
- border-radius: 13px; /* (height of inner div) / 2 + padding */
- padding: 3px;
- }
- .progressbar > div {
- background-color: orange;
- width: 1%; /* Adjust with JavaScript */
- height: 20px;
- border-radius: 10px;
- }
- /************ biz ************/
- .navRow {
- width: 100%;
- height: 10%;
- border-bottom: solid black 1px;
- }
- .navCell-left {
- float: left;
- width: 16%;
- height: 100%;
- text-align: left;
- }
- .navCell-center {
- width: 65%;
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- text-align: center;
- }
- .navCell-right {
- float: right;
- width: 19%;
- height: 100%;
- text-align: right;
- }
- .contentRow {
- width: 100%;
- height: 80%;
- margin-top: 10px;
- margin-bottom: 10px;
- overflow-y: scroll;
- }
- .contentRow::-webkit-scrollbar {
- width: 6px;
- }
- .contentRow::-webkit-scrollbar-thumb {
- border-radius: 10px;
- -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
- }
- .bottomRow {
- width: 100%;
- height: 9%;
- border-top: solid black 1px;
- }
- .bottomCell {
- width: 100%;
- height: 100%;
- }
- .main-content {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- }
- .main-content p {
- text-indent: 2em;
- font-size: 30px;
- }
- .main-content-h img {
- max-width: 100%;
- }
- .main-content-v img {
- height: 100%;
- }
- </style>
- <script type="text/javascript">
- function LnListView(containerSelector) {
- var self = this;
- var targetSelector = containerSelector;
- var itemClickedCallback = function () { };
- var dataSource = [];
- Object.defineProperty(self, "DataSource", {
- get: function () { return dataSource; },
- set: function (newValue) {
- dataSource = newValue;
- Render();
- }
- });
- Object.defineProperty(self, "ItemClicked", {
- set: function (newValue) {
- itemClickedCallback = newValue;
- }
- });
- function Render() {
- var t = $(targetSelector);
- for (var i = 0; i < dataSource.length; i++) {
- var ditem = dataSource[i];
- var licon = $('<img class="list-view-icon" />').attr("src", ditem.icon || "Images/list-item-icon.png");
- var llabel = $('<span class="list-view-label"></span>').text(ditem.text);
- var litem = $('<a class="list-view-item" href="javascript:void(0);"></a>');
- litem.append(licon);
- litem.append(llabel);
- BuildEvent(litem, ditem);
- t.append(litem);
- }
- };
- function BuildEvent(item, data) {
- item.click(function () {
- itemClickedCallback(self, data);
- });
- };
- };
- var pageFrame = {
- dummy: null
- , nativeApi: eval(LnoidNativeFunctions.GenerateFunctionStubForEval())
- , DetectInDebugging: function () {
- if (window.location.pathname.indexOf("/android_asset/") !== 0) {
- var btn = document.createElement("button");
- btn.innerHTML = "ReLoad";
- btn.onclick = function () { pageFrame.nativeApi.ReLoad(); };
- var sty = btn.style;
- sty.display = "block";
- sty.position = "fixed";
- sty.right = "10px";
- sty.bottom = "10px";
- sty.zIndex = 9999999999;
- document.body.appendChild(btn);
- }
- }
- , exitApp: function () {
- swal("正在保存设置...");
- swal.showLoading();
- var json = JSON.stringify(pageFrame.conf);
- pageFrame.nativeApi.WriteSettingAsync(function (ret) {
- if (ret.Success) {
- swal({ type: 'success', html: '已成功保存设置,正在退出' });
- swal.showLoading();
- setTimeout(function () {
- pageFrame.nativeApi.ExitApp();
- }, 1500);
- } else {
- swal("呃,保存设置出现错误……", ret.Exception.InnerException.Message, 'error');
- swal.hideLoading();
- }
- }, json);
- }
- , exitAppAsk: function () {
- swal({
- title: "真的要这样做吗?",
- text: "应用程序将会退出!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#3085d6",
- confirmButtonText: "是的,我要退出!",
- cancelButtonColor: "#d33",
- cancelButtonText: "取消"
- }).then(function () { pageFrame.exitApp(); });
- }
- , initPage: function () {
- this.nativeApi.WriteLog("_nativeApi loaded. ua:" + navigator["userAgent"]);
- this.DetectInDebugging();
- window.__backButton_Pressed = pageFrame.exitAppAsk;
- window.__menuButton_Pressed = function () {
- swal({
- title: '进入配置',
- input: 'select',
- inputOptions: {
- 'W': '排版',
- 'ZU': '界面缩放',
- 'ZC': '内容缩放'
- },
- inputPlaceholder: '请选择一项',
- showCancelButton: true
- }).then(function (result) {
- switch (result) {
- case "W":
- swal({
- title: '排版',
- input: 'select',
- inputOptions: {
- 'v': '竖排',
- 'h': '横排'
- },
- inputPlaceholder: '请选择一项',
- showCancelButton: true
- }).then(function (w) {
- pageFrame.conf.textWriteMode = w;
- });
- break;
- case "ZU":
- swal({
- title: '界面缩放',
- input: 'select',
- inputOptions: {
- '150%': '大',
- '100%': '标准',
- '75%': '小'
- },
- inputPlaceholder: '请选择一项',
- showCancelButton: true
- }).then(function (z) {
- document.getElementsByTagName("html")[0].style.zoom =
- pageFrame.conf.uiZoom = z;
- });
- break;
- default:
- swal({ type: 'success', html: 'You selected: ' + result + ' but not impl!' });
- break;
- }
- });
- }
- var ret = pageFrame.nativeApi.ReadSetting();
- if (ret.Success) {
- if (ret.Result) pageFrame.conf = JSON.parse(ret.Result);
- if (!pageFrame.conf) pageFrame.conf = { textWriteMode: "v" };
- document.getElementsByTagName("html")[0].style.zoom =
- pageFrame.conf.uiZoom = pageFrame.conf.uiZoom || "100%";
- pageFrame.showMenu();
- } else {
- swal('呃,读取设置出现错误……', ret.Exception.InnerException.Message, 'error');
- }
- }
- , showPathSetting: function (cb) {
- var storages = {};
- var result = pageFrame.nativeApi.GetDirs("/storage", true);
- if (result.Success) {
- var items = result.Result;
- for (var i = 0; i < items.length; i++) {
- var item = items[i];
- if (item === "/storage/emulated") continue;
- if (item === "/storage/self") continue;
- storages[item + "/LnO"] = "外部存储(" + item.substr(item.lastIndexOf("/") + 1) + ")";
- }
- }
- storages['/sdcard/LnO'] = '内部存储';
- swal({
- title: '选择数据所在存储器',
- input: 'select',
- showCancelButton: true,
- inputPlaceholder: '选择Lno目录所在存储器',
- inputOptions: storages,
- inputValidator: function (value) {
- return new Promise(function (resolve, reject) {
- var ret = pageFrame.nativeApi.PathExist(value);
- if (!ret.Success) reject(ret.Exception.InnerException.Message);
- else if (!ret.Result) reject("路径不存在");
- else resolve(value);
- });
- }
- }).then(function (result) {
- pageFrame.conf.dataPath = result;
- if (cb) cb();
- }, function () { pageFrame.exitAppAsk() });
- }
- , showMenu: function () {
- if (!pageFrame.conf.dataPath) {
- pageFrame.showPathSetting(pageFrame.loadPrefixList);
- } else {
- //TO DO: continue read | favs | new read
- pageFrame.loadPrefixList();
- }
- }
- , showLoadingProgressBar: function (title) {
- swal({ title: title || "正在读取数据", html: '<div id="progressBar" class="progressBar"><div></div></div>', allowOutsideClick: false });
- swal.showLoading();
- }
- , updateLoadingProgressBar: function (cent) {
- $("#progressBar>div").css("width", (cent * 100) + "%");
- }
- , loadPrefixList: function () {
- window.__backButton_Pressed = pageFrame.exitAppAsk;
- pageFrame.showLoadingProgressBar();
- pageFrame.nativeApi.GetPrefixesAsync(
- function (ret) {
- if (!ret.Success) {
- //TODO: Show Correct ERROR info
- swal('呃,读取数据出现错误……', ret.Exception.InnerException.Message, 'error');
- swal.hideLoading();
- } else {
- swal.close();
- $(".navCell-center").text("首字母列表\r\n(共 " + ret.Result.length + " 项)");
- var container = $('<div id="lvPrefix" class="tile-list fill-parent"></div>');
- $(".contentCell").html("").append(container);
- var lv = new LnListView("#lvPrefix");
- lv.DataSource = Enumerable.From(ret.Result).Select(function (p) {
- return {
- dummy: null
- , icon: "Images/prefix.png"
- , prefix: p.Prefix
- , text: p.Prefix + "\r\n(共 " + p.SeriesCount + " 项)"
- , value: p.Path
- };
- }).ToArray();
- lv.ItemClicked = function (sender, e) {
- //TODO: Save/Restore Scroll position
- pageFrame.loadSeriesList(e);
- }
- }
- }
- , pageFrame.conf.dataPath
- , function (progress) {
- pageFrame.updateLoadingProgressBar(progress.Current / progress.Total);
- }
- );
- }
- , loadSeriesList: function (dataItem) {
- window.__backButton_Pressed = pageFrame.loadPrefixList;
- pageFrame.showLoadingProgressBar();
- pageFrame.nativeApi.GetSeriesAsync(
- function (ret) {
- if (!ret.Success) {
- swal('呃,读取数据出现错误……', ret.Exception.InnerException.Message, 'error');
- swal.hideLoading();
- } else {
- swal.close();
- $(".navCell-center").text("首字母:" + dataItem.text);
- var container = $('<div id="lvSeries" class="tile-list fill-parent"></div>');
- $(".contentCell").html("").append(container);
- var lv = new LnListView("#lvSeries");
- lv.DataSource = Enumerable.From(ret.Result).Select(function (p) {
- return {
- dummy: null,
- icon: p.CoverData,
- text: p.SeriesName + "\r\n(共 " + p.VolumeCount + " 卷)",
- value: p.Path
- };
- }).ToArray();
- lv.ItemClicked = function (sender, e) {
- e.__parentItem = dataItem;
- pageFrame.loadVolumeList(e);
- }
- }
- },
- dataItem.value
- , function (progress) {
- pageFrame.updateLoadingProgressBar(progress.Current / progress.Total);
- }
- );
- }
- , loadVolumeList: function (dataItem) {
- window.__backButton_Pressed = function () { pageFrame.loadSeriesList(dataItem.__parentItem); };
- pageFrame.showLoadingProgressBar();
- pageFrame.nativeApi.GetVolumesAsync(
- function (ret) {
- if (!ret.Success) {
- swal('呃,读取数据出现错误……', ret.Exception.InnerException.Message, 'error');
- swal.hideLoading();
- } else {
- swal.close();
- $(".navCell-center").text(dataItem.text);
- var container = $('<div id="lvVolumes" class="tile-list fill-parent"></div>');
- $(".contentCell").html("").append(container);
- var lv = new LnListView("#lvVolumes");
- lv.DataSource = Enumerable.From(ret.Result).Select(function (p) {
- return {
- dummy: null
- , icon: p.CoverData
- , text: p.VolumeName
- , value: p.Path
- };
- }).ToArray();
- lv.ItemClicked = function (sender, e) {
- e.__parentItem = dataItem;
- pageFrame.loadChapterList(e, dataItem);
- }
- }
- }
- , dataItem.value
- , function (progress) {
- pageFrame.updateLoadingProgressBar(progress.Current / progress.Total);
- }
- );
- }
- , loadChapterList: function (dataItem) {
- window.__backButton_Pressed = function () { pageFrame.loadVolumeList(dataItem.__parentItem); };
- pageFrame.showLoadingProgressBar();
- pageFrame.nativeApi.GetChaptersAsync(
- function (ret) {
- if (!ret.Success) {
- swal('呃,读取数据出现错误……', ret.Exception.InnerException.Message, 'error');
- swal.hideLoading();
- } else {
- swal.close();
- $(".navCell-center").text(dataItem.text + "\r\n(共 " + ret.Result.length + " 章节)");
- var container = $('<div id="lvVolumes" class="tile-list fill-parent"></div>');
- $(".contentCell").html("").append(container);
- var lv = new LnListView("#lvVolumes");
- lv.DataSource = Enumerable.From(ret.Result).Select(function (p) {
- return {
- dummy: null
- , icon: p.FirstPicture
- , text: p.ChapterName
- , value: p.Path
- };
- }).ToArray();
- lv.ItemClicked = function (sender, e) {
- e.__parentItem = dataItem;
- pageFrame.loadContent(e);
- }
- }
- }
- , dataItem.value
- , function (progress) {
- pageFrame.updateLoadingProgressBar(progress.Current / progress.Total);
- }
- );
- }
- , handleText: function (t) {
- if (pageFrame.conf.textWriteMode == "v") {
- var arrProcessed = [];
- var code;
- for (var i = 0; i < t.length; i++) {
- code = t.charCodeAt(i);
- if (code > 32 && code < 127) {
- code += 0xFEE0;
- }
- arrProcessed.push(code);
- }
- t = String.fromCharCode.apply(window, arrProcessed);
- t = t.split("“").join("『");
- t = t.split("”").join("』");
- t = t.split("(").join("(");
- t = t.split(")").join(")");
- t = t.split("》").join(">>");
- t = t.split("《").join("<<");
- }
- return t;
- }
- , loadContent: function (dataItem) {
- var container;
- window.__backButton_Pressed = function () {
- $("#uiContainer").show();
- $(container).remove();
- window.__backButton_Pressed = function () { pageFrame.loadVolumeList(dataItem.__parentItem.__parentItem); }
- };
- pageFrame.showLoadingProgressBar();
- pageFrame.nativeApi.GetChapterContentAsync(
- function (ret) {
- if (!ret.Success) {
- swal('呃,读取数据出现错误……', ret.Exception.InnerException.Message, 'error');
- swal.hideLoading();
- } else {
- swal.close();
- container = $('<div class="main-content"></div>');
- container.addClass("main-content-" + (pageFrame.conf.textWriteMode || ""));
- var contentArray = Enumerable.From(ret.Result).Select(function (p) {
- return p.indexOf("<") !== 0
- ? $("<p></p>").html(pageFrame.handleText(p))
- : $(p);
- }).ToArray();
- var contentWrapper = $('<div></div>');
- contentWrapper.append(contentArray);
- container.append(contentWrapper);
- $("#uiContainer").hide();
- $(document.body).append(container);
- var elContainer = container[0];
- var elContentWrapper = contentWrapper[0];
- if (pageFrame.conf.textWriteMode == "v") {
- elContentWrapper.style.height = elContainer.clientHeight;
- elContentWrapper.style.webkitWritingMode = "vertical-rl";
- var myScroll = new iScroll(elContainer, { hScrollbar: true, vScrollbar: false });
- myScroll.scrollTo(-elContentWrapper.clientWidth, 0);
- } else {
- var myScroll = new iScroll(elContainer, { hScrollbar: false, vScrollbar: true });
- myScroll.scrollTo(0, 200);
- }
- }
- }
- , dataItem.value
- , function (progress) {
- pageFrame.updateLoadingProgressBar(progress.Current / progress.Total);
- }
- );
- }
- , showDownloads: function () {
- var url7ZAll = "magnet:?xt=urn:btih:f7fbc1ea18c9a3a96bfa116b772e85b75f393800";
- var urlZipByPrefix = "magnet:?xt=urn:btih:ed4feb60314b0638c263a20f346cbf888030085e";
- swal({
- title: '获取数据文件',
- input: 'radio',
- inputOptions: {
- "7z": "7z分卷完整"
- , "Zip": "Zip分卷按首字母"
- , "Help": "数据文件使用方法"
- }, inputValidator: function (result) {
- return new Promise(function (resolve, reject) {
- if (result) {
- resolve();
- } else {
- reject('请选择一项!');
- }
- });
- }
- }).then(function (result) {
- if (result === "Help") swal({ title: "数据文件使用方法", text: "请在手机存储或SD卡创建目录「LnO」区分大小写(大小大),然后将下载后的压缩包解压进去,确保里面有单个字母的文件夹。" });
- var brac = {
- "7z": { title: "7z分卷完整", text: url7ZAll, confirmButtonText: "复制" }
- , "Zip": { title: "Zip分卷按首字母", text: urlZipByPrefix, confirmButtonText: "复制" }
- };
- swal(brac[result]).then(function () {
- pageFrame.nativeApi.CopyText(brac[result].text);
- });
- });
- }
- };
- //-----------------------
- </script>
- </head>
- <body onload="pageFrame.initPage();">
- <div id="uiContainer">
- <div class="navRow">
- <div class="navCell-left">
- <a href="javascript:void(0); " onclick="window.__backButton_Pressed();">
- <img class="fill-parent-zoom" src="Images/back.png" />
- </a>
- </div>
- <div class="navCell-right">
- <a href="javascript:void(0); " onclick="window.__menuButton_Pressed();">
- <img class="fill-parent-zoom" src="Images/menu.png" />
- </a>
- </div>
- <div class="navCell-center raw-text">
- 主菜单
- </div>
- </div>
- <div class="contentRow">
- <div class="contentCell">
- </div>
- </div>
- <div class="bottomRow">
- <div class="bottomCell">
- 一个蛋疼的人做的蛋疼应用。。。
- <input type="button" value="获取数据文件" onclick="pageFrame.showDownloads();" />
- </div>
- </div>
- </div>
- <script src="Scripts/jquery-2.2.0.js"></script>
- <script src="Scripts/sweetalert2.min.js"></script>
- <script src="Scripts/linq.min.js"></script>
- <script src="Scripts/iscroll.js"></script>
- </body>
- </html>
|