willy.club/views/pages/willychat/messages.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2023-01-22 09:47:36 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2023-01-22 11:42:45 +00:00
<link rel="stylesheet" href="<?=url('/static/style/fonts.css')?>">
2023-01-22 09:47:36 +00:00
</head>
<body>
<style>
div {
border: 1px solid silver;
2023-01-22 11:42:45 +00:00
margin-bottom: .5rem;
padding: .5rem;
2023-01-22 09:47:36 +00:00
background: rgba(0, 0, 0, 0.75);
color: white;
2023-01-22 12:17:50 +00:00
word-break: break-all;
2023-01-22 09:47:36 +00:00
}
div > small {
color: gray;
}
div > p {
margin: 0;
2023-01-22 11:42:45 +00:00
margin-top: .5rem;
2023-01-22 09:47:36 +00:00
}
</style>
<?php foreach($messages as $message): ?>
<div>
2023-01-22 11:42:45 +00:00
<small><?=gmdate("D M j G:i:s Y", $message['date']);?> <span style="color: yellow"><?=htmlspecialchars($message['nick'])?></span> says:</small>
2023-01-22 09:47:36 +00:00
<p><?=htmlspecialchars($message['text'])?></p>
</div>
<?php endforeach; ?>
<script>
let hash = '';
setInterval(async () => {
let new_hash = await fetch('sync').then((response) => response.json());
if (hash == '') {
hash = new_hash;
}
if (new_hash !== hash) {
document.location.reload();
}
}, 2000);
</script>
</body>
</html>