diff --git a/application/assets/css/main.css b/application/assets/css/main.css index 31b61fd..c95fe41 100644 --- a/application/assets/css/main.css +++ b/application/assets/css/main.css @@ -61,6 +61,27 @@ kbd { margin: 0 0 5px 0; } +kbd.title { + background: rgba(113, 86, 187, 0.4); +} + +#intro-icon { + font-size: 1rem; + position: absolute; + left: 30%; + top: 40%; + border: 3px solid white; + box-shadow: 5px 5px white; + color: white; + line-height: 1.85em; + display: inline-block; + font-weight: 600; + letter-spacing: 0.05em; + padding: 3px 5px; + white-space: nowrap; + margin: 0 0 5px 0; +} + input { font-family: "Lato-Regular"; } @@ -401,7 +422,6 @@ main { main div { height: 90vh; - max-height: 90vh; overflow: hidden !important; position: relative; diff --git a/application/assets/icons/icon-112-112-png b/application/assets/icons/icon-112-112-png new file mode 100644 index 0000000..3301ddd Binary files /dev/null and b/application/assets/icons/icon-112-112-png differ diff --git a/application/assets/icons/icon-112-112.png b/application/assets/icons/icon-112-112.png deleted file mode 100644 index 79b422c..0000000 Binary files a/application/assets/icons/icon-112-112.png and /dev/null differ diff --git a/application/assets/icons/icon-112-112.svg b/application/assets/icons/icon-112-112.svg index 0526b23..11d2f1c 100644 --- a/application/assets/icons/icon-112-112.svg +++ b/application/assets/icons/icon-112-112.svg @@ -1,15 +1,37 @@ + width="112" + sodipodi:docname="icon-112-112.svg" + inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + image/svg+xml - diff --git a/application/assets/icons/icon-56-56-png b/application/assets/icons/icon-56-56-png new file mode 100644 index 0000000..99b0f80 Binary files /dev/null and b/application/assets/icons/icon-56-56-png differ diff --git a/application/assets/icons/icon-56-56.png b/application/assets/icons/icon-56-56.png deleted file mode 100644 index 4a1116d..0000000 Binary files a/application/assets/icons/icon-56-56.png and /dev/null differ diff --git a/application/assets/icons/icon-56-56.svg b/application/assets/icons/icon-56-56.svg index 75759fa..1b7bacf 100644 --- a/application/assets/icons/icon-56-56.svg +++ b/application/assets/icons/icon-56-56.svg @@ -1,15 +1,37 @@ + width="56" + sodipodi:docname="icon-56-56.svg" + inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + image/svg+xml - - - - + transform="matrix(0.52655141,0,0,0.52655141,-0.39340348,141.00763)" + id="layer1-3"> + + + + + + + diff --git a/application/assets/js/helper.js b/application/assets/js/helper.js index 384f424..6151b59 100644 --- a/application/assets/js/helper.js +++ b/application/assets/js/helper.js @@ -7,8 +7,8 @@ const helper = (() => { js.onload = function () { getKaiAd({ publisher: "4408b6fa-4e1d-438f-af4d-f3be2fa97208", - app: "parrot", - slot: "parrot", + app: "passport", + slot: "passport", test: 0, timeout: 10000, h: 120, @@ -157,7 +157,7 @@ const helper = (() => { }; //delete file - let deleteFile = function (filename) { + let deleteFile = function (filename, callback) { let sdcard = ""; try { @@ -174,13 +174,13 @@ const helper = (() => { requestDel.onsuccess = function () { helper.side_toaster("File successfully deleted", 2000); - - document.querySelector("[data-path='" + filename + "']").remove(); + callback(filename); }; requestDel.onerror = function () { console.log("error"); helper.toaster("Unable to delete the file: " + this.error); + general.blocker = false; }; }; @@ -303,15 +303,18 @@ const helper = (() => { request_del.onerror = function () { // success copy not delete helper.side_toaster("Unable to write the file", 3000); + general.blocker = false; }; }; requestAdd.onerror = function () { helper.side_toaster("Unable to write the file", 3000); + general.blocker = false; }; }; request.onerror = function () { helper.side_toaster("Unable to write the file", 3000); + general.blocker = false; }; }; diff --git a/application/assets/js/mozactivity.js b/application/assets/js/mozactivity.js index 534dacd..3aa8fc7 100644 --- a/application/assets/js/mozactivity.js +++ b/application/assets/js/mozactivity.js @@ -126,12 +126,12 @@ const mozactivity = (() => { }); pick.onsuccess = function (e) { - console.log("hey" + pick.result.blob); callback(pick); }; pick.onerror = function () { - alert("The activity encounter en error: " + this.error); + general.blocker = false; + console.log("The activity encounter en error: " + this.error); }; } catch (e) { console.log(e); @@ -147,10 +147,15 @@ const mozactivity = (() => { pick.start().then( (rv) => { + general.blocker = false; + callback(pick); + console.log("Results passed back from activity handler:"); console.log(rv); }, (err) => { + general.blocker = false; + console.log(err); } ); diff --git a/application/index.js b/application/index.js index f330bf8..289a335 100644 --- a/application/index.js +++ b/application/index.js @@ -55,8 +55,6 @@ let nav = function (move) { let targetElement = 0; - console.log(next); - if (next <= items.length) { targetElement = items[next]; targetElement.focus(); @@ -114,12 +112,8 @@ try { }); } catch (e) {} -let go_s = () => { -m.route.set("/start"); -} - -//list dic -let read_files = () => { +//list files +let read_files = (callback) => { files = []; try { var d = navigator.getDeviceStorage("sdcard"); @@ -129,6 +123,7 @@ let read_files = () => { cursor.onsuccess = function () { if (!this.result) { m.route.set("/start"); + callback(); } if (cursor.result.name !== null) { let file = cursor.result; @@ -207,7 +202,7 @@ let read_files = () => { read_files(); let load_qrcode_content = (filepath) => { -console.log(filepath); + console.log(filepath); let sdcard = ""; try { @@ -431,6 +426,8 @@ document.addEventListener("DOMContentLoaded", function () { //VIEWS var start = { view: function () { + p = m.route.param("focus") || ""; + console.log("focus:" + p); return m("div", [ m( "div", @@ -450,15 +447,13 @@ document.addEventListener("DOMContentLoaded", function () { } }, }, - [m("img", { src: "assets/icons/icon-112-112.png" })] + [m("kbd", { id: "intro-icon" }, "passport")] ), m( "ul", { id: "files-list", - oninit: () => { - p = m.route.param("focus") || ""; - }, + oninit: () => {}, oncreate: ({ dom }) => { setTimeout(() => { if (files.length == 0) { @@ -500,6 +495,8 @@ document.addEventListener("DOMContentLoaded", function () { setTimeout(() => { dom.focus(); scroll_into_center(); + document.querySelector("#no-file").style.display = + "none"; }, 400); } if (i == 1 && p == "") { @@ -531,42 +528,28 @@ document.addEventListener("DOMContentLoaded", function () { }, }, - [ - m( - "kbd", - { - class: "item test", - oncreate: ({ dom }) => { - set_tabindex(); - }, - }, - "Passport" - ), - - m("div", { - id: "text", - oncreate: ({ dom }) => { - m.render( - dom, - m.trust( - "The app is a file viewer for JPG, PNG and PDF files. It should help you display your QR code tickets more quickly during checks.The files must be stored in the directory /passport so that they can be displayed.

