224 lines
4.9 KiB
Plaintext
224 lines
4.9 KiB
Plaintext
|
|
void render_see_section(String name)
|
|
{
|
|
StringList lines = split(file_get_contents("areas/"+name+".txt"), "\n");
|
|
s32 idx = 0;
|
|
for(auto line : lines)
|
|
{
|
|
if(idx == 0)
|
|
{
|
|
<><div class="category"><h3><?= line ?></h3><ul></>
|
|
}
|
|
else if(line != "")
|
|
{
|
|
<><li><a href="index.uce?p=<?= uri_encode(line) ?>"><?= line ?><span class="dim">()</span></a></li></>
|
|
}
|
|
idx += 1;
|
|
}
|
|
<></ul></div></>
|
|
}
|
|
|
|
|
|
RENDER(Request& context)
|
|
{
|
|
|
|
String page = first(context.get["p"], "index");
|
|
|
|
<><html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
|
|
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
|
|
</head>
|
|
<body>
|
|
<h1>
|
|
<a href="index.uce">UCE Docs</a><?
|
|
if(page != "index")
|
|
{
|
|
?><span class="dim"> / </span><?= page ?><?
|
|
}
|
|
?>
|
|
</h1>
|
|
<?
|
|
|
|
if(page == "index")
|
|
{
|
|
?><div class="search-bar">
|
|
<input id="doc-search" type="search" placeholder="Search API…" autocomplete="off" spellcheck="false"/>
|
|
<span class="search-count" id="search-count"></span>
|
|
</div>
|
|
<div id="search-results" hidden></div>
|
|
<div class="index-pane" id="index-pane">
|
|
<div class="index-layout">
|
|
<nav class="sidebar"><?
|
|
for(auto file_name : ls("areas/"))
|
|
{
|
|
String ft = nibble(file_name, ".");
|
|
render_see_section(ft);
|
|
}
|
|
?></nav>
|
|
<main class="content">
|
|
<h2>All API Functions</h2>
|
|
<div class="func-grid"><?
|
|
for(auto file_name : ls("pages/"))
|
|
{
|
|
String ft = nibble(file_name, ".");
|
|
if(ft.substr(0, 2) == "0_")
|
|
{
|
|
String fn = ft;
|
|
String pre = nibble(fn, "_");
|
|
?>
|
|
<div class="func-item"><a href="?p=<?= uri_encode(ft) ?>"><?= fn ?><span class="badge">struct</span></a></div>
|
|
<?
|
|
}
|
|
else if(ft.substr(0, 2) == "1_")
|
|
{
|
|
String fn = ft;
|
|
String pre = nibble(fn, "_");
|
|
?>
|
|
<div class="func-item"><a href="?p=<?= uri_encode(ft) ?>"><?= fn ?><span class="badge">directive</span></a></div>
|
|
<?
|
|
}
|
|
else
|
|
{
|
|
?>
|
|
<div class="func-item"><a href="?p=<?= uri_encode(ft) ?>"><?= ft ?><span class="dim">()</span></a></div>
|
|
<?
|
|
}
|
|
}
|
|
?></div>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
<?
|
|
<><script>
|
|
(function () {
|
|
var input = document.getElementById('doc-search');
|
|
var results = document.getElementById('search-results');
|
|
var pane = document.getElementById('index-pane');
|
|
var counter = document.getElementById('search-count');
|
|
var timer;
|
|
|
|
function showResults(html) {
|
|
results.innerHTML = html;
|
|
results.hidden = false;
|
|
pane.hidden = true;
|
|
var hits = results.querySelectorAll('.search-hit').length;
|
|
counter.textContent = hits ? hits + ' result' + (hits > 1 ? 's' : '') : '';
|
|
}
|
|
|
|
function showIndex() {
|
|
results.innerHTML = '';
|
|
results.hidden = true;
|
|
pane.hidden = false;
|
|
counter.textContent = '';
|
|
}
|
|
|
|
input.addEventListener('input', function () {
|
|
var q = this.value.trim();
|
|
clearTimeout(timer);
|
|
if (q.length < 2) { showIndex(); return; }
|
|
counter.textContent = '\u2026';
|
|
timer = setTimeout(function () {
|
|
fetch('search.uce?q=' + encodeURIComponent(q))
|
|
.then(function (r) { return r.text(); })
|
|
.then(showResults);
|
|
}, 220);
|
|
});
|
|
|
|
input.addEventListener('keydown', function (e) {
|
|
if (e.key === 'Escape') { this.value = ''; showIndex(); }
|
|
});
|
|
})();
|
|
</script></>
|
|
}
|
|
else
|
|
{
|
|
?><article class="doc-detail"><?
|
|
auto doc = split(file_get_contents("pages/"+page+".txt"), "\n");
|
|
String layout_class = "text";
|
|
u32 line_idx = 0;
|
|
for(auto s : doc)
|
|
{
|
|
line_idx++;
|
|
if(s == "")
|
|
{
|
|
|
|
}
|
|
else if(s.substr(0, 1) == ":")
|
|
{
|
|
layout_class = s.substr(1);
|
|
if(line_idx > 1)
|
|
{
|
|
?></div><?
|
|
}
|
|
?><div class="doc-section <?= layout_class ?>"><?
|
|
if(layout_class == "params")
|
|
{
|
|
?><h3>Parameters</h3><?
|
|
}
|
|
else if(layout_class == "sig")
|
|
{
|
|
?><h3>Signature</h3><?
|
|
}
|
|
else if(layout_class == "pre")
|
|
{
|
|
layout_class = "sig";
|
|
}
|
|
else if(layout_class == "desc")
|
|
{
|
|
?><h3>Description</h3><?
|
|
}
|
|
else if(layout_class == "related")
|
|
{
|
|
?><h3>Related PHP and JS</h3><?
|
|
}
|
|
else if(layout_class == "see")
|
|
{
|
|
?><h3>Related</h3><?
|
|
}
|
|
else
|
|
{
|
|
?><h3><?= layout_class ?></h3><?
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(s.substr(0, 1) == "-")
|
|
{
|
|
nibble(s, "-");
|
|
?><li><?= (s) ?></li><?
|
|
}
|
|
else if(layout_class == "params")
|
|
{
|
|
?><div><b><?= trim(nibble(s, ":")) ?></b> : <?= trim(s) ?></div><?
|
|
}
|
|
else if(layout_class == "see")
|
|
{
|
|
if(s[0] == '>')
|
|
{
|
|
render_see_section(s.substr(1));
|
|
}
|
|
else
|
|
{
|
|
?><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span class="dim">()</span></a></div><?
|
|
}
|
|
}
|
|
else
|
|
{
|
|
?><div><?: markdown_to_html(s) ?></div><?
|
|
}
|
|
}
|
|
}
|
|
if(line_idx > 0)
|
|
{
|
|
?></div><?
|
|
}
|
|
?></article><?
|
|
}
|
|
|
|
?>
|
|
</body>
|
|
</html></>
|
|
|
|
}
|