forked from mirzaev/ff
оптимизация генерация страниц и шутника
This commit is contained in:
parent
eaeb2babfe
commit
1459a909d1
|
@ -22,48 +22,14 @@ final class index_controller extends core
|
|||
*/
|
||||
public function index(array $parameters = []): ?string
|
||||
{
|
||||
// Инициализация загружаемых категорий
|
||||
$this->variables['include'] = [
|
||||
'head' => ['self'],
|
||||
'body' => ['self']
|
||||
// Инициализация шутника
|
||||
$this->variables['troller'] = [
|
||||
'instasamka' => rand(1, 11),
|
||||
'vk' => (bool) rand(0, 1),
|
||||
'whatsapp' => (bool) rand(0, 1),
|
||||
'iphone' => (bool) rand(0, 1),
|
||||
];
|
||||
|
||||
// Инициализация бегущей строки
|
||||
$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 . 'index.html', $this->variables);
|
||||
|
|
|
@ -20,24 +20,24 @@ class troller {
|
|||
},
|
||||
start() {
|
||||
// Отображение изображения
|
||||
document.getElementById("what_image").classList.add("active");
|
||||
document.getElementById("troller_image_what").classList.add("active");
|
||||
|
||||
// Проигрывание звука
|
||||
troller.what.play();
|
||||
},
|
||||
end() {
|
||||
// Сокрытие изображения
|
||||
document.getElementById("what_image").classList.remove("active");
|
||||
document.getElementById("troller_image_what").classList.remove("active");
|
||||
|
||||
// Остановка звука
|
||||
document.getElementById("what_sound").pause();
|
||||
document.getElementById("troller_sound_what").pause();
|
||||
},
|
||||
single(event = "onmouseleave") {
|
||||
if (typeof event === "string") {
|
||||
// Получены обязательные входные параметры
|
||||
|
||||
// Отображение изображения
|
||||
document.getElementById("what_image").classList.add("active");
|
||||
document.getElementById("troller_image_what").classList.add("active");
|
||||
|
||||
// Проигрывание звука
|
||||
troller.what.play();
|
||||
|
@ -51,7 +51,7 @@ class troller {
|
|||
},
|
||||
play() {
|
||||
// Инициализация элемента со звуком
|
||||
const what_sound = document.getElementById("what_sound");
|
||||
const what_sound = document.getElementById("troller_sound_what");
|
||||
|
||||
// Воспроизведение звука
|
||||
what_sound.currentTime = 0;
|
||||
|
@ -61,7 +61,7 @@ class troller {
|
|||
|
||||
static vk() {
|
||||
setInterval(function () {
|
||||
const sound = document.getElementById("sound_vk");
|
||||
const sound = document.getElementById("troller_sound_vk");
|
||||
|
||||
if (Math.random() > 0.95) {
|
||||
// 5%
|
||||
|
@ -75,7 +75,7 @@ class troller {
|
|||
|
||||
static whatsapp() {
|
||||
setInterval(function () {
|
||||
const sound = document.getElementById("sound_whatsup");
|
||||
const sound = document.getElementById("troller_sound_whatsup");
|
||||
|
||||
if (Math.random() > 0.97) {
|
||||
// 3%
|
||||
|
@ -89,7 +89,7 @@ class troller {
|
|||
|
||||
static iphone() {
|
||||
setInterval(function () {
|
||||
const sound = document.getElementById("sound_iphone");
|
||||
const sound = document.getElementById("troller_sound_iphone");
|
||||
|
||||
if (Math.random() > 0.98) {
|
||||
// 2%
|
||||
|
@ -102,9 +102,9 @@ class troller {
|
|||
}
|
||||
|
||||
static instasamka = {
|
||||
play(track, time) {
|
||||
play(time) {
|
||||
// Инициализация элемента со звуком
|
||||
const sound = document.querySelectorAll('[data-instasamka]')[track];
|
||||
const sound = document.getElementById("troller_sound_instasamka");
|
||||
|
||||
if (sound instanceof HTMLElement) {
|
||||
// Найден звук
|
||||
|
@ -112,34 +112,17 @@ class troller {
|
|||
// Воспроизведение звука
|
||||
sound.currentTime = time ?? Math.random() * 100;
|
||||
sound.play();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[mirzaev] [troller] Не удалось найти песню инстасамки под идентификатором ' + track);
|
||||
|
||||
} else {
|
||||
// Не найден звук (подразумевается)
|
||||
troller.instasamka.play(1, time);
|
||||
|
||||
console.log('[mirzaev] [troller] Не удалось найти песню инстасамки');
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
troller.what.enable();
|
||||
|
||||
if (Math.random() > 0.60) {
|
||||
// 40%
|
||||
|
||||
troller.vk();
|
||||
}
|
||||
|
||||
if (Math.random() > 0.60) {
|
||||
// 40%
|
||||
|
||||
troller.whatsapp();
|
||||
}
|
||||
|
||||
if (Math.random() > 0.60) {
|
||||
// 40%
|
||||
|
||||
troller.iphone();
|
||||
}
|
||||
document.dispatchEvent(
|
||||
new CustomEvent("troller.loaded", {
|
||||
detail: { troller },
|
||||
}),
|
||||
);
|
|
@ -1,20 +1,20 @@
|
|||
{% extends "core.html" %}
|
||||
|
||||
{% use "core.html" with css as core_css, body as core_body, js as core_js, js_init as core_js_init %}
|
||||
{% use "trolling.html" with css as trolling_css, body as trolling_body, js as trolling_js %}
|
||||
{% use "troller.html" with css as troller_css, body as troller_body, js as troller_js, js_init as troller_js_init %}
|
||||
{% use "popups/rules.html" with css as popup_rules_css, body as popup_rules_body %}
|
||||
{% use "header.html" with css as header_css, body as header_body, js as header_js, js_init as header_js_init %}
|
||||
|
||||
{% block css %}
|
||||
{{ block('core_css') }}
|
||||
{{ block('trolling_css') }}
|
||||
{{ block('troller_css') }}
|
||||
{{ block('popup_rules_css') }}
|
||||
{{ block('header_css') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{{ block('core_body') }}
|
||||
{{ block('trolling_body') }}
|
||||
{{ block('troller_body') }}
|
||||
{{ block('popup_rules_body') }}
|
||||
{{ block('header_body') }}
|
||||
|
||||
|
@ -30,11 +30,12 @@
|
|||
|
||||
{% block js %}
|
||||
{{ block('core_js') }}
|
||||
{{ block('trolling_js') }}
|
||||
{{ block('troller_js') }}
|
||||
{{ block('header_js') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block js_init %}
|
||||
{{ block('core_js_init') }}
|
||||
{{ block('header_js_init') }}
|
||||
{{ block('troller_js_init') }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</ol>
|
||||
<div class="row separated">
|
||||
<button
|
||||
onclick="troller.instasamka.play(Math.round(Math.random() * 10)); this.parentElement.parentElement.parentElement.remove();">Прочитал</button>
|
||||
onclick="troller.instasamka.play(); this.parentElement.parentElement.parentElement.remove();">Прочитал</button>
|
||||
<button onclick="troller.what.play(); alert('ты идиот?'); this.disabled = true">Не прочитал</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
{% block css %}
|
||||
<link rel="stylesheet" type="text/css" href="/css/troller.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<img id="troller_image_what" class="hide" src="/images/what.png" />
|
||||
<audio id="troller_sound_what" class="hide" src="/sounds/what.mp3" controls></audio>
|
||||
{% if troller.vk %}
|
||||
<audio id="troller_sound_vk" class="hide" src="/sounds/vk.mp3" controls></audio>
|
||||
<script>
|
||||
document.addEventListener('troller.loaded', function (e) {
|
||||
// Загружен документ с классом шутника
|
||||
|
||||
// Активация интервального воспроизведения звука сообщения ВКонтакте
|
||||
e.detail.troller.vk();
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% if troller.whatsapp %}
|
||||
<audio id="troller_sound_whatsup" class="hide" src="/sounds/whatsup.mp3" controls></audio>
|
||||
<script>
|
||||
document.addEventListener('troller.loaded', function (e) {
|
||||
// Загружен документ с классом шутника
|
||||
|
||||
// Активация интервального воспроизведения звука сообщения WhatsApp
|
||||
e.detail.troller.whatsapp();
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% if troller.iphone %}
|
||||
<audio id="troller_sound_iphone" class="hide" src="/sounds/iphone.mp3" controls></audio>
|
||||
<script>
|
||||
document.addEventListener('troller.loaded', function (e) {
|
||||
// Загружен документ с классом шутника
|
||||
|
||||
// Активация интервального воспроизведения звука сообщения iPhone
|
||||
e.detail.troller.iphone();
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
<audio id="troller_sound_instasamka" class="hide" src="/sounds/instasamka/{{ troller.instasamka ?? 1 }}.mp3" preload="auto" loop="true"></audio>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="/js/troller.js" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block js_init %}
|
||||
<script>
|
||||
document.addEventListener('troller.loaded', function (e) {
|
||||
// Загружен документ с классом шутника
|
||||
|
||||
// Активация изображения при потере фокуса с окна
|
||||
e.detail.troller.what.enable();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -1,26 +0,0 @@
|
|||
{% block css %}
|
||||
<link rel="stylesheet" type="text/css" href="/css/trolling.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<img id="what_image" class="hide" src="/images/what.png" />
|
||||
<audio id="what_sound" class="hide" src="/sounds/what.mp3" controls></audio>
|
||||
<audio id="sound_vk" class="hide" src="/sounds/vk.mp3" controls></audio>
|
||||
<audio id="sound_whatsup" class="hide" src="/sounds/whatsup.mp3" controls></audio>
|
||||
<audio id="sound_iphone" class="hide" src="/sounds/iphone.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/1.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/2.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/3.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/4.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/5.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/6.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/7.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/8.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/9.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/10.mp3" controls></audio>
|
||||
<audio data-instasamka class="hide" src="/sounds/instasamka/11.mp3" controls></audio>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="/js/trolling.js" defer></script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue