From a653e92e03d765b1bdbe025430331effe21bb506 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Sun, 25 Dec 2022 10:09:19 +0200 Subject: [PATCH] Add share on clicking title --- sw.js | 2 +- view-station.js | 6 ++++++ view-train.js | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sw.js b/sw.js index f05f9d2..ee57a69 100755 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const VERSION = 'v22' +const VERSION = 'v23' const API_ORIGIN = 'https://scraper.infotren.dcdev.ro/' const API_TRAINS = `${API_ORIGIN}v3/trains` const API_STATIONS = `${API_ORIGIN}v3/stations` diff --git a/view-station.js b/view-station.js index 68ffbad..153780a 100644 --- a/view-station.js +++ b/view-station.js @@ -209,6 +209,12 @@ window.addEventListener('load', function (e) { }) }) + if (navigator.canShare && navigator.canShare({ url: '' })) { + document.getElementById('title').addEventListener('click', function () { + navigator.share({ url: '' }); + }) + } + refresh() setInterval(function () { diff --git a/view-train.js b/view-train.js index 3e2c79d..bcc7b4a 100755 --- a/view-train.js +++ b/view-train.js @@ -518,6 +518,12 @@ window.addEventListener('load', function (e) { }) }) + if (navigator.canShare && navigator.canShare({ url: '' })) { + document.getElementById('title').addEventListener('click', function () { + navigator.share({ url: '' }); + }) + } + var content = document.getElementsByClassName('content')[0] content.focus() content.addEventListener('keydown', function (e) {