Compare commits

...

50 Commits

Author SHA1 Message Date
ostertun
13ceef37d9 Merge branch 'hotfix/regattas_range' 2020-10-05 14:49:24 +02:00
ostertun
8808d12bf1 gitflow-hotfix-stash: regattas_range 2020-10-05 14:49:00 +02:00
ostertun
c6d5450b0e Merge branch 'hotfix/fix_db_sync_log' 2020-10-05 14:35:22 +02:00
ostertun
cb8a1817ae gitflow-hotfix-stash: fix_db_sync_log 2020-10-05 14:34:56 +02:00
ostertun
acf51ea71c Merge branch 'release/v_1.9' 2020-10-05 13:59:22 +02:00
ostertun
65608cdd5a Release v_1.9 2020-10-05 13:58:26 +02:00
ostertun
d0996fa0c3 Merge branch 'feature/RA-22-add-sites' into develop 2020-10-05 13:57:09 +02:00
ostertun
c9a90eb77c RA-#22 Show info on preloader while first sync 2020-10-05 13:56:47 +02:00
ostertun
754cb6f77d Added edit button to planning 2020-10-05 13:37:31 +02:00
ostertun
5e926f3e75 Add share button on own planning 2020-10-05 13:09:24 +02:00
ostertun
138071769c Added planning_list 2020-10-05 12:57:17 +02:00
ostertun
26d9d83ba2 Added planning_view 2020-10-05 12:26:33 +02:00
ostertun
eaa08ba301 Custom log function => log current time 2020-10-05 11:53:54 +02:00
ostertun
760c05286e RA-#22 Added planning incl setState 2020-10-02 19:26:03 +02:00
ostertun
3f676141d7 Merge branch 'feature/RA-13-dont-show-install-request-window-w' into develop 2020-10-02 17:42:39 +02:00
ostertun
ae9bf02c49 RA-#13 Dont show install promt when welcome banner active 2020-10-02 17:42:33 +02:00
ostertun
c2a482bba1 Fix RA-#10 background color of mobileConsole 2020-10-02 17:19:59 +02:00
ostertun
06266b788d Merge branch 'feature/RA-21-news-mark-unread-news-and-add-pagi' into develop 2020-10-02 14:24:11 +02:00
ostertun
3db5ae1723 RA-#21 News: mark unread and add pagination 2020-10-02 14:24:00 +02:00
ostertun
a45af73c25 Merge branch 'release/v_1.8' 2020-10-02 01:29:43 +02:00
ostertun
b784733b69 Merge branch 'release/v_1.8' into develop 2020-10-02 01:29:43 +02:00
ostertun
f30eac8aa5 Release v_1.8 2020-10-02 01:27:31 +02:00
ostertun
99b624ff92 Merge branch 'feature/RA-4-notifications-ignore-my-regattas' into develop 2020-10-02 01:24:16 +02:00
ostertun
e74ffa9a70 Merge branch 'feature/RA-19-update-url-on-year-change' into develop 2020-10-02 01:24:11 +02:00
ostertun
cbb398988d Merge branch 'feature/RA-20-update-news-badge' into develop 2020-10-02 01:24:00 +02:00
ostertun
856f6c1d66 RA-#20 Update news badge 2020-10-02 01:23:46 +02:00
ostertun
2ea26408be RA-#3 Trigger inputs after programmatically changed 2020-10-02 00:59:34 +02:00
ostertun
fb1ca6d28e RA-#19 Update URL on year change 2020-10-02 00:49:53 +02:00
ostertun
6a5d06325d RA-#4 Notifications: can select "my regattas" channels only when logged in 2020-10-02 00:13:58 +02:00
ostertun
72ac8df460 Merge branch 'feature/dev_buttons' into develop 2020-10-01 23:36:05 +02:00
ostertun
246231fd0e RA-#8 Fix deleteCache 2020-10-01 23:35:49 +02:00
ostertun
3e533f65fc Added show-console-button to preloader 2020-10-01 23:26:22 +02:00
ostertun
2533c3d66a RA-#16 Updated Dev Buttons 2020-10-01 23:25:48 +02:00
ostertun
cacee5a54a RA-#17 Fix padding of body 2020-10-01 22:46:53 +02:00
ostertun
274aa85cf7 Merge branch 'release/v_1.7' 2020-10-01 03:21:20 +02:00
ostertun
4317e4fe87 Release v_1.7
Prepare github repo
small fixes
2020-10-01 03:19:42 +02:00
Timon Ostertun
b7dec825ca Update issue templates 2020-10-01 03:00:38 +02:00
Timon Ostertun
6ca6a79dc3 Update issue templates 2020-10-01 02:59:12 +02:00
Timon Ostertun
d1e5d753b4 Create README.md 2020-10-01 01:03:41 +02:00
Timon Ostertun
7afacc3fff Update issue templates 2020-09-30 23:56:51 +02:00
Timon Ostertun
77ea57d643 RA-#1 Notifications: Badge Icon 2020-09-30 23:24:24 +02:00
Timon Ostertun
a72c462483 RA-#4 Registration open icon is red when deadline expired 2020-09-30 22:46:20 +02:00
Timon Ostertun
b739e6cc4e RA-#7 Fix serviceWorker 2020-09-30 22:45:43 +02:00
Timon Ostertun
eb47cdf016 RA-#7 Removed unnecessary files from cache 2020-09-30 22:25:59 +02:00
Timon Ostertun
12c1a614bb Fix #5 serviceWorker DB access
serviceWorker openes DB only when needed and closes it directly
2020-09-30 16:46:10 +02:00
Timon Ostertun
0fb1bb0462 Added mobile console 2020-09-30 14:36:07 +02:00
Timon Ostertun
1b1176b952 Release v_1.6 2020-09-27 23:18:37 +02:00
Timon Ostertun
00c1c93b80 Added news 2020-09-27 23:17:56 +02:00
Timon Ostertun
876776eb5b Added notifications 2020-09-27 21:54:43 +02:00
Timon Ostertun
a92dc45bb7 Can subscribe to pushes 2020-09-27 14:35:25 +02:00
35 changed files with 4014 additions and 717 deletions

View File

@@ -0,0 +1,20 @@
---
name: "[DE] Feature-Anfrage"
about: Schlage eine Idee für dieses Projekt vor
title: ''
labels: enhancement
assignees: ''
---
**Bezieht sich Deine Feature-Anfrage auf ein Problem? Bitte beschreiben.**
Eine klare und präzise Beschreibung des Problems. Z.B. Ich bin immer frustriert, wenn [...]
**Beschreibe die gewünschte Lösung**
Eine klare und präzise Beschreibung dessen, was passieren soll.
**Beschreibe Alternativen, die Du in Betracht gezogen hast**
Eine klare und präzise Beschreibung aller alternativen Lösungen oder Funktionen, die Du in Betracht gezogen hast.
**Zusätzlicher Kontext**
Füge hier weitere Kontexte oder Screenshots zur Feature-Anfrage hinzu.

View File

@@ -0,0 +1,38 @@
---
name: "[DE] Fehlerbericht"
about: Erstelle einen Bericht, um uns zu helfen, die App zu verbessern
title: ''
labels: bug
assignees: ''
---
**Beschreibe den Fehler**
Eine klare und präzise Beschreibung des Fehlers.
**Reproduzierung**
Schritte zum Reproduzieren des Fehlers:
1. Gehe zu '...'
2. Klicke auf '....'
3. Scrolle nach unten zu '....'
4. Sieh den Fehler
**Erwartetes Verhalten**
Eine klare und präzise Beschreibung dessen, was Du erwartet hattest.
**Screenshots**
Füge gegebenenfalls Screenshots hinzu, um Dein Problem zu erklären.
**Desktop (bitte verfolständige die folgenden Informationen):**
- Betriebssystem: [z.B. Windows 10]
- Browser [z.B. chrome, safari]
- Version [z.B. 2.14]
**Smartphone (bitte verfolständige die folgenden Informationen):**
- Gerät: [z.B. iPhone 6]
- Betriebssystem: [z.B. iOS 8.1]
- Browser [z.B. stock browser, safari]
- Version [z.B. 2.14]
**Zusätzlicher Kontext**
Füge hier einen anderen Kontext zum Problem hinzu.

View File

@@ -0,0 +1,38 @@
---
name: "[EN] Bug report"
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. Windows 10]
- Browser [e.g. chrome, safari]
- Version [e.g. 2.14]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone 6]
- OS: [e.g. iOS 8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 2.14]
**Additional context**
Add any other context about the problem here.

View File

@@ -0,0 +1,20 @@
---
name: "[EN] Feature request"
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

11
README.md Normal file
View File

