scorpiox-bot-plugin-gitstat
←ui_html.hc
478 lines · 25 KBHEADBlameDownload
1/* Generated by tools/gen_ui.py from src/ui.html. Do not edit by hand. */
2#ifndef SX_GITSTAT_UI_HTML_H
3#define SX_GITSTAT_UI_HTML_H
4
5static const char *UI_HTML =
6 "<!DOCTYPE html>\n"
7 "<html lang=\"en\"><head><meta charset=\"utf-8\">\n"
8 "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n"
9 "<title>git</title>\n"
10 "\001\n"
11 "<style>\n"
12 "*{box-sizing:border-box}\n"
13 "html,body{margin:0;min-height:100%}\n"
14 "body{background:var(--bg);color:var(--tx,var(--text));font-family:var(--font);\n"
15 " font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased}\n"
16 ".wrap{max-width:1200px;margin:0 auto;padding:18px 18px 40px}\n"
17 ".top{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:14px}\n"
18 ".brand{font-size:11px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;\n"
19 " color:var(--mu,var(--text-2))}\n"
20 ".title{font-size:19px;font-weight:680;margin:0;letter-spacing:-.01em}\n"
21 ".sp{flex:1 1 auto}\n"
22 ".pill{font-size:11px;font-weight:600;padding:3px 9px;border-radius:999px;\n"
23 " background:var(--sf2,var(--surface-2));color:var(--mu,var(--text-2));\n"
24 " border:1px solid var(--ln,var(--line));white-space:nowrap}\n"
25 ".icon-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;\n"
26 " background:var(--sf2,var(--surface-2));border:1px solid var(--ln,var(--line));\n"
27 " color:var(--text);border-radius:9px;height:30px;padding:0 11px;cursor:pointer;\n"
28 " font-family:inherit;font-size:12px;font-weight:600}\n"
29 ".icon-btn:hover{background:var(--surface-hover);border-color:var(--line-2)}\n"
30 ".icon-btn:active{transform:scale(.97)}\n"
31 ".icon-btn svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.9;\n"
32 " stroke-linecap:round;stroke-linejoin:round}\n"
33 ".icon-btn[disabled]{opacity:.5;cursor:default}\n"
34 "\n"
35 ".chips{display:grid;grid-template-columns:repeat(auto-fit,minmax(126px,1fr));gap:10px;\n"
36 " margin-bottom:14px}\n"
37 ".chip{background:var(--sf,var(--bg-card));border:1px solid var(--ln,var(--line));\n"
38 " border-radius:12px;padding:11px 13px;cursor:pointer;font-family:inherit;\n"
39 " text-align:left;color:var(--text)}\n"
40 ".chip:hover{border-color:var(--line-2)}\n"
41 ".chip.sel{box-shadow:inset 0 0 0 1.5px var(--ac,var(--blue))}\n"
42 ".chip .k{display:flex;align-items:center;gap:6px;font-size:10.5px;font-weight:700;\n"
43 " letter-spacing:.07em;text-transform:uppercase;color:var(--mu,var(--text-2))}\n"
44 ".chip .k svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:2;\n"
45 " stroke-linecap:round;stroke-linejoin:round}\n"
46 ".chip .v{font-family:var(--mono);font-size:23px;font-weight:700;margin-top:3px;\n"
47 " letter-spacing:-.02em}\n"
48 ".chip.ok .v{color:var(--green)}\n"
49 ".chip.bad .v{color:var(--red)}\n"
50 ".chip.warn .v{color:var(--orange)}\n"
51 ".chip.none .v{color:var(--mu,var(--text-2))}\n"
52 "\n"
53 ".bar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:10px}\n"
54 ".search{flex:1 1 240px;min-width:0;padding:9px 12px;border-radius:10px;\n"
55 " border:1px solid var(--ln,var(--line));background:var(--input-bg);color:var(--text);\n"
56 " font-family:inherit;font-size:13px}\n"
57 ".search:focus{outline:2px solid var(--ac,var(--blue));outline-offset:-1px}\n"
58 "select{padding:9px 11px;border-radius:10px;border:1px solid var(--ln,var(--line));\n"
59 " background:var(--input-bg);color:var(--text);font-family:inherit;font-size:13px}\n"
60 "\n"
61 ".panel{background:var(--sf,var(--bg-card));border:1px solid var(--ln,var(--line));\n"
62 " border-radius:14px;overflow:hidden}\n"
63 ".tb{width:100%;overflow-x:auto}\n"
64 "table{width:100%;border-collapse:collapse;font-size:13px}\n"
65 "th{text-align:left;font-size:10.5px;letter-spacing:.07em;text-transform:uppercase;\n"
66 " color:var(--mu,var(--text-2));font-weight:700;padding:9px 12px;\n"
67 " border-bottom:1px solid var(--ln,var(--line));white-space:nowrap;\n"
68 " background:var(--sf2,var(--surface-2))}\n"
69 "td{padding:9px 12px;border-bottom:1px solid var(--ln,var(--line));\n"
70 " vertical-align:middle;white-space:nowrap}\n"
71 "tr.row{cursor:pointer}\n"
72 "tr.row:hover td{background:var(--surface-hover)}\n"
73 "tr.row:last-child td{border-bottom:0}\n"
74 "tr.row.sel td{background:var(--sf2,var(--surface-2))}\n"
75 ".mo{font-family:var(--mono);font-size:12.5px}\n"
76 ".name{font-weight:600;max-width:300px;overflow:hidden;text-overflow:ellipsis}\n"
77 ".sub{font-size:11.5px;color:var(--mu,var(--text-2));max-width:300px;\n"
78 " overflow:hidden;text-overflow:ellipsis;margin-top:1px}\n"
79 ".subtext{color:var(--text);font-size:12.5px;max-width:340px}\n"
80 "td.c-last{max-width:360px;overflow:hidden}\n"
81 ".subtext{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;\n"
82 " -webkit-box-orient:vertical;overflow:hidden}\n"
83 ".hash{font-family:var(--mono);font-size:11.5px;color:var(--mu,var(--text-2))}\n"
84 ".tag{font-size:10px;font-weight:700;padding:2px 8px;border-radius:6px;\n"
85 " white-space:nowrap;letter-spacing:.03em;display:inline-block;margin:1px 3px 1px 0}\n"
86 ".t-dirty{background:rgba(255,159,10,.16);color:var(--orange)}\n"
87 ".t-ahead{background:rgba(48,209,88,.16);color:var(--green)}\n"
88 ".t-behind{background:rgba(255,69,58,.16);color:var(--red)}\n"
89 ".t-det{background:rgba(191,90,242,.16);color:var(--purple)}\n"
90 ".t-noup{background:rgba(142,142,147,.16);color:var(--gray)}\n"
91 ".t-stash{background:rgba(94,92,230,.16);color:var(--indigo)}\n"
92 ".t-clean{background:rgba(48,209,88,.12);color:var(--green)}\n"
93 ".t-unborn{background:rgba(255,214,10,.16);color:var(--yellow)}\n"
94 ".muted{color:var(--mu,var(--text-2))}\n"
95 ".empty{padding:28px 16px;text-align:center;color:var(--mu,var(--text-2));font-size:13px}\n"
96 ".hide{display:none!important}\n"
97 "\n"
98 ".drawer{position:fixed;top:0;right:0;bottom:0;width:min(560px,100%);z-index:60;\n"
99 " background:var(--modal-bg,var(--bg-card));border-left:1px solid var(--ln,var(--line));\n"
100 " box-shadow:var(--shadow-lg);transform:translateX(102%);transition:transform .22s var(--ease);\n"
101 " display:flex;flex-direction:column}\n"
102 ".drawer.open{transform:none}\n"
103 ".dh{display:flex;align-items:center;gap:10px;padding:14px 16px;\n"
104 " border-bottom:1px solid var(--ln,var(--line))}\n"
105 ".dh .t{font-size:15px;font-weight:680;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"
106 ".db{overflow:auto;padding:14px 16px 28px;flex:1 1 auto}\n"
107 ".dsec{font-size:10.5px;letter-spacing:.07em;text-transform:uppercase;font-weight:700;\n"
108 " color:var(--mu,var(--text-2));margin:16px 0 8px}\n"
109 ".dsec:first-child{margin-top:0}\n"
110 ".flist{list-style:none;margin:0;padding:0;font-size:12.5px}\n"
111 ".flist li{display:flex;gap:9px;align-items:baseline;padding:4px 0;\n"
112 " border-bottom:1px solid var(--ln,var(--line))}\n"
113 ".flist li:last-child{border-bottom:0}\n"
114 ".flist .c{font-family:var(--mono);font-size:11px;font-weight:700;width:26px;flex:0 0 26px}\n"
115 ".flist .p{font-family:var(--mono);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"
116 ".c-mod{color:var(--orange)}.c-add{color:var(--green)}.c-del{color:var(--red)}\n"
117 ".c-unt{color:var(--gray)}.c-con{color:var(--purple)}\n"
118 ".clist{list-style:none;margin:0;padding:0;font-size:12.5px}\n"
119 ".clist li{padding:5px 0;border-bottom:1px solid var(--ln,var(--line))}\n"
120 ".clist li:last-child{border-bottom:0}\n"
121 ".clist .s{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"
122 ".clist .m{font-size:11px;color:var(--mu,var(--text-2));display:flex;gap:8px}\n"
123 ".scrim{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:55}\n"
124 ".scrim.hide{display:none}\n"
125 ".note{font-size:11.5px;color:var(--mu,var(--text-2));margin-top:8px}\n"
126 ".err{color:var(--red);font-size:12.5px;margin-top:8px}\n"
127 "\n"
128 "@media(max-width:760px){\n"
129 " .wrap{padding:12px 12px 28px}\n"
130 " .drawer{width:100%;border-left:0}\n"
131 " col.c-root,th.c-root,td.c-root{display:none}\n"
132 "}\n"
133 "@media(max-width:760px){\n"
134 " /* Two fixed columns: the repo block and the commit block. The commit subject\n"
135 " * is allowed to wrap onto a second line, which is the only way it fits at\n"
136 " * 390 px without a mid-word cut at the panel edge. */\n"
137 " table{table-layout:fixed;width:100%}\n"
138 " td.c-repo{white-space:normal}\n"
139 " td.c-repo .sub{overflow:visible;text-overflow:clip;line-height:1.6}\n"
140 " td.c-last{max-width:none;white-space:normal}\n"
141 " td .sub,.subtext{max-width:none}\n"
142 " col.c-repo{width:48%}\n"
143 " col.c-last{width:52%}\n"
144 " .name{max-width:none}\n"
145 "}\n"
146 "@media(max-width:560px){\n"
147 " .chips{grid-template-columns:repeat(auto-fit,minmax(104px,1fr));gap:8px}\n"
148 " .chip .v{font-size:19px}\n"
149 " col.c-sync,th.c-sync,td.c-sync{display:none}\n"
150 " th,td{padding:8px 9px}\n"
151 " .name,td .sub,.subtext{max-width:none}\n"
152 "}\n"
153 "</style></head>\n"
154 "<body>\n"
155 "<div class=\"wrap\">\n"
156 " <div class=\"top\">\n"
157 " <div>\n"
158 " <div class=\"brand\">SCORPIOX BOT</div>\n"
159 " <h1 class=\"title\">git</h1>\n"
160 " </div>\n"
161 " <span class=\"pill\" id=\"rootPill\">local</span>\n"
162 " <span class=\"sp\"></span>\n"
163 " <button class=\"icon-btn embed-hide\" id=\"thBtn\" type=\"button\" title=\"Toggle appearance\">\n"
164 " <svg viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9L17 7M7 17l-2.1 2.1\"/></svg>\n"
165 " Theme\n"
166 " </button>\n"
167 " <button class=\"icon-btn\" id=\"rfBtn\" type=\"button\">\n"
168 " <svg viewBox=\"0 0 24 24\"><path d=\"M21 12a9 9 0 1 1-2.6-6.4\"/><path d=\"M21 3v6h-6\"/></svg>\n"
169 " Rescan\n"
170 " </button>\n"
171 " </div>\n"
172 "\n"
173 " <div class=\"chips\" id=\"chips\">\n"
174 " <button class=\"chip none\" data-filter=\"all\" id=\"vAllChip\" type=\"button\">\n"
175 " <div class=\"k\"><svg viewBox=\"0 0 24 24\"><path d=\"M3 7h18M3 12h18M3 17h18\"/></svg>All repos</div>\n"
176 " <div class=\"v\" id=\"vAll\">0</div>\n"
177 " </button>\n"
178 " <button class=\"chip warn\" data-filter=\"dirty\" type=\"button\">\n"
179 " <div class=\"k\"><svg viewBox=\"0 0 24 24\"><path d=\"M12 8v5M12 16h.01\"/><circle cx=\"12\" cy=\"12\" r=\"9\"/></svg>Dirty</div>\n"
180 " <div class=\"v\" id=\"vDirty\">0</div>\n"
181 " </button>\n"
182 " <button class=\"chip ok\" data-filter=\"ahead\" type=\"button\">\n"
183 " <div class=\"k\"><svg viewBox=\"0 0 24 24\"><path d=\"M12 19V5M6 11l6-6 6 6\"/></svg>Ahead</div>\n"
184 " <div class=\"v\" id=\"vAhead\">0</div>\n"
185 " </button>\n"
186 " <button class=\"chip bad\" data-filter=\"behind\" type=\"button\">\n"
187 " <div class=\"k\"><svg viewBox=\"0 0 24 24\"><path d=\"M12 5v14M6 13l6 6 6-6\"/></svg>Behind</div>\n"
188 " <div class=\"v\" id=\"vBehind\">0</div>\n"
189 " </button>\n"
190 " <button class=\"chip none\" data-filter=\"stash\" type=\"button\">\n"
191 " <div class=\"k\"><svg viewBox=\"0 0 24 24\"><path d=\"M4 7h16M4 12h16M4 17h10\"/></svg>Stashes</div>\n"
192 " <div class=\"v\" id=\"vStash\">0</div>\n"
193 " </button>\n"
194 " </div>\n"
195 "\n"
196 " <div class=\"bar\">\n"
197 " <input class=\"search\" id=\"q\" type=\"search\" placeholder=\"Filter by repo, branch, or last commit\" autocomplete=\"off\">\n"
198 " <select id=\"sc\" aria-label=\"Filter by state\">\n"
199 " <option value=\"\">All states</option>\n"
200 " <option value=\"dirty\">Dirty</option>\n"
201 " <option value=\"clean\">Clean</option>\n"
202 " <option value=\"ahead\">Ahead</option>\n"
203 " <option value=\"behind\">Behind</option>\n"
204 " <option value=\"detached\">Detached</option>\n"
205 " <option value=\"noup\">No upstream</option>\n"
206 " </select>\n"
207 " </div>\n"
208 "\n"
209 " <div class=\"panel\">\n"
210 " <div class=\"tb\">\n"
211 " <table>\n"
212 " <colgroup>\n"
213 " <col class=\"c-repo\"><col class=\"c-root\"><col class=\"c-sync\"><col class=\"c-sync\"><col class=\"c-last\">\n"
214 " </colgroup>\n"
215 " <thead><tr>\n"
216 " <th>Repository</th>\n"
217 " <th class=\"c-root\">Root</th>\n"
218 " <th class=\"c-sync\">Sync</th>\n"
219 " <th class=\"c-sync\">Stash</th>\n"
220 " <th>Last commit</th>\n"
221 " </tr></thead>\n"
222 " <tbody id=\"rows\"></tbody>\n"
223 " </table>\n"
224 " </div>\n"
225 " <div class=\"empty hide\" id=\"empty\">No repositories found under the allowlisted roots.</div>\n"
226 " </div>\n"
227 " <div class=\"note\" id=\"footNote\">Read-only. Fetching from a remote stays off unless the node operator enables it.</div>\n"
228 "</div>\n"
229 "\n"
230 "<div class=\"scrim hide\" id=\"scrim\"></div>\n"
231 "<aside class=\"drawer\" id=\"drawer\" aria-hidden=\"true\">\n"
232 " <div class=\"dh\">\n"
233 " <div class=\"t\" id=\"dName\">Repository</div>\n"
234 " <span class=\"sp\"></span>\n"
235 " <button class=\"icon-btn\" id=\"dClose\" type=\"button\" title=\"Close\">\n"
236 " <svg viewBox=\"0 0 24 24\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>\n"
237 " </button>\n"
238 " </div>\n"
239 " <div class=\"db\" id=\"dBody\"></div>\n"
240 "</aside>\n"
241 "\n"
242 "<script>\n"
243 "(function(){\n"
244 " var q = new URLSearchParams(location.search);\n"
245 " var node = q.get('node') || '';\n"
246 " var sid = q.get('id') || '';\n"
247 " var pwd = q.get('pwd') || (node && localStorage.getItem('bot_pwd_' + node)) ||\n"
248 " localStorage.getItem('bot_active_pwd') || '';\n"
249 " /* When the bot serves this page through its proxy, ?plugin= is the route back.\n"
250 " * Opened directly on the node, the plugin itself is the route. */\n"
251 " var HUB = q.get('plugin') || '';\n"
252 "\n"
253 " function api(action, extra){\n"
254 " var u = (HUB ? '/plugins?plugin=' + encodeURIComponent(HUB) : '/plugin_gitstat') +\n"
255 " '?action=' + encodeURIComponent(action) +\n"
256 " (extra ? ('&' + extra) : '') +\n"
257 " (node ? '&node=' + encodeURIComponent(node) : '') +\n"
258 " (sid ? '&id=' + encodeURIComponent(sid) : '') +\n"
259 " (pwd ? '&pwd=' + encodeURIComponent(pwd) : '');\n"
260 " return fetch(u, {headers: pwd ? {'X-Bot-Password': pwd} : {}}).then(function(r){\n"
261 " if (!r.ok) throw new Error('HTTP ' + r.status);\n"
262 " return r.json();\n"
263 " });\n"
264 " }\n"
265 "\n"
266 " var DATA = [];\n"
267 " var ROOTS = [];\n"
268 " var FILTER = 'all';\n"
269 " var SEL = '';\n"
270 "\n"
271 " function esc(v){\n"
272 " return String(v == null ? '' : v).replace(/[&<>\"']/g, function(c){\n"
273 " return {'&':'&amp;','<':'&lt;','>':'&gt;','\"':'&quot;',\"'\":'&#39;'}[c];\n"
274 " });\n"
275 " }\n"
276 " function txt(id, v){ var e = document.getElementById(id); if (e) e.textContent = v; }\n"
277 "\n"
278 " function ago(ct){\n"
279 " if (!ct) return '-';\n"
280 " var s = Math.max(0, Math.floor(Date.now()/1000) - ct);\n"
281 " if (s < 60) return s + 's ago';\n"
282 " if (s < 3600) return Math.floor(s/60) + 'm ago';\n"
283 " if (s < 86400) return Math.floor(s/3600) + 'h ago';\n"
284 " if (s < 2592000) return Math.floor(s/86400) + 'd ago';\n"
285 " if (s < 31536000) return Math.floor(s/2592000) + 'mo ago';\n"
286 " return Math.floor(s/31536000) + 'y ago';\n"
287 " }\n"
288 "\n"
289 " function badges(r){\n"
290 " var h = '';\n"
291 " if (r.dirty > 0) h += '<span class=\"tag t-dirty\">' + r.dirty + ' changed</span>';\n"
292 " if (r.ahead > 0) h += '<span class=\"tag t-ahead\">+' + r.ahead + '</span>';\n"
293 " if (r.behind > 0) h += '<span class=\"tag t-behind\">-' + r.behind + '</span>';\n"
294 " if (r.detached) h += '<span class=\"tag t-det\">detached</span>';\n"
295 " if (r.no_upstream && !r.detached) h += '<span class=\"tag t-noup\">no upstream</span>';\n"
296 " if (r.unborn) h += '<span class=\"tag t-unborn\">unborn</span>';\n"
297 " if (r.stash > 0) h += '<span class=\"tag t-stash\">' + r.stash + ' stash</span>';\n"
298 " if (r.dirty === 0 && !r.detached && !r.unborn) h += '<span class=\"tag t-clean\">clean</span>';\n"
299 " return h;\n"
300 " }\n"
301 "\n"
302 " function matches(r){\n"
303 " if (FILTER === 'dirty' && !(r.dirty > 0)) return false;\n"
304 " if (FILTER === 'ahead' && !(r.ahead > 0)) return false;\n"
305 " if (FILTER === 'behind' && !(r.behind > 0)) return false;\n"
306 " if (FILTER === 'stash' && !(r.stash > 0)) return false;\n"
307 "\n"
308 " var sc = document.getElementById('sc').value;\n"
309 " if (sc === 'dirty' && !(r.dirty > 0)) return false;\n"
310 " if (sc === 'clean' && (r.dirty > 0)) return false;\n"
311 " if (sc === 'ahead' && !(r.ahead > 0)) return false;\n"
312 " if (sc === 'behind' && !(r.behind > 0)) return false;\n"
313 " if (sc === 'detached' && !r.detached) return false;\n"
314 " if (sc === 'noup' && !r.no_upstream) return false;\n"
315 "\n"
316 " var f = (document.getElementById('q').value || '').toLowerCase();\n"
317 " if (!f) return true;\n"
318 " var hay = (r.name + ' ' + r.path + ' ' + r.branch + ' ' + r.upstream + ' ' +\n"
319 " (r.last_commit ? r.last_commit.subject : '')).toLowerCase();\n"
320 " return hay.indexOf(f) >= 0;\n"
321 " }\n"
322 "\n"
323 " function render(){\n"
324 " var out = DUPS(DATA), rows = document.getElementById('rows'), h = '';\n"
325 " for (var i = 0; i < out.length; i++) {\n"
326 " var r = out[i], lc = r.last_commit || {};\n"
327 " h += '<tr class=\"row' + (SEL === r.path ? ' sel' : '') + '\" data-p=\"' + esc(r.path) + '\">' +\n"
328 " '<td class=\"c-repo\"><div class=\"name\">' + esc(r.name) + '</div>' +\n"
329 " '<div class=\"sub\"><span class=\"mo\">' + esc(r.branch || '-') + '</span> ' + badges(r) + '</div></td>' +\n"
330 " '<td class=\"c-root muted mo\">' + esc(r.root || '-') + '</td>' +\n"
331 " '<td class=\"c-sync mo\">' + (r.ahead || r.behind ? ('+' + r.ahead + ' -' + r.behind) : '<span class=\"muted\">-</span>') + '</td>' +\n"
332 " '<td class=\"c-sync mo\">' + (r.stash ? r.stash : '<span class=\"muted\">-</span>') + '</td>' +\n"
333 " '<td class=\"c-last\"><div class=\"sub subtext\">' + esc(lc.subject || '-') + '</div>' +\n"
334 " '<div class=\"hash\">' + esc((lc.short || '').slice(0, 8)) + ' &middot; ' + ago(lc.ct) + '</div></td>' +\n"
335 " '</tr>';\n"
336 " }\n"
337 " rows.innerHTML = h;\n"
338 " document.getElementById('empty').className = out.length ? 'empty hide' : 'empty';\n"
339 "\n"
340 " var b = rows.querySelectorAll('tr.row');\n"
341 " for (var k = 0; k < b.length; k++) {\n"
342 " b[k].onclick = function(){\n"
343 " openDetail(this.getAttribute('data-p'));\n"
344 " };\n"
345 " }\n"
346 " }\n"
347 " function DUPS(a){ var o = []; for (var i=0;i<a.length;i++) if (matches(a[i])) o.push(a[i]); return o; }\n"
348 "\n"
349 " function setCounts(s, n){\n"
350 " s = s || {};\n"
351 " txt('vAll', n || 0);\n"
352 " txt('vDirty', s.dirty || 0);\n"
353 " txt('vAhead', s.ahead || 0);\n"
354 " txt('vBehind', s.behind || 0);\n"
355 " txt('vStash', s.stashes || 0);\n"
356 " }\n"
357 "\n"
358 " function load(){\n"
359 " var btn = document.getElementById('rfBtn');\n"
360 " btn.disabled = true;\n"
361 " return api('repos').then(function(d){\n"
362 " DATA = d.repos || [];\n"
363 " ROOTS = d.roots || [];\n"
364 " setCounts(d.summary, d.count);\n"
365 " var ex = [];\n"
366 " for (var i = 0; i < ROOTS.length; i++) if (ROOTS[i].exists) ex.push(ROOTS[i].root);\n"
367 " txt('rootPill', ex.length ? (ex.length + ' root' + (ex.length === 1 ? '' : 's')) : 'no roots');\n"
368 " render();\n"
369 " }).catch(function(e){\n"
370 " txt('rootPill', 'error');\n"
371 " document.getElementById('empty').className = 'empty';\n"
372 " document.getElementById('empty').textContent = 'Load failed: ' + e.message;\n"
373 " }).then(function(){ btn.disabled = false; });\n"
374 " }\n"
375 "\n"
376 " function codeClass(c){\n"
377 " if (c === '\\?\\?' || c === '!!') return 'c-unt';\n"
378 " if (c === 'UU' || c === 'AA' || c === 'DD') return 'c-con';\n"
379 " if (c.indexOf('A') >= 0) return 'c-add';\n"
380 " if (c.indexOf('D') >= 0) return 'c-del';\n"
381 " return 'c-mod';\n"
382 " }\n"
383 "\n"
384 " function openDetail(path){\n"
385 " SEL = path;\n"
386 " var d = document.getElementById('drawer');\n"
387 " var s = document.getElementById('scrim');\n"
388 " d.classList.add('open');\n"
389 " d.setAttribute('aria-hidden', 'false');\n"
390 " s.classList.remove('hide');\n"
391 " document.getElementById('dName').textContent = path.split(/[\\\\/]/).pop() || path;\n"
392 " document.getElementById('dBody').innerHTML = '<div class=\"muted\">Loading…</div>';\n"
393 "\n"
394 " api('repo', 'path=' + encodeURIComponent(path)).then(function(j){\n"
395 " if (!j.ok) throw new Error(j.error || 'failed');\n"
396 " var r = j.repo || {}, lc = r.last_commit || {};\n"
397 " var h = '';\n"
398 " h += '<div class=\"dsec\">Repository</div>';\n"
399 " h += '<div class=\"mo\" style=\"font-size:12px;word-break:break-all\">' + esc(r.path) + '</div>';\n"
400 " h += '<div style=\"margin-top:8px\">' + badges(r) + '</div>';\n"
401 " h += '<div class=\"note\">branch <span class=\"mo\">' + esc(r.branch || '-') + '</span>' +\n"
402 " (r.upstream ? ' &rarr; <span class=\"mo\">' + esc(r.upstream) + '</span>' : '') + '</div>';\n"
403 "\n"
404 " h += '<div class=\"dsec\">Last commit</div>';\n"
405 " h += '<div class=\"clist\"><li><div class=\"s\">' + esc(lc.subject || '-') + '</div>' +\n"
406 " '<div class=\"m\"><span class=\"mo\">' + esc((lc.short || '').slice(0, 8)) + '</span>' +\n"
407 " '<span>' + ago(lc.ct) + '</span></div></li></div>';\n"
408 "\n"
409 " var ch = j.changed || [];\n"
410 " h += '<div class=\"dsec\">Changed files (' + (j.changed_count || 0) + ')</div>';\n"
411 " if (!ch.length) {\n"
412 " h += '<div class=\"muted\">Working tree is clean.</div>';\n"
413 " } else {\n"
414 " h += '<ul class=\"flist\">';\n"
415 " for (var i = 0; i < ch.length; i++) {\n"
416 " h += '<li><span class=\"c ' + codeClass(ch[i].code) + '\">' + esc(ch[i].code) + '</span>' +\n"
417 " '<span class=\"p\">' + esc(ch[i].path) + '</span></li>';\n"
418 " }\n"
419 " h += '</ul>';\n"
420 " if (j.changed_truncated) h += '<div class=\"note\">Showing the first 500 entries.</div>';\n"
421 " }\n"
422 "\n"
423 " var cm = j.commits || [];\n"
424 " h += '<div class=\"dsec\">Recent commits (' + cm.length + ')</div>';\n"
425 " if (!cm.length) {\n"
426 " h += '<div class=\"muted\">No commits yet.</div>';\n"
427 " } else {\n"
428 " h += '<ul class=\"clist\">';\n"
429 " for (var k = 0; k < cm.length; k++) {\n"
430 " h += '<li><div class=\"s\">' + esc(cm[k].subject || '') + '</div>' +\n"
431 " '<div class=\"m\"><span class=\"mo\">' + esc((cm[k].hash || '').slice(0, 8)) + '</span>' +\n"
432 " '<span>' + esc(cm[k].author || '') + '</span>' +\n"
433 " '<span>' + ago(cm[k].ct) + '</span></div></li>';\n"
434 " }\n"
435 " h += '</ul>';\n"
436 " }\n"
437 " document.getElementById('dBody').innerHTML = h;\n"
438 " }).catch(function(e){\n"
439 " document.getElementById('dBody').innerHTML =\n"
440 " '<div class=\"err\">Could not read this repository: ' + esc(e.message) + '</div>';\n"
441 " });\n"
442 " }\n"
443 "\n"
444 " function closeDetail(){\n"
445 " SEL = '';\n"
446 " document.getElementById('drawer').classList.remove('open');\n"
447 " document.getElementById('drawer').setAttribute('aria-hidden', 'true');\n"
448 " document.getElementById('scrim').classList.add('hide');\n"
449 " render();\n"
450 " }\n"
451 "\n"
452 " document.getElementById('dClose').onclick = closeDetail;\n"
453 " document.getElementById('scrim').onclick = closeDetail;\n"
454 " document.addEventListener('keydown', function(e){ if (e.key === 'Escape') closeDetail(); });\n"
455 " document.getElementById('rfBtn').onclick = load;\n"
456 " document.getElementById('q').oninput = render;\n"
457 " document.getElementById('sc').onchange = render;\n"
458 " document.getElementById('thBtn').onclick = function(){\n"
459 " if (window.sxApplyTheme) window.sxApplyTheme(window.sxTheme() === 'dark' ? 'light' : 'dark');\n"
460 " };\n"
461 "\n"
462 " var chips = document.querySelectorAll('.chip');\n"
463 " for (var ci = 0; ci < chips.length; ci++) {\n"
464 " chips[ci].onclick = function(){\n"
465 " FILTER = this.getAttribute('data-filter');\n"
466 " for (var j = 0; j < chips.length; j++) chips[j].classList.remove('sel');\n"
467 " this.classList.add('sel');\n"
468 " render();\n"
469 " };\n"
470 " }\n"
471 "\n"
472 " load();\n"
473 "})();\n"
474 "</script>\n"
475 "\002</body></html>\n"
476 ;
477
478#endif /* SX_GITSTAT_UI_HTML_H */