1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 00:40:52 +01:00
vichan/js/catalog-link.js

65 lines
1.7 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';
*/
function catalog() {
var board = $("input[name='board']");
2014-04-06 02:47:18 +02:00
if (board.length>0) {
if (window.location.href.indexOf("/res/")==-1){ //if we are inside a thread
var catalog_url = 'catalog.html';
2014-04-06 02:47:18 +02:00
}
else {
var catalog_url = '../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);
}
}
}
2014-04-05 23:04:46 +02:00
if (!parseInt($('input[name="mod"]').val())) {
$(document).ready(catalog);
}