Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 801db8994b | |||
| 3d3c350777 | |||
| a26a0ac130 | |||
| 2cf8b64f1f |
+6
-37
@@ -48,7 +48,7 @@
|
|||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col form-check">
|
<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">
|
<label class="form-check-label" for="order-desc">
|
||||||
新しい順
|
新しい順
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col form-check">
|
<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">
|
<label class="form-check-label" for="order-asc">
|
||||||
古い順
|
古い順
|
||||||
@@ -79,14 +79,12 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="YYYY-MM-DD"
|
placeholder="YYYY-MM-DD"
|
||||||
id="filter-date-start"
|
id="filter-date-start" />
|
||||||
value="<?= $date_start ?>" />
|
|
||||||
<span class="input-group-text">〜</span>
|
<span class="input-group-text">〜</span>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="YYYY-MM-DD"
|
placeholder="YYYY-MM-DD"
|
||||||
id="filter-date-end"
|
id="filter-date-end" />
|
||||||
value="<?= $date_end ?>" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -99,8 +97,7 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="<?= $april_fool ? 'ムムムム!! クサタベテル!!!!!' : 'ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛' ?>"
|
placeholder="<?= $april_fool ? 'ムムムム!! クサタベテル!!!!!' : 'ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛' ?>"
|
||||||
id="filter-keyword"
|
id="filter-keyword" />
|
||||||
value="<?= $keyword ?>"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -119,44 +116,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (count ($log_data) > 0): ?>
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<?php require 'pagination.cmp.php' ?>
|
<?php require 'pagination.cmp.php' ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div id="message-list">
|
||||||
<?php foreach (array_slice ($log_data,
|
|
||||||
($page - 1) * $length,
|
|
||||||
$length,
|
|
||||||
true)
|
|
||||||
as $record): ?>
|
|
||||||
<div class="mb-4 message-block">
|
|
||||||
<div>
|
|
||||||
<span class="message-block-dt"><?= $record['date_time'] ?></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<img src="<?= $record['chat_icon'] ?>" width="64" height="64" />
|
|
||||||
<?= $record['chat_name'] ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="color: blue">
|
|
||||||
> <span class="message-block-chat" style="font-style: italic"><?= $record['chat_message'] ?></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<span class="message-block-answer"><?= $record['answer'] ?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<?php require 'pagination.cmp.php' ?>
|
<?php require 'pagination.cmp.php' ?>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
|
||||||
何も見つかりませんでしたぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛
|
|
||||||
<?php endif ?>
|
|
||||||
</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="//cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
|
|||||||
+2
-55
@@ -7,64 +7,11 @@ const LOG_PATH = './log.txt';
|
|||||||
|
|
||||||
$log_data = [];
|
$log_data = [];
|
||||||
|
|
||||||
exec ("(ps -Af | grep -e '^miteruzo' | grep 'python3 main.py') && (ps -Af | grep -e '^miteruzo' | grep 'obs')",
|
exec (("(ps -Af | grep -e '^miteruzo' | grep 'python3 main.py')"
|
||||||
|
. " && (ps -Af | grep -e '^miteruzo' | grep 'obs')"),
|
||||||
$output, $exit_code);
|
$output, $exit_code);
|
||||||
$available = $exit_code === 0;
|
$available = $exit_code === 0;
|
||||||
unset ($output, $exit_code);
|
unset ($output, $exit_code);
|
||||||
|
|
||||||
$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);
|
|
||||||
|
|
||||||
require_once './index.frm.php';
|
require_once './index.frm.php';
|
||||||
|
|
||||||
|
|||||||
@@ -1,63 +1,6 @@
|
|||||||
<!-- vim:set tabstop=4 softtabstop=4 expandtab :-->
|
<!-- vim:set tabstop=4 softtabstop=4 expandtab :-->
|
||||||
|
|
||||||
<nav class="d-flex justify-content-center" aria-label="...">
|
<nav class="d-flex justify-content-center d-none" aria-label="...">
|
||||||
<ul class="pagination opacity-0">
|
<ul class="pagination"></ul>
|
||||||
<?php if ($page > 1): ?>
|
|
||||||
<li class="page-item deerjika-tail">
|
|
||||||
<a class="page-link" href="javascript: void (0)" onclick="Script.jumpTo (1)">
|
|
||||||
<img src="./assets/page-first.png" />
|
|
||||||
<div class="page-link-text">|<</div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php else: ?>
|
|
||||||
<li class="page-item disabled deerjika-tail">
|
|
||||||
<span class="page-link">
|
|
||||||
<img src="./assets/page-first.png" />
|
|
||||||
<div class="page-link-text"></div>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
<?php endif ?>
|
|
||||||
|
|
||||||
<?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 ?>)">
|
|
||||||
<img src="./assets/page-body.png" />
|
|
||||||
<div class="page-link-text"><?= $i ?></div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php endfor ?>
|
|
||||||
|
|
||||||
<li class="page-item active" aria-current="page">
|
|
||||||
<span class="page-link">
|
|
||||||
<img src="./assets/page-body.png" />
|
|
||||||
<div class="page-link-text"><?= $page ?></div>
|
|
||||||
</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 ?>)">
|
|
||||||
<img src="./assets/page-body.png" />
|
|
||||||
<div class="page-link-text"><?= $i ?></div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php endfor ?>
|
|
||||||
|
|
||||||
<?php if ($page < $pages_max): ?>
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="javascript: void (0)" onclick="Script.jumpTo (<?= $pages_max ?>)">
|
|
||||||
<img src="./assets/page-last.png" />
|
|
||||||
<div class="page-link-text">>|</div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php else: ?>
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link">
|
|
||||||
<img src="./assets/page-last.png" />
|
|
||||||
<div class="page-link-text"></div>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
<?php endif ?>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|||||||
+200
-38
@@ -4,21 +4,28 @@ Script
|
|||||||
static
|
static
|
||||||
main ()
|
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',
|
const dateOptions = {dateFormat: 'yy-mm-dd',
|
||||||
firstDay: 6};
|
firstDay: 6};
|
||||||
|
|
||||||
$ ('#filter-date-start').datepicker (dateOptions);
|
$ ('#filter-date-start').datepicker (dateOptions);
|
||||||
$ ('#filter-date-end').datepicker (dateOptions);
|
$ ('#filter-date-end').datepicker (dateOptions);
|
||||||
|
|
||||||
const url = new URL (window.location.href);
|
|
||||||
|
|
||||||
const orderAsc = document.getElementById ('order-asc');
|
const orderAsc = document.getElementById ('order-asc');
|
||||||
const filterKeyword = document.getElementById ('filter-keyword');
|
const filterKeyword = document.getElementById ('filter-keyword');
|
||||||
|
|
||||||
const btnFilter = document.getElementById ('btn-filter');
|
const btnFilter = document.getElementById ('btn-filter');
|
||||||
|
|
||||||
const filter = (
|
const filter = function (e)
|
||||||
function (e)
|
|
||||||
{
|
{
|
||||||
let dateStart = $ ('#filter-date-start').val ();
|
let dateStart = $ ('#filter-date-start').val ();
|
||||||
let dateEnd = $ ('#filter-date-end').val ();
|
let dateEnd = $ ('#filter-date-end').val ();
|
||||||
@@ -28,31 +35,30 @@ Script
|
|||||||
&& (dateStart > dateEnd))
|
&& (dateStart > dateEnd))
|
||||||
[dateStart, dateEnd] = [dateEnd, dateStart];
|
[dateStart, dateEnd] = [dateEnd, dateStart];
|
||||||
|
|
||||||
url.searchParams.delete ('p');
|
self.paramAsc = orderAsc.checked ? '1' : '0';
|
||||||
|
self.paramQ = filterKeyword.value;
|
||||||
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');
|
|
||||||
|
|
||||||
if (dateStart !== '')
|
if (dateStart !== '')
|
||||||
url.searchParams.append ('start', dateStart);
|
self.paramStart = dateStart;
|
||||||
|
|
||||||
if (dateEnd !== '')
|
if (dateEnd !== '')
|
||||||
url.searchParams.append ('end', dateEnd);
|
self.paramEnd = dateEnd;
|
||||||
|
|
||||||
window.location.href = url;
|
self.paramP = null;
|
||||||
});
|
|
||||||
|
|
||||||
const resetFilter = (
|
self.fetchData ();
|
||||||
function ()
|
};
|
||||||
|
|
||||||
|
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',
|
filterKeyword.addEventListener ('keydown',
|
||||||
function (e)
|
function (e)
|
||||||
@@ -65,8 +71,6 @@ Script
|
|||||||
$ ('#btn-reset').on ('click', resetFilter);
|
$ ('#btn-reset').on ('click', resetFilter);
|
||||||
|
|
||||||
$ (window).resize (this.setPagination);
|
$ (window).resize (this.setPagination);
|
||||||
this.setPagination ();
|
|
||||||
$ ('.pagination').removeClass ('opacity-0');
|
|
||||||
|
|
||||||
$ ('#accordion-filter').on ('shown.bs.collapse', function ()
|
$ ('#accordion-filter').on ('shown.bs.collapse', function ()
|
||||||
{
|
{
|
||||||
@@ -78,31 +82,24 @@ Script
|
|||||||
$.cookie ('expand-filter', '0');
|
$.cookie ('expand-filter', '0');
|
||||||
});
|
});
|
||||||
|
|
||||||
$ ('.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 ($.cookie ('expand-filter') === '0')
|
if ($.cookie ('expand-filter') === '0')
|
||||||
{
|
{
|
||||||
$ ('#collapse-filter').removeClass ('show');
|
$ ('#collapse-filter').removeClass ('show');
|
||||||
$ ('#accordion-filter .accordion-button').addClass ('collapsed');
|
$ ('#accordion-filter .accordion-button').addClass ('collapsed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.setInterval (function ()
|
||||||
|
{
|
||||||
|
self.fetchData ();
|
||||||
|
}, 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
jumpTo (page)
|
jumpTo (page)
|
||||||
{
|
{
|
||||||
const url = new URL (window.location.href);
|
this.paramP = page;
|
||||||
|
|
||||||
url.searchParams.delete ('p');
|
this.fetchData ();
|
||||||
url.searchParams.append ('p', page);
|
|
||||||
|
|
||||||
window.location.href = url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -120,6 +117,171 @@ Script
|
|||||||
$ (`.page-${i}`).addClass ('d-none');
|
$ (`.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 ('|<')))));
|
||||||
|
}
|
||||||
|
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 ('>|')))));
|
||||||
|
}
|
||||||
|
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 ('> ')
|
||||||
|
.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 . '}');
|
||||||
|
|
||||||
Reference in New Issue
Block a user