Compare commits
3 Commits
64f0da662b
...
2cdb601706
Author | SHA1 | Date | |
---|---|---|---|
2cdb601706 | |||
e84441e7f1 | |||
7ad67a80f5 |
@ -1,5 +1,5 @@
|
|||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "1.3.52"
|
current_version = "1.3.53"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
tag_name = "{new_version}"
|
tag_name = "{new_version}"
|
||||||
|
@ -49,18 +49,35 @@
|
|||||||
<p>Version: <a href="#" id="version-link">{{ version }}</a></p>
|
<p>Version: <a href="#" id="version-link">{{ version }}</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<input type="hidden" id="is-logged-in" value="{{ 'true' if session.get('logged_in') else 'false' }}">
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
<script>
|
<script>
|
||||||
if ('serviceWorker' in navigator && 'PushManager' in window) {
|
if ('serviceWorker' in navigator && 'PushManager' in window) {
|
||||||
|
const isLoggedIn = document.getElementById('is-logged-in').value === 'true';
|
||||||
navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}').then(function(registration) {
|
navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}').then(function(registration) {
|
||||||
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
||||||
// Check for the 'loggedin' query parameter to trigger the prompt
|
const enableNotificationsBtn = document.getElementById('enable-notifications-btn');
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
if (urlParams.has('loggedin')) {
|
function setupNotificationButton() {
|
||||||
askPermission(registration);
|
registration.pushManager.getSubscription().then(function(subscription) {
|
||||||
|
if (enableNotificationsBtn) {
|
||||||
|
if (subscription) {
|
||||||
|
enableNotificationsBtn.style.display = 'none';
|
||||||
|
} else {
|
||||||
|
enableNotificationsBtn.style.display = 'block';
|
||||||
|
enableNotificationsBtn.addEventListener('click', function() {
|
||||||
|
askPermission(registration);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enableNotificationsBtn) {
|
||||||
|
setupNotificationButton();
|
||||||
}
|
}
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
console.log('ServiceWorker registration failed: ', err);
|
console.log('ServiceWorker registration failed: ', err);
|
||||||
@ -141,6 +158,10 @@
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log('Subscription saved successfully.');
|
console.log('Subscription saved successfully.');
|
||||||
|
const enableNotificationsBtn = document.getElementById('enable-notifications-btn');
|
||||||
|
if (enableNotificationsBtn) {
|
||||||
|
enableNotificationsBtn.style.display = 'none';
|
||||||
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to save subscription. Status:', response.status);
|
console.error('Failed to save subscription. Status:', response.status);
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Welcome {{ username }}!</h1>
|
<h1>Welcome {{ username }}!</h1>
|
||||||
<br>
|
<br>
|
||||||
|
<button id="enable-notifications-btn" class="btn btn-primary">Enable Notifications</button>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
<h2>You have {{ accounts }} active accounts</h2>
|
<h2>You have {{ accounts }} active accounts</h2>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user