vendor.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once __DIR__ . '/lib/identity.php';
  3. require_once __DIR__ . '/lib/render.php';
  4. $slug = $_GET['v'] ?? '';
  5. $vendor = current_actor_from_vendor($slug);
  6. $vid = (int) $vendor['id'];
  7. $maxId = max_message_id($vid);
  8. $initialHistoryId = max_history_id($vid);
  9. ?><!doctype html>
  10. <html lang="en">
  11. <head>
  12. <meta charset="utf-8">
  13. <title><?= h($vendor['name']) ?> &mdash; Schedule</title>
  14. <link rel="stylesheet" href="assets/app.css">
  15. <script>
  16. window.PDQ = {
  17. actor: <?= json_encode($vendor['slug']) ?>,
  18. audience: 'vendor',
  19. vendorId: <?= (int) $vid ?>,
  20. vendors: [<?= json_encode(['slug' => $vendor['slug'], 'name' => $vendor['name']]) ?>],
  21. pollMs: 60000,
  22. initialHistoryId: <?= (int) $initialHistoryId ?>,
  23. initialMessageMaxIds: <?= json_encode((object) [$vid => $maxId]) ?>
  24. };
  25. </script>
  26. <script src="assets/app.js" defer></script>
  27. </head>
  28. <body>
  29. <div class="topbar">
  30. <h1><?= h($vendor['name']) ?>'s Schedule</h1>
  31. <span class="who">Signed in as <strong><?= h($vendor['name']) ?></strong> &middot; <span id="sync-time">Loading…</span></span>
  32. </div>
  33. <div class="jobs-wrap">
  34. <div id="jobs-table"><?= render_jobs_table('vendor', $vid) ?></div>
  35. </div>
  36. <section class="thread" data-vendor="<?= h($vendor['slug']) ?>">
  37. <h2>Messages with ICG</h2>
  38. <div class="thread-list" data-max-id="<?= $maxId ?>">
  39. <?php
  40. $rendered = render_messages($vid);
  41. echo $rendered !== '' ? $rendered : '<div class="msg-empty">No messages yet.</div>';
  42. ?>
  43. </div>
  44. <form class="thread-compose" autocomplete="off">
  45. <input type="text" name="body" placeholder="Message ICG…" maxlength="4000" required>
  46. <button type="submit" class="btn btn-post">Post</button>
  47. </form>
  48. </section>
  49. </body>
  50. </html>