25 コミット

作成者 SHA1 メッセージ 日付
みてるぞ 72cdadb673 'broadcast/assets' にファイルをアップロード 2024-07-19 21:50:01 +09:00
みてるぞ 801db8994b [BC] ちょっと修正 2024-05-16 03:07:52 +09:00
みてるぞ 3d3c350777 [BC] 自動更新対応完了 2024-05-16 02:59:55 +09:00
みてるぞ a26a0ac130 deleted php-styled rendering 2024-05-15 03:53:42 +00:00
みてるぞ 2cf8b64f1f Ajax 用の呼出プログラム作成 2024-05-15 03:18:44 +09:00
みてるぞ 3e97e3c4f4 [BC] available の hidden 要らん 2024-05-04 00:39:41 +09:00
みてるぞ b9c990d6b5 [BC] ニジカ落ちの警報表示 2024-05-04 00:24:46 +09:00
みてるぞ 506c29a32d [BC] 詳細画面 改行可能に 2024-05-03 16:35:14 +09:00
みてるぞ 535e44c4e7 ダブル・クヲゥトを escape 2024-05-02 06:43:16 +09:00
miteruzo ba39be8551 落ち確認 2024-05-02 06:33:51 +09:00
みてるぞ d50e23172b [BC] 詳細画面 とりま動くものにはなった 2024-04-25 04:07:32 +09:00
みてるぞ 0a1e46dd37 BC詳細画面 2024-04-24 04:51:42 +09:00
みてるぞ 2fba77b89f 'broadcast/index.frm.php' を更新 2024-04-23 04:08:00 +09:00
miteruzo b447c96d2e てすと 2024-04-23 04:07:18 +09:00
みてるぞ 4cae005dfe 'broadcast/index.frm.php' を更新 2024-04-23 03:59:35 +09:00
みてるぞ 101ca991a8 'broadcast/webhook.php' を更新 2024-04-23 03:58:46 +09:00
みてるぞ 82d366de79 'broadcast/index.frm.php' を更新 2024-04-23 03:57:34 +09:00
miteruzo 4c7a0dbe59 自動 Pull に対応(Jenkins 入れんでよかったやん……時間返せ) 2024-04-23 03:55:17 +09:00
みてるぞ 12af789385 ニジカのしっぽ手前に 2024-04-08 20:55:24 +09:00
みてるぞ b0823f7766 'broadcast/index.frm.php' を更新 2024-04-08 00:15:50 +09:00
みてるぞ 96a3ff125b キャッシュ・クリア 2024-04-08 00:12:53 +09:00
みてるぞ 46b231c6ac ちょっと修正 2024-04-08 00:03:07 +09:00
みてるぞ 2df0e1d9f5 ニジカ Pagination 完成 2024-04-07 23:54:34 +09:00
みてるぞ cbb64ddcf1 Merge branch 'main' into bc-page-body 2024-04-07 20:36:19 +09:00
みてるぞ 57b261a751 ニジカ Pagination 2024-03-31 19:29:40 +09:00
20個のファイルの変更607行の追加166行の削除
実行可能ファイル
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更後

幅:  |  高さ:  |  サイズ: 450 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更後

幅:  |  高さ:  |  サイズ: 40 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.
バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更後

幅:  |  高さ:  |  サイズ: 1.0 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更後

幅:  |  高さ:  |  サイズ: 3.1 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更後

幅:  |  高さ:  |  サイズ: 9.3 KiB

バイナリ
ファイルの表示
バイナリファイルは表示されません.

変更後

幅:  |  高さ:  |  サイズ: 42 KiB

