lainchan/js/catalog-link.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

/*
* catalog-link.js - This script puts a link to the catalog below the board
* subtitle and next to the board list.
* https://github.com/vichan-devel/Tinyboard/blob/master/js/catalog-link.js
*
* Released under the MIT license
* Copyright (c) 2013 copypaste <wizardchan@hush.com>
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/catalog-link.js';
*/
2015-06-02 09:28:06 -04:00
(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 = $('<a class="catalog" />')
.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('<br />');
$('<a class="catalog" />')
.text(_('Catalog'))
.attr('href', catalog_url)
.appendTo(subtitle);
}
}
2013-08-16 10:45:01 -04:00
2015-06-02 09:28:06 -04:00
if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko') {
2013-08-16 10:45:43 -04:00
$(document).ready(catalog);
}
2015-06-02 09:28:06 -04:00
})(jQuery);