1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 01:10:51 +01:00
vichan/js/catalog.js
2016-05-05 12:01:16 +02:00

59 lines
1.7 KiB
JavaScript

if (active_page == 'catalog') $(function(){
if (localStorage.catalog !== undefined) {
var catalog = JSON.parse(localStorage.catalog);
} else {
var catalog = {};
localStorage.catalog = JSON.stringify(catalog);
}
if (localStorage.hiddenthreads) {
var hidden_data = JSON.parse(localStorage.hiddenthreads);
if (hidden_data[board_name] && !$.isEmptyObject(hidden_data[board_name])) {
$.each(hidden_data[board_name], function(k, v) {
$('a[href$="/'+k+'.html"]').parents('.mix').remove();
});
}
} else {
hidden_data = {};
}
$(document).on('click', '.mix', function(e) {
if (e.shiftKey) {
hidden_data[board_name][$(this).data('id')] = Math.round(Date.now() / 1000);
$(this).remove();
localStorage.hiddenthreads = JSON.stringify(hidden_data);
}
});
$("#sort_by").change(function(){
var value = this.value;
$('#Grid').mixItUp('sort', (value == "random" ? value : "sticky:desc " + value));
catalog.sort_by = value;
localStorage.catalog = JSON.stringify(catalog);
});
$("#image_size").change(function(){
var value = this.value, old;
$(".grid-li").removeClass("grid-size-vsmall");
$(".grid-li").removeClass("grid-size-small");
$(".grid-li").removeClass("grid-size-large");
$(".grid-li").addClass("grid-size-"+value);
catalog.image_size = value;
localStorage.catalog = JSON.stringify(catalog);
});
$('#Grid').mixItUp({
animation: {
enable: false
}
});
if (catalog.sort_by !== undefined) {
$('#sort_by').val(catalog.sort_by).trigger('change');
}
if (catalog.image_size !== undefined) {
$('#image_size').val(catalog.image_size).trigger('change');
}
});