2 Commits
0.1.0 ... 1.2.0

Author SHA1 Message Date
65a2038da2 timezones 2024-01-04 17:39:50 +07:00
1e80907235 fix rtl / symbol 2024-01-04 16:42:54 +07:00
2 changed files with 61 additions and 84 deletions

View File

@@ -1,82 +0,0 @@
<?php
declare(strict_types=1);
namespace mirzaev\site\repression\controllers;
// Файлы проекта
use mirzaev\site\repression\controllers\core;
/**
* Контроллер бегущей строки
*
* @package mirzaev\site\repression\controllers
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class hotline_controller extends core
{
/**
* Страница с бегущей строкой
*
* Можно использовать совместно с элементом <iframe> для изоляции
* содержимого бегущей строки от поисковых роботов
*
* @param array $parameters
*/
public function index(array $parameters = []): ?string
{
// Инициализация элементов для генерации в головном элементе
$this->variables['head'] = [
'title' => 'Бегущая строка',
'metas' => [
[
'attributes' => [
'name' => 'robots',
'content' => 'nofollow'
]
]
]
];
// Инициализация бегущей строки
$this->variables['hotline'] = [
'id' => $this->variables['request']['id'] ?? 'hotline'
];
// Инициализация параметров бегущей строки
$this->variables['hotline']['parameters'] = [
// 'step' => 2
];
// Инициализация аттрибутов бегущей строки
$this->variables['hotline']['attributes'] = [
];
// Инициализация элементов бегущей строки
$this->variables['hotline']['elements'] = [
['content' => '1'],
[
'tag' => 'article',
'content' => '2'
],
['content' => '3'],
['content' => '4'],
['content' => '5'],
['content' => '6'],
['content' => '7'],
['content' => '8'],
['content' => '9'],
['content' => '10'],
['content' => '11'],
['content' => '12'],
['content' => '13'],
['content' => '14'],
['content' => '15']
];
// Генерация представления
return $this->view->render(DIRECTORY_SEPARATOR . 'hotline' . DIRECTORY_SEPARATOR . 'index.html', $this->variables);
}
}

View File

@@ -80,9 +80,12 @@
<p>
<span title="{{ view.country_name }}" class="unselectable">{{ view.country_flag.emoji }}</span>
<span title="{{ view.region }}">{{ view.region }}</span>
{% if view.referer is not null %}<samp>(<small title="{{ view.referer }}">{{ view.referer }}</small>)</samp>{% endif %}
{% if view.referer is not null %}<samp>(<small title="{{ view.referer }}&lrm;">{{ view.referer
}}&lrm;</small>)</samp>{% endif %}
<span title="{{ view.useragent }}">{{ view['x-forwarded-for'] ?? view.ip }}</span>
<span title="{{ view.created|date('Y.m.d H:i:s') }}"><b>{{ view.created|date('H:i:s') }}</b></span>
<span title="{{ view.created }}" data-date-convert="title" data-date-convert-format="year.month.day hour:minute:second">
<b data-date-convert="value">{{ view.created }}</b>
</span>
</p>
{% endfor %}
</section>
@@ -146,6 +149,62 @@
{{ block('header_js_init') }}
{{ block('troller_js_init') }}
<script>
// Generate dates with user timezone
for (const element of document.body.querySelectorAll('[data-date-convert]')) {
// Enumerating elements to convert
// Initializing a format of convertation
const format = element.getAttribute('data-date-convert-format') ?? 'hour:minute:second';
if (element.getAttribute('data-date-convert') === 'title') {
// Title
// Initializing a date with timezone
const date = new Date(element.getAttribute('title') * 1000);
// Initializing parts of the date
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDay();
let hour = date.getHours();
let minute = date.getMinutes();
let second = date.getSeconds();
// Convertation parts of the date to double symbols
month = (month < 10 ? "0" : '') + month;
day = (day < 10 ? "0" : '') + day;
hour = (hour < 10 ? "0" : '') + hour;
minute = (minute < 10 ? "0" : '') + minute;
second = (second < 10 ? "0" : '') + second;
if (format === 'hour:minute:second') element.setAttribute('title', `${hour}:${minute}:${second}`);
else if (format === 'year.month.day hour:minute:second') element.setAttribute('title', `${year}.${month}.${day} ${hour}:${minute}:${second}`);
} else {
// Value (implied)
// Initializin a date with timezone
const date = new Date(element.innerText * 1000);
// Initializing parts of the date
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDay();
let hour = date.getHours();
let minute = date.getMinutes();
let second = date.getSeconds();
// Convertation parts of the date to double symbols
month = (month < 10 ? "0" : '') + month;
day = (day < 10 ? "0" : '') + day;
hour = (hour < 10 ? "0" : '') + hour;
minute = (minute < 10 ? "0" : '') + minute;
second = (second < 10 ? "0" : '') + second;
if (format === 'hour:minute:second') element.innerText = `${hour}:${minute}:${second}`;
else if (format === 'year.month.day hour:minute:second') element.innerText = `${year}.${month}.${day} ${hour}:${minute}:${second}`;
}
}
document.addEventListener('bloodchaos.loaded', function(e) {
const bloodchaos = e.detail.bloodchaos;