PDQ.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. require_once __DIR__ . '/lib/identity.php';
  3. require_once __DIR__ . '/lib/render.php';
  4. $actor = current_actor('ICG');
  5. $vendors = all_vendors();
  6. $initialMessageMaxIds = [];
  7. foreach ($vendors as $v) {
  8. $initialMessageMaxIds[(int) $v['id']] = max_message_id((int) $v['id']);
  9. }
  10. $initialHistoryId = max_history_id();
  11. ?><!doctype html>
  12. <html lang="en">
  13. <head>
  14. <meta charset="utf-8">
  15. <title>PDQ Schedule</title>
  16. <link rel="stylesheet" href="assets/app.css">
  17. <script>
  18. window.PDQ = {
  19. actor: 'ICG',
  20. audience: 'ICG',
  21. vendors: <?= json_encode(array_map(fn($v) => ['slug' => $v['slug'], 'name' => $v['name']], $vendors)) ?>,
  22. pollMs: 60000,
  23. initialHistoryId: <?= (int) $initialHistoryId ?>,
  24. initialMessageMaxIds: <?= json_encode((object) $initialMessageMaxIds) ?>
  25. };
  26. </script>
  27. <script src="assets/app.js" defer></script>
  28. </head>
  29. <body>
  30. <div class="topbar">
  31. <h1>PDQ Schedule</h1>
  32. <span class="who">
  33. <a href="log.php">Activity log</a>
  34. &middot; Signed in as <strong>ICG</strong>
  35. &middot; <span id="sync-time">Loading…</span>
  36. </span>
  37. </div>
  38. <div class="add-row">
  39. <label for="add-job-vendor">Add job for:</label>
  40. <select id="add-job-vendor">
  41. <?php foreach ($vendors as $v): ?>
  42. <option value="<?= h($v['slug']) ?>"><?= h($v['name']) ?></option>
  43. <?php endforeach; ?>
  44. </select>
  45. <button id="add-job" class="btn btn-add">Add One</button>
  46. </div>
  47. <div class="jobs-wrap">
  48. <div id="jobs-table"><?= render_jobs_table('ICG') ?></div>
  49. </div>
  50. <div class="threads-container">
  51. <?php foreach ($vendors as $v):
  52. $vid = (int) $v['id'];
  53. $maxId = max_message_id($vid);
  54. ?>
  55. <section class="thread" data-vendor="<?= h($v['slug']) ?>">
  56. <h2>Messages with <?= h($v['name']) ?></h2>
  57. <div class="thread-list" data-max-id="<?= $maxId ?>">
  58. <?php
  59. $rendered = render_messages($vid);
  60. echo $rendered !== '' ? $rendered : '<div class="msg-empty">No messages yet.</div>';
  61. ?>
  62. </div>
  63. <form class="thread-compose" autocomplete="off">
  64. <input type="text" name="body" placeholder="Message <?= h($v['name']) ?>…" maxlength="4000" required>
  65. <button type="submit" class="btn btn-post">Post</button>
  66. </form>
  67. </section>
  68. <?php endforeach; ?>
  69. </div>
  70. </body>
  71. </html>