ikibooru/index.html.l
2024-09-07 09:53:39 +03:00

102 lines
3.7 KiB
Plaintext

{% title = BigGlobe.cfg.sitename .. " - generic object database inspired by imageboards" %}
{% function content() %}
<div style="text-align:center;height:50%;margin-top:25vh;">
<div style="width:12cm;display:inline-block;">
<h1>{{ Escapes.htmlescape(BigGlobe.cfg.sitename) }}</h1>
<form action="/search" method="GET" id="searchform">
<input type="text" name="n" placeholder="Filter by name..." style="position:relative;width:100%;" />
<input type="hidden" id="tparam" name="t" value="" />
<div style="position: relative;">
<div data-formid="searchform" data-formparaminputid="tparam" style="position:relative;width:58%;margin-top:1em;display:inline-block;vertical-align:top;white-space:nowrap;overflow-x:scroll;" class="tagbox">
<p>Filter by tags...</p>
<!-- Firefox has a 10-year old bug where a contenteditable with 0 padding loses focus when you press the right arrow key to the end -->
<span style="position:relative;min-width:4px;left:0;padding-right:1px;" contenteditable autofocus></span>
</div>
{% if BigGlobe.cfg.enable18plus then %}
<ul class="over18" style="width:40%;display:inline-block;vertical-align:middle;">
<li>
<input type="radio" name="a" value="-1" id="o18h" onchange="upd(-1)" checked />
<label for="o18h">&#x1F6C7;</label>
</li><li>
<input type="radio" name="a" value="0" id="o18s" onchange="upd(0)" />
<label for="o18s">18+?</label>
</li><li>
<input type="radio" name="a" value="1" id="o18o" onchange="upd(1)" />
<label for="o18o">&check;</label>
</li>
</ul>
{% end %}
<div class="autocomplete" style="visibility:hidden;width:100%;position:absolute;top:70%;box-sizing:border-box;"></div>
</div>
<input type="submit" value="Search" style="margin-top:1em;" />
<p>Hosting <a href="/search?n=&a=0&t=&hpl">{{DB.getobjcount()}} objects</a> and <a href="#" onclick="showalltags()">{{DB.gettagcount()}} tags</a>.</p>
<div id="alltags"></div>
</form>
</div>
</div>
<script defer src="/static/tagbox.js"></script>
<script defer>
{% if BigGlobe.cfg.enable18plus then %}
function upd(over18) {
document.querySelector(".tagbox").setAttribute("data-over18", +over18 != -1)
window.localStorage.setItem("o18", over18)
}
var activeo18 = "-1"
if(window.localStorage.getItem("o18")) {
activeo18 = window.localStorage.getItem("o18")
}
upd(activeo18)
document.querySelector("ul.over18 input[type=\"radio\"][value=\"" + activeo18 + "\"]").checked = true
{% end %}
function showalltags() {
var ajax = new XMLHttpRequest()
ajax.open("GET", "/autocomp?q=" + (document.querySelector("div.tagbox").getAttribute("data-over18") == "true" ? "&a=" : ""), true)
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
var box = document.getElementById("alltags")
var datags = []
ajax.responseText.split("\n").slice(0, -1).forEach(function(line) {
var tagID = line.split(",")[0]
var newtag = document.createElement("div")
newtag.classList.toggle("tag")
newtag.classList.toggle("tc" + line.split(",")[2])
newtag.setAttribute("data-tagid", tagID)
newtag.setAttribute("data-tc", line.split(",")[2])
newtag.innerText = line.split(",")[1]
datags.push(newtag)
})
datags.sort(function(a, b) {return a.getAttribute("data-tc") - b.getAttribute("data-tc")})
datags.forEach(function(x) {
var newa = document.createElement("a")
newa.setAttribute("href", "/search?n=&t=" + x.getAttribute("data-tagid") + "&h");
newa.appendChild(x);
box.insertBefore(newa, null)
})
}
}
ajax.send()
showalltags = function() {}
}
document.querySelector("[autofocus]").focus()
</script>
{% end %}
{# base.inc