summaryrefslogtreecommitdiff
path: root/js/catalog-link.js
blob: 05ee9efb8fc01dd4bc16e2817e504545d08d715b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * 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';
 */

function catalog() {
var board = $("input[name='board']");

var catalog_url = configRoot + board.first().val() + "/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') {
	$(document).ready(catalog);
}