File size: 3,293 Bytes
6ec7f56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<style>
  * { box-sizing: border-box; margin: 0; }
  body { font-family: system-ui, -apple-system, sans-serif; background: #f4f5f7;
         color: #1c1e21; padding: 24px; }
  .hidden { display: none !important; }
  .card { background: #fff; border: 1px solid #dcdfe4; border-radius: 8px;
          max-width: 760px; margin: 0 auto; overflow: hidden; }
  .card-head { padding: 14px 20px; border-bottom: 1px solid #e8eaee;
               font-size: 17px; font-weight: 600; }
  button { font: inherit; cursor: pointer; border-radius: 6px;
           border: 1px solid #c4c9d1; background: #fff; padding: 6px 12px; }
  button.primary { background: #2456d6; border-color: #2456d6; color: #fff; }
  button:hover { filter: brightness(0.96); }
  input[type=text], input[type=email], select {
    font: inherit; padding: 7px 10px; border: 1px solid #c4c9d1;
    border-radius: 6px; width: 100%; }
  label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
  .error { color: #c0392b; font-size: 13px; margin-top: 4px; }
  .banner { background: #fde68a; border-bottom: 1px solid #f59e0b;
            padding: 12px 20px; font-size: 14px; text-align: center; }
  .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
           background: #16a34a; color: #fff; padding: 10px 18px;
           border-radius: 6px; font-size: 14px; }
  .spinner-wrap { display: flex; justify-content: center; padding: 80px 0; }
  .spinner { width: 36px; height: 36px; border: 4px solid #dcdfe4;
             border-top-color: #2456d6; border-radius: 50%;
             animation: spin 0.8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  {% block style %}{% endblock %}
</style>
</head>
<body>
<div id="loading" class="spinner-wrap"><div class="spinner"></div></div>
<div id="app" class="hidden">
{% block content %}{% endblock %}
</div>
<script>
  const OPTS = {{ opts_json | safe }};

  window.addEventListener('DOMContentLoaded', () => {
    setTimeout(() => {
      document.getElementById('loading').remove();
      document.getElementById('app').classList.remove('hidden');
      if (OPTS.layout_shift) {
        setTimeout(() => {
          const b = document.createElement('div');
          b.className = 'banner';
          b.textContent = 'New features are available — see what changed in the latest release.';
          document.body.prepend(b);
        }, 1200);
      }
    }, OPTS.latency_ms || 0);
  });

  const SID = new URLSearchParams(location.search).get('sid');

  async function act(payload) {
    const url = `/api/${OPTS.task_id}/action` + (SID ? `?sid=${encodeURIComponent(SID)}` : '');
    const r = await fetch(url, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(payload),
    });
    return { status: r.status, body: await r.json() };
  }

  function toast(msg) {
    const t = document.createElement('div');
    t.className = 'toast';
    t.textContent = msg;
    document.body.appendChild(t);
    setTimeout(() => t.remove(), 1800);
  }
</script>
{% block script %}{% endblock %}
</body>
</html>