Compare commits
45 Commits
v_1.8
...
site_build
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ee722f6c2 | ||
|
|
28ba380cca | ||
|
|
357449c1c6 | ||
|
|
de70522850 | ||
|
|
cf5f71d14e | ||
|
|
34b47e40ab | ||
|
|
32ea581437 | ||
|
|
16ccbca2af | ||
|
|
3fd9beae1e | ||
|
|
01d0ae96f9 | ||
|
|
c211817f78 | ||
|
|
9ff0b96837 | ||
|
|
7a3413b339 | ||
|
|
72ff731694 | ||
|
|
3959b208b5 | ||
|
|
7b500bf67d | ||
|
|
5c8c9db1de | ||
|
|
fa526b11a8 | ||
|
|
2dc2225263 | ||
|
|
fcf9dc9a20 | ||
|
|
203c2534eb | ||
|
|
730dd9112f | ||
|
|
13ceef37d9 | ||
|
|
54852f4383 | ||
|
|
8808d12bf1 | ||
|
|
c6d5450b0e | ||
|
|
15cbe15651 | ||
|
|
cb8a1817ae | ||
|
|
acf51ea71c | ||
|
|
be98511957 | ||
|
|
65608cdd5a | ||
|
|
d0996fa0c3 | ||
|
|
c9a90eb77c | ||
|
|
754cb6f77d | ||
|
|
5e926f3e75 | ||
|
|
138071769c | ||
|
|
26d9d83ba2 | ||
|
|
eaa08ba301 | ||
|
|
760c05286e | ||
|
|
3f676141d7 | ||
|
|
ae9bf02c49 | ||
|
|
c2a482bba1 | ||
|
|
06266b788d | ||
|
|
3db5ae1723 | ||
|
|
b784733b69 |
@@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: text/javascript');
|
header('Content-Type: text/javascript');
|
||||||
|
|
||||||
require_once(__DIR__ . '/../../server/config.php');
|
require_once(__DIR__ . '/../../server/config.php');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
log('Script "custom.js" loaded');
|
||||||
|
|
||||||
var loaderCount = 2;
|
var loaderCount = 2;
|
||||||
var showLoader = function() {
|
var showLoader = function() {
|
||||||
if (loaderCount < 1) {
|
if (loaderCount < 1) {
|
||||||
@@ -19,6 +21,7 @@ var hideLoader = function() {
|
|||||||
if (loaderCount < 1) {
|
if (loaderCount < 1) {
|
||||||
$('#preloader').addClass('preloader-hide');
|
$('#preloader').addClass('preloader-hide');
|
||||||
loaderCount = 0;
|
loaderCount = 0;
|
||||||
|
log('Loader hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,19 +30,28 @@ $(window).on('load',function(){
|
|||||||
hideLoader();
|
hideLoader();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//Generating Cookies
|
||||||
|
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)}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
log('Document ready');
|
||||||
|
|
||||||
var isAJAX = false; //Enables or disable AJAX page transitions and loading.
|
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.
|
var isDevelopment = false; // Enables development mode. Clean cache & Stops BG & Highlights from changing defaults.
|
||||||
|
|
||||||
function init_template(){
|
function init_template(){
|
||||||
|
|
||||||
|
log('Initializing template...');
|
||||||
|
|
||||||
//ADD YOUR CUSTOM JAVASCRIPT CODES HERE!
|
//ADD YOUR CUSTOM JAVASCRIPT CODES HERE!
|
||||||
//Do not put inside HTML files.
|
//Do not put inside HTML files.
|
||||||
//The init_template() function will be triggered when pages open.
|
//The init_template() function will be triggered when pages open.
|
||||||
|
|
||||||
|
|
||||||
//Generating Dynamic Styles to decrease CSS size and execute faster loading times.
|
//Generating Dynamic Styles to decrease CSS size and execute faster loading times.
|
||||||
var colorsArray = [
|
var colorsArray = [
|
||||||
//colors must be in HEX format.
|
//colors must be in HEX format.
|
||||||
@@ -93,24 +105,24 @@ $(document).ready(function(){
|
|||||||
["skype","#12A5F4"],
|
["skype","#12A5F4"],
|
||||||
["instagram","#e1306c"]
|
["instagram","#e1306c"]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
//Back Button Scroll Stop
|
//Back Button Scroll Stop
|
||||||
//if ('scrollRestoration' in history) {history.scrollRestoration = 'manual';}
|
//if ('scrollRestoration' in history) {history.scrollRestoration = 'manual';}
|
||||||
|
|
||||||
//Disable Page Jump on Empty Links.
|
//Disable Page Jump on Empty Links.
|
||||||
$('a').on('click', function(){var attrs = $(this).attr('href'); if(attrs === '#'){return false;}});
|
$('a').on('click', function(){var attrs = $(this).attr('href'); if(attrs === '#'){return false;}});
|
||||||
|
|
||||||
//Adding Background for Gradient
|
//Adding Background for Gradient
|
||||||
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
|
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
|
||||||
|
|
||||||
/*Menu Extender Function*/
|
/*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.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')};
|
$.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
|
//Add your programatically triggered menus here
|
||||||
|
|
||||||
|
|
||||||
//Menu Required Variables
|
//Menu Required Variables
|
||||||
var menu = $('.menu'),
|
var menu = $('.menu'),
|
||||||
body = $('body'),
|
body = $('body'),
|
||||||
@@ -123,21 +135,21 @@ $(document).ready(function(){
|
|||||||
pageContent = $('.page-content'),
|
pageContent = $('.page-content'),
|
||||||
headerAndContent = $('.header, .page-content, #footer-bar'),
|
headerAndContent = $('.header, .page-content, #footer-bar'),
|
||||||
menuDeployer = $('a[data-menu]');
|
menuDeployer = $('a[data-menu]');
|
||||||
|
|
||||||
//Menu System
|
//Menu System
|
||||||
menu.each(function(){
|
menu.each(function(){
|
||||||
var menuHeight = $(this).data('menu-height');
|
var menuHeight = $(this).data('menu-height');
|
||||||
var menuWidth = $(this).data('menu-width');
|
var menuWidth = $(this).data('menu-width');
|
||||||
var menuActive = $(this).data('menu-active');
|
var menuActive = $(this).data('menu-active');
|
||||||
if($(this).hasClass('menu-box-right')){$(this).css("width",menuWidth);}
|
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-left')){$(this).css("width",menuWidth);}
|
||||||
if($(this).hasClass('menu-box-bottom')){$(this).css("height",menuHeight);}
|
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-top')){$(this).css("height",menuHeight);}
|
||||||
if($(this).hasClass('menu-box-modal')){$(this).css({"height":menuHeight, "width":menuWidth});}
|
if($(this).hasClass('menu-box-modal')){$(this).css({"height":menuHeight, "width":menuWidth});}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Menu Deploy Click
|
//Menu Deploy Click
|
||||||
menuDeployer.on('click',function(){
|
menuDeployer.on('click',function(){
|
||||||
menu.removeClass('menu-active');
|
menu.removeClass('menu-active');
|
||||||
menuHider.addClass('menu-active');
|
menuHider.addClass('menu-active');
|
||||||
|
|
||||||
@@ -147,23 +159,23 @@ $(document).ready(function(){
|
|||||||
var menuWidth = menuID.data('menu-width');
|
var menuWidth = menuID.data('menu-width');
|
||||||
var menuHeight = menuID.data('menu-height');
|
var menuHeight = menuID.data('menu-height');
|
||||||
$('body').addClass('modal-open');
|
$('body').addClass('modal-open');
|
||||||
if(menuID.hasClass('menu-header-clear')){menuHider.addClass('menu-active-clear');}
|
if(menuID.hasClass('menu-header-clear')){menuHider.addClass('menu-active-clear');}
|
||||||
function menuActivate(){menuID = 'menu-active' ? menuID.addClass('menu-active') : menuID.removeClass('menu-active');}
|
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(menuID.hasClass('menu-box-bottom')){$('#footer-bar').addClass('footer-menu-hidden');}
|
||||||
if(menuEffect === "menu-parallax"){
|
if(menuEffect === "menu-parallax"){
|
||||||
if(menuID.hasClass('menu-box-bottom')){headerAndContent.css("transform", "translateY("+(menuHeight/5)*(-1)+"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-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-left')){headerAndContent.css("transform", "translateX("+(menuWidth/5)+"px)");}
|
||||||
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX("+(menuWidth/5)*(-1)+"px)");}
|
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX("+(menuWidth/5)*(-1)+"px)");}
|
||||||
}
|
}
|
||||||
if(menuEffect === "menu-push"){
|
if(menuEffect === "menu-push"){
|
||||||
if(menuID.hasClass('menu-box-bottom')){headerAndContent.css("transform", "translateY("+(menuHeight)*(-1)+"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-top')){headerAndContent.css("transform", "translateY("+(menuHeight)+"px)");}
|
||||||
if(menuID.hasClass('menu-box-left')){headerAndContent.css("transform", "translateX("+(menuWidth)+"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(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX("+(menuWidth)*(-1)+"px)");}
|
||||||
}
|
}
|
||||||
if(menuEffect === "menu-push-full"){
|
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%)");}
|
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX(-100%)");}
|
||||||
}
|
}
|
||||||
menuActivate();
|
menuActivate();
|
||||||
@@ -187,11 +199,6 @@ $(document).ready(function(){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
//Generating Cookies
|
|
||||||
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)}
|
|
||||||
|
|
||||||
//Disabling & Enabling Dark Transitions in Dark Mode to Speed up Performance.
|
//Disabling & Enabling Dark Transitions in Dark Mode to Speed up Performance.
|
||||||
function allowTransitions(){$('body').find('#transitions-remove').remove();}
|
function allowTransitions(){$('body').find('#transitions-remove').remove();}
|
||||||
function removeTransitions(){$('body').append('<style id="transitions-remove">.btn, .header, #footer-bar, .menu-box, .menu-active{transition:all 0ms ease!important;}</style>'); setTimeout(function(){allowTransitions();},10);}
|
function removeTransitions(){$('body').append('<style id="transitions-remove">.btn, .header, #footer-bar, .menu-box, .menu-active{transition:all 0ms ease!important;}</style>'); setTimeout(function(){allowTransitions();},10);}
|
||||||
@@ -204,13 +211,13 @@ $(document).ready(function(){
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if($('body').hasClass('detect-theme')){$('body').removeClass('detect-theme');}
|
if($('body').hasClass('detect-theme')){$('body').removeClass('detect-theme');}
|
||||||
if($('body').hasClass('theme-light')){
|
if($('body').hasClass('theme-light')){
|
||||||
eraseCookie('sticky_dark_mode');
|
eraseCookie('sticky_dark_mode');
|
||||||
darkSwitch.prop('checked', false);
|
darkSwitch.prop('checked', false);
|
||||||
createCookie('sticky_light_mode', true, 1);
|
createCookie('sticky_light_mode', true, 1);
|
||||||
}
|
}
|
||||||
if($('body').hasClass('theme-dark')){
|
if($('body').hasClass('theme-dark')){
|
||||||
eraseCookie('sticky_light_mode');
|
eraseCookie('sticky_light_mode');
|
||||||
darkSwitch.prop('checked', true);
|
darkSwitch.prop('checked', true);
|
||||||
createCookie('sticky_dark_mode', true, 1);
|
createCookie('sticky_dark_mode', true, 1);
|
||||||
}
|
}
|
||||||
},150);
|
},150);
|
||||||
@@ -222,7 +229,7 @@ $(document).ready(function(){
|
|||||||
//Auto Dark Mode
|
//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 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 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() {
|
function setColorScheme() {
|
||||||
const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches
|
const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||||
@@ -244,19 +251,19 @@ $(document).ready(function(){
|
|||||||
$('.footer-bar-2 .active-nav, .footer-bar-4 .active-nav, .footer-bar-5 .active-nav').append('<strong></strong>')
|
$('.footer-bar-2 .active-nav, .footer-bar-4 .active-nav, .footer-bar-5 .active-nav').append('<strong></strong>')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Back Button in Header
|
//Back Button in Header
|
||||||
var backButton = $('.back-button, [data-back-button]');
|
var backButton = $('.back-button, [data-back-button]');
|
||||||
backButton.on('click', function() {
|
backButton.on('click', function() {
|
||||||
window.history.go(-1);
|
window.history.go(-1);
|
||||||
//return false;
|
//return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
//Copyright Year
|
//Copyright Year
|
||||||
var copyrightYear = $('.copyright-year, #copyright-year');
|
var copyrightYear = $('.copyright-year, #copyright-year');
|
||||||
var dteNow = new Date(); var intYear = dteNow.getFullYear();
|
var dteNow = new Date(); var intYear = dteNow.getFullYear();
|
||||||
copyrightYear.html(intYear);
|
copyrightYear.html(intYear);
|
||||||
|
|
||||||
//Back to top Badge
|
//Back to top Badge
|
||||||
var backToTop = $('.back-to-top, [data-back-to-top], .back-to-top-badge, .back-to-top-icon'),
|
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');
|
backToTopBadge = $('.back-to-top-badge, .back-to-top-icon');
|
||||||
@@ -293,7 +300,7 @@ $(document).ready(function(){
|
|||||||
show_back_to_top_badge();
|
show_back_to_top_badge();
|
||||||
show_scroll_ad();
|
show_scroll_ad();
|
||||||
$('.header-auto-show').addClass('header-active');
|
$('.header-auto-show').addClass('header-active');
|
||||||
}
|
}
|
||||||
if (footer_reached == true){
|
if (footer_reached == true){
|
||||||
hide_back_to_top_badge();
|
hide_back_to_top_badge();
|
||||||
hide_scroll_ad();
|
hide_scroll_ad();
|
||||||
@@ -333,10 +340,10 @@ $(document).ready(function(){
|
|||||||
if(tab.length){activate_tabs()}
|
if(tab.length){activate_tabs()}
|
||||||
|
|
||||||
//Text Resizer
|
//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-decrease").click(function() {$(".text-size-changer *").css("font-size","-=1");});
|
||||||
$(".text-size-default").click(function() {$(".text-size-changer *").css("font-size", "");});
|
$(".text-size-default").click(function() {$(".text-size-changer *").css("font-size", "");});
|
||||||
|
|
||||||
//Search Menu Functions
|
//Search Menu Functions
|
||||||
function search_menu(){
|
function search_menu(){
|
||||||
$('[data-search]').on('keyup', function() {
|
$('[data-search]').on('keyup', function() {
|
||||||
@@ -387,15 +394,15 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
//Owl Carousel Sliders
|
//Owl Carousel Sliders
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.user-slider').owlCarousel({loop:false, margin:20, nav:false, lazyLoad:true, items:1, autoplay: false, dots:false, autoplayTimeout:4000});
|
$('.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});
|
$('.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});
|
$('.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});
|
$('.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});
|
$('.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');});
|
$('.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');});
|
$('.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');});
|
$('.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');});
|
$('.prev-slide-user').on('click',function(){$(this).closest('.owl-carousel').trigger('prev.owl.carousel');});
|
||||||
},10);
|
},10);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.owl-prev, .owl-next').addClass('bg-highlight');
|
$('.owl-prev, .owl-next').addClass('bg-highlight');
|
||||||
@@ -428,20 +435,20 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
//Toast, Snackbars and Notifications
|
//Toast, Snackbars and Notifications
|
||||||
$('[data-toast]').on('click',function(){
|
$('[data-toast]').on('click',function(){
|
||||||
$('.toast, .snackbar-toast, .notification').toast('hide');
|
$('.toast, .snackbar-toast, .notification').toast('hide');
|
||||||
$('#'+$(this).data('toast')).toast('show');
|
$('#'+$(this).data('toast')).toast('show');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('[data-dismiss]').on('click',function(){
|
$('[data-dismiss]').on('click',function(){
|
||||||
var thisData = $(this).data('dismiss');
|
var thisData = $(this).data('dismiss');
|
||||||
$('#'+thisData).toast('hide');
|
$('#'+thisData).toast('hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
//Tooltips
|
//Tooltips
|
||||||
$(function () {
|
$(function () {
|
||||||
$('[data-toggle="tooltip"]').tooltip()
|
$('[data-toggle="tooltip"]').tooltip()
|
||||||
})
|
})
|
||||||
|
|
||||||
//Cancel Collapse Jump on Click
|
//Cancel Collapse Jump on Click
|
||||||
if($('[data-toggle="collapse"]').length){
|
if($('[data-toggle="collapse"]').length){
|
||||||
$('[data-toggle="collapse"]').on('click',function(e){
|
$('[data-toggle="collapse"]').on('click',function(e){
|
||||||
@@ -467,10 +474,10 @@ $(document).ready(function(){
|
|||||||
$('#'+thisID).prop('checked', false);
|
$('#'+thisID).prop('checked', false);
|
||||||
} else {
|
} else {
|
||||||
$('#'+thisID).prop('checked', true);
|
$('#'+thisID).prop('checked', true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
//Working Hours
|
//Working Hours
|
||||||
var businessHours = $('.business-hours');
|
var businessHours = $('.business-hours');
|
||||||
function activate_business_hours(){
|
function activate_business_hours(){
|
||||||
if(businessHours.length){
|
if(businessHours.length){
|
||||||
@@ -501,7 +508,7 @@ $(document).ready(function(){
|
|||||||
},
|
},
|
||||||
openClass:"bg-green1-dark is-business-opened",
|
openClass:"bg-green1-dark is-business-opened",
|
||||||
closedClass:"bg-red2-dark is-business-closed"
|
closedClass:"bg-red2-dark is-business-closed"
|
||||||
});
|
});
|
||||||
if(businessHours.hasClass('is-business-opened')){
|
if(businessHours.hasClass('is-business-opened')){
|
||||||
$('.show-business-opened').removeClass('disabled');
|
$('.show-business-opened').removeClass('disabled');
|
||||||
$('.show-business-closed').addClass('disabled');
|
$('.show-business-closed').addClass('disabled');
|
||||||
@@ -540,7 +547,7 @@ $(document).ready(function(){
|
|||||||
})(document, window.navigator, "standalone")
|
})(document, window.navigator, "standalone")
|
||||||
}
|
}
|
||||||
ath();
|
ath();
|
||||||
|
|
||||||
//Add to Home Banners
|
//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-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');});
|
$('.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 +556,16 @@ $(document).ready(function(){
|
|||||||
$('.simulate-ios-banner').on('click',function(){$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active')})
|
$('.simulate-ios-banner').on('click',function(){$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active')})
|
||||||
|
|
||||||
//Extending Card Features
|
//Extending Card Features
|
||||||
function card_extender(){
|
function card_extender(){
|
||||||
/*Set Page Content to Min 100vh*/
|
/*Set Page Content to Min 100vh*/
|
||||||
if($('.is-on-homescreen').length){
|
if($('.is-on-homescreen').length){
|
||||||
var windowHeight = screen.height;
|
var windowHeight = screen.height;
|
||||||
$('.page-content, #page').css('min-height', windowHeight);
|
$('.page-content, #page').css('min-height', windowHeight);
|
||||||
}
|
}
|
||||||
if(!$('.is-on-homescreen').length){
|
if(!$('.is-on-homescreen').length){
|
||||||
var windowHeight = window.innerHeight
|
var windowHeight = window.innerHeight
|
||||||
$('.page-content, #page').css('min-height', windowHeight);
|
$('.page-content, #page').css('min-height', windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('[data-card-height]').each(function(){
|
$('[data-card-height]').each(function(){
|
||||||
var cardHeight = $(this).data('card-height');
|
var cardHeight = $(this).data('card-height');
|
||||||
@@ -567,8 +574,8 @@ $(document).ready(function(){
|
|||||||
$(this).css('height', cardHeight);
|
$(this).css('height', cardHeight);
|
||||||
if(cardHeight == "cover"){
|
if(cardHeight == "cover"){
|
||||||
if(header.length && menuFooter.length){
|
if(header.length && menuFooter.length){
|
||||||
$(this).css('height', windowHeight -headerHeight - footerHeight)
|
$(this).css('height', windowHeight -headerHeight - footerHeight)
|
||||||
$('.map-full, .map-full iframe').css('height', windowHeight - headerHeight - footerHeight +14)
|
$('.map-full, .map-full iframe').css('height', windowHeight - headerHeight - footerHeight +14)
|
||||||
} else {
|
} else {
|
||||||
$(this).css('height', windowHeight)
|
$(this).css('height', windowHeight)
|
||||||
$('.map-full, .map-full iframe').css('height', windowHeight)
|
$('.map-full, .map-full iframe').css('height', windowHeight)
|
||||||
@@ -581,20 +588,20 @@ $(document).ready(function(){
|
|||||||
$(window).resize(function(){
|
$(window).resize(function(){
|
||||||
card_extender();
|
card_extender();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Show Map
|
//Show Map
|
||||||
$('.show-map, .hide-map').on('click',function(){
|
$('.show-map, .hide-map').on('click',function(){
|
||||||
$('.map-full .caption').toggleClass('deactivate-map');
|
$('.map-full .caption').toggleClass('deactivate-map');
|
||||||
$('.map-but-1, .map-but-2').toggleClass('deactivate-map');
|
$('.map-but-1, .map-but-2').toggleClass('deactivate-map');
|
||||||
$('.map-full .hide-map').toggleClass('activate-map');
|
$('.map-full .hide-map').toggleClass('activate-map');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Card Hovers
|
//Card Hovers
|
||||||
$('.card-scale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('card-scale-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-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-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-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');});
|
$('.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 +612,7 @@ $(document).ready(function(){
|
|||||||
var readingSeconds = readingWords % 60
|
var readingSeconds = readingWords % 60
|
||||||
$('.reading-progress-words').append(readingWords);
|
$('.reading-progress-words').append(readingWords);
|
||||||
$('.reading-progress-time').append(readingMinutes + ':' + readingSeconds);
|
$('.reading-progress-time').append(readingMinutes + ':' + readingSeconds);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Timed Ads
|
//Timed Ads
|
||||||
if($('[data-auto-show-ad]').length){
|
if($('[data-auto-show-ad]').length){
|
||||||
@@ -614,7 +621,7 @@ $(document).ready(function(){
|
|||||||
$('[data-auto-show-ad]').trigger('click');
|
$('[data-auto-show-ad]').trigger('click');
|
||||||
},time*1000);
|
},time*1000);
|
||||||
}
|
}
|
||||||
$('[data-timed-ad]').on('click', function(){
|
$('[data-timed-ad]').on('click', function(){
|
||||||
var counter = $(this).data('timed-ad');
|
var counter = $(this).data('timed-ad');
|
||||||
var adwin = $('#'+$(this).data('menu'));
|
var adwin = $('#'+$(this).data('menu'));
|
||||||
menuHider.addClass('no-click');
|
menuHider.addClass('no-click');
|
||||||
@@ -686,10 +693,10 @@ $(document).ready(function(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
//Caption Hovers
|
//Caption Hovers
|
||||||
$('.caption-scale').unbind().bind('mouseenter mouseleave touchstart touchend',function(){$(this).find('img').toggleClass('caption-scale-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-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-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-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');});
|
$('.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
|
//File Upload
|
||||||
@@ -733,8 +740,8 @@ $(document).ready(function(){
|
|||||||
//Age Verification
|
//Age Verification
|
||||||
var checkAge = $('.check-age');
|
var checkAge = $('.check-age');
|
||||||
function activate_age_checker(){
|
function activate_age_checker(){
|
||||||
console.log('active');
|
log('active');
|
||||||
$(".check-age").on('click',function(){
|
$(".check-age").on('click',function(){
|
||||||
var dateBirghtDay = $("#date-birth-day").val();
|
var dateBirghtDay = $("#date-birth-day").val();
|
||||||
var dateBirthMonth = $("#date-birth-month").val();
|
var dateBirthMonth = $("#date-birth-month").val();
|
||||||
var dateBirthYear = $("#date-birth-year").val();
|
var dateBirthYear = $("#date-birth-year").val();
|
||||||
@@ -747,7 +754,7 @@ $(document).ready(function(){
|
|||||||
setDate.setFullYear(mydate.getFullYear() + age, dateBirthMonth-1, dateBirghtDay);
|
setDate.setFullYear(mydate.getFullYear() + age, dateBirthMonth-1, dateBirghtDay);
|
||||||
|
|
||||||
if ((currdate - setDate) > 0){
|
if ((currdate - setDate) > 0){
|
||||||
console.log("above 18");
|
log("above 18");
|
||||||
$('#menu-age').removeClass('menu-active')
|
$('#menu-age').removeClass('menu-active')
|
||||||
$('#menu-age-okay').addClass('menu-active');
|
$('#menu-age-okay').addClass('menu-active');
|
||||||
}else{
|
}else{
|
||||||
@@ -756,7 +763,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(checkAge.length){activate_age_checker();}
|
if(checkAge.length){activate_age_checker();}
|
||||||
|
|
||||||
|
|
||||||
@@ -816,11 +823,11 @@ $(document).ready(function(){
|
|||||||
var spanValue = $(this).parent().find('span').text();
|
var spanValue = $(this).parent().find('span').text();
|
||||||
if($(this).val() != spanValue && $(this).val() != ""){
|
if($(this).val() != spanValue && $(this).val() != ""){
|
||||||
$(this).parent().find('span').addClass('input-style-1-active').removeClass('input-style-1-inactive');
|
$(this).parent().find('span').addClass('input-style-1-active').removeClass('input-style-1-inactive');
|
||||||
}
|
}
|
||||||
if($(this).val() === ""){
|
if($(this).val() === ""){
|
||||||
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
$(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(){
|
$('.input-required input, .input-required select, .input-required textarea').on('focusout',function(){
|
||||||
var spanValue = $(this).parent().find('span').text();
|
var spanValue = $(this).parent().find('span').text();
|
||||||
if($(this).val() === ""){
|
if($(this).val() === ""){
|
||||||
@@ -833,17 +840,17 @@ $(document).ready(function(){
|
|||||||
if(getValue === "default"){
|
if(getValue === "default"){
|
||||||
$(this).parent().find('em').html(invalidIcon)
|
$(this).parent().find('em').html(invalidIcon)
|
||||||
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
|
||||||
}
|
}
|
||||||
if(getValue != "default"){
|
if(getValue != "default"){
|
||||||
$(this).parent().find('em').html(validIcon)
|
$(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="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="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="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 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 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
|
//Set Today Date to Date Inputs
|
||||||
Date.prototype.toDateInputValue = (function() {
|
Date.prototype.toDateInputValue = (function() {
|
||||||
@@ -880,7 +887,7 @@ $(document).ready(function(){
|
|||||||
$('.online-message').addClass('online-message-active');
|
$('.online-message').addClass('online-message-active');
|
||||||
$('.offline-message').removeClass('offline-message-active');
|
$('.offline-message').removeClass('offline-message-active');
|
||||||
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.simulate-offline').on('click',function(){isOffline();})
|
$('.simulate-offline').on('click',function(){isOffline();})
|
||||||
$('.simulate-online').on('click',function(){isOnline();})
|
$('.simulate-online').on('click',function(){isOnline();})
|
||||||
@@ -889,11 +896,11 @@ $(document).ready(function(){
|
|||||||
function updateOnlineStatus(event) {
|
function updateOnlineStatus(event) {
|
||||||
var condition = navigator.onLine ? "online" : "offline";
|
var condition = navigator.onLine ? "online" : "offline";
|
||||||
isOnline();
|
isOnline();
|
||||||
console.log( 'Connection: Online');
|
log( 'Connection: Online');
|
||||||
}
|
}
|
||||||
function updateOfflineStatus(event) {
|
function updateOfflineStatus(event) {
|
||||||
isOffline();
|
isOffline();
|
||||||
console.log( 'Connection: Offline');
|
log( 'Connection: Offline');
|
||||||
}
|
}
|
||||||
window.addEventListener('online', updateOnlineStatus);
|
window.addEventListener('online', updateOnlineStatus);
|
||||||
window.addEventListener('offline', updateOfflineStatus);
|
window.addEventListener('offline', updateOfflineStatus);
|
||||||
@@ -901,14 +908,14 @@ $(document).ready(function(){
|
|||||||
//QR Generator
|
//QR Generator
|
||||||
var generateQR = $('.generate-qr-result, .generate-qr-auto');
|
var generateQR = $('.generate-qr-result, .generate-qr-auto');
|
||||||
function activate_qr_generator(){
|
function activate_qr_generator(){
|
||||||
//QR Code Generator
|
//QR Code Generator
|
||||||
var qr_auto_link = window.location.href;
|
var qr_auto_link = window.location.href;
|
||||||
var qr_api_address = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=';
|
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-auto').attr('src', qr_api_address+qr_auto_link)
|
||||||
$('.generate-qr-button').on('click',function(){
|
$('.generate-qr-button').on('click',function(){
|
||||||
if($(this).parent().find('.fa').hasClass('fa-exclamation-triangle')){
|
if($(this).parent().find('.fa').hasClass('fa-exclamation-triangle')){
|
||||||
console.log('Invalid URL');
|
log('Invalid URL');
|
||||||
} else {
|
} else {
|
||||||
var get_qr_url = $('.generate-qr-input').val();
|
var get_qr_url = $('.generate-qr-input').val();
|
||||||
if(!get_qr_url == ''){
|
if(!get_qr_url == ''){
|
||||||
@@ -960,10 +967,10 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Filterable
|
//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').on('click',function(){
|
||||||
$('.gallery-filter-controls li').removeClass('gallery-filter-active color-highlight');
|
$('.gallery-filter-controls li').removeClass('gallery-filter-active color-highlight');
|
||||||
$(this).addClass('gallery-filter-active color-highlight');
|
$(this).addClass('gallery-filter-active color-highlight');
|
||||||
});
|
});
|
||||||
|
|
||||||
//Gallery Views // Added in 2.0
|
//Gallery Views // Added in 2.0
|
||||||
@@ -982,7 +989,7 @@ $(document).ready(function(){
|
|||||||
galleryViewControls.removeClass('color-highlight');
|
galleryViewControls.removeClass('color-highlight');
|
||||||
$(this).addClass('color-highlight');
|
$(this).addClass('color-highlight');
|
||||||
galleryViews.removeClass().addClass('gallery-views gallery-view-2');
|
galleryViews.removeClass().addClass('gallery-views gallery-view-2');
|
||||||
});
|
});
|
||||||
galleryView3.on('click',function(){
|
galleryView3.on('click',function(){
|
||||||
galleryViewControls.removeClass('color-highlight');
|
galleryViewControls.removeClass('color-highlight');
|
||||||
$(this).addClass('color-highlight');
|
$(this).addClass('color-highlight');
|
||||||
@@ -1064,7 +1071,7 @@ $(document).ready(function(){
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Charts
|
//Charts
|
||||||
if($('.chart').length > 0){
|
if($('.chart').length > 0){
|
||||||
var loadJS = function(url, implementationCode, location){
|
var loadJS = function(url, implementationCode, location){
|
||||||
@@ -1075,7 +1082,7 @@ $(document).ready(function(){
|
|||||||
location.appendChild(scriptTag);
|
location.appendChild(scriptTag);
|
||||||
};
|
};
|
||||||
var call_charts_to_page = function(){
|
var call_charts_to_page = function(){
|
||||||
|
|
||||||
var walletChart = $('#wallet-chart');
|
var walletChart = $('#wallet-chart');
|
||||||
var pieChart = $('#pie-chart');
|
var pieChart = $('#pie-chart');
|
||||||
var doughnutChart = $('#doughnut-chart');
|
var doughnutChart = $('#doughnut-chart');
|
||||||
@@ -1100,9 +1107,9 @@ $(document).ready(function(){
|
|||||||
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
||||||
tooltips:{enabled:true}, animation:{duration:1500}
|
tooltips:{enabled:true}, animation:{duration:1500}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pieChart.length){
|
if(pieChart.length){
|
||||||
var pieDemoChart = new Chart(pieChart, {
|
var pieDemoChart = new Chart(pieChart, {
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
@@ -1119,7 +1126,7 @@ $(document).ready(function(){
|
|||||||
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
||||||
tooltips:{enabled:true}, animation:{duration:1500}
|
tooltips:{enabled:true}, animation:{duration:1500}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doughnutChart.length){
|
if(doughnutChart.length){
|
||||||
@@ -1138,7 +1145,7 @@ $(document).ready(function(){
|
|||||||
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
||||||
tooltips:{enabled:true}, animation:{duration:1500}, layout:{ padding: {bottom: 30}}
|
tooltips:{enabled:true}, animation:{duration:1500}, layout:{ padding: {bottom: 30}}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(polarChart.length){
|
if(polarChart.length){
|
||||||
@@ -1157,7 +1164,7 @@ $(document).ready(function(){
|
|||||||
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
||||||
tooltips:{enabled:true}, animation:{duration:1500}, layout:{ padding: {bottom: 30}}
|
tooltips:{enabled:true}, animation:{duration:1500}, layout:{ padding: {bottom: 30}}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verticalChart.length){
|
if (verticalChart.length){
|
||||||
@@ -1182,7 +1189,7 @@ $(document).ready(function(){
|
|||||||
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
||||||
title: {display: false}
|
title: {display: false}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(horizontalChart.length){
|
if(horizontalChart.length){
|
||||||
@@ -1206,7 +1213,7 @@ $(document).ready(function(){
|
|||||||
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
legend: {display: true, position:'bottom', labels:{fontSize:13, padding:15,boxWidth:12},},
|
||||||
title: {display: false}
|
title: {display: false}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lineChart.length){
|
if(lineChart.length){
|
||||||
@@ -1214,11 +1221,11 @@ $(document).ready(function(){
|
|||||||
type: 'line',
|
type: 'line',
|
||||||
data: {
|
data: {
|
||||||
labels: [2000,2005,2010,2015,2010],
|
labels: [2000,2005,2010,2015,2010],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: [500,400,300,200,300],
|
data: [500,400,300,200,300],
|
||||||
label: "Desktop Web",
|
label: "Desktop Web",
|
||||||
borderColor: "#D8334A"
|
borderColor: "#D8334A"
|
||||||
}, {
|
}, {
|
||||||
data: [0,100,300,400,500],
|
data: [0,100,300,400,500],
|
||||||
label: "Mobile Web",
|
label: "Mobile Web",
|
||||||
borderColor: "#4A89DC"
|
borderColor: "#4A89DC"
|
||||||
@@ -1234,11 +1241,11 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadJS('<?php echo SERVER_ADDR; ?>/client/scripts/charts.js', call_charts_to_page, document.body);
|
loadJS('<?php echo SERVER_ADDR; ?>/client/scripts/charts.js', call_charts_to_page, document.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Local Error Message
|
//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
|
//Style Generator
|
||||||
@@ -1248,21 +1255,21 @@ $(document).ready(function(){
|
|||||||
//HEX to RGBA Converter
|
//HEX to RGBA Converter
|
||||||
function HEXtoRGBA(hex){
|
function HEXtoRGBA(hex){
|
||||||
var c;
|
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('');
|
c= hex.substring(1).split('');
|
||||||
if(c.length== 3){c= [c[0], c[0], c[1], c[1], c[2], c[2]];}
|
if(c.length== 3){c= [c[0], c[0], c[1], c[1], c[2], c[2]];}
|
||||||
c= '0x'+c.join('');
|
c= '0x'+c.join('');
|
||||||
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+',0.3)';
|
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+',0.3)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlight_colors(){
|
function highlight_colors(){
|
||||||
var bodyColor = readCookie('sticky-color-scheme')
|
var bodyColor = readCookie('sticky-color-scheme')
|
||||||
if(bodyColor == undefined){var bodyColor = $('body').data('highlight');}
|
if(bodyColor == undefined){var bodyColor = $('body').data('highlight');}
|
||||||
|
|
||||||
var bodyBackground = readCookie('sticky-bg-scheme')
|
var bodyBackground = readCookie('sticky-bg-scheme')
|
||||||
if(bodyBackground == undefined){var bodyBackground = $('body').data('background');}
|
if(bodyBackground == undefined){var bodyBackground = $('body').data('background');}
|
||||||
|
|
||||||
var data = colorsArray.map(colorsArray => colorsArray[0]);
|
var data = colorsArray.map(colorsArray => colorsArray[0]);
|
||||||
if (data.indexOf(bodyColor) > -1) {
|
if (data.indexOf(bodyColor) > -1) {
|
||||||
var highlightLocated = data.indexOf(bodyColor)
|
var highlightLocated = data.indexOf(bodyColor)
|
||||||
@@ -1282,7 +1289,7 @@ $(document).ready(function(){
|
|||||||
$('.generated-background').append(bodyBG);
|
$('.generated-background').append(bodyBG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
highlight_colors();
|
highlight_colors();
|
||||||
|
|
||||||
//Change Highlight
|
//Change Highlight
|
||||||
@@ -1306,7 +1313,7 @@ $(document).ready(function(){
|
|||||||
$('body').append('<style class="generated-highlight"></style>')
|
$('body').append('<style class="generated-highlight"></style>')
|
||||||
$('.generated-highlight').append(highlightColor, highlightBg, highlightNav, highlightBorder);
|
$('.generated-highlight').append(highlightColor, highlightBg, highlightNav, highlightBorder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Change Background
|
//Change Background
|
||||||
$('[data-change-background]').on('click',function(changeColor){
|
$('[data-change-background]').on('click',function(changeColor){
|
||||||
@@ -1322,15 +1329,15 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!generatedStyles.length){
|
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*/');
|
$('.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 (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 (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 (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;}')});
|
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() {
|
function welcomeOk() {
|
||||||
createCookie('sticky_welcome_banner', true, 1);
|
createCookie('sticky_welcome_banner', true, 1);
|
||||||
$('#menu-welcome').hideMenu();
|
$('#menu-welcome').hideMenu();
|
||||||
@@ -1344,16 +1351,19 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
$('#menu-welcome-a-okay').click(welcomeOk);
|
$('#menu-welcome-a-okay').click(welcomeOk);
|
||||||
showWelcome();
|
showWelcome();
|
||||||
|
|
||||||
|
log('Template initialized');
|
||||||
|
log('Initializing app');
|
||||||
|
|
||||||
initRegatten();
|
initRegatten();
|
||||||
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|
||||||
}
|
}
|
||||||
//Activating all the plugins
|
//Activating all the plugins
|
||||||
setTimeout(init_template, 0);
|
setTimeout(init_template, 0);
|
||||||
|
|
||||||
//Activate AJAX Transitions
|
//Activate AJAX Transitions
|
||||||
if(isAJAX === true){
|
if(isAJAX === true){
|
||||||
$(function(){
|
$(function(){
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -1361,7 +1371,7 @@ $(document).ready(function(){
|
|||||||
prefetch: true,
|
prefetch: true,
|
||||||
prefetchOn: 'mouseover',
|
prefetchOn: 'mouseover',
|
||||||
cacheLength: 100,
|
cacheLength: 100,
|
||||||
scroll: true,
|
scroll: true,
|
||||||
blacklist: '.default-link',
|
blacklist: '.default-link',
|
||||||
forms: 'contactForm',
|
forms: 'contactForm',
|
||||||
onStart: {
|
onStart: {
|
||||||
@@ -1378,7 +1388,7 @@ $(document).ready(function(){
|
|||||||
render: function ($container, $newContent) {
|
render: function ($container, $newContent) {
|
||||||
$container.removeClass('is-exiting');// Remove your CSS animation reversing class
|
$container.removeClass('is-exiting');// Remove your CSS animation reversing class
|
||||||
$container.html($newContent);// Inject the new content
|
$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');
|
$('#preloader').removeClass('preloader-hide');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1406,5 +1416,5 @@ $(document).ready(function(){
|
|||||||
caches.delete(cacheName);
|
caches.delete(cacheName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ var getJSON = function(url, callback) {
|
|||||||
callback(xhr.status, xhr.response);
|
callback(xhr.status, xhr.response);
|
||||||
};
|
};
|
||||||
xhr.ontimeout = function () {
|
xhr.ontimeout = function () {
|
||||||
console.log("getJSON: timeout");
|
log("getJSON: timeout");
|
||||||
callback(0, null);
|
callback(0, null);
|
||||||
}
|
}
|
||||||
xhr.onerror = function () {
|
xhr.onerror = function () {
|
||||||
console.log("getJSON: error");
|
log("getJSON: error");
|
||||||
callback(0, null);
|
callback(0, null);
|
||||||
}
|
}
|
||||||
if (USER_ID != null) {
|
if (USER_ID != null) {
|
||||||
@@ -76,7 +76,7 @@ function dbGetData(table, id = null) {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
resolve(data.data);
|
resolve(data.data);
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("Something went wrong (HTTP " + code + ")");
|
||||||
fail(strings.error_network, 5000);
|
fail(strings.error_network, 5000);
|
||||||
resolve([]);
|
resolve([]);
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ function dbGetData(table, id = null) {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
resolve(data.data);
|
resolve(data.data);
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("Something went wrong (HTTP " + code + ")");
|
||||||
fail(strings.error_network, 5000);
|
fail(strings.error_network, 5000);
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ function dbGetDataIndex(table, indexName, value) {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
resolve(data.data);
|
resolve(data.data);
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("Something went wrong (HTTP " + code + ")");
|
||||||
fail(strings.error_network, 5000);
|
fail(strings.error_network, 5000);
|
||||||
resolve([]);
|
resolve([]);
|
||||||
}
|
}
|
||||||
@@ -417,32 +417,35 @@ function dbSettingsSet(key, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateSyncStatus() { // TODO
|
async function updateSyncStatus() {
|
||||||
// var syncStatus = document.getElementById('syncstatus');
|
var lastSync = await dbGetData('update_times', 'last_sync');
|
||||||
// var lastSync = await dbGetData('update_times', 'last_sync');
|
lastSync = new Date(lastSync.time * 1000);
|
||||||
// lastSync = new Date(lastSync.time * 1000);
|
if (lastSync > 0) {
|
||||||
// var now = new Date();
|
var now = new Date();
|
||||||
// var diff = Math.round((now - lastSync) / 1000);
|
var diff = Math.round((now - lastSync) / 1000);
|
||||||
// var txt = '';
|
var txt = '';
|
||||||
//
|
|
||||||
// if (diff < 30) { // 30 sec
|
if (diff < 30) { // 30 sec
|
||||||
// txt = 'jetzt';
|
txt = 'jetzt';
|
||||||
// } else if (diff < 3600) { // 60 min
|
} else if (diff < 3600) { // 60 min
|
||||||
// diff = Math.round(diff / 60);
|
diff = Math.round(diff / 60);
|
||||||
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Minute' : 'Minuten');
|
txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Minute' : 'Minuten');
|
||||||
// } else if (diff < 86400) { // 24 std
|
} else if (diff < 86400) { // 24 std
|
||||||
// diff = Math.round(diff / 3600);
|
diff = Math.round(diff / 3600);
|
||||||
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Stunde' : 'Stunden');
|
txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Stunde' : 'Stunden');
|
||||||
// } else {
|
} else {
|
||||||
// diff = Math.round(diff / 86400);
|
diff = Math.round(diff / 86400);
|
||||||
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen');
|
txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen');
|
||||||
// }
|
}
|
||||||
//
|
} else {
|
||||||
// var btn = '<a href="#" onclick="setLoading(true); sync(); return false;"><i class="fas fa-sync"></i> Sync</a>';
|
var txt = 'nie';
|
||||||
// syncStatus.innerHTML = 'Zuletzt aktualisiert: ' + txt + btn;
|
}
|
||||||
|
|
||||||
|
$('#syncstatus').html('Zuletzt aktualisiert: ' + txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runPageScript() {
|
async function runPageScript() {
|
||||||
|
log('running page script...')
|
||||||
if (canUseLocalDB) {
|
if (canUseLocalDB) {
|
||||||
var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
|
||||||
osUpdateTimes.get('loggedin').onsuccess = function (event) {
|
osUpdateTimes.get('loggedin').onsuccess = function (event) {
|
||||||
@@ -460,21 +463,21 @@ async function runPageScript() {
|
|||||||
dbSettingsSet('myregattas_' + BOATCLASS, plannings);
|
dbSettingsSet('myregattas_' + BOATCLASS, plannings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof updateSyncStatusTimer == 'undefined') { // TODO
|
if (typeof updateSyncStatusTimer == 'undefined') {
|
||||||
// var syncStatus = document.getElementById('syncstatus');
|
|
||||||
if (canUseLocalDB) {
|
if (canUseLocalDB) {
|
||||||
updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000);
|
updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000);
|
||||||
} else {
|
} else {
|
||||||
// syncStatus.innerHTML = 'Keine Offline-Nutzung möglich.';
|
$('#syncstatus').html('Keine Offline-Nutzung möglich.');
|
||||||
$('#i-sync').parent().hide();
|
$('#i-sync').parent().hide();
|
||||||
updateSyncStatusTimer = null;
|
updateSyncStatusTimer = null;
|
||||||
}
|
}
|
||||||
// syncStatus.style.display = 'block';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof siteScript === 'function') {
|
if (typeof siteScript === 'function') {
|
||||||
|
log('loading site script');
|
||||||
siteScript();
|
siteScript();
|
||||||
} else {
|
} else {
|
||||||
|
log('no site script');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,256 +486,49 @@ function sync() {
|
|||||||
if (!canUseLocalDB) return false;
|
if (!canUseLocalDB) return false;
|
||||||
if (syncInProgress > 0) return false;
|
if (syncInProgress > 0) return false;
|
||||||
|
|
||||||
var now = Math.floor(Date.now() / 1000);
|
return new Promise(function(resolve) {
|
||||||
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
db.transaction('update_times').objectStore('update_times').getAll().onsuccess = function (event) {
|
db.transaction('update_times').objectStore('update_times').getAll().onsuccess = function (event) {
|
||||||
var localTimes = {};
|
var localTimes = {};
|
||||||
event.target.result.forEach(function (entry) {
|
event.target.result.forEach(function (entry) {
|
||||||
localTimes[entry['table']] = entry['time'];
|
localTimes[entry['table']] = entry['time'];
|
||||||
});
|
});
|
||||||
|
|
||||||
syncInProgress = 11;
|
syncInProgress = 11;
|
||||||
var syncOkay = true;
|
var syncOkay = true;
|
||||||
console.log("Sync Start");
|
log("Sync Start");
|
||||||
$('#i-sync').addClass('fa-spin');
|
$('#i-sync').addClass('fa-spin');
|
||||||
|
|
||||||
var interval = window.setInterval(function () {
|
var interval = window.setInterval(function () {
|
||||||
if (syncInProgress <= 0) {
|
if (syncInProgress <= 0) {
|
||||||
window.clearInterval(interval);
|
window.clearInterval(interval);
|
||||||
if (syncOkay) {
|
if (syncOkay) {
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'last_sync', time: now });
|
osUpdateTimes.put({ table: 'last_sync', time: now });
|
||||||
|
}
|
||||||
|
log("Sync Stop");
|
||||||
|
setTimeout(function(){
|
||||||
|
$('#i-sync').removeClass('fa-spin');
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
if (typeof onAfterSync === 'function') {
|
||||||
|
onAfterSync();
|
||||||
|
}
|
||||||
|
removeSyncInfoToPreloader();
|
||||||
|
runPageScript();
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
console.log("Sync Stop");
|
}, 100);
|
||||||
setTimeout(function(){
|
|
||||||
$('#i-sync').removeClass('fa-spin');
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
if (typeof onAfterSync === 'function') {
|
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
|
||||||
onAfterSync();
|
if (code == 200) {
|
||||||
}
|
|
||||||
runPageScript();
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
|
// CLUBS
|
||||||
if (code == 200) {
|
if (localTimes['clubs'] < serverTimes['clubs']) {
|
||||||
|
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
||||||
// 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);
|
|
||||||
});
|
|
||||||
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: 'clubs', time: serverTimes['clubs'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
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: 'boats', time: serverTimes['boats'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
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: 'sailors', time: serverTimes['sailors'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
os.openCursor().onsuccess = async function (event) {
|
|
||||||
var cursor = event.target.result;
|
|
||||||
if (cursor) {
|
|
||||||
if (!data.keys.includes(parseInt(cursor.key))) {
|
|
||||||
os.delete(cursor.key);
|
|
||||||
}
|
|
||||||
cursor.continue();
|
|
||||||
} else {
|
|
||||||
// update years
|
|
||||||
var regattas = await dbGetData('regattas');
|
|
||||||
var years = {};
|
|
||||||
for (id in regattas) {
|
|
||||||
var entry = regattas[id];
|
|
||||||
var date = parseDate(entry['date']);
|
|
||||||
var y = date.getFullYear();
|
|
||||||
years[y] = y;
|
|
||||||
}
|
|
||||||
var osYears = db.transaction('years', 'readwrite').objectStore('years');
|
|
||||||
osYears.clear().onsuccess = function (event) {
|
|
||||||
for (var y in years) {
|
|
||||||
osYears.put({ year: y });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
|
||||||
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
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: 'results', time: serverTimes['results'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
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: 'plannings', time: serverTimes['plannings'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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) {
|
if (code == 200) {
|
||||||
var os = db.transaction('trim_boats', 'readwrite').objectStore('trim_boats');
|
var os = db.transaction('clubs', 'readwrite').objectStore('clubs');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -745,26 +541,27 @@ function sync() {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] });
|
osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('clubs synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("clubs: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('clubs failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRIM_USERS
|
// BOATS
|
||||||
if (localTimes['trim_users'] < serverTimes['trim_users']) {
|
if (localTimes['boats'] < serverTimes['boats']) {
|
||||||
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], function (code, data) {
|
getJSON(QUERY_URL + 'get_boats?changed-after=' + localTimes['boats'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('trim_users', 'readwrite').objectStore('trim_users');
|
var os = db.transaction('boats', 'readwrite').objectStore('boats');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -777,26 +574,27 @@ function sync() {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] });
|
osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('boats synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("boats: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('boats failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRIM_TRIMS
|
// SAILORS
|
||||||
if (localTimes['trim_trims'] < serverTimes['trim_trims']) {
|
if (localTimes['sailors'] < serverTimes['sailors']) {
|
||||||
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], function (code, data) {
|
getJSON(QUERY_URL + 'get_sailors?changed-after=' + localTimes['sailors'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('trim_trims', 'readwrite').objectStore('trim_trims');
|
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -809,14 +607,301 @@ function sync() {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] });
|
osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('sailors synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("sailors: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
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');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = async function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
|
} else {
|
||||||
|
// update years
|
||||||
|
var regattas = await dbGetData('regattas');
|
||||||
|
var years = {};
|
||||||
|
for (id in regattas) {
|
||||||
|
var entry = regattas[id];
|
||||||
|
var date = parseDate(entry['date']);
|
||||||
|
var y = date.getFullYear();
|
||||||
|
years[y] = y;
|
||||||
|
}
|
||||||
|
var osYears = db.transaction('years', 'readwrite').objectStore('years');
|
||||||
|
osYears.clear().onsuccess = function (event) {
|
||||||
|
for (var y in years) {
|
||||||
|
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 {
|
||||||
|
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');
|
||||||
|
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: 'results', time: serverTimes['results'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('results synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
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');
|
||||||
|
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: 'plannings', time: serverTimes['plannings'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('plannings synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
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');
|
||||||
|
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: 'trim_boats', time: serverTimes['trim_boats'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_boats synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
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');
|
||||||
|
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: 'trim_users', time: serverTimes['trim_users'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_users synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
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');
|
||||||
|
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: 'trim_trims', time: serverTimes['trim_trims'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_trims synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
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');
|
||||||
|
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: 'users', time: serverTimes['users'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('users synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("users: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('users failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -824,80 +909,13 @@ function sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
syncInProgress -= 3;
|
log("Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress = 0;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// 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');
|
|
||||||
console.log(data);
|
|
||||||
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 --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
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: 'users', time: serverTimes['users'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress = 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSync() {
|
function checkSync() {
|
||||||
@@ -913,15 +931,18 @@ function checkSync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initDatabase() {
|
function initDatabase() {
|
||||||
|
log('Initializing DB...');
|
||||||
if (window.indexedDB) {
|
if (window.indexedDB) {
|
||||||
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
|
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
|
||||||
request.onerror = function (event) {
|
request.onerror = function (event) {
|
||||||
console.log("Cannot open DB: " + event.target.errorCode);
|
log("Cannot open DB: " + event.target);
|
||||||
|
|
||||||
|
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||||
|
|
||||||
runPageScript();
|
runPageScript();
|
||||||
};
|
};
|
||||||
request.onsuccess = function (event) {
|
request.onsuccess = function (event) {
|
||||||
console.log("Database loaded");
|
log("Database loaded");
|
||||||
db = event.target.result;
|
db = event.target.result;
|
||||||
|
|
||||||
db.onversionchange = function (event) {
|
db.onversionchange = function (event) {
|
||||||
@@ -934,7 +955,7 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.onerror = function (event) {
|
db.onerror = function (event) {
|
||||||
console.log("DB Error: " + event.target.errorCode);
|
log("DB Error: " + event.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
canUseLocalDB = true;
|
canUseLocalDB = true;
|
||||||
@@ -946,6 +967,7 @@ function initDatabase() {
|
|||||||
if (lastSync > 0) {
|
if (lastSync > 0) {
|
||||||
runPageScript();
|
runPageScript();
|
||||||
} else {
|
} else {
|
||||||
|
addSyncInfoToPreloader();
|
||||||
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
|
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -964,10 +986,10 @@ function initDatabase() {
|
|||||||
var oldVersion = event.oldVersion;
|
var oldVersion = event.oldVersion;
|
||||||
var newVersion = event.newVersion;
|
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)) {
|
if ((oldVersion < 1) && (newVersion >= 1)) {
|
||||||
console.log('to version 1');
|
log('to version 1');
|
||||||
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
|
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
|
||||||
var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
|
var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
|
||||||
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
|
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
|
||||||
@@ -996,7 +1018,7 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 2) && (newVersion >= 2)) {
|
if ((oldVersion < 2) && (newVersion >= 2)) {
|
||||||
console.log('to version 2');
|
log('to version 2');
|
||||||
var osUsers = db.createObjectStore('users', { keyPath: 'id' });
|
var osUsers = db.createObjectStore('users', { keyPath: 'id' });
|
||||||
osUsers.createIndex('username', 'username', { unique: true });
|
osUsers.createIndex('username', 'username', { unique: true });
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
@@ -1004,25 +1026,25 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 3) && (newVersion >= 3)) {
|
if ((oldVersion < 3) && (newVersion >= 3)) {
|
||||||
console.log('to version 3');
|
log('to version 3');
|
||||||
var osYears = db.createObjectStore('years', { keyPath: 'year' });
|
var osYears = db.createObjectStore('years', { keyPath: 'year' });
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 4) && (newVersion >= 4)) {
|
if ((oldVersion < 4) && (newVersion >= 4)) {
|
||||||
console.log('to version 4');
|
log('to version 4');
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
|
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 5) && (newVersion >= 5)) {
|
if ((oldVersion < 5) && (newVersion >= 5)) {
|
||||||
console.log('to version 5');
|
log('to version 5');
|
||||||
var osPushes = db.createObjectStore('settings', { keyPath: 'key' });
|
var osPushes = db.createObjectStore('settings', { keyPath: 'key' });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 6) && (newVersion >= 6)) {
|
if ((oldVersion < 6) && (newVersion >= 6)) {
|
||||||
console.log('to version 6');
|
log('to version 6');
|
||||||
var osNews = db.createObjectStore('news', { keyPath: 'id' });
|
var osNews = db.createObjectStore('news', { keyPath: 'id' });
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
osUpdateTimes.add({ table: 'news', time: 0 });
|
osUpdateTimes.add({ table: 'news', time: 0 });
|
||||||
@@ -1032,6 +1054,8 @@ function initDatabase() {
|
|||||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||||
|
|
||||||
runPageScript();
|
runPageScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1052,7 +1076,24 @@ function resetDb() {
|
|||||||
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
|
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'news', time: 0 });
|
osUpdateTimes.put({ table: 'news', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'users', time: 0 });
|
osUpdateTimes.put({ table: 'users', time: 0 });
|
||||||
console.log('DB update times reset');
|
log('DB update times reset');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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ötigen Informationen anzeigen zu können, müssen wir die Datenbank synchronisieren.<br>Dies kann einen Moment dauern. Bitte habe etwas Geduld. Beim nächsten Öffnen geht es schneller.</p>';
|
||||||
|
preloader.appendChild(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeSyncInfoToPreloader() {
|
||||||
|
$('#preloader-sync-info').remove();
|
||||||
|
}
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ var mobileConsole = (function () {
|
|||||||
var elements = {
|
var elements = {
|
||||||
lines: [],
|
lines: [],
|
||||||
acItems: [],
|
acItems: [],
|
||||||
base: createElem('div', 'base', {
|
base: createElem('div', 'base page-bg', {
|
||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
resize: 'none',
|
resize: 'none',
|
||||||
@@ -1038,7 +1038,7 @@ var mobileConsole = (function () {
|
|||||||
function isRepeat(message, method) {
|
function isRepeat(message, method) {
|
||||||
return (history.output.prevMsg === message && history.output.prevMethod === method) && (typeof message !== 'object') && (method !== 'trace') && (method !== 'group') && (method !== 'groupCollapsed') && (method !== 'groupEnd');
|
return (history.output.prevMsg === message && history.output.prevMethod === method) && (typeof message !== 'object') && (method !== 'trace') && (method !== 'group') && (method !== 'groupCollapsed') && (method !== 'groupEnd');
|
||||||
}
|
}
|
||||||
function newConsole() {
|
function newConsole2() {
|
||||||
try {
|
try {
|
||||||
//get arguments, set vars
|
//get arguments, set vars
|
||||||
var method = arguments[0], className, isHTMLElement,
|
var method = arguments[0], className, isHTMLElement,
|
||||||
@@ -1195,11 +1195,7 @@ var mobileConsole = (function () {
|
|||||||
}
|
}
|
||||||
//scroll
|
//scroll
|
||||||
consoleElement.toggleScroll();
|
consoleElement.toggleScroll();
|
||||||
//==========================================================
|
|
||||||
//make sure we still call the original method, if applicable (not window.onerror)
|
|
||||||
if (typeof arguments[1].original === 'function') {
|
|
||||||
arguments[1].original.apply(console, arguments[1].originalArguments);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//not logging. why? throw error
|
//not logging. why? throw error
|
||||||
if (options.browserinfo.isMobile) { alert(e); }
|
if (options.browserinfo.isMobile) { alert(e); }
|
||||||
@@ -1211,6 +1207,37 @@ var mobileConsole = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function newConsole() {
|
||||||
|
if (typeof arguments[1].newMessage === 'object') {
|
||||||
|
var args = arguments[1].newMessage.slice();
|
||||||
|
var argString = [];
|
||||||
|
for (var i in args) {
|
||||||
|
if (typeof args[i] === 'object') {
|
||||||
|
if (argString.length > 0) {
|
||||||
|
arguments[1].newMessage = argString.join(' ');
|
||||||
|
newConsole2(...arguments);
|
||||||
|
argString = [];
|
||||||
|
}
|
||||||
|
arguments[1].newMessage = args[i];
|
||||||
|
newConsole2(...arguments);
|
||||||
|
} else {
|
||||||
|
argString.push(args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argString.length > 0) {
|
||||||
|
arguments[1].newMessage = argString.join(' ');
|
||||||
|
newConsole2(...arguments);
|
||||||
|
argString = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newConsole2(...arguments);
|
||||||
|
}
|
||||||
|
//==========================================================
|
||||||
|
//make sure we still call the original method, if applicable (not window.onerror)
|
||||||
|
if (typeof arguments[1].original === 'function') {
|
||||||
|
arguments[1].original.apply(console, arguments[1].originalArguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
function interceptConsole(method) {
|
function interceptConsole(method) {
|
||||||
var original = console ? console[method] : missingMethod(), i, stackTraceOrig;
|
var original = console ? console[method] : missingMethod(), i, stackTraceOrig;
|
||||||
if (!console) { console = {}; } //create empty console if we have no console (IE?)
|
if (!console) { console = {}; } //create empty console if we have no console (IE?)
|
||||||
@@ -1218,7 +1245,7 @@ var mobileConsole = (function () {
|
|||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
args.original = original;
|
args.original = original;
|
||||||
args.originalArguments = arguments;
|
args.originalArguments = arguments;
|
||||||
args.newMessage = (method === 'assert') ? [args[0], args[1]] : args[0];
|
//args.newMessage = (method === 'assert') ? [args[0], args[1]] : args[0];
|
||||||
//create an Error and get its stack trace and format it
|
//create an Error and get its stack trace and format it
|
||||||
try { throw new Error(); } catch (e) { stackTraceOrig = e.stack; }
|
try { throw new Error(); } catch (e) { stackTraceOrig = e.stack; }
|
||||||
args.newStackTrace = formatStackTrace(args.newStackTrace, stackTraceOrig);
|
args.newStackTrace = formatStackTrace(args.newStackTrace, stackTraceOrig);
|
||||||
@@ -1241,6 +1268,12 @@ var mobileConsole = (function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Handle the new console logging
|
//Handle the new console logging
|
||||||
|
args.newMessage = [];
|
||||||
|
var i = 0;
|
||||||
|
while (typeof args[i] !== 'undefined') {
|
||||||
|
args.newMessage.push(args[i]);
|
||||||
|
i ++;
|
||||||
|
}
|
||||||
newConsole(method, args);
|
newConsole(method, args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: text/javascript');
|
header('Content-Type: text/javascript');
|
||||||
|
|
||||||
require_once(__DIR__ . '/../../server/version.php');
|
require_once(__DIR__ . '/../../server/version.php');
|
||||||
require_once(__DIR__ . '/../../server/config.php');
|
require_once(__DIR__ . '/../../server/config.php');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
//Loading the Service Worker
|
//Loading the Service Worker
|
||||||
var swRegistration = null;
|
var swRegistration = null;
|
||||||
@@ -16,31 +16,31 @@ if ('serviceWorker' in navigator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var pwaVersion = '<?php echo PWA_VERSION; ?>'; //must be identical to _manifest.json version. If not it will create update window loop
|
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 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
|
var pwaNoCache = false; // always keep the cache clear to serve the freshest possible content
|
||||||
|
|
||||||
|
|
||||||
$('[data-pwa-version]').data('pwa-version', pwaVersion);
|
$('[data-pwa-version]').data('pwa-version', pwaVersion);
|
||||||
|
|
||||||
|
|
||||||
//Creating Cookie System for PWA Hide
|
//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 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 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)}
|
function eraseCookie(e) {createCookie(e, "", -1)}
|
||||||
|
|
||||||
//Enabling dismiss button
|
//Enabling dismiss button
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.pwa-dismiss').on('click',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);
|
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);
|
},1500);
|
||||||
|
|
||||||
//Detecting Mobile Operating Systems
|
//Detecting Mobile Operating Systems
|
||||||
var isMobile = {
|
var isMobile = {
|
||||||
Android: function() {return navigator.userAgent.match(/Android/i);},
|
Android: function() {return navigator.userAgent.match(/Android/i);},
|
||||||
@@ -49,37 +49,40 @@ $(document).ready(function(){
|
|||||||
};
|
};
|
||||||
var isInWebAppiOS = (window.navigator.standalone == true);
|
var isInWebAppiOS = (window.navigator.standalone == true);
|
||||||
var isInWebAppChrome = (window.matchMedia('(display-mode: standalone)').matches);
|
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()) {
|
if (isMobile.Android()) {
|
||||||
console.log('Android Detected');
|
log('Android Detected');
|
||||||
function showInstallPromotion(){
|
function showInstallPromotion(){
|
||||||
if($('#menu-install-pwa-android, .add-to-home').length){
|
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')) {
|
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-android');
|
$('.add-to-home').addClass('add-to-home-visible add-to-home-android');
|
||||||
$('#menu-install-pwa-android, .menu-hider').addClass('menu-active')
|
$('#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;
|
let deferredPrompt;
|
||||||
window.addEventListener('beforeinstallprompt', (e) => {
|
window.addEventListener('beforeinstallprompt', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
deferredPrompt = e;
|
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){
|
$('.pwa-install').on('click',function(e){
|
||||||
deferredPrompt.prompt();
|
deferredPrompt.prompt();
|
||||||
deferredPrompt.userChoice
|
deferredPrompt.userChoice
|
||||||
.then((choiceResult) => {
|
.then((choiceResult) => {
|
||||||
if (choiceResult.outcome === 'accepted') {
|
if (choiceResult.outcome === 'accepted') {
|
||||||
console.log('User accepted the A2HS prompt');
|
log('User accepted the A2HS prompt');
|
||||||
} else {
|
} else {
|
||||||
console.log('User dismissed the A2HS prompt');
|
log('User dismissed the A2HS prompt');
|
||||||
}
|
}
|
||||||
deferredPrompt = null;
|
deferredPrompt = null;
|
||||||
});
|
});
|
||||||
@@ -87,26 +90,32 @@ $(document).ready(function(){
|
|||||||
window.addEventListener('appinstalled', (evt) => {
|
window.addEventListener('appinstalled', (evt) => {
|
||||||
$('#menu-install-pwa-android, .menu-hider').removeClass('menu-active')
|
$('#menu-install-pwa-android, .menu-hider').removeClass('menu-active')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile.iOS()) {
|
if (isMobile.iOS()) {
|
||||||
if(!isInWebAppiOS){
|
if(!isInWebAppiOS){
|
||||||
console.log('iOS Detected');
|
log('iOS Detected');
|
||||||
if($('#menu-install-pwa-ios, .add-to-home').length){
|
if($('#menu-install-pwa-ios, .add-to-home').length){
|
||||||
if (!readCookie('Sticky_pwa_rejected_install')) {
|
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||||
console.log('Triggering PWA / Add to Home Screen Menu for iOS');
|
function triggerPwaInstallIos() {
|
||||||
setTimeout(function(){
|
log('Triggering PWA / Add to Home Screen Menu for iOS');
|
||||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
|
setTimeout(function(){
|
||||||
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
|
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
|
||||||
},4500);
|
$('#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
|
//Creating Update Modal
|
||||||
function updateModal(){
|
function updateModal(){
|
||||||
var body = $('body');
|
var body = $('body');
|
||||||
@@ -116,7 +125,7 @@ $(document).ready(function(){
|
|||||||
if(!updateModal.length){
|
if(!updateModal.length){
|
||||||
body.append('<div id="menu-update"></div>');
|
body.append('<div id="menu-update"></div>');
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
body.find('#menu-update').load('menu-update.html?ver='+menuUpdate);
|
body.find('#menu-update').load('menu-update.html?ver='+menuUpdate);
|
||||||
},250);
|
},250);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -125,15 +134,15 @@ $(document).ready(function(){
|
|||||||
var counter = 3;
|
var counter = 3;
|
||||||
var interval = setInterval(function() {
|
var interval = setInterval(function() {
|
||||||
counter--;
|
counter--;
|
||||||
console.log(counter);
|
log(counter);
|
||||||
$('.page-update').html('Aktuallisierung in ... '+ counter + ' Sekunden');
|
$('.page-update').html('Aktuallisierung in ... '+ counter + ' Sekunden');
|
||||||
if (counter == 0) {
|
if (counter == 0) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
window.location.reload(true)
|
window.location.reload(true)
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
caches.delete('workbox-runtime').then(function() {
|
caches.delete('workbox-runtime').then(function() {
|
||||||
console.log('Content Updated - Cache Removed!');
|
log('Content Updated - Cache Removed!');
|
||||||
});
|
});
|
||||||
//localStorage.clear();
|
//localStorage.clear();
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
@@ -143,34 +152,34 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//Check Version
|
//Check Version
|
||||||
function check_version(){
|
function check_version(){
|
||||||
if($('link[data-pwa-version]').length){
|
if($('link[data-pwa-version]').length){
|
||||||
function versionCheck(){
|
function versionCheck(){
|
||||||
var dt = new Date();
|
var dt = new Date();
|
||||||
var maniTimeVersion = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
|
var maniTimeVersion = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
|
||||||
var localVersionNumber = $('link[rel="manifest"]').data('pwa-version');
|
var localVersionNumber = $('link[rel="manifest"]').data('pwa-version');
|
||||||
var onlineVersionJSON = "<?php echo SERVER_ADDR; ?>/manifest.json.php?ver=" + maniTimeVersion;
|
var onlineVersionJSON = "<?php echo SERVER_ADDR; ?>/manifest.json.php?ver=" + maniTimeVersion;
|
||||||
var onlineVersionNumber = "Connection Offline. Waiting to Reconect";
|
var onlineVersionNumber = "Connection Offline. Waiting to Reconect";
|
||||||
$.getJSON(onlineVersionJSON, function(onlineData) {onlineVersionNumber = onlineData.version;});
|
$.getJSON(onlineVersionJSON, function(onlineData) {onlineVersionNumber = onlineData.version;});
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
//console.log(' Checking PWA Content for updates...\n PWA Server Version: ' + onlineVersionNumber + '\n' + ' PWA Cached Version: ' + localVersionNumber);
|
//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"){
|
if(onlineVersionNumber != localVersionNumber && onlineVersionNumber != "Connection Offline. Waiting to Reconect"){
|
||||||
updateModal();
|
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(){
|
setTimeout(function(){
|
||||||
$('body').find('#menu-update').addClass('menu-active');
|
$('body').find('#menu-update').addClass('menu-active');
|
||||||
$('.menu-hider').addClass('menu-active-no-click');
|
$('.menu-hider').addClass('menu-active-no-click');
|
||||||
updateButton();
|
updateButton();
|
||||||
},500);
|
},500);
|
||||||
}
|
}
|
||||||
if(onlineVersionNumber == localVersionNumber){/*No update required. Versions Identical*/}
|
if(onlineVersionNumber == localVersionNumber){/*No update required. Versions Identical*/}
|
||||||
if(onlineVersionNumber === "undefined"){/*Error Checking for Updates*/}
|
if(onlineVersionNumber === "undefined"){/*Error Checking for Updates*/}
|
||||||
if(onlineVersionNumber === "Finding Online Version..."){
|
if(onlineVersionNumber === "Finding Online Version..."){
|
||||||
$('.reloadme').addClass('disabled');
|
$('.reloadme').addClass('disabled');
|
||||||
$('body').find('#menu-update').removeClass('menu-active');
|
$('body').find('#menu-update').removeClass('menu-active');
|
||||||
$('.menu-hider').removeClass('menu-active-no-click');
|
$('.menu-hider').removeClass('menu-active-no-click');
|
||||||
}
|
}
|
||||||
},3000);
|
},3000);
|
||||||
}
|
}
|
||||||
@@ -184,15 +193,15 @@ $(document).ready(function(){
|
|||||||
if(pwaCookie == false){
|
if(pwaCookie == false){
|
||||||
eraseCookie('Sticky_pwa_rejected_install');
|
eraseCookie('Sticky_pwa_rejected_install');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reload To Clear Button
|
//Reload To Clear Button
|
||||||
$('body').on('click', '.page-update, .reloadme', function() {
|
$('body').on('click', '.page-update, .reloadme', function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Check for Version Change if Online If not Kill the Function
|
//Check for Version Change if Online If not Kill the Function
|
||||||
if (navigator.onLine) {check_version();} else {function check_version(){}}
|
if (navigator.onLine) {check_version();} else {function check_version(){}}
|
||||||
|
|
||||||
//Adding Offline Alerts
|
//Adding Offline Alerts
|
||||||
var offlineAlerts = $('.offline-message');
|
var offlineAlerts = $('.offline-message');
|
||||||
|
|
||||||
@@ -200,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="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>');
|
$('body').append('<p class="online-message bg-green1-dark color-white center-text uppercase ultrabold">' + strings['inetMsgOnline'] + '</p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Offline Function Show
|
//Offline Function Show
|
||||||
function isOffline(){
|
function isOffline(){
|
||||||
$('.offline-message').addClass('offline-message-active');
|
$('.offline-message').addClass('offline-message-active');
|
||||||
$('.online-message').removeClass('online-message-active');
|
$('.online-message').removeClass('online-message-active');
|
||||||
setTimeout(function(){$('.offline-message').removeClass('offline-message-active');},2000);
|
setTimeout(function(){$('.offline-message').removeClass('offline-message-active');},2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Online Function Show
|
//Online Function Show
|
||||||
function isOnline(){
|
function isOnline(){
|
||||||
$('.online-message').addClass('online-message-active');
|
$('.online-message').addClass('online-message-active');
|
||||||
$('.offline-message').removeClass('offline-message-active');
|
$('.offline-message').removeClass('offline-message-active');
|
||||||
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.simulate-offline').on('click',function(){isOffline();})
|
$('.simulate-offline').on('click',function(){isOffline();})
|
||||||
$('.simulate-online').on('click',function(){isOnline();})
|
$('.simulate-online').on('click',function(){isOnline();})
|
||||||
|
|
||||||
//Disable links to other pages if offline.
|
//Disable links to other pages if offline.
|
||||||
//Warning! Enabling offline for iOS can cause issues
|
//Warning! Enabling offline for iOS can cause issues
|
||||||
//To allow offline functionality delete the next 7 lines
|
//To allow offline functionality delete the next 7 lines
|
||||||
@@ -226,27 +235,27 @@ $(document).ready(function(){
|
|||||||
if(detectHREF.match(/.html/)){
|
if(detectHREF.match(/.html/)){
|
||||||
isOffline();
|
isOffline();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if Online / Offline
|
//Check if Online / Offline
|
||||||
function updateOnlineStatus(event) {
|
function updateOnlineStatus(event) {
|
||||||
var condition = navigator.onLine ? "online" : "offline";
|
var condition = navigator.onLine ? "online" : "offline";
|
||||||
isOnline();
|
isOnline();
|
||||||
console.log( 'Connection: Online');
|
log( 'Connection: Online');
|
||||||
$("a").off( "click", returnFalse );
|
$("a").off( "click", returnFalse );
|
||||||
}
|
}
|
||||||
function updateOfflineStatus(event) {
|
function updateOfflineStatus(event) {
|
||||||
isOffline();
|
isOffline();
|
||||||
$("a").on( "click", returnFalse );
|
$("a").on( "click", returnFalse );
|
||||||
console.log( 'Connection: Offline');
|
log( 'Connection: Offline');
|
||||||
}
|
}
|
||||||
window.addEventListener('online', updateOnlineStatus);
|
window.addEventListener('online', updateOnlineStatus);
|
||||||
window.addEventListener('offline', updateOfflineStatus);
|
window.addEventListener('offline', updateOfflineStatus);
|
||||||
|
|
||||||
|
|
||||||
if(pwaNoCache == true){
|
if(pwaNoCache == true){
|
||||||
caches.delete('workbox-runtime').then(function() {
|
caches.delete('workbox-runtime').then(function() {
|
||||||
});
|
});
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
@@ -256,6 +265,6 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,19 @@ const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
|
|||||||
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
|
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
|
||||||
const PUSH_SERVER_KEY = '<?php echo PUSH_SERVER_KEY; ?>';
|
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); }
|
var randomId = function() { return '_' + Math.random().toString(36).substr(2, 9); }
|
||||||
|
|
||||||
var badges = {
|
var badges = {
|
||||||
@@ -140,8 +153,8 @@ var login = function() {
|
|||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
|
||||||
$('#menu-login').hideMenu();
|
$('#menu-login').hideMenu();
|
||||||
} else {
|
} else {
|
||||||
console.log('Login: unbekannter Fehler', status, error);
|
log('Login: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
@@ -173,7 +186,7 @@ var logout = function() {
|
|||||||
hash: localStorage.getItem('auth_hash')
|
hash: localStorage.getItem('auth_hash')
|
||||||
}
|
}
|
||||||
if ((auth.id === null) || (auth.hash === null)) {
|
if ((auth.id === null) || (auth.hash === null)) {
|
||||||
console.log('Not logged in');
|
log('Not logged in');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -185,14 +198,14 @@ var logout = function() {
|
|||||||
},
|
},
|
||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
if (xhr.status == 401) {
|
if (xhr.status == 401) {
|
||||||
console.log('Not logged in');
|
log('Not logged in');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
} else if (xhr.status == 0) {
|
} else if (xhr.status == 0) {
|
||||||
console.log('Could not delete auth from server');
|
log('Could not delete auth from server');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
} else {
|
} else {
|
||||||
console.log('Logout: unbekannter Fehler', status, error);
|
log('Logout: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
@@ -209,12 +222,12 @@ function deleteDb() {
|
|||||||
showLoader();
|
showLoader();
|
||||||
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
|
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
|
||||||
request.onerror = function (event) {
|
request.onerror = function (event) {
|
||||||
console.log('Cannot delete DB: ', event.target.errorCode);
|
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);
|
toastError('Beim Löschen der Datenbank ist ein Fehler aufgetreten.<br>Bitte melde diesen Fehler. (Dev-Menu => Problem melden)', 5000);
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
request.onsuccess = function (event) {
|
request.onsuccess = function (event) {
|
||||||
console.log('DB deleted');
|
log('DB deleted');
|
||||||
toastInfo('Die Datenbank wurde gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit eine neue Datenbank.', 10000);
|
toastInfo('Die Datenbank wurde gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit eine neue Datenbank.', 10000);
|
||||||
hideLoader();
|
hideLoader();
|
||||||
setTimeout(function(){ location.reload(); }, 3000);
|
setTimeout(function(){ location.reload(); }, 3000);
|
||||||
@@ -228,13 +241,13 @@ function deleteCache() {
|
|||||||
$('#menu-developer').hideMenu();
|
$('#menu-developer').hideMenu();
|
||||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||||
for (let registration of registrations) {
|
for (let registration of registrations) {
|
||||||
console.log('Unregister sW:', registration);
|
log('Unregister sW:', registration);
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
caches.keys().then((keyList) => {
|
caches.keys().then((keyList) => {
|
||||||
return Promise.all(keyList.map((key) => {
|
return Promise.all(keyList.map((key) => {
|
||||||
console.log('Cache deleted:', key);
|
log('Cache deleted:', key);
|
||||||
return caches.delete(key);
|
return caches.delete(key);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -260,7 +273,7 @@ function urlB64ToUint8Array(base64String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pushesSubscribe() {
|
function pushesSubscribe() {
|
||||||
console.log('Subscribing');
|
log('Subscribing');
|
||||||
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
|
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
|
||||||
swRegistration.pushManager.subscribe({
|
swRegistration.pushManager.subscribe({
|
||||||
userVisibleOnly: true,
|
userVisibleOnly: true,
|
||||||
@@ -272,14 +285,14 @@ function pushesSubscribe() {
|
|||||||
updatePushBadge();
|
updatePushBadge();
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
console.log('Failed to subscribe the user: ', 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);
|
toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
|
||||||
pushesUnSubscribe(true);
|
pushesUnSubscribe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushesUnSubscribe(silent = false) {
|
function pushesUnSubscribe(silent = false) {
|
||||||
console.log('Unsubscribing');
|
log('Unsubscribing');
|
||||||
swRegistration.pushManager.getSubscription()
|
swRegistration.pushManager.getSubscription()
|
||||||
.then(function(subscription) {
|
.then(function(subscription) {
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
@@ -291,7 +304,7 @@ function pushesUnSubscribe(silent = false) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
console.log('Error unsubscribing', error);
|
log('Error unsubscribing', error);
|
||||||
$('#menu-pushes').hideMenu();
|
$('#menu-pushes').hideMenu();
|
||||||
if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000);
|
if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000);
|
||||||
updatePushBadge();
|
updatePushBadge();
|
||||||
@@ -300,7 +313,7 @@ function pushesUnSubscribe(silent = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pushesUpdateServerSubscription(subscription, enabled) {
|
function pushesUpdateServerSubscription(subscription, enabled) {
|
||||||
console.log('updateServer', enabled, subscription);
|
log('updateServer', enabled, subscription);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -427,8 +440,12 @@ async function updateNewsBadge() {
|
|||||||
var initRegatten = function() {
|
var initRegatten = function() {
|
||||||
showLoader();
|
showLoader();
|
||||||
|
|
||||||
|
log('Initializing DB...');
|
||||||
|
|
||||||
initDatabase();
|
initDatabase();
|
||||||
|
|
||||||
|
log('Loading app specific code...');
|
||||||
|
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
$('.show-loggedin').show();
|
$('.show-loggedin').show();
|
||||||
$('.show-notloggedin').hide();
|
$('.show-notloggedin').hide();
|
||||||
@@ -448,6 +465,7 @@ var initRegatten = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var onServiceWorkerLoaded = function() {
|
var onServiceWorkerLoaded = function() {
|
||||||
|
log('sW loaded');
|
||||||
if ((swRegistration !== null) && canUseLocalDB) {
|
if ((swRegistration !== null) && canUseLocalDB) {
|
||||||
pushesPossible = true;
|
pushesPossible = true;
|
||||||
updatePushBadge();
|
updatePushBadge();
|
||||||
@@ -457,6 +475,21 @@ var onServiceWorkerLoaded = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var onDatabaseLoaded = function() {
|
var onDatabaseLoaded = function() {
|
||||||
|
log('DB loaded');
|
||||||
|
if (!canUseLocalDB && !$('#menu-welcome').hasClass('menu-active')) {
|
||||||
|
function NoDbWarningOk() {
|
||||||
|
createCookie('regatten_nodb_banner', true, 1);
|
||||||
|
$('#menu-nodb-warning').hideMenu();
|
||||||
|
}
|
||||||
|
function showNoDbWarning() {
|
||||||
|
if (!readCookie('regatten_nodb_banner')) {
|
||||||
|
$('#menu-nodb-warning').showMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#menu-nodb-warning-okay').click(NoDbWarningOk);
|
||||||
|
showNoDbWarning();
|
||||||
|
}
|
||||||
|
|
||||||
onServiceWorkerLoaded();
|
onServiceWorkerLoaded();
|
||||||
initPushSettings();
|
initPushSettings();
|
||||||
|
|
||||||
@@ -473,13 +506,13 @@ var addConsoleOpenerToPreloader = function() {
|
|||||||
var preloader = document.getElementById('preloader');
|
var preloader = document.getElementById('preloader');
|
||||||
var button = document.createElement('a');
|
var button = document.createElement('a');
|
||||||
button.href = '#';
|
button.href = '#';
|
||||||
button.classList = 'btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight m-3';
|
button.classList = 'btn rounded-s text-uppercase font-900 shadow-m m-3';
|
||||||
button.style.position = 'fixed';
|
button.style.position = 'fixed';
|
||||||
button.style.bottom = 0;
|
button.style.bottom = 0;
|
||||||
button.style.left = 0;
|
|
||||||
button.style.right = 0;
|
button.style.right = 0;
|
||||||
button.innerHTML = 'Show Console';
|
button.innerHTML = '</>';
|
||||||
button.onclick = function(){
|
button.onclick = function(){
|
||||||
|
alert('CONSOLE OPENED\nDir werden jetzt einige Entwickler-Informationen angezeigt. Du kannst die Console über das X oben rechts wieder schließen.');
|
||||||
mobileConsole.displayConsole();
|
mobileConsole.displayConsole();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,4 +194,4 @@ blockquote {
|
|||||||
-ms-animation: fa-blink .75s linear infinite;
|
-ms-animation: fa-blink .75s linear infinite;
|
||||||
-o-animation: fa-blink .75s linear infinite;
|
-o-animation: fa-blink .75s linear infinite;
|
||||||
animation: fa-blink .75s linear infinite;
|
animation: fa-blink .75s linear infinite;
|
||||||
}
|
}
|
||||||
|
|||||||
13
server/content/go2url.php
Normal file
13
server/content/go2url.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$sp['title'] = 'Umleitung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
|
||||||
|
// Title
|
||||||
|
$content = '<h1>Umleitung</h1>';
|
||||||
|
$content .= '<p>Wir leiten Dich in Kürze zur gewünschten Website weiter</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-title']);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('go2url');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,22 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$sp['title'] = 'News - Regatten.net ' . $_CLASS['name'];
|
$sp['title'] = 'News - Regatten.net ' . $_CLASS['name'];
|
||||||
$sp['backbutton'] = true;
|
$sp['backbutton'] = true;
|
||||||
$sp['activenav'] = 5;
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
$content = "<h1>Neuigkeiten</h1>";
|
$content = "<h1>Neuigkeiten</h1>";
|
||||||
$content .= '<p>Aktuelles der letzten zwölf Monate</p>';
|
$content .= '<p>Aktuelles der letzten zwölf Monate</p>';
|
||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content]);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
$sp['output'] .= '<div id="news-entries"></div>';
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
$sp['menus'] .= $tpl->load('menu/modal', ['html-id' => 'menu-news', 'title' => 'Details']);
|
$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 = $tpl->load('card', ['%CONTENT%', 'html-id' => '%ID%', 'css-class' => 'card-news']);
|
||||||
$cardTemplate = str_replace("\n", '', $cardTemplate);
|
$cardTemplate = str_replace("\n", '', $cardTemplate);
|
||||||
$cardTemplate = str_replace("\r", '', $cardTemplate);
|
$cardTemplate = str_replace("\r", '', $cardTemplate);
|
||||||
$sp['scripts'] .= "<script>const cardTemplate = '" . $cardTemplate . "';</script>";
|
$sp['scripts'] .= "<script>const cardTemplate = '" . $cardTemplate . "';</script>";
|
||||||
$sp['scripts'] .= $scripts->load('news');
|
$sp['scripts'] .= $scripts->load('news');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,19 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'index';
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
$sp['activenav'] = 5;
|
||||||
$sp['backbutton'] = true;
|
|
||||||
|
// Title
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
$content .= '<p>';
|
$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 .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
$content .= $tpl->load('button', ['<i class="fas fa-edit"></i> bearbeiten', LINK_PRE . 'planning_edit']);
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
// Not loggedin
|
||||||
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
$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');
|
||||||
|
|
||||||
|
?>
|
||||||
|
|||||||
@@ -1,19 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planung bearbeiten - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'planning';
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
$sp['activenav'] = 5;
|
||||||
$sp['backbutton'] = true;
|
|
||||||
|
// Title, Inputs
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$content = "<h1>Saison-Planung bearbeiten</h1>";
|
||||||
$content .= '<p>';
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
// Regattas
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
$content = '<p id="p-count" class="mb-0"></p>';
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
$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, 'css-class' => 'text-center pt-3']);
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
|
||||||
?>
|
|
||||||
|
// Menu
|
||||||
|
$items = $tpl->load('menu/item-switch', ['In die Saison-Planung aufnehmen', 'html-id' => 'switch-planning-include', 'icon' => 'fa-check']);
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['', '#', 'html-id' => 'item-steuermann']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edit', 'title' => 'Regatta bearbeiten', 'height' => 320]);
|
||||||
|
|
||||||
|
// Select sailor
|
||||||
|
$items = $tpl->load('input', ['html-id' => 'input-edit-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-sailor', 'height' => 500, 'width' => 350]);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('planning_edit');
|
||||||
|
|
||||||
|
?>
|
||||||
|
|||||||
@@ -1,19 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'planning';
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
$sp['activenav'] = 5;
|
||||||
$sp['backbutton'] = true;
|
|
||||||
|
// Title
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$content = '<h1>Saison-Planungen</h1>';
|
||||||
$content .= '<p>';
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
// Not loggedin
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
$content = '<h1>Saison-Planungen</h1>';
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
$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' => 'text-center pt-3']);
|
$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');
|
||||||
|
|
||||||
|
?>
|
||||||
|
|||||||
@@ -1,19 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'planning_list';
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
$sp['activenav'] = 5;
|
||||||
$sp['backbutton'] = true;
|
|
||||||
|
// Title
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
$content .= '<p>';
|
$content .= '<p id="p-username" class="mb-1"></p>';
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
$content .= $tpl->load('button', ['<i class="fas fa-share-alt"></i> Teilen', '#', 'html-id' => 'button-share']);
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
// Regattas
|
||||||
|
$content = '<p id="p-count" class="mb-0"></p>';
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
$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');
|
||||||
|
|
||||||
|
?>
|
||||||
|
|||||||
@@ -3,27 +3,27 @@
|
|||||||
<div class="content mb-0">
|
<div class="content mb-0">
|
||||||
<div class="divider mb-0"></div>
|
<div class="divider mb-0"></div>
|
||||||
<div class="list-group list-custom-small list-icon-0">
|
<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>
|
<i class="font-18 fab fa-facebook color-facebook"></i>
|
||||||
<span class="font-13">Facebook</span>
|
<span class="font-13">Facebook</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToTwitter">
|
<a href="#" class="shareToTwitter" target="_blank">
|
||||||
<i class="font-18 fab fa-twitter-square color-twitter"></i>
|
<i class="font-18 fab fa-twitter-square color-twitter"></i>
|
||||||
<span class="font-13">Twitter</span>
|
<span class="font-13">Twitter</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToLinkedIn">
|
<a href="#" class="shareToLinkedIn" target="_blank">
|
||||||
<i class="font-18 fab fa-linkedin color-linkedin"></i>
|
<i class="font-18 fab fa-linkedin color-linkedin"></i>
|
||||||
<span class="font-13">LinkedIn</span>
|
<span class="font-13">LinkedIn</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToWhatsApp">
|
<a href="#" class="shareToWhatsApp" target="_blank">
|
||||||
<i class="font-18 fab fa-whatsapp-square color-whatsapp"></i>
|
<i class="font-18 fab fa-whatsapp-square color-whatsapp"></i>
|
||||||
<span class="font-13">WhatsApp</span>
|
<span class="font-13">WhatsApp</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</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>
|
<i class="font-18 fa fa-envelope-square color-mail"></i>
|
||||||
<span class="font-13">Email</span>
|
<span class="font-13">Email</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
@@ -291,6 +291,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="menu-nodb-warning" class="menu menu-box-bottom menu-box-detached rounded-m" data-height="500">
|
||||||
|
<div class="menu-title"><h1>Warnung</h1><p class="color-highlight">Datenbank nicht unterstützt</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 bottom-0">
|
||||||
|
<p>
|
||||||
|
Das Speichern der benötigten Daten wird von Deinem Gerät nicht unterstützt.<br>
|
||||||
|
Da deshalb die Daten jedesmal direkt vom Server geladen werden müssen, kannst Du die App nicht offline nutzen.<br>
|
||||||
|
Das Nachladen kann außerdem gerade bei großen Datenmengen (wie Ranglisten) sehr lange dauern.
|
||||||
|
Wir empfehlen Dir daher, auf diesem Gerät unsere normale Website zu benutzen. Diese ist auch für Mobil-Geräte optimiert.
|
||||||
|
</p>
|
||||||
|
<a class="btn btn-m mt-2 btn-full bg-highlight text-uppercase font-900" href="https://regatten.net/">Zur Website</a>
|
||||||
|
<a id="menu-nodb-warning-okay" class="btn btn-m mt-2 mb-3 btn-full bg-highlight text-uppercase font-900" href="#">Nicht erneut anzeigen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="menu-update">
|
<div id="menu-update">
|
||||||
<div class="content bottom-0">
|
<div class="content bottom-0">
|
||||||
<p class="text-center mt-5"><i class="fa fa-sync-alt fa-7x color-highlight fa-spin"></i></p>
|
<p class="text-center mt-5"><i class="fa fa-sync-alt fa-7x color-highlight fa-spin"></i></p>
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
<?php include(__DIR__ . '/headerfooter.php'); ?>
|
<?php include(__DIR__ . '/headerfooter.php'); ?>
|
||||||
|
|
||||||
<!--start of page content, add your stuff here-->
|
<!--start of page content, add your stuff here-->
|
||||||
<div class="page-content header-clear-medium">
|
<div class="page-content header-clear">
|
||||||
|
<div id="syncstatus" class="text-right mr-2 mb-1">Zuletzt aktualisiert: nie</div>
|
||||||
<?php echo $sp['output']; ?>
|
<?php echo $sp['output']; ?>
|
||||||
</div>
|
</div>
|
||||||
<!--end of page content, off canvas elements here-->
|
<!--end of page content, off canvas elements here-->
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ async function onEditBoatnameClick() {
|
|||||||
if (xhr.status == 0) {
|
if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Bootsnamen zu bearbeiten');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Bootsnamen zu bearbeiten');
|
||||||
} else {
|
} else {
|
||||||
console.log('EditBoatname: unbekannter Fehler', status, error);
|
log('EditBoatname: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
@@ -47,9 +47,9 @@ async function onEditBoatnameClick() {
|
|||||||
|
|
||||||
async function onListClicked(id) {
|
async function onListClicked(id) {
|
||||||
var boat = await dbGetData('boats', id);
|
var boat = await dbGetData('boats', id);
|
||||||
|
|
||||||
$('#menu-boat').find('.menu-title').find('p').text(boat.sailnumber);
|
$('#menu-boat').find('.menu-title').find('p').text(boat.sailnumber);
|
||||||
|
|
||||||
// Edit Boatname
|
// Edit Boatname
|
||||||
$('#button-editboatname').attr('data-boat-id', boat.id);
|
$('#button-editboatname').attr('data-boat-id', boat.id);
|
||||||
$('#menu-editboatname').find('.menu-title').find('p').text(boat.sailnumber);
|
$('#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').val(boat.name);
|
||||||
}
|
}
|
||||||
$('#input-editboatname').trigger('focusin').trigger('focusout');
|
$('#input-editboatname').trigger('focusin').trigger('focusout');
|
||||||
|
|
||||||
// club website
|
// club website
|
||||||
var clubwebsite = '';
|
var clubwebsite = '';
|
||||||
if (boat['club'] != null) {
|
if (boat['club'] != null) {
|
||||||
@@ -76,7 +76,7 @@ async function onListClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-clubwebsite').hide();
|
$('#menu-item-clubwebsite').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#menu-boat').showMenu();
|
$('#menu-boat').showMenu();
|
||||||
$('#menu-boat').scrollTop(0);
|
$('#menu-boat').scrollTop(0);
|
||||||
}
|
}
|
||||||
@@ -89,19 +89,19 @@ function pageChange() {
|
|||||||
async function drawList() {
|
async function drawList() {
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
var list = '';
|
var list = '';
|
||||||
|
|
||||||
if (displayed.length > 0) {
|
if (displayed.length > 0) {
|
||||||
var offset = (page - 1) * showCount;
|
var offset = (page - 1) * showCount;
|
||||||
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
|
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
|
||||||
if (count == 0) count = showCount;
|
if (count == 0) count = showCount;
|
||||||
|
|
||||||
for (i = 0; i < count; i ++) {
|
for (i = 0; i < count; i ++) {
|
||||||
list += displayed[i + offset];
|
list += displayed[i + offset];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
|
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#div-list').html(list);
|
$('#div-list').html(list);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
@@ -135,9 +135,9 @@ var siteScript = async function() {
|
|||||||
$('#menu-item-boatname').click(function(){ $('#menu-boat').hideMenu(); $('#menu-editboatname').showMenu(); });
|
$('#menu-item-boatname').click(function(){ $('#menu-boat').hideMenu(); $('#menu-editboatname').showMenu(); });
|
||||||
$('#button-editboatname').click(onEditBoatnameClick);
|
$('#button-editboatname').click(onEditBoatnameClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = await dbGetData('boats');
|
var results = await dbGetData('boats');
|
||||||
|
|
||||||
var count = results.length;
|
var count = results.length;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
@@ -147,51 +147,51 @@ var siteScript = async function() {
|
|||||||
}
|
}
|
||||||
$('#div-list').show();
|
$('#div-list').show();
|
||||||
$('#input-search').parent().show();
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
results.sort(function (a, b) {
|
results.sort(function (a, b) {
|
||||||
return a.sailnumber.localeCompare(b.sailnumber);
|
return a.sailnumber.localeCompare(b.sailnumber);
|
||||||
});
|
});
|
||||||
|
|
||||||
rows = [];
|
rows = [];
|
||||||
|
|
||||||
for (id in results) {
|
for (id in results) {
|
||||||
var entry = results[id];
|
var entry = results[id];
|
||||||
var club = null;
|
var club = null;
|
||||||
if (entry['club'] != null)
|
if (entry['club'] != null)
|
||||||
club = await dbGetData('clubs', entry['club']);
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
|
||||||
var row = { keywords: [], content: '' };
|
var row = { keywords: [], content: '' };
|
||||||
row.keywords.push(entry['sailnumber']);
|
row.keywords.push(entry['sailnumber']);
|
||||||
if (entry['name'] != '') row.keywords.push(entry['name']);
|
if (entry['name'] != '') row.keywords.push(entry['name']);
|
||||||
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
|
||||||
row.content += '<div onclick="onListClicked(' + entry['id'] + ');">';
|
row.content += '<div onclick="onListClicked(' + entry['id'] + ');">';
|
||||||
|
|
||||||
// ZEILE 1
|
// ZEILE 1
|
||||||
// Sailnumber
|
// Sailnumber
|
||||||
row.content += '<div><b>' + entry['sailnumber'] + '</b></div>';
|
row.content += '<div><b>' + entry['sailnumber'] + '</b></div>';
|
||||||
|
|
||||||
// ZEILE 2
|
// ZEILE 2
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
row.content += '<div>' + entry['name'] + '</div>';
|
row.content += '<div>' + entry['name'] + '</div>';
|
||||||
|
|
||||||
// Club
|
// Club
|
||||||
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||||
|
|
||||||
row.content += '</div></div>';
|
row.content += '</div></div>';
|
||||||
|
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
reSearch();
|
reSearch();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$('#p-count').html('Keine Boote gefunden!');
|
$('#p-count').html('Keine Boote gefunden!');
|
||||||
$('#div-list').hide();
|
$('#div-list').hide();
|
||||||
$('#input-search').parent().hide();
|
$('#input-search').parent().hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ function sendMessage() {
|
|||||||
if (xhr.status == 0) {
|
if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um eine Nachricht zu versenden');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um eine Nachricht zu versenden');
|
||||||
} else {
|
} else {
|
||||||
console.log('Contact: unbekannter Fehler', status, error);
|
log('Contact: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|||||||
12
server/scripts/go2url.js
Normal file
12
server/scripts/go2url.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
var siteScript = function() {
|
||||||
|
hideLoader();
|
||||||
|
setTimeout(function() {
|
||||||
|
var url = findGetParameter('url');
|
||||||
|
if (url === null) {
|
||||||
|
$('#card-title').find('p').html('Wir konnten Dich leider nicht umleiten.<br><a href="' + LINK_PRE + 'index">Hier kommst Du zurück zur Startseite</a>');
|
||||||
|
} else {
|
||||||
|
showLoader();
|
||||||
|
location.href = url;
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
@@ -50,7 +50,7 @@ var siteScript = async function() {
|
|||||||
// Your next
|
// Your next
|
||||||
var planningsDB = await dbGetDataIndex('plannings', 'user', user.id);
|
var planningsDB = await dbGetDataIndex('plannings', 'user', user.id);
|
||||||
var minDate = getToday();
|
var minDate = getToday();
|
||||||
minDate.setDate(minDate.getDate() - 1);
|
minDate.setDate(minDate.getDate());
|
||||||
var maxDate = getToday();
|
var maxDate = getToday();
|
||||||
maxDate.setDate(maxDate.getDate() + 28);
|
maxDate.setDate(maxDate.getDate() + 28);
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
@@ -166,7 +166,7 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
// Next
|
// Next
|
||||||
var minDate = getToday();
|
var minDate = getToday();
|
||||||
minDate.setDate(minDate.getDate() - 1);
|
minDate.setDate(minDate.getDate());
|
||||||
var maxDate = getToday();
|
var maxDate = getToday();
|
||||||
maxDate.setDate(maxDate.getDate() + 14);
|
maxDate.setDate(maxDate.getDate() + 14);
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var page = 1;
|
||||||
|
var pageCount = 0;
|
||||||
|
const showCount = 10;
|
||||||
|
|
||||||
async function onNewsClicked(id) {
|
async function onNewsClicked(id) {
|
||||||
var newsEntry = await dbGetData('news', id);
|
var newsEntry = await dbGetData('news', id);
|
||||||
if (newsEntry == null) return;
|
if (newsEntry == null) return;
|
||||||
@@ -11,23 +17,50 @@ async function onNewsClicked(id) {
|
|||||||
$('#menu-news').showMenu();
|
$('#menu-news').showMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pageChange() {
|
||||||
|
$('h1')[0].scrollIntoView({ behavior: "smooth" });
|
||||||
|
drawList();
|
||||||
|
}
|
||||||
|
|
||||||
function addCard(newsEntry) {
|
function addCard(newsEntry) {
|
||||||
var content = '<h2>' + newsEntry.title + '</h2>';
|
var badge = '';
|
||||||
|
if (newsEntry.unread) {
|
||||||
|
badge += '<span class="badge bg-highlight color-white p-1">NEW</span> ';
|
||||||
|
}
|
||||||
|
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-2"><i>' + formatDate('d.m.Y', newsEntry.date) + '</i></p>';
|
||||||
content += '<p class="mb-0">' + newsEntry.description.replace('\n', '<br>') + '</p>';
|
content += '<p class="mb-0">' + newsEntry.description.replace('\n', '<br>') + '</p>';
|
||||||
if (newsEntry.html != '') {
|
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>';
|
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>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.page-content').append(cardTemplate.replace('%ID%', 'card-news-' + newsEntry.id).replace('%CONTENT%', content));
|
$('#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() {
|
var siteScript = async function() {
|
||||||
$('.card-news').remove();
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initPagination();
|
||||||
|
}
|
||||||
|
rows = [];
|
||||||
var news = await dbGetData('news');
|
var news = await dbGetData('news');
|
||||||
news.sort(function (a,b) {
|
news.sort(function (a,b) {
|
||||||
return b.date.localeCompare(a.date);
|
return b.date.localeCompare(a.date);
|
||||||
});
|
});
|
||||||
|
var newsRead = await dbSettingsGet('news_read_' + BOATCLASS);
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var lastYear = new Date();
|
var lastYear = new Date();
|
||||||
lastYear.setFullYear(lastYear.getFullYear() - 1);
|
lastYear.setFullYear(lastYear.getFullYear() - 1);
|
||||||
@@ -36,8 +69,19 @@ var siteScript = async function() {
|
|||||||
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||||
if (newsEntry.date > now) continue;
|
if (newsEntry.date > now) continue;
|
||||||
if (newsEntry.date < lastYear) break;
|
if (newsEntry.date < lastYear) break;
|
||||||
addCard(newsEntry);
|
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);
|
dbSettingsSet('news_read_' + BOATCLASS, now);
|
||||||
updateNewsBadge();
|
updateNewsBadge();
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
async function onRegattaClicked(id) {
|
async function onRegattaClicked(id) {
|
||||||
var regatta = await dbGetData('regattas', id);
|
var regatta = await dbGetData('regattas', id);
|
||||||
|
|
||||||
$('#menu-regatta').find('.menu-title').find('p').text(regatta.name);
|
$('#menu-regatta').find('.menu-title').find('p').text(regatta.name);
|
||||||
|
|
||||||
var dateTo = parseDate(regatta['date']);
|
var dateTo = parseDate(regatta['date']);
|
||||||
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
|
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
|
||||||
|
|
||||||
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
|
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
|
||||||
var planning = null;
|
var planning = null;
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
@@ -16,7 +16,7 @@ async function onRegattaClicked(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Your Planning
|
// Your Planning
|
||||||
if (planning != null) {
|
if (planning != null) {
|
||||||
$('#menu-item-yourplanning').show();
|
$('#menu-item-yourplanning').show();
|
||||||
@@ -32,11 +32,26 @@ async function onRegattaClicked(id) {
|
|||||||
crew.push(sailor.name);
|
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>'));
|
$('#menu-item-yourplanning').html(crew.join('<br>'));
|
||||||
} else {
|
} else {
|
||||||
$('#menu-item-yourplanning').hide();
|
$('#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
|
// Planning
|
||||||
if ((plannings.length > 0) && (dateTo >= today)) {
|
if ((plannings.length > 0) && (dateTo >= today)) {
|
||||||
$('#menu-item-plannings').show();
|
$('#menu-item-plannings').show();
|
||||||
@@ -44,7 +59,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-plannings').hide();
|
$('#menu-item-plannings').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Results
|
// Results
|
||||||
var results = await dbGetDataIndex('results', 'regatta', regatta['id']);
|
var results = await dbGetDataIndex('results', 'regatta', regatta['id']);
|
||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
@@ -53,7 +68,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-results').hide();
|
$('#menu-item-results').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bericht
|
// Bericht
|
||||||
if (regatta['bericht'] != '') {
|
if (regatta['bericht'] != '') {
|
||||||
$('#menu-item-bericht').show();
|
$('#menu-item-bericht').show();
|
||||||
@@ -62,7 +77,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-bericht').hide();
|
$('#menu-item-bericht').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
if (regatta['info'] != '') {
|
if (regatta['info'] != '') {
|
||||||
$('#menu-item-info').show();
|
$('#menu-item-info').show();
|
||||||
@@ -71,7 +86,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-info').hide();
|
$('#menu-item-info').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Meldung
|
// Meldung
|
||||||
if ((regatta['meldung'] != '') && (dateTo >= today)) {
|
if ((regatta['meldung'] != '') && (dateTo >= today)) {
|
||||||
$('#menu-item-meldung').show();
|
$('#menu-item-meldung').show();
|
||||||
@@ -129,7 +144,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-meldung').hide();
|
$('#menu-item-meldung').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// off. results
|
// off. results
|
||||||
if (regatta['oresults'] != '') {
|
if (regatta['oresults'] != '') {
|
||||||
$('#menu-item-oresults').show();
|
$('#menu-item-oresults').show();
|
||||||
@@ -138,7 +153,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-oresults').hide();
|
$('#menu-item-oresults').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// club website
|
// club website
|
||||||
var clubwebsite = '';
|
var clubwebsite = '';
|
||||||
if (regatta['club'] != null) {
|
if (regatta['club'] != null) {
|
||||||
@@ -151,7 +166,7 @@ async function onRegattaClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-clubwebsite').hide();
|
$('#menu-item-clubwebsite').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#menu-regatta').showMenu();
|
$('#menu-regatta').showMenu();
|
||||||
$('#menu-regatta').scrollTop(0);
|
$('#menu-regatta').scrollTop(0);
|
||||||
}
|
}
|
||||||
|
|||||||
312
server/scripts/planning.js
Normal file
312
server/scripts/planning.js
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
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) {
|
||||||
|
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 ändern');
|
||||||
|
} else {
|
||||||
|
log('Login: unbekannter Fehler', status, error);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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(' ') + '</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();
|
||||||
|
}
|
||||||
473
server/scripts/planning_edit.js
Normal file
473
server/scripts/planning_edit.js
Normal file
@@ -0,0 +1,473 @@
|
|||||||
|
async function planningSwitchChanged() {
|
||||||
|
showLoader();
|
||||||
|
var id = $('#switch-planning-include').data('regatta');
|
||||||
|
var include = $('#switch-planning-include').prop('checked');
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
if (include) {
|
||||||
|
// add to planning
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_add',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: id
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
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 die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log('planning_add: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(id);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// remove from planning
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_remove',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: id
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
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 die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log('planning_remove: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(id);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var sailorIsSteuermann;
|
||||||
|
var sailors = [];
|
||||||
|
|
||||||
|
async function sailorSelected(sid) {
|
||||||
|
$('#menu-sailor').hideMenu();
|
||||||
|
showLoader();
|
||||||
|
var rid = $('#switch-planning-include').data('regatta');
|
||||||
|
var action = (sailorIsSteuermann ? 'planning_set_steuermann' : 'planning_add_crew');
|
||||||
|
// add sailor
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + action,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: rid,
|
||||||
|
sailor: sid
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
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 die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log(action + ': unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(rid);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sailorsSearch() {
|
||||||
|
$('.item-sailor-search').remove();
|
||||||
|
if (sailorIsSteuermann) {
|
||||||
|
var item = '<a class="item-sailor-search" onclick="sailorSelected(null)">';
|
||||||
|
item += '<span style="font-style:italic;">noch unklar</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-sailor').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
if ($('#input-edit-search').val().length >= 3) {
|
||||||
|
sailors.forEach(function (entry) {
|
||||||
|
if (search($('#input-edit-search').val(), entry.keywords)) {
|
||||||
|
$('#menu-sailor').find('.content').find('.list-group').append(entry.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var item = '<p class="item-sailor-search">Gib mindestens 3 Zeichen ein</p>';
|
||||||
|
$('#menu-sailor').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initSailors() {
|
||||||
|
sailors = [];
|
||||||
|
var dbSailors = await dbGetData('sailors');
|
||||||
|
dbSailors.sort(function(a,b){
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
|
for (s in dbSailors) {
|
||||||
|
var item = '<a class="item-sailor-search" onclick="sailorSelected(' + dbSailors[s].id + ')">';
|
||||||
|
item += '<span>' + dbSailors[s].name + '</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
sailors.push({
|
||||||
|
keywords: [dbSailors[s].name],
|
||||||
|
content: item
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningChangeCrew(sid = null) {
|
||||||
|
if (sid !== null) {
|
||||||
|
showLoader();
|
||||||
|
var rid = $('#switch-planning-include').data('regatta');
|
||||||
|
// remove sailor
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_remove_crew',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: rid,
|
||||||
|
sailor: sid
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
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 die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log('planning_remove_crew: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(rid);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
sailorIsSteuermann = false;
|
||||||
|
$('#input-edit-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
sailorsSearch();
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
$('#menu-sailor').find('.menu-title').find('h1').text('Crew hinzufügen');
|
||||||
|
$('#menu-sailor').showMenu();
|
||||||
|
$('#input-edit-search').focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningChangeSteuermann() {
|
||||||
|
sailorIsSteuermann = true;
|
||||||
|
$('#input-edit-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
sailorsSearch();
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
$('#menu-sailor').find('.menu-title').find('h1').text('Steuermann/-frau bearbeiten');
|
||||||
|
$('#menu-sailor').showMenu();
|
||||||
|
$('#input-edit-search').focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningEdit(id) {
|
||||||
|
var regatta = await dbGetData('regattas', id);
|
||||||
|
|
||||||
|
$('#menu-edit').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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#switch-planning-include').data('regatta', id);
|
||||||
|
if (planning !== null) {
|
||||||
|
$('#switch-planning-include').prop('checked', true);
|
||||||
|
$('#item-steuermann').show();
|
||||||
|
if (planning.steuermann !== null) {
|
||||||
|
$('#item-steuermann').find('span').text('Am Steuer: ' + (await dbGetData('sailors', planning.steuermann)).name);
|
||||||
|
} else {
|
||||||
|
$('#item-steuermann').find('span').html('Am Steuer: <font style="font-style:italic;">noch unklar</font>');
|
||||||
|
}
|
||||||
|
$('.item-crew').remove();
|
||||||
|
var crew = planning.crew.split(',');
|
||||||
|
for (c in crew) {
|
||||||
|
var sailor = await dbGetData('sailors', crew[c]);
|
||||||
|
if (sailor !== null) {
|
||||||
|
var item = '<a class="item-crew" onclick="planningChangeCrew(' + sailor.id + ')">';
|
||||||
|
item += '<span>' + sailor.name + '</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-edit').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var item = '<a class="item-crew" onclick="planningChangeCrew()">';
|
||||||
|
item += '<span style="font-style:italic;">Weiteren Segler hinzufügen</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-edit').find('.content').find('.list-group').append(item);
|
||||||
|
} else {
|
||||||
|
$('#switch-planning-include').prop('checked', false);
|
||||||
|
$('#item-steuermann').hide();
|
||||||
|
$('.item-crew').remove();
|
||||||
|
}
|
||||||
|
$('#menu-edit').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()) {
|
||||||
|
location.href = LINK_PRE + 'planning';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initYear();
|
||||||
|
$('#select-year').change(selectChange);
|
||||||
|
$('#input-search').on('input', drawList);
|
||||||
|
$('#switch-planning-include').parent().parent().click(planningSwitchChanged);
|
||||||
|
$('#item-steuermann').click(planningChangeSteuermann);
|
||||||
|
$('#input-edit-search').on('input', sailorsSearch);
|
||||||
|
initSailors();
|
||||||
|
}
|
||||||
|
|
||||||
|
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[i].planning = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 !== null) {
|
||||||
|
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 (!heute && (today <= dateFrom)) {
|
||||||
|
rows.push(null);
|
||||||
|
heute = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.planning !== null) {
|
||||||
|
row.content += '<div onclick="planningEdit(' + entry['id'] + ');">';
|
||||||
|
} else {
|
||||||
|
row.content += '<div onclick="planningEdit(' + entry['id'] + ');" style="opacity:0.5;">';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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>';
|
||||||
|
|
||||||
|
if (entry.planning !== null) {
|
||||||
|
// ZEILE 4
|
||||||
|
row.content += '<div></div>';
|
||||||
|
|
||||||
|
// ZEILE 5
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : 'noch unklar') + '</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>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.content += '<div>Du planst nicht, hierhin zu fahren</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '</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();
|
||||||
|
}
|
||||||
146
server/scripts/planning_list.js
Normal file
146
server/scripts/planning_list.js
Normal 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();
|
||||||
|
}
|
||||||
219
server/scripts/planning_view.js
Normal file
219
server/scripts/planning_view.js
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
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 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 !== null ? entry.planning.steuermann : 'noch unklar') + '</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>';
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
@@ -21,8 +21,8 @@ async function onEditYearClick() {
|
|||||||
if (xhr.status == 0) {
|
if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Jahrgang zu bearbeiten');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Jahrgang zu bearbeiten');
|
||||||
} else {
|
} else {
|
||||||
console.log('EditYear: unbekannter Fehler', status, error);
|
log('EditYear: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
@@ -47,9 +47,9 @@ async function onEditYearClick() {
|
|||||||
|
|
||||||
async function onListClicked(id) {
|
async function onListClicked(id) {
|
||||||
var sailor = await dbGetData('sailors', id);
|
var sailor = await dbGetData('sailors', id);
|
||||||
|
|
||||||
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
|
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
|
||||||
|
|
||||||
// Edit Year
|
// Edit Year
|
||||||
$('#button-edityear').attr('data-sailor-id', sailor.id);
|
$('#button-edityear').attr('data-sailor-id', sailor.id);
|
||||||
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
|
$('#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').val(sailor.year);
|
||||||
}
|
}
|
||||||
$('#input-edityear').trigger('focusin').trigger('focusout');
|
$('#input-edityear').trigger('focusin').trigger('focusout');
|
||||||
|
|
||||||
// club website
|
// club website
|
||||||
var clubwebsite = '';
|
var clubwebsite = '';
|
||||||
if (sailor['club'] != null) {
|
if (sailor['club'] != null) {
|
||||||
@@ -76,7 +76,7 @@ async function onListClicked(id) {
|
|||||||
} else {
|
} else {
|
||||||
$('#menu-item-clubwebsite').hide();
|
$('#menu-item-clubwebsite').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#menu-sailor').showMenu();
|
$('#menu-sailor').showMenu();
|
||||||
$('#menu-sailor').scrollTop(0);
|
$('#menu-sailor').scrollTop(0);
|
||||||
}
|
}
|
||||||
@@ -89,19 +89,19 @@ function pageChange() {
|
|||||||
async function drawList() {
|
async function drawList() {
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
var list = '';
|
var list = '';
|
||||||
|
|
||||||
if (displayed.length > 0) {
|
if (displayed.length > 0) {
|
||||||
var offset = (page - 1) * showCount;
|
var offset = (page - 1) * showCount;
|
||||||
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
|
var count = (page == pageCount ? (displayed.length % showCount) : showCount);
|
||||||
if (count == 0) count = showCount;
|
if (count == 0) count = showCount;
|
||||||
|
|
||||||
for (i = 0; i < count; i ++) {
|
for (i = 0; i < count; i ++) {
|
||||||
list += displayed[i + offset];
|
list += displayed[i + offset];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
|
list = '<div><div>Keine Ergebnisse, die der Suche entsprechen</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#div-list').html(list);
|
$('#div-list').html(list);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
@@ -135,9 +135,9 @@ var siteScript = async function() {
|
|||||||
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
|
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
|
||||||
$('#button-edityear').click(onEditYearClick);
|
$('#button-edityear').click(onEditYearClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = await dbGetData('sailors');
|
var results = await dbGetData('sailors');
|
||||||
|
|
||||||
var count = results.length;
|
var count = results.length;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
@@ -147,51 +147,51 @@ var siteScript = async function() {
|
|||||||
}
|
}
|
||||||
$('#div-list').show();
|
$('#div-list').show();
|
||||||
$('#input-search').parent().show();
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
results.sort(function (a, b) {
|
results.sort(function (a, b) {
|
||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
rows = [];
|
rows = [];
|
||||||
|
|
||||||
for (id in results) {
|
for (id in results) {
|
||||||
var entry = results[id];
|
var entry = results[id];
|
||||||
var club = null;
|
var club = null;
|
||||||
if (entry['club'] != null)
|
if (entry['club'] != null)
|
||||||
club = await dbGetData('clubs', entry['club']);
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
|
||||||
var row = { keywords: [], content: '' };
|
var row = { keywords: [], content: '' };
|
||||||
row.keywords.push(entry['name']);
|
row.keywords.push(entry['name']);
|
||||||
if (entry['year'] != null) row.keywords.push(entry['year']);
|
if (entry['year'] != null) row.keywords.push(entry['year']);
|
||||||
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
|
||||||
row.content += '<div onclick="onListClicked(' + entry['id'] + ');">';
|
row.content += '<div onclick="onListClicked(' + entry['id'] + ');">';
|
||||||
|
|
||||||
// ZEILE 1
|
// ZEILE 1
|
||||||
// Name
|
// Name
|
||||||
row.content += '<div><b>' + entry['name'] + '</b></div>';
|
row.content += '<div><b>' + entry['name'] + '</b></div>';
|
||||||
|
|
||||||
// ZEILE 2
|
// ZEILE 2
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
|
|
||||||
// Year
|
// Year
|
||||||
row.content += '<div>' + ((entry['year'] != null) ? (entry['year']) : '') + '</div>';
|
row.content += '<div>' + ((entry['year'] != null) ? (entry['year']) : '') + '</div>';
|
||||||
|
|
||||||
// Club
|
// Club
|
||||||
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||||
|
|
||||||
row.content += '</div></div>';
|
row.content += '</div></div>';
|
||||||
|
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
reSearch();
|
reSearch();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$('#p-count').html('Keine Segler gefunden!');
|
$('#p-count').html('Keine Segler gefunden!');
|
||||||
$('#div-list').hide();
|
$('#div-list').hide();
|
||||||
$('#input-search').parent().hide();
|
$('#input-search').parent().hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
|
|||||||
8
server/templates/menu/item-switch.html
Normal file
8
server/templates/menu/item-switch.html
Normal 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>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PWA_VERSION', '1.8');
|
define('PWA_VERSION', '1.10.3h2');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ self.addEventListener('push', async function(event) {
|
|||||||
case 'meldeschluss':
|
case 'meldeschluss':
|
||||||
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
|
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
|
||||||
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
||||||
|
// TODO: only if not already registered
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -310,3 +311,16 @@ self.addEventListener('notificationclick', function(event) {
|
|||||||
clients.openWindow(url)
|
clients.openWindow(url)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.addEventListener('pushsubscriptionchange', function(event) {
|
||||||
|
var formData = new URLSearchParams();
|
||||||
|
formData.append('old', JSON.stringify(event.oldSubscription));
|
||||||
|
formData.append('new', JSON.stringify(event.newSubscription));
|
||||||
|
event.waitUntil(
|
||||||
|
fetch('<?php echo QUERY_URL; ?>update_subscription', {
|
||||||
|
method: 'POST',
|
||||||
|
cache: 'no-cache',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user