more intuitive search parameters

master
Aevann 2023-06-24 17:36:57 +03:00
parent bc0763591e
commit 0420b98080
2 changed files with 22 additions and 20 deletions

View File

@ -1,8 +1,10 @@
function addParam(e) {
e = e || window.event;
let paramExample = e.target.innerText;
let param = paramExample.split(":")[0];
function addParam(t, bool) {
let text = t.innerText;
if (bool)
text = text + ' '
else
text = text.split(":")[0] + ':';
let searchInput = document.querySelector("#large_searchbar input");
searchInput.value = `${searchInput.value} ${param}:`;
searchInput.value = `${searchInput.value} ${text}`;
searchInput.focus();
}

View File

@ -34,53 +34,53 @@
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Before Date:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">before:2022-12-30</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">before:2022-12-30</button>
</div>
<div>
<div style="display: inline-block; width: 150px; text-align: center;">After Date:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">after:2022-12-30</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">after:2022-12-30</button>
</div>
{% if not request.path.startswith('/search/users') %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Author:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">author:quadnarca</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">author:quadnarca</button>
</div>
{% endif %}
{% if request.path.startswith('/search/messages') %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Sent To:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">sentto:carpathianflorist</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">sentto:carpathianflorist</button>
</div>
{% elif request.path.startswith('/search/posts') or request.path.startswith('/search/comments') %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">{{HOLE_NAME | capitalize }}:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">{{HOLE_NAME}}:music</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">{{HOLE_NAME}}:music</button>
</div>
{% if FEATURES['NSFW_MARKING'] %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">NSFW:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">over18:true</button>
</div>
{% endif %}
{% if request.path.startswith('/search/comments') %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Post ID:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">post:504</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">post:504</button>
</div>
{% elif request.path.startswith('/search/posts') %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Domain:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">domain:reddit.com</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this)" class="searchparam mb-1">domain:reddit.com</button>
</div>
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Post Title Only:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">title:true</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this, 'bool')" class="searchparam mb-1">title:true</button>
</div>
<div>
<div style="display: inline-block; width: 150px; text-align: center;">Exact Match Only:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam()" class="searchparam mb-1">exact:true</button>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this, 'bool')" class="searchparam mb-1">exact:true</button>
</div>
{% endif %}
{% if FEATURES['NSFW_MARKING'] %}
<div>
<div style="display: inline-block; width: 150px; text-align: center;">NSFW Only:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this, 'bool')" class="searchparam mb-1">over18:true</button>
</div>
{% endif %}
{% endif %}