Credits: Mithril.js, PDF.js
License: MIT

" - ) - ); - }, - }), - m( - "kbd", - { - class: "item", - oncreate: () => { - document.querySelector(".item").focus(); - }, - }, - "KaiOs Ads" - ), - - m("div", { id: "KaiOsAds-Wrapper", class: "item" }), - ] + m("div", { + id: "text", + oncreate: ({ dom }) => { + m.render( + dom, + m.trust( + "" + + "Passport
" + + "The app is a file viewer for JPG, PNG, and PDF files. It should help you display your QR code tickets more quickly during checks. The files must be stored in the directory /passport so that they can be displayed.

" + + "" + + "" + + "Good to know
With key 2, you can rename or delete files

" + + "Credits
Mithril.js, PDF.js

" + + "" + + "License
MIT

" + + "" + + "KaiOS Ads
" + + "
" + ) + ); + }, + }) ); }, }; @@ -657,18 +640,60 @@ document.addEventListener("DOMContentLoaded", function () { m.route.prefix = "#"; let pickGalllery_callback = (e) => { + general.blocker = false; + let fileName = e.result.blob.name.split("/"); fileName = fileName[fileName.length - 1]; write_file(e.result.blob, "passport/" + fileName); + m.route.set("/start?focus=" + filename); }; let renameFile_callback = (filename) => { - read_files(); + general.blocker = false; + let cb = () => { + m.route.set("/start?focus=+/sdcard/passport/" + filename); + }; + + read_files(cb); + }; - setTimeout(() => { - document.querySelector("[data-filepath='" + filename + "']").focus(); - }, 2000); + let deleteFile_callback = (filename) => { + general.blocker = false; + + let cb = () => { + if (files.length == 0) { + console.log("why"); + + setTimeout(() => { + m.route.set("/start"); + }, 1000); + } else { + let currentFileElement = document.querySelector( + "[data-path='" + filename + "']" + ); + + // Get the tabindex attribute value and convert it to a number + let tabindex = currentFileElement.getAttribute("tabindex"); + tabindex = Number(tabindex) - 1; + tabindex_next = tabindex + 2; + + // Find the next element with the adjusted tabindex and set focus + let nextElement = document.querySelector( + "[tabindex='" + tabindex + "']" + ); + + if (nextElement) { + nextElement.focus(); + } else { + nextElement = document.querySelector( + "[tabindex='" + tabindex_next + "']" + ); + nextElement.focus(); + } + } + }; + read_files(cb); }; ////////////////////////////// @@ -820,10 +845,15 @@ document.addEventListener("DOMContentLoaded", function () { if (m.route.get().includes("/start")) { if (general.fileAction) { let filePath = document.activeElement.getAttribute("data-path"); - helper.deleteFile(filePath); + helper.deleteFile(filePath, deleteFile_callback); break; } - if (general.importAction) { + if ( + m.route.get().includes("/start") && + general.importAction && + general.blocker == false + ) { + general.blocker = true; mozactivity.pickGallery(pickGalllery_callback); break; } @@ -842,12 +872,17 @@ document.addEventListener("DOMContentLoaded", function () { } } - if (m.route.get().includes("/start") && general.importAction) { + if ( + m.route.get().includes("/start") && + general.importAction && + general.blocker == false + ) { m.route.set("/scan"); general.importAction = false; } else { selected_image = document.activeElement.getAttribute("data-file"); selected_image_url = document.activeElement.getAttribute("data-path"); + if (!selected_image) return false; if (document.activeElement.getAttribute("data-type") == "pdf") { m.route.set("/show_pdf"); diff --git a/application/manifest.webapp b/application/manifest.webapp index 3ef336f..e02eedf 100644 --- a/application/manifest.webapp +++ b/application/manifest.webapp @@ -1,5 +1,5 @@ { - "version": "1.1.93", + "version": "1.2.0", "name": "passport", "description": "At times it is practically fast to access digital train airplane qrcode tickets to showcase at a check-in. I wrote an app for that. All images in the folder passport are listed.", "launch_path": "/index.html", diff --git a/application/manifest.webmanifest b/application/manifest.webmanifest index 378205e..8c04721 100644 --- a/application/manifest.webmanifest +++ b/application/manifest.webmanifest @@ -22,7 +22,7 @@ ], "b2g_features": { - "version": "0.0.712", + "version": "0.0.718", "id": "parrot", "core": true, "categories": ["utilities"],