Added hide event option

Added option to hide Events. Next to all event notifications, an "X" will now be displays, which hides the notification if clicked until a new event notification is shown. This works by setting a cookie with the ID of the event notification. Learn more about this on the Blog post here: https://blog.littlelink-custom.com/hide-event-option/
This commit is contained in:
Julian Prieber 2022-03-20 23:43:27 +01:00 committed by GitHub
parent 29d5c7d4b2
commit e319301b51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 2 deletions

View File

@ -197,11 +197,26 @@
<?php <?php
$GetEventJson = file_get_contents("https://julianprieber.github.io/littlelink-custom-events/event.json"); $GetEventJson = file_get_contents("https://julianprieber.github.io/littlelink-custom-events/event.json");
$EventJson = json_decode($GetEventJson, true); $EventJson = json_decode($GetEventJson, true);
if(isset($_COOKIE['HideEvent']) == NULL) {
setcookie("HideEvent",$_COOKIE['ID'] = "0", time()+60*60*24*5, "/");
header('Location: ' . url('/panel/index'));
exit();
}
?> ?>
@if(auth()->user()->role == 'admin' and strtotime(date("d-m-Y")) < strtotime($EventJson['enddate'])) @if(auth()->user()->role == 'admin' and strtotime(date("d-m-Y")) < strtotime($EventJson['enddate']))
@if(isset($_COOKIE['HideEvent']) and $_COOKIE['HideEvent'] != $EventJson['id'])
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid"> <div class="container-fluid">
<a class="nav-link" href="{{ $EventJson['link'] }}" target="{{ $EventJson['target'] }}"><mark onMouseOver="{{ $EventJson['hoveron'] }}" onMouseOut="{{ $EventJson['hoveroff'] }}" style="{{ $EventJson['style'] }}" title="{{ $EventJson['hover'] }}">{{ $EventJson['title'] }}</mark></a>
<a class="nav-link" href="{{ $EventJson['link'] }}" target="{{ $EventJson['target'] }}"><mark onMouseOver="{{ $EventJson['hoveron'] }}" onMouseOut="{{ $EventJson['hoveroff'] }}" style="{{ $EventJson['style'] }}" title="{{ $EventJson['hover'] }}">{{ $EventJson['title'] }}</mark></a> <a href="?hide_event" title="Click to hide this message"></a>
<?php
if (strpos($_SERVER['REQUEST_URI'], "hide_event") !== false){
setcookie("HideEvent",$_COOKIE['ID'] = $EventJson['id'], time()+60*60*24*5, "/");
header('Location: ' . url('/panel/index'));
exit();
}
?>
</div> </div>
</nav> </nav>
@endif @endif
@ -215,6 +230,7 @@ if(localStorage.getItem("firstTime")==null){
} }
</script> </script>
@endif @endif
@endif
<! #### end event detection #### > <! #### end event detection #### >
@yield('content') @yield('content')