1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-05 04:18:03 +01:00
vichan/js/update_boards.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-10-07 03:01:01 +02:00
$(document).ready(function(){
window.boards = new Array();
2015-01-01 07:28:49 +01:00
if (window.Options && Options.get_tab('general')) {
Options.extend_tab("general", "<label id='show-top'><input type='checkbox' /> "+_('Show top boards')+"</label>");
if (typeof localStorage.show_top === 'undefined') {
localStorage.show_top = 'true';
var show_top = JSON.parse(localStorage.show_top);
$('#show-top>input').attr('checked', 'checked');
} else {
var show_top = JSON.parse(localStorage.show_top);
if (show_top) $('#show-top>input').attr('checked', 'checked');
}
$('#show-top>input').on('change', function() {
var show_top = ($(this).is(':checked'));
localStorage.show_top = JSON.stringify(show_top);
});
}
2014-10-07 03:01:01 +02:00
function handle_boards(data) {
$.each(data, function(k, v) {
2014-10-29 07:22:13 +01:00
if (v.uri != 'meta' && v.uri != 'b') {
2014-12-14 12:28:19 +01:00
boards.push('<a href="/'+v.uri+(window.active_page === 'catalog' ? '/catalog.html' : '/index.html')+'">'+v.uri+'</a>');
2014-10-07 03:01:01 +02:00
}
})
if (boards[0]) {
2015-01-01 07:28:49 +01:00
$('.sub[data-description="2"]').after('<span class="sub" data-description="3"> [ '+boards.slice(0,25).join(" / ")+' ] </span>');
2014-10-07 03:01:01 +02:00
}
}
2015-01-01 07:28:49 +01:00
if (!(window.location.pathname != '' && window.location.pathname != '/' && window.location.pathname != '/index.html' && typeof show_top !== "undefined" && !show_top)) {
$.getJSON("/boards-top20.json", handle_boards)
}
2014-10-07 03:01:01 +02:00
});