implement URL on random elements in js file rather than inline

This commit is contained in:
Oleg Belyaev 2025-03-23 11:23:32 +03:00
parent f2a1c15951
commit 0b4fd5f468
2 changed files with 15 additions and 4 deletions

View file

@ -1,4 +1,9 @@
$( document ).ready(function() { $( document ).ready(function() {
// Link elements that do not have href out of the box
$('.link').on("click", function () {
window.location=$(this)[0].dataset.href+window.location.search+window.location.hash;
});
function bindMapOpen() { function bindMapOpen() {
// $('#modal_map').data('abv-entry',$(this).data('abv-entry')); // $('#modal_map').data('abv-entry',$(this).data('abv-entry'));
// $('#modal_map')[0].showModal(); // $('#modal_map')[0].showModal();

View file

@ -55,13 +55,15 @@ declare function page:header($lang as xs:string, $href-other as xs:string) {
<li>{ <li>{
(element {if ($lang = 'ru') then 'mark' else 'a'}{ (element {if ($lang = 'ru') then 'mark' else 'a'}{
if ($lang != 'ru') then if ($lang != 'ru') then
(attribute onclick {`window.location='{$href-other}'+window.location.search;`}, (attribute class {'link'},
attribute data-href {`{$href-other}`},
attribute href {'#'}) else (), attribute href {'#'}) else (),
'ru' 'ru'
}, ' / ', }, ' / ',
element {if ($lang = 'ru') then 'a' else 'mark'}{ element {if ($lang = 'ru') then 'a' else 'mark'}{
if ($lang = 'ru') then if ($lang = 'ru') then
(attribute onclick {`window.location='{$href-other}'+window.location.search;`}, (attribute class {'link'},
attribute data-href {`{$href-other}`},
attribute href {'#'}) else (), attribute href {'#'}) else (),
'en' 'en'
}) })
@ -113,7 +115,7 @@ declare function page:header($lang as xs:string, $href-other as xs:string) {
else else
( (
if (session:get('searchN') > 1) then if (session:get('searchN') > 1) then
<button type="button" onclick="location.href='./search/prev'"> <button type="button" class="link" data-href="./search/prev">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/> <path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
</svg> </svg>
@ -121,7 +123,7 @@ declare function page:header($lang as xs:string, $href-other as xs:string) {
<button disabled="true">{session:get('searchN')}/{array:size(session:get('searchData'))}</button> <button disabled="true">{session:get('searchN')}/{array:size(session:get('searchData'))}</button>
, ,
if (session:get('searchN') and session:get('searchN') < array:size(session:get('searchData'))) then if (session:get('searchN') and session:get('searchN') < array:size(session:get('searchData'))) then
<button type="button" onclick="location.href='./search/next'"> <button type="button" class="link" data-href="./search/next">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/> <path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/>
</svg> </svg>
@ -550,6 +552,10 @@ declare %rest:path("{$lang}/dict")
<footer><button class="abv-close-map">Close</button></footer> <footer><button class="abv-close-map">Close</button></footer>
</article> </article>
</dialog> </dialog>
{if (session:get('searchQuery')) then
<dialog id="modal_searchResults">
</dialog>}
</body> </body>
</html> </html>
}; };