+44
ファイルの表示
@@ -0,0 +1,44 @@
export default class
CommonModule
{
static
isWide (chr)
{
return chr.match (/[^\x01-\x7f]/) !== null;
}
static
lenByFull (str)
{
return str.split ('').map (c => this.isWide (c) ? 1 : .5)
.reduce ((a, c) => a + c);
}
static
indexByFToC (str, index)
{
let i = 0;
let work = '';
for (let c of str)
{
work += c;
if (this.lenByFull (work) > index)
break;
i += 1;
}
return i;
}
static
midByFull (str, start, length)
{
const trimmedLeft = str.slice (this.indexByFToC (str, start));
return trimmedLeft.slice (0, this.indexByFToC (trimmedLeft, length));
}
}
+32 -45
ファイルの表示
@@ -1,3 +1,5 @@
<!-- vim:set tabstop=4 softtabstop=4 expandtab :-->
<!DOCTYPE html>
<html lang="ja">
<head>
@@ -9,7 +11,7 @@
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-ja.min.js"></script>
<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.min.css" />
<link href="./style.css" rel="stylesheet" />
<link href="./style.css?<?= filemtime ('./style.css') ?>" rel="stylesheet" />
<?php $april_fool = ((int) date ('n') === 4) && ((int) date ('j') === 1) ?>
<?php if ($april_fool): ?>
<link rel="icon" href="favicon-goatoh.ico" />
@@ -20,6 +22,12 @@
</head>
<body>
<?php if (!($available)): ?>
<div class="alert alert-danger" role="alert">
<strong>【警報】</strong>AIニジカが落ちてるぬ゛〜゛ん゛(泣)
</div>
<?php endif ?>
<div class="container my-5">
<div class="accordion mb-5" id="accordion-filter">
<div class="accordion-item">
@@ -40,7 +48,7 @@
<div class="col-sm">
<div class="row align-items-center">
<div class="col form-check">
<input class="form-check-input" type="radio" name="order" id="order-desc"<?= $asc ? '' : ' checked="checked"' ?> />
<input class="form-check-input" type="radio" name="order" id="order-desc" checked="checked" />
<label class="form-check-label" for="order-desc">
新しい順
@@ -48,7 +56,7 @@
</div>
<div class="col form-check">
<input class="form-check-input" type="radio" name="order" id="order-asc"<?= $asc ? ' checked="checked"' : '' ?> />
<input class="form-check-input" type="radio" name="order" id="order-asc" />
<label class="form-check-label" for="order-asc">
古い順
@@ -68,11 +76,15 @@
</div>
<div class="col-sm input-group">
<input type="text" class="form-control" placeholder="YYYY-MM-DD" id="filter-date-start"
value="<?= $date_start ?>" />
<input type="text"
class="form-control"
placeholder="YYYY-MM-DD"
id="filter-date-start" />
<span class="input-group-text">〜</span>
<input type="text" class="form-control" placeholder="YYYY-MM-DD" id="filter-date-end"
value="<?= $date_end ?>" />
<input type="text"
class="form-control"
placeholder="YYYY-MM-DD"
id="filter-date-end" />
</div>
</div>
@@ -82,8 +94,10 @@
</div>
<div class="col-sm">
<input type="text" class="form-control" placeholder="<?= $april_fool ? 'ムムムム!! クサタベテル!!!!!' : 'ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛' ?>" id="filter-keyword"
value="<?= $keyword ?>"/>
<input type="text"
class="form-control"
placeholder="<?= $april_fool ? 'ムムムム!! クサタベテル!!!!!' : 'ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛' ?>"
id="filter-keyword" />
</div>
</div>
</div>
@@ -102,47 +116,20 @@
</div>
</div>
<?php if (count ($log_data) > 0): ?>
<div class="mb-4">
<?php require 'pagination.cmp.php' ?>
</div>
<div class="mb-4">
<?php require 'pagination.cmp.php' ?>
</div>
<div>
<?php foreach (array_slice ($log_data,
($page - 1) * $length,
$length,
true) as $record): ?>
<div class="mb-4">
<div>
<?= $record['date_time'] ?>
</div>
<div id="message-list">
</div>
<div>
<img src="<?= $record['chat_icon'] ?>" width="64" height="64" />
<?= $record['chat_name'] ?>
</div>
<div style="color: blue">
&gt; <span style="font-style: italic"><?= $record['chat_message'] ?></span>
</div>
<div>
<?= $record['answer'] ?>
</div>
</div>
<?php endforeach ?>
</div>
<div class="mt-5">
<?php require 'pagination.cmp.php' ?>
</div>
<?php else: ?>
何も見つかりませんでしたぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛
<?php endif ?>
<div class="mt-5">
<?php require 'pagination.cmp.php' ?>
</div>
</div>
<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script src="./script.js" type="text/javascript"></script>
<script src="./script.js?<?= filemtime ('./script.js') ?>" type="text/javascript"></script>
</body>
</html>
+5 -53
ファイルの表示
@@ -7,59 +7,11 @@ const LOG_PATH = './log.txt';
$log_data = [];
$page = (int) ($_GET['p'] ?? 1);
$length = (int) ($_GET['max'] ?? 20);
$asc = ($_GET['asc'] ?? 0) != 0;
$keyword = trim ($_GET['q'] ?? '');
$escaped = ($_GET['escaped'] ?? 0) != 0;
$date_start = ($_GET['start'] ?? null) ?: null;
$date_end = ($_GET['end'] ?? null) ?: null;
$f = fopen (LOG_PATH, 'r');
if ($f !== false)
{
while (($dt = fgetcsv ($f, 0, "\t")) !== false)
{
$chat_info = json_decode ($dt[1]);
$log_data[] = ['date_time' => $dt[0],
'chat_icon' => $chat_info -> author -> imageUrl,
'chat_name' => $escaped ? htmlspecialchars ($chat_info -> author -> name) : $chat_info -> author -> name,
'chat_message' => $escaped ? htmlspecialchars ($chat_info -> message) : $chat_info -> message,
'answer' => $escaped ? htmlspecialchars ($dt[2]) : $dt[2]];
}
}
fclose ($f);
unset ($f);
if ($keyword != '')
{
$log_data = array_filter ($log_data, fn ($row) => (
strpos ($row['chat_name'] . "\n" . $row['chat_message'] . "\n" . $row['answer'],
$keyword)
!== false));
}
if ($date_start)
{
$log_data = array_filter ($log_data, fn ($row) => (
substr ($row['date_time'], 0, 10) >= $date_start));
}
if ($date_end)
{
$log_data = array_filter ($log_data, fn ($row) => (
substr ($row['date_time'], 0, 10) <= $date_end));
}
$pages_max = (int) ((count ($log_data) - 1) / $length) + 1;
if (!($asc))
$log_data = array_reverse ($log_data);
exec (("(ps -Af | grep -e '^miteruzo' | grep 'python3 main.py')"
. " && (ps -Af | grep -e '^miteruzo' | grep 'obs')"),
$output, $exit_code);
$available = $exit_code === 0;
unset ($output, $exit_code);
require_once './index.frm.php';
+3 -37
ファイルの表示
@@ -1,40 +1,6 @@
<nav class="d-flex justify-content-center" aria-label="...">
<ul class="pagination opacity-0">
<?php if ($page > 1): ?>
<li class="page-item">
<a class="page-link no-wrap" href="javascript: void (0)" onclick="Script.jumpTo (1)">|&lt;</a>
</li>
<?php else: ?>
<li class="page-item disabled">
<span class="page-link">|&lt;</span>
</li>
<?php endif ?>
<!-- vim:set tabstop=4 softtabstop=4 expandtab :-->
<?php for ($i = max (min ($page + 10, $pages_max) - 20, 1); $i < $page; ++$i): ?>
<li class="page-item page-<?= $page - $i ?>">
<a class="page-link" href="javascript: void (0)" onclick="Script.jumpTo (<?= $i ?>)"><?= $i ?></a>
</li>
<?php endfor ?>
<li class="page-item active" aria-current="page">
<span class="page-link"><?= $page ?></span>
</li>
<?php for ($i = $page + 1; $i <= min (max ($page - 10, 1) + 20, $pages_max); ++$i): ?>
<li class="page-item page-<?= $i - $page ?>">
<a class="page-link" href="javascript: void (0)" onclick="Script.jumpTo (<?= $i ?>)"><?= $i ?></a>
</li>
<?php endfor ?>
<?php if ($page < $pages_max): ?>
<li class="page-item">
<a class="page-link no-wrap" href="javascript: void (0)" onclick="Script.jumpTo (<?= $pages_max ?>)">&gt;|</a>
</li>
<?php else: ?>
<li class="page-item disabled">
<span class="page-link">&gt;|</span>
</li>
<?php endif ?>
</ul>
<nav class="d-flex justify-content-center d-none" aria-label="...">
<ul class="pagination"></ul>
</nav>
+200 -29
ファイルの表示
@@ -4,21 +4,28 @@ Script
static
main ()
{
const self = this;
self.paramAsc = null;
self.paramStart = null;
self.paramEnd = null;
self.paramQ = null;
self.paramP = null;
self.fetchData ();
const dateOptions = {dateFormat: 'yy-mm-dd',
firstDay: 6};
$ ('#filter-date-start').datepicker (dateOptions);
$ ('#filter-date-end').datepicker (dateOptions);
const url = new URL (window.location.href);
const orderAsc = document.getElementById ('order-asc');
const filterKeyword = document.getElementById ('filter-keyword');
const btnFilter = document.getElementById ('btn-filter');
const filter = (
function (e)
const filter = function (e)
{
let dateStart = $ ('#filter-date-start').val ();
let dateEnd = $ ('#filter-date-end').val ();
@@ -28,31 +35,30 @@ Script
&& (dateStart > dateEnd))
[dateStart, dateEnd] = [dateEnd, dateStart];
url.searchParams.delete ('p');
url.searchParams.delete ('asc');
url.searchParams.append ('asc', orderAsc.checked ? '1' : '0');
url.searchParams.delete ('q');
url.searchParams.append ('q', filterKeyword.value);
url.searchParams.delete ('start');
url.searchParams.delete ('end');
self.paramAsc = orderAsc.checked ? '1' : '0';
self.paramQ = filterKeyword.value;
if (dateStart !== '')
url.searchParams.append ('start', dateStart);
self.paramStart = dateStart;
if (dateEnd !== '')
url.searchParams.append ('end', dateEnd);
self.paramEnd = dateEnd;
window.location.href = url;
});
self.paramP = null;
const resetFilter = (
function ()
self.fetchData ();
};
const resetFilter = function ()
{
window.location.href = '/';
});
self.paramAsc = null;
self.paramStart = null;
self.paramEnd = null;
self.paramQ = null;
self.paramP = null;
self.fetchData ();
};
filterKeyword.addEventListener ('keydown',
function (e)
@@ -65,8 +71,6 @@ Script
$ ('#btn-reset').on ('click', resetFilter);
$ (window).resize (this.setPagination);
this.setPagination ();
$ ('.pagination').removeClass ('opacity-0');
$ ('#accordion-filter').on ('shown.bs.collapse', function ()
{
@@ -83,17 +87,19 @@ Script
$ ('#collapse-filter').removeClass ('show');
$ ('#accordion-filter .accordion-button').addClass ('collapsed');
}
window.setInterval (function ()
{
self.fetchData ();
}, 60000);
}
static
jumpTo (page)
{
const url = new URL (window.location.href);
this.paramP = page;
url.searchParams.delete ('p');
url.searchParams.append ('p', page);
window.location.href = url;
this.fetchData ();
}
static
@@ -111,6 +117,171 @@ Script
$ (`.page-${i}`).addClass ('d-none');
}
}
static
fetchData ()
{
const self = this;
const postData = {}
if (this.paramAsc != null)
postData.asc = this.paramAsc;
if (this.paramStart != null)
postData.start = this.paramStart;
if (this.paramEnd != null)
postData.end = this.paramEnd;
if (this.paramQ != null)
postData.q = this.paramQ;
if (this.paramP != null)
postData.p = this.paramP;
const done = function (data)
{
$ ('.pagination').empty ();
if (data.page > 1)
{
($ ('.pagination')
.append ($ ('<li>', {class: 'page-item deerjika-tail'})
.append ($ ('<a>', {class: 'page-link',
href: 'javascript: void 0',
onclick: 'Script.jumpTo (1)'})
.append ($ ('<img>',
{src: './assets/page-first.png'}))
.append ($ ('<div>', {class: 'page-link-text'})
.append ('|&lt;')))));
}
else
{
($ ('.pagination')
.append ($ ('<li>', {class: 'page-item disabled deerjika-tail'})
.append ($ ('<span>', {class: 'page-link'})
.append ($ ('<img>',
{src: './assets/page-first.png'}))
.append ($ ('<div>', {class: 'page-link-text'})))));
}
for (let i = Math.max (Math.min (data.page + 10, data.max) - 20, 1);
i < data.page;
++i)
{
($ ('.pagination')
.append ($ ('<li>', {class: `page-item page-${ data.page - i }`})
.append ($ ('<a>', {class: 'page-link',
href: 'javascript: void 0',
onclick: `Script.jumpTo (${ i })`})
.append ($ ('<img>',
{src: './assets/page-body.png'}))
.append ($ ('<div>', {class: 'page-link-text'})
.append (i)))));
}
($ ('.pagination')
.append ($ ('<li>', {class: 'page-item active',
'aria-current': 'page'})
.append ($ ('<span>', {class: 'page-link'})
.append ($ ('<img>', {src: './assets/page-body.png'}))
.append ($ ('<div>', {class: 'page-link-text'})
.append (data.page)))));
for (let i = data.page + 1;
i <= Math.min (Math.max (data.page - 10, 1) + 20, data.max);
++i)
{
($ ('.pagination')
.append ($ ('<li>', {class: `page-item page-${ i - data.page }`})
.append ($ ('<a>', {class: 'page-link',
href: 'javascript: void 0',
onclick: `Script.jumpTo (${ i })`})
.append ($ ('<img>',
{src: './assets/page-body.png'}))
.append ($ ('<div>', {class: 'page-link-text'})
.append (i)))));
}
if (data.page < data.max)
{
($ ('.pagination')
.append ($ ('<li>', {class: 'page-item'})
.append ($ ('<a>',
{class: 'page-link',
href: 'javascript: void 0',
onclick: `Script.jumpTo (${ data.max })`})
.append ($ ('<img>',
{src: './assets/page-last.png'}))
.append ($ ('<div>', {class: 'page-link-text'})
.append ('&gt;|')))));
}
else
{
($ ('.pagination')
.append ($ ('<li>', {class: 'page-item disabled'})
.append ($ ('<span>', {class: 'page-link'})
.append ($ ('<img>',
{src: './assets/page-last.png'}))
.append ($ ('<div>', {class: 'page-link-text'})))));
}
$ ('#message-list').empty ();
for (let datum of data.data)
{
($ ('#message-list')
.append ($ ('<div>', {class: 'mb-4 message-block'})
.append ($ ('<div>')
.append ($ ('<span>', {
class: 'message-block-dt'})
.append (datum.dateTime)))
.append ($ ('<div>')
.append ($ ('<img>', {src: datum.chatIcon,
width: '64',
height: '64'}))
.append (datum.chatName))
.append ($ ('<div>', {style: 'color: blue'})
.append ('&gt; ')
.append ($ ('<span>',
{class: 'message-block-chat',
style: 'font-style: italic'})
.append (datum.chatMessage)))
.append ($ ('<div>')
.append ($ ('<span>',
{class: 'message-block-answer'})
.append (datum.answer)))));
}
$ ('.message-block').on ('click', function ()
{
const dt = $ (this).find ('.message-block-dt').text ();
const chat = $ (this).find ('.message-block-chat').text ();
const answer = $ (this).find ('.message-block-answer').text ();
window.open (
`./talk.php?dt=${dt}&chat=${chat}&answer=${answer}`);
});
if (data.data.length > 0)
$ ('nav').removeClass ('d-none');
else
{
$ ('nav').addClass ('d-none');
($ ('#message-list')
.text ('何も見つかりませんでしたぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛'));
}
self.setPagination ();
};
$.post ({url: './services/fetch_data.php',
dataType: 'json',
data: postData})
.done (done);
}
}
+67
ファイルの表示
@@ -0,0 +1,67 @@
<?php
const LOG_PATH = '../log.txt';
header ('Content-Type: application/json; charset=UTF-8');
$log_data = [];
$page = (int) (filter_input (INPUT_POST, 'p') ?? 1);
$length = (int) (filter_input (INPUT_POST, 'max') ?? 20);
$asc = (int) (filter_input (INPUT_POST, 'asc') ?? 0) !== 0;
$keyword = trim (filter_input (INPUT_POST, 'q') ?? '');
$date_start = filter_input (INPUT_POST, 'start');
$date_end = filter_input (INPUT_POST, 'end');
$f = fopen (LOG_PATH, 'r');
if ($f !== false)
{
while (($dt = fgetcsv ($f, 0, "\t")) !== false)
{
$chat_info = json_decode ($dt[1]);
$log_data[] = ['dateTime' => $dt[0],
'chatIcon' => $chat_info -> author -> imageUrl,
'chatName' => htmlspecialchars ($chat_info -> author -> name),
'chatMessage' => htmlspecialchars ($chat_info -> message),
'answer' => htmlspecialchars ($dt[2])];
}
}
fclose ($f);
unset ($f);
if ($keyword !== '')
{
$log_data = array_filter ($log_data, fn ($row) => (
strpos (($row['chatName'] . "\n" . $row['chatMessage'] . "\n"
. $row['answer']),
$keyword)
!== false));
}
if ($date_start)
{
$log_data = array_filter ($log_data, fn ($row) => (
substr ($row['dateTime'], 0, 10) >= $date_start));
}
if ($date_end)
{
$log_data = array_filter ($log_data, fn ($row) => (
substr ($row['dateTime'], 0, 10) <= $date_end));
}
$pages_max = (int) ((count ($log_data) - 1) / $length) + 1;
if (!($asc))
$log_data = array_reverse ($log_data);
$log_data = array_slice ($log_data, ($page - 1) * $length, $length, false);
echo ('{"data": ' . json_encode ($log_data) . ', "max": ' . $pages_max
. ', "page": ' . $page . '}');
+51 -2
ファイルの表示
@@ -1,3 +1,5 @@
/* vim:set tabstop=2 softtabstop=2 expandtab :*/
.container-max-width
{
max-width: 1600px;
@@ -20,7 +22,54 @@
.page-item
{
width: 3.5em;
text-align: center;
width: 3.5em;
text-align: center;
vertical-align: middle;
margin: 0;
padding: 0;
}
.page-link
{
color: black;
padding: 0;
margin: 0;
border: none;
margin-right: -3px;
}
.page-item.active > .page-link
{
font-weight: bold;
font-size: 150%;
}
.page-item.disabled > .page-link
{
color: lightgray;
}
.page-link-text
{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -48%);
padding: 0;
margin: 0;
}
.pagination
{
--bs-pagination-bg: none;
--bs-pagination-disabled-bg: none;
--bs-pagination-hover-bg: none;
--bs-pagination-active-color: none;
--bs-pagination-active-bg: none;
}
.deerjika-tail
{
z-index: 1024;
}
+32
ファイルの表示
@@ -0,0 +1,32 @@
/* vim:set tabstop=2 softtabstop=2 expandtab :*/
@font-face
{
font-family: 'Nikumaru';
src: url(./assets/nikumaru.otf);
}
html, body
{
overflow: hidden;
}
body
{
background-color: black;
}
#canvas
{
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: unset;
border: none
!important;
outline: none
!important;
display: block;
}
+23
ファイルの表示
@@ -0,0 +1,23 @@
<!-- vim:set tabstop=4 softtabstop=4 expandtab :-->
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="./talk.css?<?= filemtime ('./talk.css') ?>" />
<link rel="preconnect" href="./assets/nikumaru.otf" />
<title>あほ</title>
<input type="hidden" id="dt" value="<?= $dt ?>" />
<input type="hidden" id="chat" value="<?= $chat ?>" />
<input type="hidden" id="answer" value="<?= $answer ?>" />
</head>
<body>
<canvas id="canvas"></canvas>
<script src="./talk.js?<?= filemtime ('./talk.js') ?>" type="module"></script>
</body>
</html>
+136
ファイルの表示
@@ -0,0 +1,136 @@
import CommonModule from './common_module.js';
class
Talk
{
static
main ()
{
const canvas = new Canvas;
window.onresize = () => canvas.resize ();
}
}
class
Canvas
{
constructor ()
{
this.canvas = $ ('#canvas');
this.ctx = this.canvas[0].getContext ('2d');
(this.bg = new Image ()).src = './assets/bg.jpg';
this.bg.onload = () => this.resize ();
(this.nizika = new Image ()).src = './assets/nizika.png';
this.nizika.onload = () => this.resize ();
(this.talking = new Image ()).src = './assets/talking.png';
this.talking.onload = () => this.resize ();
(new FontFace ('Nikumaru', 'url(./assets/nikumaru.otf)')).load ().then (
() => this.resize ());
}
resize ()
{
this.canvas[0].width = $ (window).width ();
this.canvas[0].height = $ (window).height ();
this.redraw ();
}
redraw ()
{
this.putBG ();
this.putText (0, 0, 15, $ ('#dt').val ());
this.putImage (this.nizika, 370, 260, 1.1);
this.putImage (this.talking, 0, 0, 640 / 1024);
this.putText (75, 43.75, 20,
('> ' + ((CommonModule.lenByFull ($ ('#chat').val ()) <= 21)
? $ ('#chat').val ()
: (CommonModule.midByFull ($ ('#chat').val (), 0, 19.5)
+ '...'))),
undefined, undefined,
true);
this.putText (62.5, 93.75, 31.25,
((CommonModule.lenByFull ($ ('#answer').val ()) <= 16)
? $ ('#answer').val ()
: CommonModule.midByFull ($ ('#answer').val (), 0, 16)),
'Nikumaru', '#c00000');
if (CommonModule.lenByFull ($ ('#answer').val ()) > 16)
{
this.putText (62.5, 125, 31.25,
((CommonModule.lenByFull ($ ('#answer').val ()) <= 32)
? CommonModule.midByFull ($ ('#answer').val (), 16, 16)
: (CommonModule.midByFull ($ ('#answer').val (), 16, 14.5)
+ '...')),
'Nikumaru', '#c00000');
}
}
putBG ()
{
const [x, y, zoom] = this.convertPosition (0, 0);
const width = this.bg.height * 4 / 3;
const height = this.bg.height;
this.ctx.drawImage (this.bg,
(852 - 640) / 2, 0, width, height,
x, y, width * zoom, height * zoom);
}
putImage (image, x, y, zoom = 1)
{
let zoom2
[x, y, zoom2] = this.convertPosition (x, y);
zoom *= zoom2
this.ctx.drawImage (image,
0, 0, image.width, image.height,
x, y, image.width * zoom, image.height * zoom);
}
putText (x, y, size, text, style = 'sans-serif', colour = 'black',
italic = false)
{
let zoom;
[x, y, zoom] = this.convertPosition (x, y);
size *= zoom;
this.ctx.font = `${italic ? 'italic ' : ''}${Math.trunc (size)}px ${style}`;
this.ctx.fillStyle = colour;
this.ctx.textBaseline = 'top';
this.ctx.fillText (text, x, y);
}
convertPosition (x, y)
{
const sizeX = this.canvas.width ();
const sizeY = this.canvas.height ();
const width = this.bg.height * 4 / 3;
const height = this.bg.height;
const vertical = sizeY / sizeX > height / width;
const zoom = vertical ? (sizeX / width) : (sizeY / height);
const baseX = vertical ? 0 : ((sizeX - width * zoom) / 2);
const baseY = vertical ? ((sizeY - height * zoom) / 2) : 0;
return [baseX + x * zoom, baseY + y * zoom, zoom];
}
}
$ (() => Talk.main ());
+11
ファイルの表示
@@ -0,0 +1,11 @@
<?php
if ($_SERVER['HTTP_HOST'] === 'nizika.monster')
header ('location: //nizika.tv/talk.php');
$dt = htmlspecialchars ($_GET['dt']);
$chat = htmlspecialchars ($_GET['chat']);
$answer = htmlspecialchars ($_GET['answer']);
require_once './talk.frm.php';
+3
ファイルの表示
@@ -0,0 +1,3 @@
<?php
exec ('git pull');