remotes/1693045480750635534/spooky-22
Aevann1 2022-04-07 03:18:46 +02:00
parent 6993d28e18
commit 2dc99c8d18
3 changed files with 38 additions and 1 deletions

View File

@ -106,6 +106,8 @@ def before_request():
if 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua or ' firefox/' in ua: g.inferior_browser = True
else: g.inferior_browser = False
g.timestamp = int(time.time())
@app.teardown_appcontext
def teardown_request(error):

View File

@ -425,4 +425,11 @@ def settings_security(v):
@app.get("/.well-known/assetlinks.json")
def googleplayapp():
with open("files/assets/assetlinks.json", "r") as f:
return Response(f.read(), mimetype='application/json')
return Response(f.read(), mimetype='application/json')
@app.post("/dismiss_mobile_tip")
def dismiss_mobile_tip():
session["tooltip_last_dismissed"] = int(time.time())
return "", 204

View File

@ -260,4 +260,32 @@
</script>
{% endif %}
{% if request.path == '/' and g.timestamp > session.get('tooltip_last_dismissed',0)+60*60*24*30 and not g.webview %}
<div id="mobile-prompt-container" class="fixed-top">
<div id="mobile-prompt" href="javascript:void(0)" data-bs-toggle="tooltip" data-bs-container="#mobile-prompt-container" data-bs-placement="top" data-bs-trigger="click" data-bs-original-title="Install the {{SITE_NAME}} webapp by saving this page to your home screen!"></div>
</div>
<script>
if (!("standalone" in window.navigator) && !(window.navigator.standalone)) {
if (window.innerWidth <= 737) {
const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt'))
tt.show()
document.getElementsByClassName('tooltip')[0].onclick = function(event){
tt.hide()
var xhr = new XMLHttpRequest();
xhr.withCredentials=true;
xhr.open("POST", '/dismiss_mobile_tip', true);
xhr.send();
}
}
}
</script>
<style>
#mobile-prompt + .bs-tooltip-bottom {
transform: translate3d(98%, 0px, 0px) !important
}
</style>
{% endif %}
{% endblock %}