From 8e5681b44f4732f438e1f186c00275ef1ada8fe4 Mon Sep 17 00:00:00 2001 From: RealAngeleno Date: Sat, 5 Aug 2023 15:32:46 -0700 Subject: [PATCH] Add mod.php logic --- js/catalog-link.js | 90 +++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/js/catalog-link.js b/js/catalog-link.js index a98078f7..50557700 100644 --- a/js/catalog-link.js +++ b/js/catalog-link.js @@ -12,51 +12,53 @@ * $config['additional_javascript'][] = 'js/catalog-link.js'; */ -(function($) { -var catalog = function() { - var board = $('input[name="board"]'); - - if (!board.length) { - return; - } - - var catalog_url = configRoot + board.first().val() + '/catalog.html'; - - var pages = $('.pages'); - var bottom = $('.boardlist.bottom'); - var subtitle = $('.subtitle'); - - var link = $('') - .attr('href', catalog_url); - - if (pages.length) { - link.text(_('Catalog')) - .css({ - color: '#F10000', - padding: '4px', - textDecoration: 'underline', - display: 'table-cell' - }); - link.insertAfter(pages); - } else if (bottom.length) { - link.text('['+_('Catalog')+']') - .css({ - paddingLeft: '10px', - textDecoration: 'underline' - }); - link.insertBefore(bottom); - } - - if (subtitle.length) { - subtitle.append('
'); - $('
') - .text(_('Catalog')) - .attr('href', catalog_url) - .appendTo(subtitle); - } +function catalog() { + var board = $("input[name='board']"); + var boardValue = board.first().val(); + + var catalog_url = ''; + if (window.location.href.includes('mod.php?/')) { + catalog_url = configRoot + 'mod.php?/' + boardValue + '/catalog.html'; + } else { + catalog_url = configRoot + boardValue + '/catalog.html'; + } + + var pages = document.getElementsByClassName('pages')[0]; + var bottom = document.getElementsByClassName('boardlist bottom')[0]; + var subtitle = document.getElementsByClassName('subtitle')[0]; + + var link = document.createElement('a'); + link.href = catalog_url; + + if (pages) { + link.textContent = _('Catalog'); + link.style.color = '#F10000'; + link.style.padding = '4px'; + link.style.paddingLeft = '9px'; + link.style.borderLeft = '1px solid'; + link.style.borderLeftColor = '#A8A8A8'; + link.style.textDecoration = "underline"; + + pages.appendChild(link); + } else { + link.textContent = '['+_('Catalog')+']'; + link.style.paddingLeft = '10px'; + link.style.textDecoration = "underline"; + document.body.insertBefore(link, bottom); + } + + if (subtitle) { + var link2 = document.createElement('a'); + link2.textContent = _('Catalog'); + link2.href = catalog_url; + + var br = document.createElement('br'); + subtitle.appendChild(br); + subtitle.appendChild(link2); + } } -if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko') { - $(document).ready(catalog); +if (active_page == 'thread' || active_page == 'index') { + $(document).ready(catalog); } })(jQuery);