aboutsummaryrefslogtreecommitdiffstats
path: root/hesla.ts
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-01-07 19:20:21 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-01-15 15:22:41 +0100
commit8b859019a61484a31aa3d3cde96f9fe85b3c95af (patch)
tree65ca4d36924e467a45423c2aa45355de90c8ad2d /hesla.ts
parent843b6baebc3a49fef9895b60f85b393776b2d8ab (diff)
downloadhesla-8b859019a61484a31aa3d3cde96f9fe85b3c95af.tar.gz
Use read.andbible.org URLs for displaying Bible verses in AndBible.
Partially fixes: gb#52572e2 (aka https://todo.sr.ht/~mcepl/devel/22)
Diffstat (limited to 'hesla.ts')
-rw-r--r--hesla.ts21
1 files changed, 18 insertions, 3 deletions
diff --git a/hesla.ts b/hesla.ts
index 473f194..f7b8711 100644
--- a/hesla.ts
+++ b/hesla.ts
@@ -1,3 +1,5 @@
+/// <reference lib="dom" />
+
import {ActivePage} from "./activePage.js";
function toISODateString(date) {
@@ -97,9 +99,22 @@ export class Hesla extends ActivePage {
super.display();
console.log("cur_watchword = " + toISODateString(this.cur_watchword));
- document.getElementById(toISODateString(this.cur_watchword)).
- classList.add("visible");
-
+ var disp_watchword = document.getElementById(toISODateString(this.cur_watchword));
+ disp_watchword.classList.add("visible");
+
+ // Complete mobile device identification /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/
+ if (/Android/i.test(navigator.userAgent)) {
+ // true for mobile device
+ var href_attr = "";
+ Array.prototype.forEach.call(disp_watchword.getElementsByTagName("a"), a_elem => {
+ href_attr = a_elem.getAttribute("href");
+ console.log("before replacement: href_attr = " + href_attr);
+ href_attr = href_attr.replace(/http:\/\/www\.crosswire\.org\/study\/passagestudy\.jsp\?key=([^&]+)&mod=([a-zA-Z]+)/,
+ "https://read.andbible.org/$1?v11n=$2");
+ console.log("after replacement: href_attr = " + href_attr);
+ a_elem.setAttribute("href", href_attr);
+ });
+ }
window.scroll(0, 0);
}