@@ -0,0 +1,11 @@
# Regatten.net App
Willkommen im GitHub-Repository unserer neuen Regatten.net App.
Falls sich jemand dafür interessiert, ist hier der gesamte Quellcode unserer neuen App zu finden.
Bitte beachtet, dass diese App einschließlich dem gesamten Quellcode exklusivem Urheberrecht unterliegt. Sie darf also nicht kopiert, verteilt oder verändert werden.
Sollte Interesse an einer Anbindung an unser System bestehen, kontaktiere uns bitte einfach (https://regatten.net/contact)
Der Hauptzweck dieses Repository besteht jedoch darin, Feedback von Euch zu unserer neuen App zu bekommen.
Selbstverständlich könnt Ihr uns auch weiterhin auf anderen Kanälen erreichen, doch für Problem-Meldungen und Verbesserungsvorschläge ist GitHub am besten geeignet.
Wie Du Teil unseres BETA-Programmes wirst, die App installierst und Feedback gibst, erfährst Du in unserem [Wiki](https://github.com/ostertun/RegattenApp/wiki).

View File

@@ -1,9 +1,9 @@
<?php
header('Content-Type: text/javascript');
require_once(__DIR__ . '/../../server/config.php');
?>
var loaderCount = 2;
@@ -29,17 +29,17 @@ $(window).on('load',function(){
$(document).ready(function(){
'use strict'
var isAJAX = false; //Enables or disable AJAX page transitions and loading.
var isDevelopment = false; // Enables development mode. Clean cache & Stops BG & Highlights from changing defaults.
function init_template(){
//ADD YOUR CUSTOM JAVASCRIPT CODES HERE!
//Do not put inside HTML files.
//The init_template() function will be triggered when pages open.
//Generating Dynamic Styles to decrease CSS size and execute faster loading times.
var colorsArray = [
//colors must be in HEX format.
@@ -93,24 +93,24 @@ $(document).ready(function(){
["skype","#12A5F4"],
["instagram","#e1306c"]
];
//Back Button Scroll Stop
//if ('scrollRestoration' in history) {history.scrollRestoration = 'manual';}
//Disable Page Jump on Empty Links.
$('a').on('click', function(){var attrs = $(this).attr('href'); if(attrs === '#'){return false;}});
//Adding Background for Gradient
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
/*Menu Extender Function*/
$.fn.showMenu = function() {$(this).addClass('menu-active'); $('#footer-bar').addClass('footer-menu-hidden');setTimeout(function(){$('.menu-hider').addClass('menu-active');},250);$('body').addClass('modal-open')};
$.fn.hideMenu = function() {$(this).removeClass('menu-active'); $('#footer-bar').removeClass('footer-menu-hidden');$('.menu-hider').removeClass('menu-active menu-active-clear');$('body').removeClass('modal-open')};
//Add your programatically triggered menus here
//Menu Required Variables
var menu = $('.menu'),
body = $('body'),
@@ -123,21 +123,21 @@ $(document).ready(function(){
pageContent = $('.page-content'),
headerAndContent = $('.header, .page-content, #footer-bar'),
menuDeployer = $('a[data-menu]');
//Menu System
menu.each(function(){
var menuHeight = $(this).data('menu-height');
var menuWidth = $(this).data('menu-width');
var menuActive = $(this).data('menu-active');
if($(this).hasClass('menu-box-right')){$(this).css("width",menuWidth);}
if($(this).hasClass('menu-box-left')){$(this).css("width",menuWidth);}
if($(this).hasClass('menu-box-bottom')){$(this).css("height",menuHeight);}
if($(this).hasClass('menu-box-top')){$(this).css("height",menuHeight);}
if($(this).hasClass('menu-box-right')){$(this).css("width",menuWidth);}
if($(this).hasClass('menu-box-left')){$(this).css("width",menuWidth);}
if($(this).hasClass('menu-box-bottom')){$(this).css("height",menuHeight);}
if($(this).hasClass('menu-box-top')){$(this).css("height",menuHeight);}
if($(this).hasClass('menu-box-modal')){$(this).css({"height":menuHeight, "width":menuWidth});}
});
});
//Menu Deploy Click
menuDeployer.on('click',function(){
menuDeployer.on('click',function(){
menu.removeClass('menu-active');
menuHider.addClass('menu-active');
@@ -147,23 +147,23 @@ $(document).ready(function(){
var menuWidth = menuID.data('menu-width');
var menuHeight = menuID.data('menu-height');
$('body').addClass('modal-open');
if(menuID.hasClass('menu-header-clear')){menuHider.addClass('menu-active-clear');}
function menuActivate(){menuID = 'menu-active' ? menuID.addClass('menu-active') : menuID.removeClass('menu-active');}
if(menuID.hasClass('menu-header-clear')){menuHider.addClass('menu-active-clear');}
function menuActivate(){menuID = 'menu-active' ? menuID.addClass('menu-active') : menuID.removeClass('menu-active');}
if(menuID.hasClass('menu-box-bottom')){$('#footer-bar').addClass('footer-menu-hidden');}
if(menuEffect === "menu-parallax"){
if(menuID.hasClass('menu-box-bottom')){headerAndContent.css("transform", "translateY("+(menuHeight/5)*(-1)+"px)");}
if(menuID.hasClass('menu-box-top')){headerAndContent.css("transform", "translateY("+(menuHeight/5)+"px)");}
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX("+(menuWidth/5)+"px)");}
if(menuID.hasClass('menu-box-bottom')){headerAndContent.css("transform", "translateY("+(menuHeight/5)*(-1)+"px)");}
if(menuID.hasClass('menu-box-top')){headerAndContent.css("transform", "translateY("+(menuHeight/5)+"px)");}
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX("+(menuWidth/5)+"px)");}
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX("+(menuWidth/5)*(-1)+"px)");}
}
}
if(menuEffect === "menu-push"){
if(menuID.hasClass('menu-box-bottom')){headerAndContent.css("transform", "translateY("+(menuHeight)*(-1)+"px)");}
if(menuID.hasClass('menu-box-top')){headerAndContent.css("transform", "translateY("+(menuHeight)+"px)");}
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX("+(menuWidth)+"px)");}
if(menuID.hasClass('menu-box-bottom')){headerAndContent.css("transform", "translateY("+(menuHeight)*(-1)+"px)");}
if(menuID.hasClass('menu-box-top')){headerAndContent.css("transform", "translateY("+(menuHeight)+"px)");}
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX("+(menuWidth)+"px)");}
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX("+(menuWidth)*(-1)+"px)");}
}
}
if(menuEffect === "menu-push-full"){
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX(100%)");}
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX(100%)");}
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX(-100%)");}
}
menuActivate();
@@ -204,13 +204,13 @@ $(document).ready(function(){
setTimeout(function(){
if($('body').hasClass('detect-theme')){$('body').removeClass('detect-theme');}
if($('body').hasClass('theme-light')){
eraseCookie('sticky_dark_mode');
darkSwitch.prop('checked', false);
eraseCookie('sticky_dark_mode');
darkSwitch.prop('checked', false);
createCookie('sticky_light_mode', true, 1);
}
if($('body').hasClass('theme-dark')){
eraseCookie('sticky_light_mode');
darkSwitch.prop('checked', true);
eraseCookie('sticky_light_mode');
darkSwitch.prop('checked', true);
createCookie('sticky_dark_mode', true, 1);
}
},150);
@@ -222,7 +222,7 @@ $(document).ready(function(){
//Auto Dark Mode
function activateDarkMode(){$('body').removeClass('theme-light').addClass('theme-dark'); $('#dark-mode-detected').removeClass('disabled'); eraseCookie('sticky_light_mode'); createCookie('sticky_dark_mode', true, 1);}
function activateLightMode(){$('body').removeClass('theme-dark').addClass('theme-light'); $('#dark-mode-detected').removeClass('disabled'); eraseCookie('sticky_dark_mode'); createCookie('sticky_light_mode', true, 1);}
function activateNoPreference(){$('#manual-mode-detected').removeClass('disabled');}
function activateNoPreference(){$('#manual-mode-detected').removeClass('disabled');}
function setColorScheme() {
const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches
@@ -244,19 +244,19 @@ $(document).ready(function(){
$('.footer-bar-2 .active-nav, .footer-bar-4 .active-nav, .footer-bar-5 .active-nav').append('<strong></strong>')
}
}
//Back Button in Header
var backButton = $('.back-button, [data-back-button]');
backButton.on('click', function() {
window.history.go(-1);
//return false;
});
//Copyright Year
//Copyright Year
var copyrightYear = $('.copyright-year, #copyright-year');
var dteNow = new Date(); var intYear = dteNow.getFullYear();
copyrightYear.html(intYear);
//Back to top Badge
var backToTop = $('.back-to-top, [data-back-to-top], .back-to-top-badge, .back-to-top-icon'),
backToTopBadge = $('.back-to-top-badge, .back-to-top-icon');
@@ -293,7 +293,7 @@ $(document).ready(function(){
show_back_to_top_badge();
show_scroll_ad();
$('.header-auto-show').addClass('header-active');
}
}
if (footer_reached == true){
hide_back_to_top_badge();
hide_scroll_ad();
@@ -333,10 +333,10 @@ $(document).ready(function(){
if(tab.length){activate_tabs()}
//Text Resizer
$(".text-size-increase").click(function() {$(".text-size-changer *").css("font-size","+=1");});
$(".text-size-increase").click(function() {$(".text-size-changer *").css("font-size","+=1");});
$(".text-size-decrease").click(function() {$(".text-size-changer *").css("font-size","-=1");});
$(".text-size-default").click(function() {$(".text-size-changer *").css("font-size", "");});
//Search Menu Functions
function search_menu(){
$('[data-search]').on('keyup', function() {
@@ -387,15 +387,15 @@ $(document).ready(function(){
//Owl Carousel Sliders
setTimeout(function(){
$('.user-slider').owlCarousel({loop:false, margin:20, nav:false, lazyLoad:true, items:1, autoplay: false, dots:false, autoplayTimeout:4000});
$('.single-slider').owlCarousel({loop:true, margin:20, nav:false, lazyLoad:true, items:1, autoplay: true, autoplayTimeout:4000});
$('.cover-slider').owlCarousel({loop:true, margin:0, nav:false, lazyLoad:true, items:1, autoplay: true, autoplayTimeout:6000});
$('.double-slider').owlCarousel({loop:true, margin:20, nav:false, lazyLoad:false, items:2, autoplay: true, autoplayTimeout:4000});
$('.task-slider').owlCarousel({loop:true, margin:20, nav:false, stagePadding:50, lazyLoad:true, items:2, autoplay: false, autoplayTimeout:4000});
$('.next-slide, .next-slide-arrow, .next-slide-text, .cover-next').on('click',function(){$(this).parent().find('.owl-carousel').trigger('next.owl.carousel');});
$('.prev-slide, .prev-slide-arrow, .prev-slide-text, .cover-prev').on('click',function(){$(this).parent().find('.owl-carousel').trigger('prev.owl.carousel');});
$('.next-slide-user').on('click',function(){$(this).closest('.owl-carousel').trigger('next.owl.carousel');});
$('.prev-slide-user').on('click',function(){$(this).closest('.owl-carousel').trigger('prev.owl.carousel');});
$('.user-slider').owlCarousel({loop:false, margin:20, nav:false, lazyLoad:true, items:1, autoplay: false, dots:false, autoplayTimeout:4000});
$('.single-slider').owlCarousel({loop:true, margin:20, nav:false, lazyLoad:true, items:1, autoplay: true, autoplayTimeout:4000});
$('.cover-slider').owlCarousel({loop:true, margin:0, nav:false, lazyLoad:true, items:1, autoplay: true, autoplayTimeout:6000});
$('.double-slider').owlCarousel({loop:true, margin:20, nav:false, lazyLoad:false, items:2, autoplay: true, autoplayTimeout:4000});
$('.task-slider').owlCarousel({loop:true, margin:20, nav:false, stagePadding:50, lazyLoad:true, items:2, autoplay: false, autoplayTimeout:4000});
$('.next-slide, .next-slide-arrow, .next-slide-text, .cover-next').on('click',function(){$(this).parent().find('.owl-carousel').trigger('next.owl.carousel');});
$('.prev-slide, .prev-slide-arrow, .prev-slide-text, .cover-prev').on('click',function(){$(this).parent().find('.owl-carousel').trigger('prev.owl.carousel');});
$('.next-slide-user').on('click',function(){$(this).closest('.owl-carousel').trigger('next.owl.carousel');});
$('.prev-slide-user').on('click',function(){$(this).closest('.owl-carousel').trigger('prev.owl.carousel');});
},10);
setTimeout(function(){
$('.owl-prev, .owl-next').addClass('bg-highlight');
@@ -428,20 +428,20 @@ $(document).ready(function(){
//Toast, Snackbars and Notifications
$('[data-toast]').on('click',function(){
$('.toast, .snackbar-toast, .notification').toast('hide');
$('#'+$(this).data('toast')).toast('show');
$('.toast, .snackbar-toast, .notification').toast('hide');
$('#'+$(this).data('toast')).toast('show');
return false;
});
$('[data-dismiss]').on('click',function(){
var thisData = $(this).data('dismiss');
$('#'+thisData).toast('hide');
});
//Tooltips
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
//Cancel Collapse Jump on Click
if($('[data-toggle="collapse"]').length){
$('[data-toggle="collapse"]').on('click',function(e){
@@ -467,10 +467,10 @@ $(document).ready(function(){
$('#'+thisID).prop('checked', false);
} else {
$('#'+thisID).prop('checked', true);
}
}
})
//Working Hours
//Working Hours
var businessHours = $('.business-hours');
function activate_business_hours(){
if(businessHours.length){
@@ -501,7 +501,7 @@ $(document).ready(function(){
},
openClass:"bg-green1-dark is-business-opened",
closedClass:"bg-red2-dark is-business-closed"
});
});
if(businessHours.hasClass('is-business-opened')){
$('.show-business-opened').removeClass('disabled');
$('.show-business-closed').addClass('disabled');
@@ -540,7 +540,7 @@ $(document).ready(function(){
})(document, window.navigator, "standalone")
}
ath();
//Add to Home Banners
$('.simulate-android-badge').on('click',function(){$('.add-to-home').removeClass('add-to-home-ios').addClass('add-to-home-visible add-to-home-android');});
$('.simulate-iphone-badge').on('click',function(){$('.add-to-home').removeClass('add-to-home-android').addClass('add-to-home-visible add-to-home-ios');});
@@ -549,16 +549,16 @@ $(document).ready(function(){
$('.simulate-ios-banner').on('click',function(){$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active')})
//Extending Card Features
function card_extender(){
function card_extender(){
/*Set Page Content to Min 100vh*/
if($('.is-on-homescreen').length){
var windowHeight = screen.height;
$('.page-content, #page').css('min-height', windowHeight);
}
}
if(!$('.is-on-homescreen').length){
var windowHeight = window.innerHeight
$('.page-content, #page').css('min-height', windowHeight);
}
}
$('[data-card-height]').each(function(){
var cardHeight = $(this).data('card-height');
@@ -567,8 +567,8 @@ $(document).ready(function(){
$(this).css('height', cardHeight);
if(cardHeight == "cover"){
if(header.length && menuFooter.length){
$(this).css('height', windowHeight -headerHeight - footerHeight)
$('.map-full, .map-full iframe').css('height', windowHeight - headerHeight - footerHeight +14)
$(this).css('height', windowHeight -headerHeight - footerHeight)
$('.map-full, .map-full iframe').css('height', windowHeight - headerHeight - footerHeight +14)
} else {
$(this).css('height', windowHeight)
$('.map-full, .map-full iframe').css('height', windowHeight)
@@ -581,20 +581,20 @@ $(document).ready(function(){
$(window).resize(function(){
card_extender();
});
//Show Map
$('.show-map, .hide-map').on('click',function(){
$('.map-full .caption').toggleClass('deactivate-map');
$('.map-but-1, .map-but-2').toggleClass('deactivate-map');
$('.map-full .hide-map').toggleClass('activate-map');
});
});
//Card Hovers
$('.card-scale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-scale-image');});
$('.card-grayscale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-grayscale-image');});
$('.card-rotate').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-rotate-image');});
$('.card-blur').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-blur-image');});
$('.card-scale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-scale-image');});
$('.card-grayscale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-grayscale-image');});
$('.card-rotate').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-rotate-image');});
$('.card-blur').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-blur-image');});
$('.card-hide').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('.card-center, .card-bottom, .card-top, .card-overlay').toggleClass('card-hide-image');});
@@ -605,7 +605,7 @@ $(document).ready(function(){
var readingSeconds = readingWords % 60
$('.reading-progress-words').append(readingWords);
$('.reading-progress-time').append(readingMinutes + ':' + readingSeconds);
});
});
//Timed Ads
if($('[data-auto-show-ad]').length){
@@ -614,7 +614,7 @@ $(document).ready(function(){
$('[data-auto-show-ad]').trigger('click');
},time*1000);
}
$('[data-timed-ad]').on('click', function(){
$('[data-timed-ad]').on('click', function(){
var counter = $(this).data('timed-ad');
var adwin = $('#'+$(this).data('menu'));
menuHider.addClass('no-click');
@@ -686,10 +686,10 @@ $(document).ready(function(){
})
//Caption Hovers
$('.caption-scale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-scale-image');});
$('.caption-grayscale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-grayscale-image');});
$('.caption-rotate').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-rotate-image');});
$('.caption-blur').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-blur-image');});
$('.caption-scale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-scale-image');});
$('.caption-grayscale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-grayscale-image');});
$('.caption-rotate').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-rotate-image');});
$('.caption-blur').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-blur-image');});
$('.caption-hide').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('.caption-center, .caption-bottom, .caption-top, .caption-overlay').toggleClass('caption-hide-image');});
//File Upload
@@ -733,8 +733,8 @@ $(document).ready(function(){
//Age Verification
var checkAge = $('.check-age');
function activate_age_checker(){
console.log('active');
$(".check-age").on('click',function(){
log('active');
$(".check-age").on('click',function(){
var dateBirghtDay = $("#date-birth-day").val();
var dateBirthMonth = $("#date-birth-month").val();
var dateBirthYear = $("#date-birth-year").val();
@@ -747,7 +747,7 @@ $(document).ready(function(){
setDate.setFullYear(mydate.getFullYear() + age, dateBirthMonth-1, dateBirghtDay);
if ((currdate - setDate) > 0){
console.log("above 18");
log("above 18");
$('#menu-age').removeClass('menu-active')
$('#menu-age-okay').addClass('menu-active');
}else{
@@ -756,7 +756,7 @@ $(document).ready(function(){
}
return true;
});
}
}
if(checkAge.length){activate_age_checker();}
@@ -816,11 +816,11 @@ $(document).ready(function(){
var spanValue = $(this).parent().find('span').text();
if($(this).val() != spanValue && $(this).val() != ""){
$(this).parent().find('span').addClass('input-style-1-active').removeClass('input-style-1-inactive');
}
}
if($(this).val() === ""){
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
}
});
});
$('.input-required input, .input-required select, .input-required textarea').on('focusout',function(){
var spanValue = $(this).parent().find('span').text();
if($(this).val() === ""){
@@ -833,17 +833,17 @@ $(document).ready(function(){
if(getValue === "default"){
$(this).parent().find('em').html(invalidIcon)
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
}
}
if(getValue != "default"){
$(this).parent().find('em').html(validIcon)
}
}
});
$('.input-required input[type="email"]').on('focusout',function(){if (emailValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="email"]').on('focusout',function(){if (emailValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="tel"]').on('focusout',function(){if (phoneValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="password"]').on('focusout',function(){if (passwordValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="url"]').on('focusout',function(){if (urlValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="name"]').on('focusout',function(){if (nameValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required textarea').on('focusout',function(){if (textareaValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="password"]').on('focusout',function(){if (passwordValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="url"]').on('focusout',function(){if (urlValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required input[type="name"]').on('focusout',function(){if (nameValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
$('.input-required textarea').on('focusout',function(){if (textareaValidator.test($(this).val())){$(this).parent().find('em').html(validIcon);}else{if($(this).val() === ""){$(this).parent().find('em').html("(required)");}else{$(this).parent().find('em').html(invalidIcon);}}});
//Set Today Date to Date Inputs
Date.prototype.toDateInputValue = (function() {
@@ -880,7 +880,7 @@ $(document).ready(function(){
$('.online-message').addClass('online-message-active');
$('.offline-message').removeClass('offline-message-active');
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
}
}
$('.simulate-offline').on('click',function(){isOffline();})
$('.simulate-online').on('click',function(){isOnline();})
@@ -889,11 +889,11 @@ $(document).ready(function(){
function updateOnlineStatus(event) {
var condition = navigator.onLine ? "online" : "offline";
isOnline();
console.log( 'Connection: Online');
log( 'Connection: Online');
}
function updateOfflineStatus(event) {
isOffline();
console.log( 'Connection: Offline');
log( 'Connection: Offline');
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOfflineStatus);
@@ -901,14 +901,14 @@ $(document).ready(function(){
//QR Generator
var generateQR = $('.generate-qr-result, .generate-qr-auto');
function activate_qr_generator(){
//QR Code Generator
//QR Code Generator
var qr_auto_link = window.location.href;
var qr_api_address = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=';
$('.generate-qr-auto').attr('src', qr_api_address+qr_auto_link)
$('.generate-qr-button').on('click',function(){
if($(this).parent().find('.fa').hasClass('fa-exclamation-triangle')){
console.log('Invalid URL');
log('Invalid URL');
} else {
var get_qr_url = $('.generate-qr-input').val();
if(!get_qr_url == ''){
@@ -960,10 +960,10 @@ $(document).ready(function(){
});
//Filterable
if($('.gallery-filter').length > 0){$('.gallery-filter').filterizr(); $('.gallery-filter-active').addClass('color-highlight');}
if($('.gallery-filter').length > 0){$('.gallery-filter').filterizr(); $('.gallery-filter-active').addClass('color-highlight');}
$('.gallery-filter-controls li').on('click',function(){
$('.gallery-filter-controls li').removeClass('gallery-filter-active color-highlight');
$(this).addClass('gallery-filter-active color-highlight');
$('.gallery-filter-controls li').removeClass('gallery-filter-active color-highlight');
$(this).addClass('gallery-filter-active color-highlight');
});
//Gallery Views // Added in 2.0
@@ -982,7 +982,7 @@ $(document).ready(function(){
galleryViewControls.removeClass('color-highlight');
$(this).addClass('color-highlight');
galleryViews.removeClass().addClass('gallery-views gallery-view-2');
});
});
galleryView3.on('click',function(){
galleryViewControls.removeClass('color-highlight');
$(this).addClass('color-highlight');
@@ -1064,7 +1064,7 @@ $(document).ready(function(){
})
});
//Charts
if($('.chart').length > 0){
var loadJS = function(url, implementationCode, location){
@@ -1075,7 +1075,7 @@ $(document).ready(function(){
location.appendChild(scriptTag);
};
var call_charts_to_page = function(){
var walletChart = $('#wallet-chart');
var pieChart = $('#pie-chart');
var doughnutChart = $('#doughnut-chart');
@@ -1100,9 +1100,9 @@ $(document).ready(function(){
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
tooltips:{enabled:true}, animation:{duration:1500}
}
});
});
}
if(pieChart.length){
var pieDemoChart = new Chart(pieChart, {
type: 'pie',
@@ -1119,7 +1119,7 @@ $(document).ready(function(){
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
tooltips:{enabled:true}, animation:{duration:1500}
}
});
});
}
if(doughnutChart.length){
@@ -1138,7 +1138,7 @@ $(document).ready(function(){
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
tooltips:{enabled:true}, animation:{duration:1500}, layout:{ padding: {bottom: 30}}
}
});
});
}
if(polarChart.length){
@@ -1157,7 +1157,7 @@ $(document).ready(function(){
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
tooltips:{enabled:true}, animation:{duration:1500}, layout:{ padding: {bottom: 30}}
}
});
});
}
if (verticalChart.length){
@@ -1182,7 +1182,7 @@ $(document).ready(function(){
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
title: {display: false}
}
});
});
}
if(horizontalChart.length){
@@ -1206,7 +1206,7 @@ $(document).ready(function(){
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
title: {display: false}
}
});
});
}
if(lineChart.length){
@@ -1214,11 +1214,11 @@ $(document).ready(function(){
type: 'line',
data: {
labels: [2000,2005,2010,2015,2010],
datasets: [{
datasets: [{
data: [500,400,300,200,300],
label: "Desktop Web",
borderColor: "#D8334A"
}, {
}, {
data: [0,100,300,400,500],
label: "Mobile Web",
borderColor: "#4A89DC"
@@ -1234,11 +1234,11 @@ $(document).ready(function(){
}
}
loadJS('<?php echo SERVER_ADDR; ?>/client/scripts/charts.js', call_charts_to_page, document.body);
}
}
//Local Error Message
if (window.location.protocol === "file:"){$('a').on('mouseover',function(){console.log("You are seeing these errors because your file is on your local computer. For real life simulations please use a Live Server or a Local Server such as AMPPS or WAMPP or simulate a Live Preview using a Code Editor like http://brackets.io (it's 100% free) - PWA functions and AJAX Page Transitions will only work in these scenarios.");});}
if (window.location.protocol === "file:"){$('a').on('mouseover',function(){log("You are seeing these errors because your file is on your local computer. For real life simulations please use a Live Server or a Local Server such as AMPPS or WAMPP or simulate a Live Preview using a Code Editor like http://brackets.io (it's 100% free) - PWA functions and AJAX Page Transitions will only work in these scenarios.");});}
//Style Generator
@@ -1248,21 +1248,21 @@ $(document).ready(function(){
//HEX to RGBA Converter
function HEXtoRGBA(hex){
var c;
if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
c= hex.substring(1).split('');
if(c.length== 3){c= [c[0], c[0], c[1], c[1], c[2], c[2]];}
c= '0x'+c.join('');
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+',0.3)';
}
}
function highlight_colors(){
var bodyColor = readCookie('sticky-color-scheme')
if(bodyColor == undefined){var bodyColor = $('body').data('highlight');}
var bodyBackground = readCookie('sticky-bg-scheme')
if(bodyBackground == undefined){var bodyBackground = $('body').data('background');}
var data = colorsArray.map(colorsArray => colorsArray[0]);
if (data.indexOf(bodyColor) > -1) {
var highlightLocated = data.indexOf(bodyColor)
@@ -1282,7 +1282,7 @@ $(document).ready(function(){
$('.generated-background').append(bodyBG);
}
}
}
}
highlight_colors();
//Change Highlight
@@ -1306,7 +1306,7 @@ $(document).ready(function(){
$('body').append('<style class="generated-highlight"></style>')
$('.generated-highlight').append(highlightColor, highlightBg, highlightNav, highlightBorder);
}
});
});
//Change Background
$('[data-change-background]').on('click',function(changeColor){
@@ -1322,15 +1322,15 @@ $(document).ready(function(){
});
if (!generatedStyles.length){
$('body').append('<style class="generated-styles"></style>');
$('body').append('<style class="generated-styles"></style>');
$('.generated-styles').append('/*Generated using JS for lower CSS file Size, Easier Editing & Faster Loading*/');
colorsArray.forEach(function (colorValue) {$('.generated-styles').append('.bg-'+colorValue[0]+'-light{ background-color: '+colorValue[1]+'!important; color:#FFFFFF!important;} .bg-'+colorValue[0]+'-light i, .bg-'+colorValue[0]+'-dark i{color:#FFFFFF;} .bg-'+colorValue[0]+'-dark{ background-color: '+colorValue[2]+'!important; color:#FFFFFF!important;} .border-'+colorValue[0]+'-light{ border-color:'+colorValue[1]+'!important;} .border-'+colorValue[0]+'-dark{ border-color:'+colorValue[2]+'!important;} .color-'+colorValue[0]+'-light{ color: '+colorValue[1]+'!important;} .color-'+colorValue[0]+'-dark{ color: '+colorValue[2]+'!important;}');});
colorsArray.forEach(function (colorFadeValue) {$('.generated-styles').append('.bg-fade-'+colorFadeValue[0]+'-light{ background-color: '+ HEXtoRGBA(colorFadeValue[1]) + '!important; color:#FFFFFF;} .bg-fade-'+colorFadeValue[0]+'-light i, .bg-'+colorFadeValue[0]+'-dark i{color:#FFFFFF;} .bg-fade-'+colorFadeValue[0]+'-dark{ background-color: '+HEXtoRGBA(colorFadeValue[2])+'!important; color:#FFFFFF;} .border-fade-'+colorFadeValue[0]+'-light{ border-color:'+HEXtoRGBA(colorFadeValue[1])+'!important;} .border-fade-'+colorFadeValue[0]+'-dark{ border-color:'+HEXtoRGBA(colorFadeValue[2])+'!important;} .color-fade-'+colorFadeValue[0]+'-light{ color: '+HEXtoRGBA(colorFadeValue[1])+'!important;} .color-fade-'+colorFadeValue[0]+'-dark{ color: '+HEXtoRGBA(colorFadeValue[2])+'!important;}');});
colorsArray.forEach(function (gradientValue) {$('.generated-styles').append('.bg-gradient-'+gradientValue[0]+'{background-image: linear-gradient(to bottom, '+gradientValue[1]+' 0, '+gradientValue[2]+' 100%)}')});
colorsArray.forEach(function (colorValue) {$('.generated-styles').append('.bg-'+colorValue[0]+'-light{ background-color: '+colorValue[1]+'!important; color:#FFFFFF!important;} .bg-'+colorValue[0]+'-light i, .bg-'+colorValue[0]+'-dark i{color:#FFFFFF;} .bg-'+colorValue[0]+'-dark{ background-color: '+colorValue[2]+'!important; color:#FFFFFF!important;} .border-'+colorValue[0]+'-light{ border-color:'+colorValue[1]+'!important;} .border-'+colorValue[0]+'-dark{ border-color:'+colorValue[2]+'!important;} .color-'+colorValue[0]+'-light{ color: '+colorValue[1]+'!important;} .color-'+colorValue[0]+'-dark{ color: '+colorValue[2]+'!important;}');});
colorsArray.forEach(function (colorFadeValue) {$('.generated-styles').append('.bg-fade-'+colorFadeValue[0]+'-light{ background-color: '+ HEXtoRGBA(colorFadeValue[1]) + '!important; color:#FFFFFF;} .bg-fade-'+colorFadeValue[0]+'-light i, .bg-'+colorFadeValue[0]+'-dark i{color:#FFFFFF;} .bg-fade-'+colorFadeValue[0]+'-dark{ background-color: '+HEXtoRGBA(colorFadeValue[2])+'!important; color:#FFFFFF;} .border-fade-'+colorFadeValue[0]+'-light{ border-color:'+HEXtoRGBA(colorFadeValue[1])+'!important;} .border-fade-'+colorFadeValue[0]+'-dark{ border-color:'+HEXtoRGBA(colorFadeValue[2])+'!important;} .color-fade-'+colorFadeValue[0]+'-light{ color: '+HEXtoRGBA(colorFadeValue[1])+'!important;} .color-fade-'+colorFadeValue[0]+'-dark{ color: '+HEXtoRGBA(colorFadeValue[2])+'!important;}');});
colorsArray.forEach(function (gradientValue) {$('.generated-styles').append('.bg-gradient-'+gradientValue[0]+'{background-image: linear-gradient(to bottom, '+gradientValue[1]+' 0, '+gradientValue[2]+' 100%)}')});
socialColorArray.forEach(function (socialColorValue) {$('.generated-styles').append('.bg-'+socialColorValue[0]+'{background-color:'+socialColorValue[1]+'!important; color:#FFFFFF;} .color-'+socialColorValue[0]+'{color:'+socialColorValue[1]+'!important;}')});
colorsArray.forEach(function (gradientBodyValue) {$('.generated-styles').append('.body-'+gradientBodyValue[0]+'{background-image: linear-gradient(to bottom, '+gradientBodyValue[1]+' 0, '+gradientBodyValue[3]+' 100%)}')});
colorsArray.forEach(function (gradientBodyValue) {$('.generated-styles').append('.body-'+gradientBodyValue[0]+'{background-image: linear-gradient(to bottom, '+gradientBodyValue[1]+' 0, '+gradientBodyValue[3]+' 100%)}')});
}
function welcomeOk() {
createCookie('sticky_welcome_banner', true, 1);
$('#menu-welcome').hideMenu();
@@ -1344,16 +1344,16 @@ $(document).ready(function(){
}
$('#menu-welcome-a-okay').click(welcomeOk);
showWelcome();
initRegatten();
hideLoader();
}
//Activating all the plugins
setTimeout(init_template, 0);
//Activate AJAX Transitions
//Activate AJAX Transitions
if(isAJAX === true){
$(function(){
'use strict';
@@ -1361,7 +1361,7 @@ $(document).ready(function(){
prefetch: true,
prefetchOn: 'mouseover',
cacheLength: 100,
scroll: true,
scroll: true,
blacklist: '.default-link',
forms: 'contactForm',
onStart: {
@@ -1378,7 +1378,7 @@ $(document).ready(function(){
render: function ($container, $newContent) {
$container.removeClass('is-exiting');// Remove your CSS animation reversing class
$container.html($newContent);// Inject the new content
setTimeout(init_template, 0)//Timeout required to properly initiate all JS Functions.
setTimeout(init_template, 0)//Timeout required to properly initiate all JS Functions.
$('#preloader').removeClass('preloader-hide');
}
},
@@ -1406,5 +1406,5 @@ $(document).ready(function(){
caches.delete(cacheName);
});
});
}
});
}
});

View File

@@ -1,4 +1,4 @@
const DB_VERSION = 4;
const DB_VERSION = 6;
const USER_ID = localStorage.getItem('auth_user');
const USER_NAME = localStorage.getItem('auth_username');
@@ -20,11 +20,11 @@ var getJSON = function(url, callback) {
callback(xhr.status, xhr.response);
};
xhr.ontimeout = function () {
console.log("getJSON: timeout");
log("getJSON: timeout");
callback(0, null);
}
xhr.onerror = function () {
console.log("getJSON: error");
log("getJSON: error");
callback(0, null);
}
if (USER_ID != null) {
@@ -76,7 +76,7 @@ function dbGetData(table, id = null) {
if (code == 200) {
resolve(data.data);
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000);
resolve([]);
}
@@ -86,7 +86,7 @@ function dbGetData(table, id = null) {
if (code == 200) {
resolve(data.data);
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000);
resolve(null);
}
@@ -108,7 +108,7 @@ function dbGetDataIndex(table, indexName, value) {
if (code == 200) {
resolve(data.data);
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000);
resolve([]);
}
@@ -161,19 +161,19 @@ function dbGetResultCalculated(regatta) {
return new Promise(async function(resolve) {
var results = await dbGetDataIndex('results', 'regatta', regatta.id);
if (results.length > 0) {
var gemeldet = results.length;
for (id in results) {
results[id]['finished'] = false;
results[id]['values'] = [];
results[id]['values_all'] = [];
results[id]['texts'] = [];
var copy = [];
for (var i = 0; i < regatta['races']; i ++) {
var race = results[id]['race' + (i + 1)].replace(',', '.');
if (!isNaN(race)) {
copy[i] = results[id]['values'][i] = parseFloat(race);
results[id]['texts'][i] = race;
@@ -198,7 +198,7 @@ function dbGetResultCalculated(regatta) {
// Unbekannt
default: results[id]['values'][i] = 0; copy[i] = 0; break;
}
if (results[id]['values'][i] != 0) {
results[id]['texts'][i] = race + ' (' + results[id]['values'][i] + ')';
} else {
@@ -206,7 +206,7 @@ function dbGetResultCalculated(regatta) {
}
}
}
results[id]['values_all'] = [...results[id]['values']];
for (var s = 0; s < regatta['streicher']; s ++) {
var max = Math.max(...copy);
@@ -217,7 +217,7 @@ function dbGetResultCalculated(regatta) {
}
}
}
var brutto = 0;
var netto = 0;
for (var i = 0; i < regatta['races']; i ++) {
@@ -233,11 +233,11 @@ function dbGetResultCalculated(regatta) {
results[id]['brutto'] = brutto;
results[id]['netto'] = netto;
}
compareResultsRaceCount = regatta['races'];
results.sort(compareResults);
var place = 1;
for (id in results) {
if ((id > 0) && (compareResults(results[id], results[id - 1]) == 0)) {
@@ -247,9 +247,9 @@ function dbGetResultCalculated(regatta) {
}
place ++;
}
resolve(results);
} else {
resolve([]);
}
@@ -259,26 +259,26 @@ function dbGetResultCalculated(regatta) {
function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
return new Promise(async function(resolve) {
var rankNoResults = [];
var sailors = await dbGetData('sailors');
var regattas = await dbGetRegattasRange(minDate, maxDate);
var sailorIds = {};
for (s in sailors) {
sailorIds[sailors[s].id] = s;
}
for (var i in sailors) {
sailors[i].regattas = {};
sailors[i].tmp_rlp = [];
}
for (var i in regattas) {
var regatta = regattas[i];
// regatta has to be min. 2 days to be ranking regatta
if (regatta.length < 2) continue;
var results = await dbGetDataIndex('results', 'regatta', regatta.id);
if (results.length <= 0) {
if (regatta.dateTo <= getToday()) {
@@ -288,7 +288,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
}
continue;
}
// in one race there must be at least 10 boats started
var ok = false;
for (var j = 1; j <= regatta.races; j ++) {
@@ -304,9 +304,9 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
}
}
if (!ok) continue;
var fb = regatta.finishedBoats;
// calc m
var m;
if (regatta.m > 0) {
@@ -320,16 +320,16 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
m = 4;
}
}
// add regatta to each sailor
for (var r in results) {
var result = results[r];
if (result.rlp == 0) continue;
// check if crew is youth
// TODO: not used
sailors[sailorIds[result.steuermann]].regattas[regatta.id] = {
regatta: regatta.id,
boat: result.boat,
@@ -345,7 +345,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
}
}
}
// remove not german or not youth sailors
for (var i = sailors.length - 1; i >= 0; i --) {
if (sailors[i].german == '0') {
@@ -357,13 +357,13 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
}
}
}
for (var i = sailors.length - 1; i >= 0; i --) {
// sort rlps desc
sailors[i].tmp_rlp.sort(function (a,b) {
return b[1] - a[1];
});
// calc mean rlp
var sum = 0;
var cnt = 0;
@@ -383,20 +383,40 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
sailors.splice(i, 1);
}
}
sailors.sort(function (a,b) {
if (a.m != b.m) return b.m - a.m;
return b.rlp - a.rlp;
});
for (var i = 0; i < sailors.length; i ++) {
sailors[i].rank = (i + 1);
}
resolve([sailors, rankNoResults]);
});
}
function dbSettingsGet(key) {
return new Promise(function(resolve) {
if (canUseLocalDB) {
var request = db.transaction('settings').objectStore('settings').get(key);
request.onsuccess = function (event) {
resolve(typeof request.result != 'undefined' ? request.result.value : null);
}
} else {
resolve(null);
}
});
}
function dbSettingsSet(key, value) {
if (canUseLocalDB) {
var os = db.transaction('settings', 'readwrite').objectStore('settings');
os.put({ key: key, value: value});
}
}
async function updateSyncStatus() { // TODO
// var syncStatus = document.getElementById('syncstatus');
// var lastSync = await dbGetData('update_times', 'last_sync');
@@ -404,7 +424,7 @@ async function updateSyncStatus() { // TODO
// var now = new Date();
// var diff = Math.round((now - lastSync) / 1000);
// var txt = '';
//
//
// if (diff < 30) { // 30 sec
// txt = 'jetzt';
// } else if (diff < 3600) { // 60 min
@@ -417,7 +437,7 @@ async function updateSyncStatus() { // TODO
// diff = Math.round(diff / 86400);
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen');
// }
//
//
// var btn = '<a href="#" onclick="setLoading(true); sync(); return false;"><i class="fas fa-sync"></i> Sync</a>';
// syncStatus.innerHTML = 'Zuletzt aktualisiert: ' + txt + btn;
}
@@ -433,6 +453,12 @@ async function runPageScript() {
}
};
updateSyncStatus();
if (isLoggedIn()) {
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
plannings = plannings.map(function (e) { return e.regatta; });
dbSettingsSet('myregattas_' + BOATCLASS, plannings);
}
}
if (typeof updateSyncStatusTimer == 'undefined') { // TODO
// var syncStatus = document.getElementById('syncstatus');
@@ -445,7 +471,7 @@ async function runPageScript() {
}
// syncStatus.style.display = 'block';
}
if (typeof siteScript === 'function') {
siteScript();
} else {
@@ -456,20 +482,20 @@ async function runPageScript() {
function sync() {
if (!canUseLocalDB) return false;
if (syncInProgress > 0) return false;
var now = Math.floor(Date.now() / 1000);
db.transaction('update_times').objectStore('update_times').getAll().onsuccess = function (event) {
var localTimes = {};
event.target.result.forEach(function (entry) {
localTimes[entry['table']] = entry['time'];
});
syncInProgress = 10;
syncInProgress = 11;
var syncOkay = true;
console.log("Sync Start");
log("Sync Start");
$('#i-sync').addClass('fa-spin');
var interval = window.setInterval(function () {
if (syncInProgress <= 0) {
window.clearInterval(interval);
@@ -477,24 +503,27 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'last_sync', time: now });
}
console.log("Sync Stop");
log("Sync Stop");
setTimeout(function(){
$('#i-sync').removeClass('fa-spin');
}, 500);
if (typeof onAfterSync === 'function') {
onAfterSync();
}
removeSyncInfoToPreloader();
runPageScript();
}
}, 100);
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
if (code == 200) {
// CLUBS
if (localTimes['clubs'] < serverTimes['clubs']) {
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
if (code == 200) {
var os = db.transaction('clubs', 'readwrite').objectStore('clubs');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -509,24 +538,25 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] });
syncInProgress --;
log('clubs synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("clubs: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('clubs failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// BOATS
if (localTimes['boats'] < serverTimes['boats']) {
getJSON(QUERY_URL + 'get_boats?changed-after=' + localTimes['boats'], function (code, data) {
if (code == 200) {
var os = db.transaction('boats', 'readwrite').objectStore('boats');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -541,24 +571,25 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] });
syncInProgress --;
log('boats synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("boats: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('boats failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// SAILORS
if (localTimes['sailors'] < serverTimes['sailors']) {
getJSON(QUERY_URL + 'get_sailors?changed-after=' + localTimes['sailors'], function (code, data) {
if (code == 200) {
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -573,24 +604,25 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] });
syncInProgress --;
log('sailors synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("sailors: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('sailors failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// REGATTAS
if (localTimes['regattas'] < serverTimes['regattas']) {
getJSON(QUERY_URL + 'get_regattas?changed-after=' + localTimes['regattas'], function (code, data) {
if (code == 200) {
var os = db.transaction('regattas', 'readwrite').objectStore('regattas');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -617,28 +649,29 @@ function sync() {
osYears.put({ year: y });
}
}
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
syncInProgress --;
log('regattas synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("regattas: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('regattas failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// RESULTS
if (localTimes['results'] < serverTimes['results']) {
getJSON(QUERY_URL + 'get_results?changed-after=' + localTimes['results'], function (code, data) {
if (code == 200) {
var os = db.transaction('results', 'readwrite').objectStore('results');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -653,24 +686,25 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'results', time: serverTimes['results'] });
syncInProgress --;
log('results synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("results: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('results failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// PLANNINGS
if (localTimes['plannings'] < serverTimes['plannings']) {
getJSON(QUERY_URL + 'get_plannings?changed-after=' + localTimes['plannings'], function (code, data) {
if (code == 200) {
var os = db.transaction('plannings', 'readwrite').objectStore('plannings');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -685,25 +719,26 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'plannings', time: serverTimes['plannings'] });
syncInProgress --;
log('plannings synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("plannings: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('plannings failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
if (isLoggedIn()) {
// TRIM_BOATS
if (localTimes['trim_boats'] < serverTimes['trim_boats']) {
getJSON(QUERY_URL + 'get_trim_boats?changed-after=' + localTimes['trim_boats'], function (code, data) {
if (code == 200) {
var os = db.transaction('trim_boats', 'readwrite').objectStore('trim_boats');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -718,24 +753,25 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] });
syncInProgress --;
log('trim_boats synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("trim_boats: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('trim_boats failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// TRIM_USERS
if (localTimes['trim_users'] < serverTimes['trim_users']) {
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], function (code, data) {
if (code == 200) {
var os = db.transaction('trim_users', 'readwrite').objectStore('trim_users');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -750,24 +786,25 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] });
syncInProgress --;
log('trim_users synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("trim_users: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('trim_users failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// TRIM_TRIMS
if (localTimes['trim_trims'] < serverTimes['trim_trims']) {
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], function (code, data) {
if (code == 200) {
var os = db.transaction('trim_trims', 'readwrite').objectStore('trim_trims');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -782,28 +819,62 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] });
syncInProgress --;
log('trim_trims synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("trim_trims: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('trim_trims failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
} else {
syncInProgress -= 3;
}
// NEWS
if (localTimes['news'] < serverTimes['news']) {
getJSON(QUERY_URL + 'get_news?changed-after=' + localTimes['news'], function (code, data) {
if (code == 200) {
var os = db.transaction('news', 'readwrite').objectStore('news');
data.data.forEach(function (entry) {
os.put(entry);
});
os.openCursor().onsuccess = function (event) {
var cursor = event.target.result;
if (cursor) {
if (!data.keys.includes(parseInt(cursor.key))) {
os.delete(cursor.key);
}
cursor.continue();
} else {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'news', time: serverTimes['news'] });
syncInProgress --;
log('news synced, remaining:', syncInProgress);
}
};
} else {
log("news: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('news failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
// USERS
if (localTimes['users'] < serverTimes['users']) {
getJSON(QUERY_URL + 'get_users?changed-after=' + localTimes['users'], function (code, data) {
if (code == 200) {
var os = db.transaction('users', 'readwrite').objectStore('users');
console.log(data);
data.data.forEach(function (entry) {
os.put(entry);
});
@@ -818,20 +889,22 @@ function sync() {
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
osUpdateTimes.put({ table: 'users', time: serverTimes['users'] });
syncInProgress --;
log('users synced, remaining:', syncInProgress);
}
};
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("users: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('users failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress --;
}
} else {
console.log("Something went wrong (HTTP " + code + ")");
log("Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress = 0;
}
@@ -855,14 +928,14 @@ function initDatabase() {
if (window.indexedDB) {
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
request.onerror = function (event) {
console.log("Cannot open DB: " + event.target.errorCode);
log("Cannot open DB: " + event.target);
runPageScript();
};
request.onsuccess = function (event) {
console.log("Database loaded");
log("Database loaded");
db = event.target.result;
db.onversionchange = function (event) {
if (syncTimer != null) window.clearInterval(syncTimer);
if (updateSyncStatusTimer != null) window.clearInterval(updateSyncStatusTimer);
@@ -871,26 +944,29 @@ function initDatabase() {
db.close();
location.reload;
}
db.onerror = function (event) {
console.log("DB Error: " + event.target.errorCode);
log("DB Error: " + event.target);
};
canUseLocalDB = true;
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
db.transaction('update_times').objectStore('update_times').get('last_sync').onsuccess = function (event) {
var lastSync = event.target.result.time;
if (lastSync > 0) {
runPageScript();
} else {
addSyncInfoToPreloader();
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
}
};
checkSync();
syncTimer = window.setInterval(checkSync, 300000); // 5 min
window.ononline = function () {
checkSync();
}
@@ -900,11 +976,11 @@ function initDatabase() {
var upgradeTransaction = event.target.transaction;
var oldVersion = event.oldVersion;
var newVersion = event.newVersion;
console.log("Datenbank Version Upgrade von " + oldVersion + " auf " + newVersion);
log("Datenbank Version Upgrade von " + oldVersion + " auf " + newVersion);
if ((oldVersion < 1) && (newVersion >= 1)) {
console.log('to version 1');
log('to version 1');
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
@@ -931,28 +1007,40 @@ function initDatabase() {
osUpdateTimes.add({ table: 'trim_users', time: 0 });
osUpdateTimes.add({ table: 'trim_trims', time: 0 });
}
if ((oldVersion < 2) && (newVersion >= 2)) {
console.log('to version 2');
log('to version 2');
var osUsers = db.createObjectStore('users', { keyPath: 'id' });
osUsers.createIndex('username', 'username', { unique: true });
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.add({ table: 'users', time: 0 });
}
if ((oldVersion < 3) && (newVersion >= 3)) {
console.log('to version 3');
log('to version 3');
var osYears = db.createObjectStore('years', { keyPath: 'year' });
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.put({ table: 'regattas', time: 0 });
}
if ((oldVersion < 4) && (newVersion >= 4)) {
console.log('to version 4');
log('to version 4');
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
}
if ((oldVersion < 5) && (newVersion >= 5)) {
log('to version 5');
var osPushes = db.createObjectStore('settings', { keyPath: 'key' });
}
if ((oldVersion < 6) && (newVersion >= 6)) {
log('to version 6');
var osNews = db.createObjectStore('news', { keyPath: 'id' });
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.add({ table: 'news', time: 0 });
}
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
osUpdateTimes.put({ table: 'last_sync', time: 0 });
}
@@ -961,8 +1049,7 @@ function initDatabase() {
}
}
function resetDb(silent = true) {
$('#menu-developer').hideMenu();
function resetDb() {
if (canUseLocalDB) {
showLoader();
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
@@ -976,13 +1063,26 @@ function resetDb(silent = true) {
osUpdateTimes.put({ table: 'trim_boats', time: 0 });
osUpdateTimes.put({ table: 'trim_users', time: 0 });
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
osUpdateTimes.put({ table: 'news', time: 0 });
osUpdateTimes.put({ table: 'users', time: 0 });
console.log('DB update times reset');
if (!silent)
toastInfo('The database was reset. Please reload or close this tab.<br>At the next visit, a full sync will be performed.');
log('DB update times reset');
hideLoader();
} else {
if (!silent)
toastWarn('Your device does not support storing data locally. All data is fetched directly from our server.<br>As a result, you can not reset your database.');
}
}
function addSyncInfoToPreloader() {
var preloader = document.getElementById('preloader');
var div = document.createElement('div');
div.id = 'preloader-sync-info';
div.classList = 'rounded-s shadow-m bg-highlight m-3 p-3';
div.style.position = 'fixed';
div.style.top = 0;
div.style.left = 0;
div.style.right = 0;
div.innerHTML = '<h2 class="color-white">Datenbank SYNC</h2><p class="mb-0 color-white">Um Dir alle n&ouml;tigen Informationen anzeigen zu k&ouml;nnen, m&uuml;ssen wir die Datenbank synchronisieren.<br>Dies kann einen Moment dauern. Bitte habe etwas Geduld. Beim n&auml;chsten &Ouml;ffnen geht es schneller.</p>';
preloader.appendChild(div);
}
function removeSyncInfoToPreloader() {
$('#preloader-sync-info').remove();
}

View File

@@ -27,13 +27,13 @@ function parseDate(string) {
} else {
return null;
}
if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
if (year.toString().length == 2) year = (year < 70 ? 2000 : 1900) + year;
if ((year < 1970) || (year > 3000)) return null;
if ((month < 1) || (month > 12)) return null;
if ((day < 1) || (day > 31)) return null;
var date = new Date(Date.UTC(year, month - 1, day));
return date;
}
@@ -51,37 +51,37 @@ function formatDate(format, date = null) {
date = new Date(date.valueOf());
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
}
format = format.replace("M", "%1%");
format = format.replace("F", "%2%");
format = format.replace("D", "%3%");
format = format.replace("l", "%4%");
var tmp = date.getFullYear().toString();
var tmp2 = tmp.substr(2);
format = format.replace("Y", tmp);
format = format.replace('y', tmp2);
tmp = (date.getMonth() + 1).toString();
tmp2 = (tmp.length > 1 ? tmp : ('0' + tmp));
format = format.replace('n', tmp);
format = format.replace('m', tmp2);
tmp = date.getDate().toString();
tmp2 = (tmp.length > 1 ? tmp : ('0' + tmp));
format = format.replace('j', tmp);
format = format.replace('d', tmp2);
tmp = date.getDay();
tmp2 = (tmp == 0 ? 7 : tmp);
format = format.replace('w', tmp);
format = format.replace('N', tmp2);
format = format.replace('%1%', strings.months_short[date.getMonth()]);
format = format.replace('%2%', strings.months_long[date.getMonth()]);
format = format.replace('%3%', strings.weekdays_short[date.getDay()]);
format = format.replace('%4%', strings.weekdays_long[date.getDay()]);
return format;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,44 +1,46 @@
<?php
header('Content-Type: text/javascript');
require_once(__DIR__ . '/../../server/version.php');
require_once(__DIR__ . '/../../server/config.php');
?>
//Loading the Service Worker
var swRegistration = null;
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('<?php echo SERVER_ADDR; ?>/service-worker.js.php');
window.addEventListener('load', async function() {
swRegistration = await navigator.serviceWorker.register('<?php echo SERVER_ADDR; ?>/service-worker.js.php');
if (typeof onServiceWorkerLoaded === 'function') onServiceWorkerLoaded();
});
}
$(document).ready(function(){
'use strict'
$(document).ready(function(){
'use strict'
var pwaVersion = '<?php echo PWA_VERSION; ?>'; //must be identical to _manifest.json version. If not it will create update window loop
var pwaCookie = true; // if set to false, the PWA prompt will appear even if the user selects "maybe later"
var pwaNoCache = false; // always keep the cache clear to serve the freshest possible content
$('[data-pwa-version]').data('pwa-version', pwaVersion);
//Creating Cookie System for PWA Hide
function createCookie(e, t, n) {if (n) {var o = new Date;o.setTime(o.getTime() + n * 365 * 24 * 3600 * 1e3);var r = "; expires=" + o.toGMTString()} else var r = "";document.cookie = e + "=" + t + r + "; path=/"}
function readCookie(e) {for (var t = e + "=", n = document.cookie.split(";"), o = 0; o < n.length; o++) {for (var r = n[o];" " == r.charAt(0);) r = r.substring(1, r.length);if (0 == r.indexOf(t)) return r.substring(t.length, r.length)}return null}
function eraseCookie(e) {createCookie(e, "", -1)}
//Enabling dismiss button
setTimeout(function(){
$('.pwa-dismiss').on('click',function(){
console.log('User Closed Add to Home / PWA Prompt')
log('User Closed Add to Home / PWA Prompt')
createCookie('Sticky_pwa_rejected_install', true, 1);
$('body').find('#menu-install-pwa-android, #menu-install-pwa-ios, .menu-hider').removeClass('menu-active');
$('body').find('#menu-install-pwa-android, #menu-install-pwa-ios, .menu-hider').removeClass('menu-active');
});
},1500);
//Detecting Mobile Operating Systems
var isMobile = {
Android: function() {return navigator.userAgent.match(/Android/i);},
@@ -47,37 +49,40 @@ $(document).ready(function(){
};
var isInWebAppiOS = (window.navigator.standalone == true);
var isInWebAppChrome = (window.matchMedia('(display-mode: standalone)').matches);
//Firing PWA prompts for specific versions and when not on home screen.
//Firing PWA prompts for specific versions and when not on home screen.
if (isMobile.Android()) {
console.log('Android Detected');
log('Android Detected');
function showInstallPromotion(){
if($('#menu-install-pwa-android, .add-to-home').length){
console.log('Triggering PWA Menu for Android');
log('Triggering PWA Menu for Android');
if (!readCookie('Sticky_pwa_rejected_install')) {
setTimeout(function(){
$('.add-to-home').addClass('add-to-home-visible add-to-home-android');
$('#menu-install-pwa-android, .menu-hider').addClass('menu-active')
},4500);
},3000);
}
} else {
console.log('The div #menu-install-pwa-android was not found. Please add this div to show the install window')
}
}
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
showInstallPromotion();
var welcomActive = $('#menu-welcome').hasClass('menu-active');
if (welcomActive) {
$('#menu-welcome-a-okay').click(showInstallPromotion);
} else {
showInstallPromotion();
}
});
$('.pwa-install').on('click',function(e){
deferredPrompt.prompt();
deferredPrompt.userChoice
.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});
@@ -85,26 +90,32 @@ $(document).ready(function(){
window.addEventListener('appinstalled', (evt) => {
$('#menu-install-pwa-android, .menu-hider').removeClass('menu-active')
});
}
}
if (isMobile.iOS()) {
if(!isInWebAppiOS){
console.log('iOS Detected');
log('iOS Detected');
if($('#menu-install-pwa-ios, .add-to-home').length){
if (!readCookie('Sticky_pwa_rejected_install')) {
console.log('Triggering PWA / Add to Home Screen Menu for iOS');
setTimeout(function(){
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
},4500);
function triggerPwaInstallIos() {
log('Triggering PWA / Add to Home Screen Menu for iOS');
setTimeout(function(){
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
},3000);
}
var welcomActive = $('#menu-welcome').hasClass('menu-active');
if (welcomActive) {
$('#menu-welcome-a-okay').click(triggerPwaInstallIos);
} else {
triggerPwaInstallIos();
}
};
} else {
console.log('The div #menu-install-pwa-ios was not found. Please add this div to show the install window')
}
}
}
}
//Creating Update Modal
function updateModal(){
var body = $('body');
@@ -114,7 +125,7 @@ $(document).ready(function(){
if(!updateModal.length){
body.append('<div id="menu-update"></div>');
setTimeout(function(){
body.find('#menu-update').load('menu-update.html?ver='+menuUpdate);
body.find('#menu-update').load('menu-update.html?ver='+menuUpdate);
},250);
}
};
@@ -123,15 +134,15 @@ $(document).ready(function(){
var counter = 3;
var interval = setInterval(function() {
counter--;
console.log(counter);
log(counter);
$('.page-update').html('Aktuallisierung in ... '+ counter + ' Sekunden');
if (counter == 0) {
clearInterval(interval);
window.location.reload(true)
}
}, 1000);
caches.delete('workbox-runtime').then(function() {
console.log('Content Updated - Cache Removed!');
caches.delete('workbox-runtime').then(function() {
log('Content Updated - Cache Removed!');
});
//localStorage.clear();
sessionStorage.clear()
@@ -141,34 +152,34 @@ $(document).ready(function(){
});
});
};
//Check Version
//Check Version
function check_version(){
if($('link[data-pwa-version]').length){
function versionCheck(){
function versionCheck(){
var dt = new Date();
var maniTimeVersion = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
var localVersionNumber = $('link[rel="manifest"]').data('pwa-version');
var onlineVersionJSON = "<?php echo SERVER_ADDR; ?>/manifest.json.php?ver=" + maniTimeVersion;
var onlineVersionNumber = "Connection Offline. Waiting to Reconect";
$.getJSON(onlineVersionJSON, function(onlineData) {onlineVersionNumber = onlineData.version;});
$.getJSON(onlineVersionJSON, function(onlineData) {onlineVersionNumber = onlineData.version;});
setTimeout(function(){
//console.log(' Checking PWA Content for updates...\n PWA Server Version: ' + onlineVersionNumber + '\n' + ' PWA Cached Version: ' + localVersionNumber);
if(onlineVersionNumber != localVersionNumber && onlineVersionNumber != "Connection Offline. Waiting to Reconect"){
updateModal();
console.log('New Version of Content Available. Refreshing. On Desktop Browsers a manual refresh maybe required.')
log('New Version of Content Available. Refreshing. On Desktop Browsers a manual refresh maybe required.')
setTimeout(function(){
$('body').find('#menu-update').addClass('menu-active');
$('.menu-hider').addClass('menu-active-no-click');
$('.menu-hider').addClass('menu-active-no-click');
updateButton();
},500);
}
if(onlineVersionNumber == localVersionNumber){/*No update required. Versions Identical*/}
if(onlineVersionNumber === "undefined"){/*Error Checking for Updates*/}
}
if(onlineVersionNumber == localVersionNumber){/*No update required. Versions Identical*/}
if(onlineVersionNumber === "undefined"){/*Error Checking for Updates*/}
if(onlineVersionNumber === "Finding Online Version..."){
$('.reloadme').addClass('disabled');
$('.reloadme').addClass('disabled');
$('body').find('#menu-update').removeClass('menu-active');
$('.menu-hider').removeClass('menu-active-no-click');
$('.menu-hider').removeClass('menu-active-no-click');
}
},3000);
}
@@ -182,15 +193,15 @@ $(document).ready(function(){
if(pwaCookie == false){
eraseCookie('Sticky_pwa_rejected_install');
}
//Reload To Clear Button
//Reload To Clear Button
$('body').on('click', '.page-update, .reloadme', function() {
location.reload();
});
//Check for Version Change if Online If not Kill the Function
if (navigator.onLine) {check_version();} else {function check_version(){}}
//Adding Offline Alerts
var offlineAlerts = $('.offline-message');
@@ -198,24 +209,24 @@ $(document).ready(function(){
$('body').append('<p class="offline-message bg-red2-dark color-white center-text uppercase ultrabold">' + strings['inetMsgOffline'] + '</p>');
$('body').append('<p class="online-message bg-green1-dark color-white center-text uppercase ultrabold">' + strings['inetMsgOnline'] + '</p>');
}
//Offline Function Show
function isOffline(){
$('.offline-message').addClass('offline-message-active');
$('.online-message').removeClass('online-message-active');
setTimeout(function(){$('.offline-message').removeClass('offline-message-active');},2000);
}
//Online Function Show
function isOnline(){
$('.online-message').addClass('online-message-active');
$('.offline-message').removeClass('offline-message-active');
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
}
}
$('.simulate-offline').on('click',function(){isOffline();})
$('.simulate-online').on('click',function(){isOnline();})
//Disable links to other pages if offline.
//Warning! Enabling offline for iOS can cause issues
//To allow offline functionality delete the next 7 lines
@@ -224,27 +235,27 @@ $(document).ready(function(){
if(detectHREF.match(/.html/)){
isOffline();
return false;
}
}
}
}
//Check if Online / Offline
function updateOnlineStatus(event) {
var condition = navigator.onLine ? "online" : "offline";
isOnline();
console.log( 'Connection: Online');
log( 'Connection: Online');
$("a").off( "click", returnFalse );
}
function updateOfflineStatus(event) {
isOffline();
$("a").on( "click", returnFalse );
console.log( 'Connection: Offline');
log( 'Connection: Offline');
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOfflineStatus);
if(pwaNoCache == true){
caches.delete('workbox-runtime').then(function() {
caches.delete('workbox-runtime').then(function() {
});
localStorage.clear();
sessionStorage.clear()
@@ -254,6 +265,6 @@ $(document).ready(function(){
});
});
}
});
});

View File

@@ -1,9 +1,9 @@
<?php
header('Content-Type: text/javascript');
require_once(__DIR__ . '/../../server/config.php');
?>
const QUERY_URL = '<?php echo QUERY_URL; ?>';
@@ -11,6 +11,20 @@ const BOATCLASS = '<?php echo BOATCLASS; ?>';
const LINK_PRE = '<?php echo SERVER_ADDR; ?>/';
const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
const PUSH_SERVER_KEY = '<?php echo PUSH_SERVER_KEY; ?>';
function log() {
var now = new Date();
var hour = now.getHours().toString();
var min = now.getMinutes().toString();
var sec = now.getSeconds().toString();
var millis = now.getMilliseconds().toString();
hour = (hour.length < 2 ? '0' + hour : hour);
min = (min.length < 2 ? '0' + min : min);
sec = (sec.length < 2 ? '0' + sec : sec);
while (millis.length < 3) millis = '0' + millis;
console.log('[' + hour + ':' + min + ':' + sec + '.' + millis + ']', ...arguments);
}
var randomId = function() { return '_' + Math.random().toString(36).substr(2, 9); }
@@ -121,8 +135,8 @@ var login = function() {
showLoader();
var username = $('#input-login-username').val();
var password = $('#input-login-password').val();
$('#input-login-username').val('');
$('#input-login-password').val('');
$('#input-login-username').val('').trigger('focusin').trigger('focusout');
$('#input-login-password').val('').trigger('focusin').trigger('focusout');
$.ajax({
url: QUERY_URL + 'login',
method: 'POST',
@@ -134,13 +148,13 @@ var login = function() {
error: function (xhr, status, error) {
if (xhr.status == 401) {
toastError('Benutzername oder Passwort falsch');
$('#input-login-username').val(username);
$('#input-login-username').val(username).trigger('focusin').trigger('focusout');
} else if (xhr.status == 0) {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
$('#menu-login').hideMenu();
} else {
console.log('Login: unbekannter Fehler', status, error);
console.log(xhr);
log('Login: unbekannter Fehler', status, error);
log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
}
hideLoader();
@@ -172,7 +186,7 @@ var logout = function() {
hash: localStorage.getItem('auth_hash')
}
if ((auth.id === null) || (auth.hash === null)) {
console.log('Not logged in');
log('Not logged in');
logoutClearStorage();
return;
}
@@ -184,14 +198,14 @@ var logout = function() {
},
error: function (xhr, status, error) {
if (xhr.status == 401) {
console.log('Not logged in');
log('Not logged in');
logoutClearStorage();
} else if (xhr.status == 0) {
console.log('Could not delete auth from server');
log('Could not delete auth from server');
logoutClearStorage();
} else {
console.log('Logout: unbekannter Fehler', status, error);
console.log(xhr);
log('Logout: unbekannter Fehler', status, error);
log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
hideLoader();
}
@@ -202,28 +216,232 @@ var logout = function() {
});
}
function resetCache() {
function deleteDb() {
$('#menu-developer').hideMenu();
if (canUseLocalDB) {
showLoader();
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
request.onerror = function (event) {
log('Cannot delete DB: ', event.target.errorCode);
toastError('Beim Löschen der Datenbank ist ein Fehler aufgetreten.<br>Bitte melde diesen Fehler. (Dev-Menu => Problem melden)', 5000);
hideLoader();
}
request.onsuccess = function (event) {
log('DB deleted');
toastInfo('Die Datenbank wurde gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit eine neue Datenbank.', 10000);
hideLoader();
setTimeout(function(){ location.reload(); }, 3000);
}
} else {
toastWarn('Dein Gerät unterstützt kein lokales Speichern der Daten. Alle Daten werden direkt vom Server gezogen.<br>Entsprechend kannst Du die Datenbank auch nicht zurücksetzen.', 10000);
}
}
function deleteCache() {
$('#menu-developer').hideMenu();
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) {
console.log('Unregister sW:', registration);
log('Unregister sW:', registration);
registration.unregister();
}
});
caches.keys().then((keyList) => {
return Promise.all(keyList.map((key) => {
console.log('Cache deleted:', key);
log('Cache deleted:', key);
return caches.delete(key);
}));
});
toastInfo('The serviceWorker and the cache were deleted. A new serviceWorker will be generated on the next refresh.');
toastInfo('Der serviceWorker und alle Caches wurden gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit neue Caches.', 10000);
setTimeout(function(){ location.reload(); }, 3000);
}
var pushesPossible = false;
function urlB64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}
return outputArray;
}
function pushesSubscribe() {
log('Subscribing');
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
swRegistration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: applicationServerKey
})
.then(function(subscription) {
pushesUpdateServerSubscription(subscription, true);
updatePushSwitches();
updatePushBadge();
})
.catch(function(err) {
log('Failed to subscribe the user: ', err);
toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
pushesUnSubscribe(true);
});
}
function pushesUnSubscribe(silent = false) {
log('Unsubscribing');
swRegistration.pushManager.getSubscription()
.then(function(subscription) {
if (subscription) {
pushesUpdateServerSubscription(subscription, false);
subscription.unsubscribe();
$('#menu-pushes').hideMenu();
updatePushBadge();
hideLoader();
}
})
.catch(function(error) {
log('Error unsubscribing', error);
$('#menu-pushes').hideMenu();
if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000);
updatePushBadge();
hideLoader();
});
}
function pushesUpdateServerSubscription(subscription, enabled) {
log('updateServer', enabled, subscription);
$.ajax({
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
type: 'POST',
data: { subscription: JSON.stringify(subscription) },
success: function (data, textStatus, jqXHR) {
if (!enabled) {
toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
}
hideLoader();
},
error: function (jqXHR, textStatus, errorThrown) {
throw 'Cannot update server subscription';
}
});
}
async function initPushSettings() {
var items = [
['notify_channel_' + BOATCLASS + '_news', true],
['notify_channel_' + BOATCLASS + '_regatta_changed_my', true],
['notify_channel_' + BOATCLASS + '_regatta_changed_all', false],
['notify_channel_' + BOATCLASS + '_result_ready_my', true],
['notify_channel_' + BOATCLASS + '_result_ready_all', true],
['notify_channel_' + BOATCLASS + '_meldeschluss', true]
];
for (var i in items) {
var item = items[i];
if ((await dbSettingsGet(item[0])) == null) dbSettingsSet(item[0], item[1]);
}
}
async function updatePushSwitches() {
$('#switch-pushes-news').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_news'));
$('#switch-pushes-regatta-changed-my').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_regatta_changed_my'));
$('#switch-pushes-regatta-changed-all').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_regatta_changed_all'));
$('#switch-pushes-result-ready-my').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_result_ready_my'));
$('#switch-pushes-result-ready-all').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_result_ready_all'));
$('#switch-pushes-meldeschluss').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_meldeschluss'));
if ($('#switch-pushes').prop('checked')) {
$('#p-pushes-info').show();
$('.a-switch-pushes-channel-all').show();
$('.a-switch-pushes-channel-my').show();
if (!isLoggedIn()) {
$('.a-switch-pushes-channel-my').find('div').remove();
$('.a-switch-pushes-channel-my').find('.badge').text('nicht angemeldet');
}
} else {
$('#p-pushes-info').hide();
$('.a-switch-pushes-channel-all').hide();
$('.a-switch-pushes-channel-my').hide();
}
}
function pushesSubscribeClicked() {
showLoader();
if ($('#switch-pushes').prop('checked')) {
pushesSubscribe();
} else {
pushesUnSubscribe();
}
}
function pushesChannelClicked() {
dbSettingsSet('notify_channel_' + BOATCLASS + '_news', $('#switch-pushes-news').prop('checked'));
dbSettingsSet('notify_channel_' + BOATCLASS + '_regatta_changed_my', $('#switch-pushes-regatta-changed-my').prop('checked'));
dbSettingsSet('notify_channel_' + BOATCLASS + '_regatta_changed_all', $('#switch-pushes-regatta-changed-all').prop('checked'));
dbSettingsSet('notify_channel_' + BOATCLASS + '_result_ready_my', $('#switch-pushes-result-ready-my').prop('checked'));
dbSettingsSet('notify_channel_' + BOATCLASS + '_result_ready_all', $('#switch-pushes-result-ready-all').prop('checked'));
dbSettingsSet('notify_channel_' + BOATCLASS + '_meldeschluss', $('#switch-pushes-meldeschluss').prop('checked'));
}
function pushesOpenMenu() {
$('#menu-settings').hideMenu();
if (!pushesPossible) {
toastWarn('Dein Browser unterst&uuml;tzt leider keine Benachrichtigungen.', 5000);
return;
}
if (Notification.permission == 'denied') {
toastWarn('Benachrichtigungen werden von Deinem Browser blockiert.', 5000);
return;
}
swRegistration.pushManager.getSubscription().then(function(subscription) {
var isSub = (subscription !== null);
$('#switch-pushes').prop('checked', isSub);
updatePushSwitches();
$('#menu-pushes').showMenu();
});
}
function updatePushBadge() {
if (!pushesPossible) return;
if (Notification.permission == 'denied') {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED');
return;
}
swRegistration.pushManager.getSubscription().then(function(subscription) {
var isSub = (subscription !== null);
if (isSub) {
$('#badge-pushes').removeClass('bg-red2-dark').addClass('bg-green2-dark').text('AN');
} else {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('AUS');
}
});
}
async function updateNewsBadge() {
var newsRead = await dbSettingsGet('news_read_' + BOATCLASS);
if (newsRead === null) dbSettingsSet('news_read_' + BOATCLASS, newsRead = new Date());
var news = await dbGetData('news');
var now = new Date();
var sum = 0;
for (var n in news) {
var newsEntry = news[n];
newsEntry.date = new Date(Date.parse(newsEntry.date));
if (newsEntry.date > now) continue;
if (newsEntry.date < newsRead) continue;
sum ++;
}
updateBadge('more/news', sum);
}
var initRegatten = function() {
showLoader();
initDatabase();
if (isLoggedIn()) {
$('.show-loggedin').show();
$('.show-notloggedin').hide();
@@ -235,4 +453,51 @@ var initRegatten = function() {
$('.show-loggedin').hide();
$('.show-notloggedin').show();
}
}
// Pushes
$('#a-switch-pushes').click(pushesSubscribeClicked);
$('.a-switch-pushes-channel-all').click(pushesChannelClicked);
$('.a-switch-pushes-channel-my').click(pushesChannelClicked);
}
var onServiceWorkerLoaded = function() {
if ((swRegistration !== null) && canUseLocalDB) {
pushesPossible = true;
updatePushBadge();
} else {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('NOT SUPPORTED');
}
}
var onDatabaseLoaded = function() {
onServiceWorkerLoaded();
initPushSettings();
updateNewsBadge();
}
var onAfterSync = function() {
updateNewsBadge();
}
// Add console opener to preloader
var addConsoleOpenerToPreloader = function() {
addConsoleOpenerToPreloader = function(){};
var preloader = document.getElementById('preloader');
var button = document.createElement('a');
button.href = '#';
button.classList = 'btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight m-3';
button.style.position = 'fixed';
button.style.bottom = 0;
button.style.left = 0;
button.style.right = 0;
button.innerHTML = 'Show Console';
button.onclick = function(){
mobileConsole.displayConsole();
return false;
}
setTimeout(function(){
preloader.appendChild(button);
}, 5000);
}
addConsoleOpenerToPreloader();

View File

@@ -173,6 +173,13 @@
text-align: right;
}
/*** BLOCKQUOTE ***/
blockquote {
border-left: 0.5em solid rgba(0, 0, 0, 0.125);
font-style: italic;
padding-left: 1em;
}
/*** BLINKING ICONS ***/
@keyframes fa-blink {
0% { opacity: 1; }
@@ -187,4 +194,4 @@
-ms-animation: fa-blink .75s linear infinite;
-o-animation: fa-blink .75s linear infinite;
animation: fa-blink .75s linear infinite;
}
}

View File

@@ -12,6 +12,9 @@
define('QUERY_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/api/' . BOATCLASS . '/'); // url to api backend
define('LOGGING_APIKEY', 'xxx'); // Apikey for Logging API -> get from ostertun.net/logging
// PUSH
define('PUSH_SERVER_KEY', '');
// BOAT CLASS
$_CLASS = array(
'name' => 'Pirat',

View File

@@ -1,19 +1,28 @@
<?php
// TODO: Create site
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
$sp['title'] = 'News - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = true;
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
$content .= '<p>';
$content .= 'Die gesuchte Seite ist leider noch nicht verf&uuml;gbar.<br>';
$content .= 'Wir arbeiten daran, sie schnellstm&ouml;glich zur Verf&uuml;gung zu stellen.<br>';
$content .= 'Wie w&auml;re es mit der Homepage?';
$content .= '</p>';
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
?>
$sp['activenav'] = 5;
// Title
$content = "<h1>Neuigkeiten</h1>";
$content .= '<p>Aktuelles der letzten zw&ouml;lf Monate</p>';
$sp['output'] .= $tpl->load('card', [$content]);
$sp['output'] .= '<div id="news-entries"></div>';
// Pagination
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
// Menu
$sp['menus'] .= $tpl->load('menu/modal', ['html-id' => 'menu-news', 'title' => 'Details']);
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
$cardTemplate = $tpl->load('card', ['%CONTENT%', 'html-id' => '%ID%', 'css-class' => 'card-news']);
$cardTemplate = str_replace("\n", '', $cardTemplate);
$cardTemplate = str_replace("\r", '', $cardTemplate);
$sp['scripts'] .= "<script>const cardTemplate = '" . $cardTemplate . "';</script>";
$sp['scripts'] .= $scripts->load('news');
?>

View File

@@ -1,19 +1,48 @@
<?php
// TODO: Create site
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = true;
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
$content .= '<p>';
$content .= 'Die gesuchte Seite ist leider noch nicht verf&uuml;gbar.<br>';
$content .= 'Wir arbeiten daran, sie schnellstm&ouml;glich zur Verf&uuml;gung zu stellen.<br>';
$content .= 'Wie w&auml;re es mit der Homepage?';
$content .= '</p>';
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
?>
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'index';
$sp['activenav'] = 5;
// Title
$content = '<h1>Saison-Planung</h1>';
$content .= '<p class="mb-1"><b>Hinweis:</b> Diese Seite kannst nur Du sehen.<br>Wenn Du Deine Saison-Planung teilen möchtest, <a id="a-share-planning">klicke hier</a></p>';
$content .= $tpl->load('button', ['<i class="fas fa-edit"></i>&ensp;bearbeiten', LINK_PRE . 'planning_edit']);
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
// Not loggedin
$content = '<h1>Saison-Planung</h1>';
$content .= '<p>Um Deine Saison-Planung zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="#" data-menu="menu-signup">registriere Dich jetzt kostenlos</a>.</p>';
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
// Regattas
$content = '<p id="p-count" class="mb-0"></p>';
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
$content .= '<div id="div-regattas" class="regattas-list mb-0"></div>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
// Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon', ['Status bearbeiten', '#', 'html-id' => 'menu-item-status', 'icon' => 'fa-edit']);
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']);
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
$items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']);
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]);
// Menu Edit status
$items = $tpl->load('menu/item-switch', ['Gemeldet', 'html-id' => 'switch-status-gemeldet', 'icon' => 'fa-file-signature']);
$items .= $tpl->load('menu/item-switch', ['Bezahlt', 'html-id' => 'switch-status-bezahlt', 'icon' => 'fa-euro-sign', 'css-class' => 'border-0']);
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-status', 'title' => 'Status bearbeiten', 'height' => 220]);
$sp['scripts'] .= $scripts->load('onRegattaClicked');
$sp['scripts'] .= $scripts->load('planning');
?>

View File

@@ -1,19 +1,21 @@
<?php
// TODO: Create site
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = true;
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
$content .= '<p>';
$content .= 'Die gesuchte Seite ist leider noch nicht verf&uuml;gbar.<br>';
$content .= 'Wir arbeiten daran, sie schnellstm&ouml;glich zur Verf&uuml;gung zu stellen.<br>';
$content .= 'Wie w&auml;re es mit der Homepage?';
$content .= 'Du kannst die Saison-Planung momentan leider noch nicht in der App bearbeiten.<br>';
$content .= 'Bis diese Funktion implementiert wurde, erstelle Deine Saison-Planung bitte auf <a target="_blank" href="https://regatten.net/' . BOATCLASS . '/planning_edit">unserer Website</a>.<br>';
$content .= 'Deine Saison-Planung wird dann automatisch synchronisiert und ist dann auch in dieser App verf&uuml;gbar.<br>';
$content .= 'Wir arbeiten daran, dass Du Deine Saison-Planung bald auch in der App bearbeiten kannst.<br>';
$content .= '</p>';
$content .= $tpl->load('button', ['Zur Website', 'https://regatten.net/' . BOATCLASS, 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
?>
?>

View File

@@ -1,19 +1,27 @@
<?php
// TODO: Create site
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = true;
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
$content .= '<p>';
$content .= 'Die gesuchte Seite ist leider noch nicht verf&uuml;gbar.<br>';
$content .= 'Wir arbeiten daran, sie schnellstm&ouml;glich zur Verf&uuml;gung zu stellen.<br>';
$content .= 'Wie w&auml;re es mit der Homepage?';
$content .= '</p>';
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
?>
$sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'planning';
$sp['activenav'] = 5;
// Title
$content = '<h1>Saison-Planungen</h1>';
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
// Not loggedin
$content = '<h1>Saison-Planungen</h1>';
$content .= '<p>Um die Saison-Planungen anderer zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="#" data-menu="menu-signup">registriere Dich jetzt kostenlos</a>.</p>';
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
// Regattas
$content = $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text']);
$content .= '<div id="div-users" class="normal-list mb-0"></div>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
$sp['scripts'] .= $scripts->load('planning_list');
?>

View File

@@ -1,19 +1,36 @@
<?php
// TODO: Create site
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = true;
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
$content .= '<p>';
$content .= 'Die gesuchte Seite ist leider noch nicht verf&uuml;gbar.<br>';
$content .= 'Wir arbeiten daran, sie schnellstm&ouml;glich zur Verf&uuml;gung zu stellen.<br>';
$content .= 'Wie w&auml;re es mit der Homepage?';
$content .= '</p>';
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
?>
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
$sp['backbutton'] = 'planning_list';
$sp['activenav'] = 5;
// Title
$content = '<h1>Saison-Planung</h1>';
$content .= '<p id="p-username" class="mb-1"></p>';
$content .= $tpl->load('button', ['<i class="fas fa-share-alt"></i>&ensp;Teilen', '#', 'html-id' => 'button-share']);
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
$sp['output'] .= $tpl->load('card', [$content]);
// Regattas
$content = '<p id="p-count" class="mb-0"></p>';
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
$content .= '<div id="div-regattas" class="ranking-detail-list mb-0"></div>';
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
// Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']);
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
$items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']);
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]);
$sp['scripts'] .= $scripts->load('onRegattaClicked');
$sp['scripts'] .= $scripts->load('planning_view');
?>

View File

@@ -3,27 +3,27 @@
<div class="content mb-0">
<div class="divider mb-0"></div>
<div class="list-group list-custom-small list-icon-0">
<a href="#" class="shareToFacebook">
<a href="#" class="shareToFacebook" target="_blank">
<i class="font-18 fab fa-facebook color-facebook"></i>
<span class="font-13">Facebook</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" class="shareToTwitter">
<a href="#" class="shareToTwitter" target="_blank">
<i class="font-18 fab fa-twitter-square color-twitter"></i>
<span class="font-13">Twitter</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" class="shareToLinkedIn">
<a href="#" class="shareToLinkedIn" target="_blank">
<i class="font-18 fab fa-linkedin color-linkedin"></i>
<span class="font-13">LinkedIn</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" class="shareToWhatsApp">
<a href="#" class="shareToWhatsApp" target="_blank">
<i class="font-18 fab fa-whatsapp-square color-whatsapp"></i>
<span class="font-13">WhatsApp</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" class="shareToMail border-0">
<a href="#" class="shareToMail border-0" target="_blank">
<i class="font-18 fa fa-envelope-square color-mail"></i>
<span class="font-13">Email</span>
<i class="fa fa-angle-right"></i>
@@ -92,7 +92,7 @@
</div>
</div>
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="270">
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="310">
<div class="menu-title"><h1>Einstellungen</h1><p class="color-highlight">&nbsp;</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
<div class="divider divider-margins mb-n2"></div>
<div class="content">
@@ -110,7 +110,7 @@
<span>Login</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" data-menu="menu-signup" class="show-notloggedin border-0">
<a href="#" data-menu="menu-signup" class="show-notloggedin">
<i class="fa font-14 fa-user-plus rounded-s bg-highlight color-white"></i>
<span>Registrieren</span>
<span class="badge bg-red2-dark color-white">FREE</span>
@@ -120,40 +120,125 @@
<span>Account</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" onclick="logout();" class="show-loggedin border-0">
<a href="#" onclick="logout();" class="show-loggedin">
<i class="fa font-14 fa-sign-out-alt rounded-s bg-highlight color-white"></i>
<span>Logout</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" onclick="pushesOpenMenu()" class="border-0">
<i class="fa font-14 fa-bell rounded-s bg-highlight color-white"></i>
<span>Benachrichtigungen</span>
<span id="badge-pushes" class="badge color-white"></span>
<i class="fa fa-angle-right"></i>
</a>
</div>
</div>
</div>
<div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="310">
<div id="menu-pushes" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="500">
<div class="menu-title"><h1>Benachrichtigungen</h1><p class="color-highlight">Bleibe immer auf dem aktuellen Stand</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
<div class="divider divider-margins mb-n2"></div>
<div class="content">
<div class="list-group list-custom-small">
<a id="a-switch-pushes" href="#" data-trigger-switch="switch-pushes" class="pb-2">
<i class="fa font-14 fa-bell rounded-s bg-highlight color-white"></i>
<span>Benachrichtigungen aktivieren</span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes">
<label class="custom-control-label" for="switch-pushes"></label>
</div>
</a>
<div class="divider"></div>
<p style="line-height: 1.5em;" id="p-pushes-info">
W&auml;hle hier, &uuml;ber was Du informiert werden m&ouml;chtest.<br>
(meine) bezieht sich auf die Regatten, die in Deiner Saison-Planung sind,<br>
(alle) informiert Dich &uuml;ber alle Regatten
</p>
<a href="#" data-trigger-switch="switch-pushes-news" class="pb-2 a-switch-pushes-channel-all">
<i class="fa font-14 fa-newspaper rounded-s bg-highlight color-white"></i>
<span>Neuigkeiten</span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes-news">
<label class="custom-control-label" for="switch-pushes-news"></label>
</div>
</a>
<a href="#" data-trigger-switch="switch-pushes-regatta-changed-my" class="pb-2 a-switch-pushes-channel-my">
<i class="fa font-14 fa-calendar-check rounded-s bg-highlight color-white"></i>
<span>Regatta verschoben (meine)</span>
<span class="badge bg-red2-dark color-white"></span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes-regatta-changed-my">
<label class="custom-control-label" for="switch-pushes-regatta-changed-my"></label>
</div>
</a>
<a href="#" data-trigger-switch="switch-pushes-regatta-changed-all" class="pb-2 a-switch-pushes-channel-all">
<i class="fa font-14 fa-calendar-check rounded-s bg-highlight color-white"></i>
<span>Regatta verschoben (alle)</span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes-regatta-changed-all">
<label class="custom-control-label" for="switch-pushes-regatta-changed-all"></label>
</div>
</a>
<a href="#" data-trigger-switch="switch-pushes-result-ready-my" class="pb-2 a-switch-pushes-channel-my">
<i class="fa font-14 fa-poll rounded-s bg-highlight color-white"></i>
<span>Ergebnisse verf&uuml;gbar (meine)</span>
<span class="badge bg-red2-dark color-white"></span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes-result-ready-my">
<label class="custom-control-label" for="switch-pushes-result-ready-my"></label>
</div>
</a>
<a href="#" data-trigger-switch="switch-pushes-result-ready-all" class="pb-2 a-switch-pushes-channel-all">
<i class="fa font-14 fa-poll rounded-s bg-highlight color-white"></i>
<span>Ergebnisse verf&uuml;gbar (alle)</span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes-result-ready-all">
<label class="custom-control-label" for="switch-pushes-result-ready-all"></label>
</div>
</a>
<a href="#" data-trigger-switch="switch-pushes-meldeschluss" class="pb-2 a-switch-pushes-channel-my">
<i class="fa font-14 fa-file-signature rounded-s bg-highlight color-white"></i>
<span>Melde-Erinnerungen</span>
<span class="badge bg-red2-dark color-white"></span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="switch-pushes-meldeschluss">
<label class="custom-control-label" for="switch-pushes-meldeschluss"></label>
</div>
</a>
</div>
</div>
</div>
<div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="360">
<div class="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight">Version <?php echo PWA_VERSION; ?></p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
<div class="divider divider-margins mb-n2"></div>
<div class="content">
<div class="list-group list-custom-small">
<a href="https://info.ostertun.net/regatten/beta">
<a href="https://github.com/ostertun/RegattenApp/wiki">
<i class="fa font-14 fa-info rounded-s bg-highlight color-white"></i>
<span>Infos zur BETA</span>
<span>App-Wiki</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="javascript:resetDb(false);">
<a href="javascript:deleteDb();">
<i class="fa font-14 fa-database rounded-s bg-highlight color-white"></i>
<span>Reset Database</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="javascript:resetCache();">
<a href="javascript:deleteCache();">
<i class="fa font-14 fa-trash-alt rounded-s bg-highlight color-white"></i>
<span>Reset Cache</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="https://report.regatten.net/" class="border-0">
<a href="https://github.com/ostertun/RegattenApp/issues">
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
<span>Problem melden</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="#" onclick="mobileConsole.displayConsole(); return false;" class="border-0 menu-close">
<i class="fa font-14 fa-terminal rounded-s bg-highlight color-white"></i>
<span>Console anzeigen</span>
<i class="fa fa-angle-right"></i>
</a>
</div>
</div>
</div>
@@ -181,7 +266,7 @@
<p class="text-center">
Momentan kannst Du Dich leider nicht in der App registrieren.<br>
Das ist aber kein Problem, registriere Dich einfach kostenlos auf unserer Website!
</p>
</p>
<a href="https://regatten.net/de/signup" class="btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Registrieren</a>
<p class="text-center font-10 bottom-0">Du kannst Dich danach in dieser App anmelden.</p>
</div>
@@ -212,8 +297,8 @@
<h1 class="text-center mt-5 font-900">Update Verfügbar</h1>
<p class="text-center">
Eine neue Version unserer App ist verf&uuml;gbar. Keine Sorge, Du musst nichts machen. Wir aktuallisieren den Inhalt in wenigen Sekunden.
</p>
</p>
<a href="#" class="page-update btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Update</a>
<p class="text-center font-10 bottom-0">Die App wird neu laden und das Update ist abgeschlossen.</p>
</div>
</div>
</div>

View File

@@ -1,7 +1,8 @@
<!DOCTYPE HTML>
<html lang="de">
<head>
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/mobileconsole.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
@@ -16,36 +17,36 @@
<link rel="icon" type="image/x-icon" href="<?php echo SERVER_ADDR; ?>/client/app/icons/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
</head>
<body class="detect-theme" data-background="none" data-highlight="blue2">
<div id="preloader"><div class="spinner-border color-highlight" role="status"></div></div>
<div id="page">
<?php include(__DIR__ . '/headerfooter.php'); ?>
<!--start of page content, add your stuff here-->
<div class="page-content header-clear-medium">
<?php echo $sp['output']; ?>
</div>
<!--end of page content, off canvas elements here-->
<?php include(__DIR__ . '/menus.php'); ?>
<?php echo $sp['menus']; ?>
<?php
if ($site == 'index') {
include(__DIR__ . '/install.php');
}
?>
<!--end of div id page-->
</div>
<?php echo $sp['scripts']; ?>
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/jquery.js"></script>
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/strings.js.php"></script>
@@ -55,5 +56,5 @@
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/custom.js.php"></script>
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/pwa.js.php"></script>
</body>
</html>
</html>

View File

@@ -21,8 +21,8 @@ async function onEditBoatnameClick() {
if (xhr.status == 0) {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Bootsnamen zu bearbeiten');
} else {
console.log('EditBoatname: unbekannter Fehler', status, error);
console.log(xhr);
log('EditBoatname: unbekannter Fehler', status, error);
log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
}
hideLoader();
@@ -47,9 +47,9 @@ async function onEditBoatnameClick() {
async function onListClicked(id) {
var boat = await dbGetData('boats', id);
$('#menu-boat').find('.menu-title').find('p').text(boat.sailnumber);
// Edit Boatname
$('#button-editboatname').attr('data-boat-id', boat.id);
$('#menu-editboatname').find('.menu-title').find('p').text(boat.sailnumber);
@@ -63,7 +63,7 @@ async function onListClicked(id) {
$('#input-editboatname').val(boat.name);
}
$('#input-editboatname').trigger('focusin').trigger('focusout');
// club website
var clubwebsite = '';
if (boat['club'] != null) {
@@ -76,7 +76,7 @@ async function onListClicked(id) {
} else {
$('#menu-item-clubwebsite').hide();
}
$('#menu-boat').showMenu();
$('#menu-boat').scrollTop(0);
}
@@ -89,19 +89,19 @@ function pageChange() {
async function drawList() {
window.setTimeout(function () {
var list = '';
if (displayed.length > 0) {
var offset = (page - 1) * showCount;
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
if (count == 0) count = showCount;
for (i = 0; i < count; i ++) {
list += displayed[i + offset];
}
} else {
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
}
$('#div-list').html(list);
}, 0);
}
@@ -135,9 +135,9 @@ var siteScript = async function() {
$('#menu-item-boatname').click(function(){ $('#menu-boat').hideMenu(); $('#menu-editboatname').showMenu(); });
$('#button-editboatname').click(onEditBoatnameClick);
}
var results = await dbGetData('boats');
var count = results.length;
if (count > 0) {
if (count == 1) {
@@ -147,51 +147,51 @@ var siteScript = async function() {
}
$('#div-list').show();
$('#input-search').parent().show();
results.sort(function (a, b) {
return a.sailnumber.localeCompare(b.sailnumber);
});
rows = [];
for (id in results) {
var entry = results[id];
var club = null;
if (entry['club'] != null)
club = await dbGetData('clubs', entry['club']);
var row = { keywords: [], content: '' };
row.keywords.push(entry['sailnumber']);
if (entry['name'] != '') row.keywords.push(entry['name']);
if (club != null) row.keywords.push(club['kurz'], club['name']);
row.content += '<div onclick="onListClicked(' + entry['id'] + ');">';
// ZEILE 1
// Sailnumber
row.content += '<div><b>' + entry['sailnumber'] + '</b></div>';
// ZEILE 2
row.content += '<div>';
// Name
row.content += '<div>' + entry['name'] + '</div>';
// Club
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
row.content += '</div></div>';
rows.push(row);
}
reSearch();
} else {
$('#p-count').html('Keine Boote gefunden!');
$('#div-list').hide();
$('#input-search').parent().hide();
}
hideLoader();
}
}

View File

@@ -42,7 +42,7 @@ function addRace() {
var m = parseFloat($('#input-m').val());
var fb = parseFloat($('#input-fb').val());
var pl = parseFloat($('#input-pl').val().replace(',', '.'));
if (isNaN(rlf) || (rlf < 1) || (rlf > 1.6)) {
toastError('RLF ungültig');
return;
@@ -59,7 +59,7 @@ function addRace() {
toastError('pl ungültig');
return;
}
var race = {
rlf: rlf,
m: m,
@@ -67,12 +67,12 @@ function addRace() {
pl: pl,
rlp: (100 * rlf * ((fb + 1 - pl) / fb))
};
$('#input-rlf').val('');
$('#input-m').val('');
$('#input-fb').val('');
$('#input-pl').val('');
$('#input-rlf').val('').trigger('focusin').trigger('focusout');
$('#input-m').val('').trigger('focusin').trigger('focusout');
$('#input-fb').val('').trigger('focusin').trigger('focusout');
$('#input-pl').val('').trigger('focusin').trigger('focusout');
races.push(race);
reCalc();
}
@@ -89,4 +89,4 @@ var siteScript = async function () {
}
reCalc();
hideLoader();
}
}

View File

@@ -3,12 +3,12 @@ function sendMessage() {
var email = $('#input-email').val();
var subject = $('#input-subject').val();
var message = $('#input-message').val();
if ((name == '') || (email == '') || (subject == '') || (message == '')) {
toastError('Bitte f&uuml;lle alle Felder aus!');
return;
}
showLoader();
$.ajax({
url: QUERY_URL + 'contact',
@@ -23,16 +23,16 @@ function sendMessage() {
if (xhr.status == 0) {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um eine Nachricht zu versenden');
} else {
console.log('Contact: unbekannter Fehler', status, error);
console.log(xhr);
log('Contact: unbekannter Fehler', status, error);
log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
}
hideLoader();
},
success: function (data, status, xhr) {
toastOk('Nachricht erfolgreich versandt!');
$('#input-subject').val('');
$('#input-message').val('');
$('#input-subject').val('').trigger('focusin').trigger('focusout');
$('#input-message').val('').trigger('focusin').trigger('focusout');
hideLoader();
}
});
@@ -46,4 +46,4 @@ var siteScript = async function () {
}
$('#button-send').click(sendMessage);
hideLoader();
}
}

View File

@@ -2,12 +2,12 @@ var today;
var siteScript = async function() {
today = getToday();
if (isLoggedIn()) {
$('#card-notloggedin').hide();
var user = await dbGetData('users', localStorage.getItem('auth_user'));
// Favorites
var watched = [];
for (var i = 1; i <= 5; i ++) {
@@ -46,11 +46,11 @@ var siteScript = async function() {
$('#p-favorites').show();
}
$('#card-favorites').show();
// Your next
var planningsDB = await dbGetDataIndex('plannings', 'user', user.id);
var minDate = getToday();
minDate.setDate(minDate.getDate() - 1);
minDate.setDate(minDate.getDate());
var maxDate = getToday();
maxDate.setDate(maxDate.getDate() + 28);
var regattas = await dbGetRegattasRange(minDate, maxDate);
@@ -75,35 +75,35 @@ var siteScript = async function() {
for (i in plannings) {
var planning = plannings[i];
var regatta = planning.regatta;
if (regatta['length'] < 1) continue;
var club = null;
if (regatta['club'] != null)
club = await dbGetData('clubs', regatta['club']);
var dateFrom = regatta['dateFrom'];
var dateTo = regatta['dateTo'];
// output
list += '<div onclick="onRegattaClicked(' + regatta['id'] + ');">';
// ZEILE 1
// Name
list += '<div><b>' + (regatta['canceled'] == 1 ? '<s>' : '') + regatta['name'] + (regatta['canceled'] == 1 ? '</s>' : '') + '</b></div>';
// ZEILE 2
list += '<div>';
// Number
list += '<div>' + ((regatta['number'] != null) ? ('# ' + regatta['number']) : '') + '</div>';
// Club
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
list += '<div>' + regatta['special'] + '</div>';
// Icons
var icons = [];
if (regatta['info'] != '')
@@ -120,8 +120,10 @@ var siteScript = async function() {
ms = parseDate(regatta['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if ((ms >= today) && (diff < 7)) {
if (ms < today) {
color = ' color-red2-dark';
} else if (diff < 7) {
color = ' color-yellow2-dark';
}
}
}
@@ -134,18 +136,18 @@ var siteScript = async function() {
icons.push('<i class="fas fa-times color-red2-dark"></i>');
}
list += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
list += '</div>';
// ZEILE 3
list += '<div>';
// Date
list += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
// RLF
list += '<div>' + parseFloat(regatta['rlf']).toFixed(2) + '</div>';
list += '</div></div>';
}
$('#div-yournext').html(list);
@@ -161,10 +163,10 @@ var siteScript = async function() {
$('#card-yournext').hide();
$('#card-notloggedin').show();
}
// Next
var minDate = getToday();
minDate.setDate(minDate.getDate() - 1);
minDate.setDate(minDate.getDate());
var maxDate = getToday();
maxDate.setDate(maxDate.getDate() + 14);
var regattas = await dbGetRegattasRange(minDate, maxDate);
@@ -172,35 +174,35 @@ var siteScript = async function() {
list = '';
for (i in regattas) {
var regatta = regattas[i];
if (regatta['length'] < 1) continue;
var club = null;
if (regatta['club'] != null)
club = await dbGetData('clubs', regatta['club']);
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
var dateFrom = regatta['dateFrom'];
var dateTo = regatta['dateTo'];
// output
list += '<div onclick="onRegattaClicked(' + regatta['id'] + ');">';
// ZEILE 1
// Name
list += '<div><b>' + (regatta['canceled'] == 1 ? '<s>' : '') + regatta['name'] + (regatta['canceled'] == 1 ? '</s>' : '') + '</b></div>';
// ZEILE 2
list += '<div>';
// Number
list += '<div>' + ((regatta['number'] != null) ? ('# ' + regatta['number']) : '') + '</div>';
// Club
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
list += '<div>' + regatta['special'] + '</div>';
// Icons
var icons = [];
if (regatta['info'] != '')
@@ -227,8 +229,10 @@ var siteScript = async function() {
ms = parseDate(regatta['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if ((ms >= today) && (diff < 7)) {
if (ms < today) {
color = ' color-red2-dark';
} else if (diff < 7) {
color = ' color-yellow2-dark';
}
}
}
@@ -241,18 +245,18 @@ var siteScript = async function() {
icons.push('<i class="fas fa-times color-red2-dark"></i>');
}
list += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
list += '</div>';
// ZEILE 3
list += '<div>';
// Date
list += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
// RLF
list += '<div>' + parseFloat(regatta['rlf']).toFixed(2) + '</div>';
list += '</div></div>';
}
$('#div-next').html(list);
@@ -262,7 +266,7 @@ var siteScript = async function() {
$('#div-next').hide();
$('#p-next').show();
}
// Last
var minDate = getToday();
minDate.setDate(minDate.getDate() - 14);
@@ -279,35 +283,35 @@ var siteScript = async function() {
list = '';
for (i in regattas) {
var regatta = regattas[i];
if (regatta['length'] < 1) continue;
var club = null;
if (regatta['club'] != null)
club = await dbGetData('clubs', regatta['club']);
var dateFrom = regatta['dateFrom'];
var dateTo = regatta['dateTo'];
// output
list += '<div onclick="onRegattaClicked(' + regatta['id'] + ');">';
// ZEILE 1
// Name
list += '<div><b>' + (regatta['canceled'] == 1 ? '<s>' : '') + regatta['name'] + (regatta['canceled'] == 1 ? '</s>' : '') + '</b></div>';
// ZEILE 2
list += '<div>';
// Number
list += '<div>' + ((regatta['number'] != null) ? ('# ' + regatta['number']) : '') + '</div>';
// Club
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
list += '<div>' + regatta['special'] + '</div>';
// Icons
var icons = [];
if (regatta['info'] != '')
@@ -320,18 +324,18 @@ var siteScript = async function() {
icons.push('<i class="fas fa-poll"></i>');
}
list += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
list += '</div>';
// ZEILE 3
list += '<div>';
// Date
list += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
// RLF
list += '<div>' + parseFloat(regatta['rlf']).toFixed(2) + '</div>';
list += '</div></div>';
}
$('#div-last').html(list);
@@ -341,6 +345,6 @@ var siteScript = async function() {
$('#div-last').hide();
$('#p-last').show();
}
hideLoader();
}
}

88
server/scripts/news.js Normal file
View File

@@ -0,0 +1,88 @@
var firstCall = true;
var rows = [];
var page = 1;
var pageCount = 0;
const showCount = 10;
async function onNewsClicked(id) {
var newsEntry = await dbGetData('news', id);
if (newsEntry == null) return;
$('#menu-news').css('height', '80%');
$('#menu-news').css('width', '90%');
$('#menu-news').find('.menu-title').find('p').text(newsEntry.title);
$('#menu-news').find('.content').addClass('pb-3');
$('#menu-news').find('.content').html(newsEntry.html);
$('#menu-news').showMenu();
}
function pageChange() {
$('h1')[0].scrollIntoView({ behavior: "smooth" });
drawList();
}
function addCard(newsEntry) {
var badge = '';
if (newsEntry.unread) {
badge += '<span class="badge bg-highlight color-white p-1">NEW</span>&ensp;';
}
var content = '<h2>' + badge + newsEntry.title + '</h2>';
content += '<p class="mb-2"><i>' + formatDate('d.m.Y', newsEntry.date) + '</i></p>';
content += '<p class="mb-0">' + newsEntry.description.replace('\n', '<br>') + '</p>';
if (newsEntry.html != '') {
content += '<a class="btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight mt-3" href="#" onclick="onNewsClicked(' + newsEntry.id + '); return false;">Mehr lesen</a>';
}
$('#news-entries').append(cardTemplate.replace('%ID%', 'card-news-' + newsEntry.id).replace('%CONTENT%', content));
}
async function drawList() {
$('.card-news').remove();
if (rows.length > 0) {
var offset = (page - 1) * showCount;
var count = (page == pageCount ? (rows.length % showCount) : showCount);
if (count == 0) count = showCount;
for (i = 0; i < count; i ++) {
addCard(rows[i + offset]);
}
}
}
var siteScript = async function() {
if (firstCall) {
firstCall = false;
initPagination();
}
rows = [];
var news = await dbGetData('news');
news.sort(function (a,b) {
return b.date.localeCompare(a.date);
});
var newsRead = await dbSettingsGet('news_read_' + BOATCLASS);
var now = new Date();
var lastYear = new Date();
lastYear.setFullYear(lastYear.getFullYear() - 1);
for (var n in news) {
var newsEntry = news[n];
newsEntry.date = new Date(Date.parse(newsEntry.date));
if (newsEntry.date > now) continue;
if (newsEntry.date < lastYear) break;
newsEntry.unread = (newsEntry.date > newsRead);
rows.push(newsEntry);
}
pageCount = Math.ceil(rows.length / showCount);
if ((page < 1) || (page > pageCount)) {
if (page < 1) {
page = 1;
} else {
page = pageCount;
}
}
drawPagination();
drawList();
dbSettingsSet('news_read_' + BOATCLASS, now);
updateNewsBadge();
hideLoader();
}

View File

@@ -1,11 +1,11 @@
async function onRegattaClicked(id) {
var regatta = await dbGetData('regattas', id);
$('#menu-regatta').find('.menu-title').find('p').text(regatta.name);
var dateTo = parseDate(regatta['date']);
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
var planning = null;
if (isLoggedIn()) {
@@ -16,7 +16,7 @@ async function onRegattaClicked(id) {
}
}
}
// Your Planning
if (planning != null) {
$('#menu-item-yourplanning').show();
@@ -32,11 +32,26 @@ async function onRegattaClicked(id) {
crew.push(sailor.name);
}
}
var status = '';
if (planning.gemeldet == '1') status = 'gemeldet';
if (planning.bezahlt == '1') {
if (status != '') status += ' und ';
status += 'bezahlt';
}
if (status != '') crew.push('<font style="font-style:italic;">' + status + '</font>');
$('#menu-item-yourplanning').html(crew.join('<br>'));
} else {
$('#menu-item-yourplanning').hide();
}
// Planning: Edit Status
if ((planning != null) && (typeof planningEditStatus === 'function')) {
$('#menu-item-status').show();
$('#menu-item-status').attr('onclick', 'planningEditStatus(' + regatta['id'] + ')');
} else {
$('#menu-item-status').hide();
}
// Planning
if ((plannings.length > 0) && (dateTo >= today)) {
$('#menu-item-plannings').show();
@@ -44,7 +59,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-plannings').hide();
}
// Results
var results = await dbGetDataIndex('results', 'regatta', regatta['id']);
if (results.length > 0) {
@@ -53,7 +68,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-results').hide();
}
// Bericht
if (regatta['bericht'] != '') {
$('#menu-item-bericht').show();
@@ -62,7 +77,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-bericht').hide();
}
// Info
if (regatta['info'] != '') {
$('#menu-item-info').show();
@@ -71,7 +86,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-info').hide();
}
// Meldung
if ((regatta['meldung'] != '') && (dateTo >= today)) {
$('#menu-item-meldung').show();
@@ -129,7 +144,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-meldung').hide();
}
// off. results
if (regatta['oresults'] != '') {
$('#menu-item-oresults').show();
@@ -138,7 +153,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-oresults').hide();
}
// club website
var clubwebsite = '';
if (regatta['club'] != null) {
@@ -151,7 +166,7 @@ async function onRegattaClicked(id) {
} else {
$('#menu-item-clubwebsite').hide();
}
$('#menu-regatta').showMenu();
$('#menu-regatta').scrollTop(0);
}
}

314
server/scripts/planning.js Normal file
View File

@@ -0,0 +1,314 @@
async function planningSwitchChanged() {
showLoader();
var id = $('#switch-status-gemeldet').data('regatta');
var gemeldet = $('#switch-status-gemeldet').prop('checked');
var bezahlt = $('#switch-status-bezahlt').prop('checked');
var auth = {
id: localStorage.getItem('auth_id'),
hash: localStorage.getItem('auth_hash')
}
$.ajax({
url: QUERY_URL + 'planning_set_state',
method: 'POST',
data: {
auth: auth,
regatta: id,
gemeldet: gemeldet,
bezahlt: bezahlt
},
error: function (xhr, status, error) {
if (xhr.status == 401) {
console.log('authentification failed');
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
} else if (xhr.status == 0) {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Status zu &auml;ndern');
} else {
console.log('Login: unbekannter Fehler', status, error);
console.log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
}
$('#menu-status').hideMenu();
hideLoader();
},
success: function (data, status, xhr) {
sync();
hideLoader();
}
});
console.log(id, gemeldet, bezahlt);
hideLoader();
}
async function planningEditStatus(id) {
$('#menu-regatta').hideMenu();
var regatta = await dbGetData('regattas', id);
$('#menu-status').find('.menu-title').find('p').text(regatta.name);
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
var planning = null;
if (isLoggedIn()) {
for (i in plannings) {
if (plannings[i]['user'] == USER_ID) {
planning = plannings[i];
break;
}
}
}
if (planning !== null) {
$('#switch-status-gemeldet').data('regatta', id);
$('#switch-status-gemeldet').prop('checked', planning.gemeldet == '1');
$('#switch-status-bezahlt').prop('checked', planning.bezahlt == '1');
$('#menu-status').showMenu();
}
}
function selectChange() {
var val = $('#select-year').val();
if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val);
siteScript();
}
}
function initYear() {
var year = findGetParameter('year');
if (year === null) year = new Date().getFullYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year);
}
var firstCall = true;
var rows = [];
var today;
async function drawList () {
window.setTimeout(function () {
var list = '';
rows.forEach(function (entry) {
if (entry == null) {
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
} else if (search($('#input-search').val(), entry.keywords)) {
list += entry.content;
}
});
$('#div-regattas').html(list);
}, 0);
}
var siteScript = async function() {
if (!isLoggedIn()) {
hideLoader();
return;
}
if (firstCall) {
firstCall = false;
initYear();
$('#select-year').change(selectChange);
$('#input-search').on('input', drawList);
$('#switch-status-gemeldet').parent().parent().click(planningSwitchChanged);
$('#switch-status-bezahlt').parent().parent().click(planningSwitchChanged);
}
$('#a-share-planning').attr('href', LINK_PRE + 'planning_view?user=' + USER_ID);
today = getToday();
var selectedYear = $('#select-year').val();
var minDate = parseDate(selectedYear + '-01-01');
var maxDate = parseDate(selectedYear + '-12-31');
var regattas = await dbGetRegattasRange(minDate, maxDate);
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
for (var i = regattas.length - 1; i >= 0; i --) {
var entry = regattas[i];
var okay = false;
for (p in plannings) {
if (plannings[p].regatta == entry.id) {
regattas[i].planning = plannings[p];
okay = true;
break;
}
}
if (!okay) {
regattas.splice(i, 1);
}
}
var regattaResults = [];
for (id in regattas) {
var entry = regattas[id];
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
regattaResults[entry['id']] = (results.length > 0);
}
var years = await dbGetData('years');
years.sort(function (a, b) {
if (a['year'] > b['year']) return -1;
if (a['year'] < b['year']) return 1;
return 0;
});
var options = '';
for (id in years) {
var year = years[id]['year'];
options += '<option value="' + year + '">' + year + '</option>';
}
$('#select-year').html(options);
$('#select-year').val(selectedYear);
var count = regattas.length;
if (count > 0) {
if (count == 1) {
$('#p-count').html('Es wurde 1 Regatta gefunden!');
} else {
$('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
}
$('#div-regattas').show();
$('#input-search').parent().show();
var heute = false;
rows = [];
for (id in regattas) {
var entry = regattas[id];
var club = null;
if (entry['club'] != null)
club = await dbGetData('clubs', entry['club']);
if (entry.planning.steuermann !== null) {
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
}
var crewString = entry.planning.crew.split(',');
entry.planning.crew = [];
for (c in crewString) {
var sailor = await dbGetData('sailors', crewString[c]);
if (sailor !== null) {
entry.planning.crew.push(sailor.name);
}
}
var dateFrom = entry['dateFrom'];
var dateTo = entry['dateTo'];
var row = { keywords: [], content: '' };
row.keywords.push(entry['name']);
if (entry['number'] != null) row.keywords.push(entry['number']);
if (club != null) row.keywords.push(club['kurz'], club['name']);
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
if (!heute && (today <= dateFrom)) {
rows.push(null);
heute = true;
}
row.content += '<div onclick="onRegattaClicked(' + entry['id'] + ');">';
// ZEILE 1
// Name
row.content += '<div><b>' + (entry['canceled'] == 1 ? '<s>' : '') + entry['name'] + (entry['canceled'] == 1 ? '</s>' : '') + '</b></div>';
// ZEILE 2
row.content += '<div>';
// Number
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Club
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
row.content += '<div>' + entry['special'] + '</div>';
// Icons
var icons = [];
if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1') && (entry.planning.gemeldet != '1')) {
var color = '';
var planning = null;
if (isLoggedIn()) {
var plannings = await dbGetDataIndex('plannings', 'regatta', entry['id']);
for (id in plannings) {
if (plannings[id]['user'] == USER_ID) {
planning = plannings[id];
break;
}
}
}
if (entry['meldungSchluss'] != null) {
if ((planning == null) || (planning['gemeldet'] == '0')) {
var ms = 0;
if (entry['meldungEarly'] != null) {
ms = parseDate(entry['meldungEarly']);
}
if (ms < today) {
ms = parseDate(entry['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if (ms < today) {
color = ' color-red2-dark';
} else if (diff < 7) {
color = ' color-yellow2-dark';
}
}
}
if ((planning != null) && (planning['gemeldet'] == '0')) {
color += ' fa-blink';
}
icons.push('<i class="fas fa-file-signature' + color + '"></i>');
}
if (entry['bericht'] != '')
icons.push('<i class="fas fa-book"></i>');
if (entry['canceled'] == '1') {
icons.push('<i class="fas fa-times color-red2-dark"></i>');
} else if (regattaResults[entry['id']]) {
icons.push('<i class="fas fa-poll"></i>');
}
if (entry.planning.gemeldet == '1') {
icons.push('<i class="fas fa-file-signature color-highlight"></i>');
}
if (entry.planning.bezahlt == '1') {
icons.push('<i class="fas fa-euro-sign color-highlight"></i>');
}
row.content += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
row.content += '</div>';
// ZEILE 3
row.content += '<div>';
// Date
if (entry['length'] < 1) {
if (formatDate('d.m', dateFrom) == '01.01') {
row.content += '<div><font class="color-red2-dark">Datum noch unklar</font></div>';
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font></div>';
}
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
}
// RLF
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
row.content += '</div></div>';
rows.push(row);
}
if (!heute) {
rows.push(null);
}
drawList();
} else {
$('#p-count').html('Du hast noch keine Regatten in Deiner Saison-Planung!');
$('#div-regattas').hide();
$('#input-search').parent().hide();
}
hideLoader();
}

View File

@@ -0,0 +1,146 @@
async function onUserClicked(id) {
var user = await dbGetData('users', id);
if (user !== null) {
location.href = LINK_PRE + 'planning_view?user=' + user.id;
}
}
function selectChange() {
var val = $('#select-year').val();
if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val);
siteScript();
}
}
function initYear() {
var year = findGetParameter('year');
if (year === null) year = new Date().getFullYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year);
}
var firstCall = true;
var rows = [];
var today;
async function drawList () {
window.setTimeout(function () {
var list = '';
rows.forEach(function (entry) {
if (search($('#input-search').val(), entry.keywords)) {
list += entry.content;
}
});
$('#div-users').html(list);
}, 0);
}
var siteScript = async function() {
if (!isLoggedIn()) {
hideLoader();
return;
}
if (firstCall) {
firstCall = false;
initYear();
$('#select-year').change(selectChange);
$('#input-search').on('input', drawList);
}
var selectedYear = $('#select-year').val();
var minDate = parseDate(selectedYear + '-01-01');
var maxDate = parseDate(selectedYear + '-12-31');
var regattas = await dbGetRegattasRange(minDate, maxDate);
var plannings = {};
for (var i in regattas) {
var entry = regattas[i];
var planning = await dbGetDataIndex('plannings', 'regatta', entry.id);
for (p in planning) {
if (!(planning[p].user in plannings)) {
plannings[planning[p].user] = {
user: await dbGetData('users', planning[p].user),
regattas: [],
sailors: {}
};
}
plannings[planning[p].user].regattas.push(entry);
var sailor = null;
if (planning[p].steuermann !== null) sailor = await dbGetData('sailors', planning[p].steuermann);
if (sailor !== null) {
if (!(sailor.id in plannings[planning[p].user].sailors)) plannings[planning[p].user].sailors[sailor.id] = sailor.name;
}
var crew = planning[p].crew.split(',');
for (i in crew) {
sailor = await dbGetData('sailors', crew[i]);
if (sailor !== null) {
if (!(sailor.id in plannings[planning[p].user].sailors)) plannings[planning[p].user].sailors[sailor.id] = sailor.name;
}
}
}
}
plannings = Object.values(plannings);
plannings.sort(function(a,b){
return a.user.username.localeCompare(b.user.username);
});
var years = await dbGetData('years');
years.sort(function (a, b) {
if (a['year'] > b['year']) return -1;
if (a['year'] < b['year']) return 1;
return 0;
});
var options = '';
for (id in years) {
var year = years[id]['year'];
options += '<option value="' + year + '">' + year + '</option>';
}
$('#select-year').html(options);
$('#select-year').val(selectedYear);
var count = plannings.length;
if (count > 0) {
$('#input-search').parent().show();
rows = [];
for (id in plannings) {
var entry = plannings[id];
var row = { keywords: [], content: '' };
row.keywords.push(entry.user.username);
for (i in entry.sailors) {
row.keywords.push(entry.sailors[i]);
}
row.content += '<div onclick="onUserClicked(' + entry.user.id + ');">';
// ZEILE 1
row.content += '<div></div>';
// ZEILE 2
row.content += '<div>';
// Name
row.content += '<div>' + entry.user.username + '</div>';
// Count of regattas
row.content += '<div>' + entry.regattas.length + ' Regatten</div>';
row.content += '</div></div>';
rows.push(row);
}
drawList();
} else {
$('#div-users').html('Es hat noch niemand eine Saison-Planung erstellt');
$('#input-search').parent().hide();
}
hideLoader();
}

View File

@@ -0,0 +1,290 @@
function selectChange() {
var val = $('#select-year').val();
if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=' + val);
siteScript();
}
}
function initYear() {
var year = findGetParameter('year');
if (year === null) year = new Date().getFullYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year);
}
var firstCall = true;
var rows = [];
var today;
async function drawList () {
window.setTimeout(function () {
var list = '';
rows.forEach(function (entry) {
if (entry == null) {
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
} else if (search($('#input-search').val(), entry.keywords)) {
list += entry.content;
}
});
$('#div-regattas').html(list);
}, 0);
}
var siteScript = async function() {
var userid = findGetParameter('user');
var user = null;
if (userid !== null) {
user = await dbGetData('users', userid);
}
if (user === null) {
location.href = LINK_PRE + 'planning_list';
return;
}
$('#p-username').text(user.username);
if (isLoggedIn() && (userid == USER_ID)) {
$('#button-share').show();
$('#button-share').click(function(){
$('#menu-share').showMenu();
});
} else {
$('#button-share').hide();
}
if (firstCall) {
firstCall = false;
initYear();
$('#select-year').change(selectChange);
$('#input-search').on('input', drawList);
}
today = getToday();
var selectedYear = $('#select-year').val();
var minDate = parseDate(selectedYear + '-01-01');
var maxDate = parseDate(selectedYear + '-12-31');
var regattas = await dbGetRegattasRange(minDate, maxDate);
var plannings = await dbGetDataIndex('plannings', 'user', user.id);
for (var i = regattas.length - 1; i >= 0; i --) {
var entry = regattas[i];
var okay = false;
for (p in plannings) {
if (plannings[p].regatta == entry.id) {
regattas[i].planning = plannings[p];
okay = true;
break;
}
}
if (!okay) {
regattas.splice(i, 1);
}
}
var regattaResults = [];
for (id in regattas) {
var entry = regattas[id];
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
regattaResults[entry['id']] = (results.length > 0);
}
var years = await dbGetData('years');
years.sort(function (a, b) {
if (a['year'] > b['year']) return -1;
if (a['year'] < b['year']) return 1;
return 0;
});
var options = '';
for (id in years) {
var year = years[id]['year'];
options += '<option value="' + year + '">' + year + '</option>';
}
$('#select-year').html(options);
$('#select-year').val(selectedYear);
var count = regattas.length;
if (count > 0) {
if (count == 1) {
$('#p-count').html('Es wurde 1 Regatta gefunden!');
} else {
$('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
}
$('#div-regattas').show();
$('#input-search').parent().show();
var heute = false;
rows = [];
for (id in regattas) {
var entry = regattas[id];
var club = null;
if (entry['club'] != null)
club = await dbGetData('clubs', entry['club']);
if (entry.planning.steuermann !== null) {
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
}
var crewString = entry.planning.crew.split(',');
entry.planning.crew = [];
for (c in crewString) {
var sailor = await dbGetData('sailors', crewString[c]);
if (sailor !== null) {
entry.planning.crew.push(sailor.name);
}
}
var dateFrom = entry['dateFrom'];
var dateTo = entry['dateTo'];
var row = { keywords: [], content: '' };
row.keywords.push(entry['name']);
if (entry['number'] != null) row.keywords.push(entry['number']);
if (club != null) row.keywords.push(club['kurz'], club['name']);
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
if (!heute && (today <= dateFrom)) {
rows.push(null);
heute = true;
}
row.content += '<div onclick="onRegattaClicked(' + entry['id'] + ');">';
// ZEILE 1
// Name
row.content += '<div><b>' + (entry['canceled'] == 1 ? '<s>' : '') + entry['name'] + (entry['canceled'] == 1 ? '</s>' : '') + '</b></div>';
// ZEILE 2
row.content += '<div>';
// Number
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Special
row.content += '<div>' + entry['special'] + '</div>';
// Club
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
row.content += '</div>';
// ZEILE 3
row.content += '<div>';
// Date
if (entry['length'] < 1) {
if (formatDate('d.m', dateFrom) == '01.01') {
row.content += '<div><font class="color-red2-dark">Datum noch unklar</font></div>';
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font></div>';
}
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
}
// RLF
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
row.content += '</div>';
// ZEILE 4
row.content += '<div></div>';
// ZEILE 5
row.content += '<div>';
row.content += '<div>' + entry.planning.steuermann + '</div>';
row.content += '</div>';
// ZEILE 6...
for (var i in entry.planning.crew) {
row.content += '<div>';
row.content += '<div>' + entry.planning.crew[i] + '</div>';
row.content += '</div>';
}
row.content += '</div>';
/*
// ZEILE 2
row.content += '<div>';
// Number
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Club
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
row.content += '<div>' + entry['special'] + '</div>';
// Icons
var icons = [];
if (entry['info'] != '')
icons.push('<i class="fas fa-info"></i>');
if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1')) {
var color = '';
if (entry['meldungSchluss'] != null) {
var ms = 0;
if (entry['meldungEarly'] != null) {
ms = parseDate(entry['meldungEarly']);
}
if (ms < today) {
ms = parseDate(entry['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if (ms < today) {
color = ' color-red2-dark';
} else if (diff < 7) {
color = ' color-yellow2-dark';
}
}
icons.push('<i class="fas fa-file-signature' + color + '"></i>');
}
if (entry['bericht'] != '')
icons.push('<i class="fas fa-book"></i>');
if (entry['canceled'] == '1') {
icons.push('<i class="fas fa-times color-red2-dark"></i>');
} else if (regattaResults[entry['id']]) {
icons.push('<i class="fas fa-poll"></i>');
}
row.content += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
row.content += '</div>';
// ZEILE 3
row.content += '<div>';
// Date
if (entry['length'] < 1) {
if (formatDate('d.m', dateFrom) == '01.01') {
row.content += '<div><font class="color-red2-dark">Datum noch unklar</font></div>';
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font></div>';
}
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
}
// RLF
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
row.content += '</div></div>';
*/
rows.push(row);
}
if (!heute) {
rows.push(null);
}
drawList();
} else {
$('#p-count').html(user.username + ' hat noch keine Regatten in seiner/ihrer Saison-Planung!');
$('#div-regattas').hide();
$('#input-search').parent().hide();
}
hideLoader();
}

View File

@@ -11,7 +11,7 @@ async function onRankingClicked(id) {
}
}
if (sailor == null) return;
$('#menu-rank').find('.menu-title').find('p').text(sailor.name);
if (lastRanking != null) {
var lastRank;
@@ -25,83 +25,83 @@ async function onRankingClicked(id) {
} else {
$('#menu-item-text').hide();
}
list = '';
for (var i in sailor.regattas) {
var entry = sailor.regattas[i];
var regatta = entry.regatta;
var boat = await dbGetData('boats', entry.boat);
var dateFrom = parseDate(regatta.date);
var dateTo = parseDate(regatta.date);
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta.length) - 1, 0));
list += '<div onclick="onDetailClicked(' + regatta.id + ')">';
// ZEILE 1
list += '<div><b>' + regatta.name + '</b></div>';
// ZEILE 2
list += '<div>';
// DATE
list += '<div>' + formatDate('d.m.Y', dateFrom) + ' - ' + formatDate('d.m.Y', dateTo) + '</div>';
// m
list += '<div>m: ' + entry.m + '</div>';
// rlf
list += '<div>RLF: ' + parseFloat(regatta.rlf).toFixed(2) + '</div>';
list += '</div>';
// ZEILE 3
list += '<div>';
// Place
list += '<div>Platz ' + entry.place + ' / ' + entry.fb + '</div>';
// rlp
var color;
if (entry.used == 0) { color = 'color-red2-dark'; }
else if (entry.used == entry.m) { color = 'color-green2-dark'; }
else { color = 'color-yellow2-dark'; }
list += '<div>Punkte: ' + entry.used + ' x <b class="' + color + '">' + parseFloat(entry.rlp).toFixed(2) + '</b></div>';
list += '</div>';
// ZEILE 4
list += '<div>';
// Sailnumber
list += '<div>' + boat.sailnumber + '</div>';
// Boatname
list += '<div>' + boat.name + '</div>';
list += '</div>';
// ZEILE 5...
var crew = entry.crew.split(',');
for (var c in crew) {
var cr = await dbGetData('sailors', crew[c]);
if (cr != null) {
list += '<div>';
// Name
list += '<div>' + cr.name + '</div>';
// Year
list += '<div>' + ((cr.year != null) ? ('(' + cr.year + ')') : '') + '</div>';
list += '</div>';
}
}
list += '</div>';
}
$('#div-details').html(list);
$('#menu-rank').showMenu();
$('#menu-rank').scrollTop(0);
}
@@ -111,8 +111,8 @@ async function selectChange(callSiteScript = true) {
var year = parseInt($('#select-year').val());
if (type == "user") {
$('#select-year').parent().hide();
$('#input-from').parent().show();
$('#input-to').parent().show();
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
$('#input-jugend').parent().parent().show();
$('#input-jugstrict').parent().parent().show();
$('#button-show').show();
@@ -123,7 +123,7 @@ async function selectChange(callSiteScript = true) {
$('#input-jugend').parent().parent().hide();
$('#input-jugstrict').parent().parent().hide();
$('#button-show').hide();
var from, to, jugend, jugstrict;
switch (type) {
case 'year':
@@ -168,14 +168,26 @@ async function selectChange(callSiteScript = true) {
}
break;
}
$('#input-from').val(from);
$('#input-to').val(to);
$('#input-jugend').prop('checked', jugend);
$('#input-jugstrict').prop('checked', jugstrict);
if (callSiteScript && (typeof siteScript === 'function'))
if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?type=' + type + '&year=' + year)
siteScript();
}
}
}
function buttonShowPressed() {
if (typeof siteScript === 'function') {
var chboxes = '';
if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on'
if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on'
history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes)
siteScript();
}
}
@@ -186,10 +198,23 @@ function initSelects() {
if (year === null) year = new Date().getFullYear();
$('#select-type').val(type);
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year);
if (type == "user") {
var from = findGetParameter('from');
var to = findGetParameter('to');
if (from === null) from = formatDate('Y-m-d')
if (to === null) to = formatDate('Y-m-d')
$('#input-from').val(from).trigger('focusin').trigger('focusout');
$('#input-to').val(to).trigger('focusin').trigger('focusout');
var jugend = findGetParameter('jugend');
var jugstrict = findGetParameter('jugstrict');
$('#input-jugend').prop('checked', jugend !== null);
$('#input-jugstrict').prop('checked', jugstrict !== null);
}
selectChange(false);
}
@@ -218,17 +243,17 @@ var siteScript = async function() {
initSelects();
$('#select-type').change(selectChange);
$('#select-year').change(selectChange);
$('#button-show').click(siteScript);
$('#button-show').click(buttonShowPressed);
$('#input-search').on('input', drawList);
}
var minDate = parseDate($('#input-from').val());
var maxDate = parseDate($('#input-to').val());
var jugend = $('#input-jugend').prop('checked');
var jugstrict = $('#input-jugstrict').prop('checked');
var dbRanking = await dbGetRanking(minDate, maxDate, jugend, jugstrict);
ranking = dbRanking[0];
lastRanking = null;
if (($('#select-type').val() == 'year') || ($('#select-type').val() == 'youth')) {
lastRanking = {};
@@ -240,9 +265,9 @@ var siteScript = async function() {
lastRanking[lDbRanking[i].id] = lDbRanking[i].rank;
}
}
var selectedYear = $('#select-year').val();
var years = await dbGetData('years');
years.sort(function (a, b) {
if (a['year'] > b['year']) return -1;
@@ -256,7 +281,7 @@ var siteScript = async function() {
}
$('#select-year').html(options);
$('#select-year').val(selectedYear);
if (dbRanking[1].length > 0) {
$('#card-noresults').show();
list = '';
@@ -269,18 +294,18 @@ var siteScript = async function() {
} else {
$('#card-noresults').hide();
}
var count = ranking.length;
if (count > 0) {
$('#input-search').parent().show();
var dsvEnd = false;
rows = [];
for (id in ranking) {
var entry = ranking[id];
for (var i in entry.regattas) {
entry.regattas[i].regatta = await dbGetData('regattas', entry.regattas[i].regatta);
}
@@ -288,26 +313,26 @@ var siteScript = async function() {
entry.regattas.sort(function (a,b) {
return a.regatta.date.localeCompare(b.regatta.date);
});
var club = null;
if (entry['club'] != null)
club = await dbGetData('clubs', entry['club']);
var row = { keywords: [], content: '' };
row.keywords.push(entry['name']);
if (entry['year'] != null) row.keywords.push(entry['year']);
if (club != null) row.keywords.push(club['kurz'], club['name']);
if (!dsvEnd && (entry.m < 9)) {
rows.push(null);
dsvEnd = true;
}
row.content += '<div onclick="onRankingClicked(' + entry['id'] + ');">';
// ZEILE 1
row.content += '<div>';
// Rank
var icon = '';
if (lastRanking != null) {
@@ -321,39 +346,39 @@ var siteScript = async function() {
icon = '<i class="font-16 fas ' + icon + '" style="width: 1.1em; text-align: center;"></i> ';
}
row.content += '<div>' + icon + '<b>' + entry.rank + '.</b></div>';
// m
row.content += '<div>m = ' + entry.m + '</div>';
// rlp
row.content += '<div>' + entry.rlp.toFixed(3) + '</div>';
row.content += '</div>';
// ZEILE 2
row.content += '<div>';
// Name
row.content += '<div><b>' + entry.name + '</b></div>';
// Year
row.content += '<div>' + ((entry.year != null) ? ('(' + entry.year + ')') : '') + '</div>';
row.content += '</div></div>';
rows.push(row);
}
if (!dsvEnd) {
rows.push(null);
}
drawList();
} else {
$('#div-rank').html('Keine Ergebnisse gefunden!');
$('#input-search').parent().hide();
}
hideLoader();
}
}

View File

@@ -1,29 +1,47 @@
function selectChange(callSiteScript = true) {
var val = $('#select-year').val();
if (val == "user") {
$('#input-from').parent().show();
$('#input-to').parent().show();
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
$('#button-show').show();
} else {
$('#input-from').parent().hide();
$('#input-to').parent().hide();
$('#button-show').hide();
$('#input-from').val(val + '-01-01');
$('#input-to').val(val + '-12-31');
if (callSiteScript && (typeof siteScript === 'function'))
if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?year=' + val);
siteScript();
}
}
}
function buttonShowPressed() {
if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val())
siteScript();
}
}
function initYear() {
var year = findGetParameter('year');
if (year === null) year = new Date().getFullYear();
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#select-year').val(year);
if (year == "user") {
var from = findGetParameter('from');
var to = findGetParameter('to');
if (from === null) from = formatDate('Y-m-d')
if (to === null) to = formatDate('Y-m-d')
$('#input-from').val(from).trigger('focusin').trigger('focusout');
$('#input-to').val(to).trigger('focusin').trigger('focusout');
}
selectChange(false);
}
@@ -50,12 +68,12 @@ var siteScript = async function() {
firstCall = false;
initYear();
$('#select-year').change(selectChange);
$('#button-show').click(siteScript);
$('#button-show').click(buttonShowPressed);
$('#input-search').on('input', drawList);
}
today = getToday();
var minDate = parseDate($('#input-from').val());
var maxDate = parseDate($('#input-to').val());
var regattas = await dbGetRegattasRange(minDate, maxDate);
@@ -65,9 +83,9 @@ var siteScript = async function() {
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
regattaResults[entry['id']] = (results.length > 0);
}
var selectedYear = $('#select-year').val();
var years = await dbGetData('years');
years.sort(function (a, b) {
if (a['year'] > b['year']) return -1;
@@ -81,7 +99,7 @@ var siteScript = async function() {
}
$('#select-year').html(options);
$('#select-year').val(selectedYear);
var count = regattas.length;
if (count > 0) {
if (count == 1) {
@@ -91,49 +109,49 @@ var siteScript = async function() {
}
$('#div-regattas').show();
$('#input-search').parent().show();
var heute = false;
rows = [];
for (id in regattas) {
var entry = regattas[id];
var club = null;
if (entry['club'] != null)
club = await dbGetData('clubs', entry['club']);
var plannings = await dbGetDataIndex('plannings', 'regatta', entry['id']);
var dateFrom = entry['dateFrom'];
var dateTo = entry['dateTo'];
var row = { keywords: [], content: '' };
row.keywords.push(entry['name']);
if (entry['number'] != null) row.keywords.push(entry['number']);
if (club != null) row.keywords.push(club['kurz'], club['name']);
if (!heute && (today <= dateFrom)) {
rows.push(null);
heute = true;
}
row.content += '<div onclick="onRegattaClicked(' + entry['id'] + ');">';
// ZEILE 1
// Name
row.content += '<div><b>' + (entry['canceled'] == 1 ? '<s>' : '') + entry['name'] + (entry['canceled'] == 1 ? '</s>' : '') + '</b></div>';
// ZEILE 2
row.content += '<div>';
// Number
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Club
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
row.content += '<div>' + entry['special'] + '</div>';
// Icons
var icons = [];
if (entry['info'] != '')
@@ -160,8 +178,10 @@ var siteScript = async function() {
ms = parseDate(entry['meldungSchluss']);
}
var diff = Math.round((ms - today) / 86400000);
if ((ms >= today) && (diff < 7)) {
if (ms < today) {
color = ' color-red2-dark';
} else if (diff < 7) {
color = ' color-yellow2-dark';
}
}
}
@@ -178,12 +198,12 @@ var siteScript = async function() {
icons.push('<i class="fas fa-poll"></i>');
}
row.content += '<div class="color-green2-dark">' + icons.join('&ensp;') + '</div>';
row.content += '</div>';
// ZEILE 3
row.content += '<div>';
// Date
if (entry['length'] < 1) {
if (formatDate('d.m', dateFrom) == '01.01') {
@@ -194,26 +214,26 @@ var siteScript = async function() {
} else {
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
}
// RLF
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
row.content += '</div></div>';
rows.push(row);
}
if (!heute) {
rows.push(null);
}
drawList();
} else {
$('#p-count').html('Keine Regatten gefunden!');
$('#div-regattas').hide();
$('#input-search').parent().hide();
}
hideLoader();
}
}

View File

@@ -21,8 +21,8 @@ async function onEditYearClick() {
if (xhr.status == 0) {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Jahrgang zu bearbeiten');
} else {
console.log('EditYear: unbekannter Fehler', status, error);
console.log(xhr);
log('EditYear: unbekannter Fehler', status, error);
log(xhr);
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
}
hideLoader();
@@ -47,9 +47,9 @@ async function onEditYearClick() {
async function onListClicked(id) {
var sailor = await dbGetData('sailors', id);
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
// Edit Year
$('#button-edityear').attr('data-sailor-id', sailor.id);
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
@@ -63,7 +63,7 @@ async function onListClicked(id) {
$('#input-edityear').val(sailor.year);
}
$('#input-edityear').trigger('focusin').trigger('focusout');
// club website
var clubwebsite = '';
if (sailor['club'] != null) {
@@ -76,7 +76,7 @@ async function onListClicked(id) {
} else {
$('#menu-item-clubwebsite').hide();
}
$('#menu-sailor').showMenu();
$('#menu-sailor').scrollTop(0);
}
@@ -89,19 +89,19 @@ function pageChange() {
async function drawList() {
window.setTimeout(function () {
var list = '';
if (displayed.length > 0) {
var offset = (page - 1) * showCount;
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
if (count == 0) count = showCount;
for (i = 0; i < count; i ++) {
list += displayed[i + offset];
}
} else {
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
}
$('#div-list').html(list);
}, 0);
}
@@ -135,9 +135,9 @@ var siteScript = async function() {
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
$('#button-edityear').click(onEditYearClick);
}
var results = await dbGetData('sailors');
var count = results.length;
if (count > 0) {
if (count == 1) {
@@ -147,51 +147,51 @@ var siteScript = async function() {
}
$('#div-list').show();
$('#input-search').parent().show();
results.sort(function (a, b) {
return a.name.localeCompare(b.name);
});
rows = [];
for (id in results) {
var entry = results[id];
var club = null;
if (entry['club'] != null)
club = await dbGetData('clubs', entry['club']);
var row = { keywords: [], content: '' };
row.keywords.push(entry['name']);
if (entry['year'] != null) row.keywords.push(entry['year']);
if (club != null) row.keywords.push(club['kurz'], club['name']);
row.content += '<div onclick="onListClicked(' + entry['id'] + ');">';
// ZEILE 1
// Name
row.content += '<div><b>' + entry['name'] + '</b></div>';
// ZEILE 2
row.content += '<div>';
// Year
row.content += '<div>' + ((entry['year'] != null) ? (entry['year']) : '') + '</div>';
// Club
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
row.content += '</div></div>';
rows.push(row);
}
reSearch();
} else {
$('#p-count').html('Keine Segler gefunden!');
$('#div-list').hide();
$('#input-search').parent().hide();
}
hideLoader();
}
}

View File

@@ -0,0 +1,8 @@
<a href="#" data-trigger-switch="$$html-id;" class="pb-2 $$css-class;">
<i class="fa font-14 $$icon; rounded-s bg-highlight color-white"></i>
<span>$$0;</span>
<div class="custom-control scale-switch ios-switch">
<input type="checkbox" class="ios-input" id="$$html-id;">
<label class="custom-control-label" for="$$html-id;"></label>
</div>
</a>

View File

@@ -1,5 +1,5 @@
<?php
define('PWA_VERSION', '1.5');
?>
define('PWA_VERSION', '1.9.2');
?>

View File

@@ -1,9 +1,9 @@
<?php
header('Content-Type: text/javascript');
require_once(__DIR__ . '/server/config.php');
?>
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
@@ -41,7 +41,7 @@ workbox.precaching.precacheAndRoute([
return $hash;
}
$hash = md5(getDirHash(__DIR__));
$path = __DIR__ . '/server/content/';
$dir = opendir($path);
while ($file = readdir($dir)) {
@@ -50,21 +50,25 @@ workbox.precaching.precacheAndRoute([
echo "\t{url: '$file', revision: '$hash'},\n";
}
closedir($dir);
// ASSETS
$filesToCache = [
'/manifest.json.php',
];
$dirsToCache = [
'/client',
'/client/app',
'/client/fonts/css',
'/client/fonts/webfonts',
'/client/images',
'/client/scripts',
'/client/styles',
];
function addDir($path) {
global $filesToCache;
if ($dir = opendir(__DIR__ . $path)) {
while (($file = readdir($dir)) !== false) {
if ($file == '.') continue;
if ($file == '..') continue;
if (substr($file, 0, 1) == '.') continue;
if (is_dir(__DIR__ . $path . '/' . $file)) {
addDir($path . '/' . $file);
} else {
@@ -74,11 +78,11 @@ workbox.precaching.precacheAndRoute([
closedir($dir);
}
}
foreach ($dirsToCache as $path) {
addDir($path);
}
foreach ($filesToCache as $file) {
$revision = md5_file(__DIR__ . $file);
$file = SERVER_ADDR . $file;
@@ -104,4 +108,205 @@ workbox.routing.registerRoute(
//Learn more about Service Workers and Configurations
//https://developers.google.com/web/tools/workbox/
//https://developers.google.com/web/tools/workbox/
// DB
function openDb() {
return new Promise(function(resolve) {
if (indexedDB) {
var request = indexedDB.open('regatten_app_db_<?php echo BOATCLASS; ?>');
request.onerror = function (e) {
console.log('[sW] Cannot open DB:', e.targer.errorCode);
resolve(null);
};
request.onupgradeneeded = function (e) {
console.log('[sW] DB does not exist');
e.target.transaction.abort();
resolve(null);
};
request.onsuccess = function (e) {
console.log('[sW] DB loaded');
var db = e.target.result;
db.onerror = function (e) {
console.log('[sW] DB Error:', e);
};
resolve(db);
}
} else {
resolve(null);
}
});
}
function dbSettingsGet(key) {
return new Promise(async function(resolve) {
var db = await openDb();
if (db !== null) {
var request = db.transaction('settings').objectStore('settings').get(key);
request.onsuccess = function (event) {
db.close();
console.log('[sW] DB closed');
resolve(typeof request.result != 'undefined' ? request.result.value : null);
}
} else {
resolve(null);
}
});
}
async function dbSettingsSet(key, value) {
var db = await openDb();
if (db != null) {
var os = db.transaction('settings', 'readwrite').objectStore('settings');
var request = os.put({ key: key, value: value});
request.onerror = function (event) {
console.log('[sW] Error while saving data to DB:', e);
db.close();
console.log('[sW] DB closed');
}
request.onsuccess = function (event) {
db.close();
console.log('[sW] DB closed');
}
}
}
// PUSHES
function getEntry(data, index, defaultValue) {
return ((typeof data[index] !== "undefined") ? data[index] : defaultValue);
}
function isMyRegatta(id) {
return new Promise(async function (resolve) {
var regattas = await dbSettingsGet('myregattas_<?php echo BOATCLASS; ?>');
if (regattas == null) resolve(false);
else resolve(regattas.includes(id.toString()));
});
}
self.addEventListener('push', async function(event) {
console.log('[sW] Push received:', event.data.text());
var data;
try {
data = JSON.parse(event.data.text());
} catch(e) {
console.log(e);
data = undefined;
}
if (typeof data.type !== "undefined") {
switch (data.type) {
case 'notification':
if (typeof data.title === "undefined") break;
if (typeof data.body === "undefined") break;
if (typeof data.channel === "undefined") break;
// check channel
var okay = false;
switch (data.channel) {
case 'news':
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_news')) okay = true;
break;
case 'regatta_changed':
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_regatta_changed_all')) okay = true;
else if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_regatta_changed_my')) {
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
}
break;
case 'result_ready':
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_result_ready_all')) okay = true;
else if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_result_ready_my')) {
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
}
break;
case 'meldeschluss':
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
}
break;
default:
console.log('Unknown channel:', data.channel);
break;
}
if (!okay) {
console.log('Notification channel not subscribed');
return;
}
const options = {
data: data,
body: data.body,
icon: getEntry(data, 'icon', '<?php echo SERVER_ADDR; ?>/client/app/icons/icon-512x512.png'),
badge: '<?php echo SERVER_ADDR; ?>/client/app/icons/badge-128x128.png',
vibrate: [500,100,500]
};
if ((image = getEntry(data, 'image', null)) !== null) {
options.image = image;
}
// Force refresh on next app open
var db = await openDb();
if (db != null) {
var os = db.transaction('update_times', 'readwrite').objectStore('update_times');
var request = os.put({ table: 'last_sync', time: 0 });
request.onerror = function (event) {
console.log('[sW] Error while saving data to DB:', e);
db.close();
console.log('[sW] DB closed');
}
request.onsuccess = function (event) {
db.close();
console.log('[sW] DB closed');
}
}
console.log('Showing notification');
self.registration.showNotification(data.title, options);
break;
case 'forcesync':
// Force refresh on next app open
var db = await openDb();
if (db != null) {
var os = db.transaction('update_times', 'readwrite').objectStore('update_times');
var request = os.put({ table: 'last_sync', time: 0 });
request.onerror = function (event) {
console.log('[sW] Error while saving data to DB:', e);
db.close();
console.log('[sW] DB closed');
}
request.onsuccess = function (event) {
console.log('[sW] Data successfully saved');
db.close();
console.log('[sW] DB closed');
}
}
break;
default:
console.log('[sW] Push type unknown:', data.type);
break;
}
} else {
console.log('[sW] No push type given!');
}
});
self.addEventListener('notificationclick', function(event) {
var data = event.notification.data;
event.notification.close();
var url = '<?php echo SERVER_ADDR; ?>' + getEntry(data, 'url', '');
event.waitUntil(
clients.openWindow(url)
);
});