make the "Enable push notifications" button link to /app on non-pwa iphone

master
Aevann 2023-06-29 22:05:24 +03:00
parent f82bdfa2ef
commit f3f01bad96
7 changed files with 26 additions and 9 deletions

View File

@ -236,8 +236,15 @@ for (const input of inputs) {
} }
if (!('serviceWorker' in navigator && 'PushManager' in window)) { if (!('serviceWorker' in navigator && 'PushManager' in window)) {
let e = document.getElementById("enable-push-nav-item").style = "display: none"; let e = document.getElementById("enable-push-nav-item");
if (e) { if (e) {
e.style = "display: none" e.classList.add('d-none')
}
}
if (gbrowser == 'iphone' && !is_pwa) {
let e = document.getElementById("enable-push-nav-item-iphone");
if (e) {
e.classList.remove('d-none')
} }
} }

View File

@ -369,14 +369,16 @@ function sort_table(t) {
} }
} }
if (window.matchMedia('(display-mode: standalone)')['matches']) { const is_pwa = window.matchMedia('(display-mode: standalone)')['matches']
if (is_pwa) {
const links = document.querySelectorAll('a[data-target="t"]'); const links = document.querySelectorAll('a[data-target="t"]');
for (const link of links) { for (const link of links) {
link.removeAttribute("target"); link.removeAttribute("target");
} }
} }
if (document.getElementById('gbrowser').value == 'apple') { const gbrowser = document.getElementById('gbrowser').value
if (gbrowser == 'iphone' || gbrowser == 'mac') {
const videos = document.querySelectorAll('video') const videos = document.querySelectorAll('video')
for (const video of videos) { for (const video of videos) {

View File

@ -1,4 +1,4 @@
if (!window.matchMedia('(display-mode: standalone)')['matches']) { if (!is_pwa) {
if (window.innerWidth <= 737) { if (window.innerWidth <= 737) {
const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt')) const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt'))
tt.show() tt.show()

View File

@ -35,8 +35,10 @@ def before_request():
g.browser = 'webview' g.browser = 'webview'
elif ' firefox/' in ua: elif ' firefox/' in ua:
g.browser = 'firefox' g.browser = 'firefox'
elif 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua: elif 'iphone' in ua or 'ipad' in ua or 'ipod' in ua:
g.browser = 'apple' g.browser = 'iphone'
elif 'mac os' in ua:
g.browser = 'mac'
else: else:
g.browser = 'chromium' g.browser = 'chromium'

View File

@ -6,6 +6,8 @@
{% if not v and g.browser == 'chromium' %} {% if not v and g.browser == 'chromium' %}
{% set type = 'chromium-lo' %} {% set type = 'chromium-lo' %}
{% elif g.browser in ('iphone','mac') %}
{% set type = 'apple' %}
{% else %} {% else %}
{% set type = g.browser %} {% set type = g.browser %}
{% endif %} {% endif %}

View File

@ -121,7 +121,7 @@
<button type="button" class="text-danger text-lg font-weight-bold ml-2 remove-files d-none" data-bs-toggle="tooltip" title="Remove Files">X</button> <button type="button" class="text-danger text-lg font-weight-bold ml-2 remove-files d-none" data-bs-toggle="tooltip" title="Remove Files">X</button>
</span> </span>
<textarea id="input-text" minlength="1" maxlength="{% if SITE == 'rdrama.net' %}200{% else %}1000{% endif %}" {% if g.browser == "apple" %}style="font-size:16px!important"{% endif %} class="file-ta form-control" placeholder="Message" autocomplete="off" autofocus rows="1"></textarea> <textarea id="input-text" minlength="1" maxlength="{% if SITE == 'rdrama.net' %}200{% else %}1000{% endif %}" {% if g.browser in ("iphone","mac") %}style="font-size:16px!important"{% endif %} class="file-ta form-control" placeholder="Message" autocomplete="off" autofocus rows="1"></textarea>
<i id="chatsend" data-nonce="{{g.nonce}}" data-onclick="send()" class="btn btn-secondary fas fa-reply ml-3 my-auto" style="transform:rotateY(180deg);font-size:1.3rem!important"></i> <i id="chatsend" data-nonce="{{g.nonce}}" data-onclick="send()" class="btn btn-secondary fas fa-reply ml-3 my-auto" style="transform:rotateY(180deg);font-size:1.3rem!important"></i>
</div> </div>

View File

@ -240,6 +240,10 @@
<input hidden id="VAPID_PUBLIC_KEY" value="{{VAPID_PUBLIC_KEY}}"> <input hidden id="VAPID_PUBLIC_KEY" value="{{VAPID_PUBLIC_KEY}}">
{% if g.browser == 'iphone' %}
<a id="enable-push-nav-item-iphone" class="dropdown-item" href="/app"><i class="fas fa-bell fa-fw mr-3 d-none"></i>Enable push notifications</a>
{% endif %}
<button id="enable-push-nav-item" type="button" class="dropdown-item" data-nonce="{{g.nonce}}" data-onclick="enablePushNotifications()"><i class="fas fa-bell fa-fw mr-3"></i>Enable push notifications</button> <button id="enable-push-nav-item" type="button" class="dropdown-item" data-nonce="{{g.nonce}}" data-onclick="enablePushNotifications()"><i class="fas fa-bell fa-fw mr-3"></i>Enable push notifications</button>
{% if g.browser != 'webview' %} {% if g.browser != 'webview' %}