Merge pull request #1573 from bramley/correct_good_afternoon

Welcome message displays "good night" in the afternoon
This commit is contained in:
Diego Najar 2024-08-06 22:40:05 +02:00 committed by GitHub
commit 151c5ab482
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,140 +1,140 @@
<div id="dashboard" class="container"> <div id="dashboard" class="container">
<div class="row"> <div class="row">
<div class="col-md-7"> <div class="col-md-7">
<!-- Good message --> <!-- Good message -->
<div> <div>
<h2 id="hello-message" class="pt-0"> <h2 id="hello-message" class="pt-0">
<?php <?php
$username = $login->username(); $username = $login->username();
$user = new User($username); $user = new User($username);
$name = ''; $name = '';
if ($user->nickname()) { if ($user->nickname()) {
$name = $user->nickname(); $name = $user->nickname();
} elseif ($user->firstName()) { } elseif ($user->firstName()) {
$name = $user->firstName(); $name = $user->firstName();
} }
?> ?>
<span class="fa fa-hand-spock-o"></span><span><?php echo $L->g('welcome') ?></span> <span class="fa fa-hand-spock-o"></span><span><?php echo $L->g('welcome') ?></span>
</h2> </h2>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$("#hello-message").fadeOut(2400, function() { $("#hello-message").fadeOut(2400, function() {
var date = new Date() var date = new Date()
var hours = date.getHours() var hours = date.getHours()
if (hours > 6 && hours < 12) { if (hours >= 6 && hours < 12) {
$(this).html('<span class="fa fa-sun-o"></span><?php echo $L->g('good-morning') . ', ' . $name ?>'); $(this).html('<span class="fa fa-sun-o"></span><?php echo $L->g('good-morning') . ', ' . $name ?>');
} else if (hours > 12 && hours < 18) { } else if (hours >= 12 && hours < 18) {
$(this).html('<span class="fa fa-sun-o"></span><?php echo $L->g('good-afternoon') . ', ' . $name ?>'); $(this).html('<span class="fa fa-sun-o"></span><?php echo $L->g('good-afternoon') . ', ' . $name ?>');
} else if (hours > 18 && hours < 22) { } else if (hours >= 18 && hours < 22) {
$(this).html('<span class="fa fa-moon-o"></span><?php echo $L->g('good-evening') . ', ' . $name ?>'); $(this).html('<span class="fa fa-moon-o"></span><?php echo $L->g('good-evening') . ', ' . $name ?>');
} else { } else {
$(this).html('<span class="fa fa-moon-o"></span><span><?php echo $L->g('good-night') . ', ' . $name ?></span>'); $(this).html('<span class="fa fa-moon-o"></span><span><?php echo $L->g('good-night') . ', ' . $name ?></span>');
} }
}).fadeIn(1000); }).fadeIn(1000);
}); });
</script> </script>
</div> </div>
<!-- Quick Links --> <!-- Quick Links -->
<div class="container pb-5" id="jsclippyContainer"> <div class="container pb-5" id="jsclippyContainer">
<div class="row"> <div class="row">
<div class="col p-0"> <div class="col p-0">
<div class="form-group"> <div class="form-group">
<select id="jsclippy" class="clippy" name="state"></select> <select id="jsclippy" class="clippy" name="state"></select>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
var clippy = $("#jsclippy").select2({ var clippy = $("#jsclippy").select2({
placeholder: "<?php $L->p('Start typing to see a list of suggestions') ?>", placeholder: "<?php $L->p('Start typing to see a list of suggestions') ?>",
allowClear: true, allowClear: true,
width: "100%", width: "100%",
theme: "bootstrap4", theme: "bootstrap4",
minimumInputLength: 2, minimumInputLength: 2,
dropdownParent: "#jsclippyContainer", dropdownParent: "#jsclippyContainer",
language: { language: {
inputTooShort: function() { inputTooShort: function() {
return ''; return '';
} }
}, },
ajax: { ajax: {
url: HTML_PATH_ADMIN_ROOT + "ajax/clippy", url: HTML_PATH_ADMIN_ROOT + "ajax/clippy",
data: function(params) { data: function(params) {
var query = { var query = {
query: params.term query: params.term
} }
return query; return query;
}, },
processResults: function(data) { processResults: function(data) {
return data; return data;
} }
}, },
templateResult: function(data) { templateResult: function(data) {
// console.log(data); // console.log(data);
var html = ''; var html = '';
if (data.type == 'menu') { if (data.type == 'menu') {
html += '<a href="' + data.url + '"><div class="search-suggestion">'; html += '<a href="' + data.url + '"><div class="search-suggestion">';
html += '<span class="fa fa-' + data.icon + '"></span>' + data.text + '</div></a>'; html += '<span class="fa fa-' + data.icon + '"></span>' + data.text + '</div></a>';
} else { } else {
if (typeof data.id === 'undefined') { if (typeof data.id === 'undefined') {
return ''; return '';
} }
html += '<div class="search-suggestion">'; html += '<div class="search-suggestion">';
html += '<div class="search-suggestion-item">' + data.text + ' <span class="badge badge-pill badge-light">' + data.type + '</span></div>'; html += '<div class="search-suggestion-item">' + data.text + ' <span class="badge badge-pill badge-light">' + data.type + '</span></div>';
html += '<div class="search-suggestion-options">'; html += '<div class="search-suggestion-options">';
html += '<a target="_blank" href="' + DOMAIN_PAGES + data.id + '"><?php $L->p('view') ?></a>'; html += '<a target="_blank" href="' + DOMAIN_PAGES + data.id + '"><?php $L->p('view') ?></a>';
html += '<a class="ml-2" href="' + DOMAIN_ADMIN + 'edit-content/' + data.id + '"><?php $L->p('edit') ?></a>'; html += '<a class="ml-2" href="' + DOMAIN_ADMIN + 'edit-content/' + data.id + '"><?php $L->p('edit') ?></a>';
html += '</div></div>'; html += '</div></div>';
} }
return html; return html;
}, },
escapeMarkup: function(markup) { escapeMarkup: function(markup) {
return markup; return markup;
} }
}).on("select2:closing", function(e) { }).on("select2:closing", function(e) {
e.preventDefault(); e.preventDefault();
}).on("select2:closed", function(e) { }).on("select2:closed", function(e) {
clippy.select2("open"); clippy.select2("open");
}); });
clippy.select2("open"); clippy.select2("open");
}); });
</script> </script>
</div> </div>
<?php Theme::plugins('dashboard') ?> <?php Theme::plugins('dashboard') ?>
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<!-- Notifications --> <!-- Notifications -->
<ul class="list-group list-group-striped b-0"> <ul class="list-group list-group-striped b-0">
<li class="list-group-item pt-0"> <li class="list-group-item pt-0">
<h4 class="m-0"><?php $L->p('Notifications') ?></h4> <h4 class="m-0"><?php $L->p('Notifications') ?></h4>
</li> </li>
<?php <?php
$logs = array_slice($syslog->db, 0, NOTIFICATIONS_AMOUNT); $logs = array_slice($syslog->db, 0, NOTIFICATIONS_AMOUNT);
foreach ($logs as $log) { foreach ($logs as $log) {
$phrase = $L->g($log['dictionaryKey']); $phrase = $L->g($log['dictionaryKey']);
echo '<li class="list-group-item">'; echo '<li class="list-group-item">';
echo $phrase; echo $phrase;
if (!empty($log['notes'])) { if (!empty($log['notes'])) {
echo ' « <b>' . $log['notes'] . '</b> »'; echo ' « <b>' . $log['notes'] . '</b> »';
} }
echo '<br><span class="notification-date"><small>'; echo '<br><span class="notification-date"><small>';
echo Date::format($log['date'], DB_DATE_FORMAT, NOTIFICATIONS_DATE_FORMAT); echo Date::format($log['date'], DB_DATE_FORMAT, NOTIFICATIONS_DATE_FORMAT);
echo ' [ ' . $log['username'] . ' ]'; echo ' [ ' . $log['username'] . ' ]';
echo '</small></span>'; echo '</small></span>';
echo '</li>'; echo '</li>';
} }
?> ?>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>