var animateGif = function () {
if ($(this).children('img.post-image').attr('src') != '/static/spoiler.png')
$(this).children('img.post-image').attr('src', $(this).attr('href'));
}
$('div.file').children('a[href*=".gif"]').each(animateGif);
$(document).on('new_post', function (e, post) {
$(post).find('div.file').children('a[href*=".gif"]').each(animateGif);
});
});
$('document').ready(function () {
if(active_page == 'catalog') {
var getThreadInfo = function() {
var $post = $(this)
if ($post.attr('src').split('.')[$post.attr('src').split('.').length-1] == 'jpg') {
var url = $post.parent().attr('href').replace('html','json');
var newImage = ''
var threadJson = $.getJSON(url)
.done(function ( json) {
if (json.posts[0].ext === '.gif') {
newImage = 'https://' + window.location.host + '/' + board_name +'/src/' + json.posts[0].tim + json.posts[0].ext
$post.attr('src', newImage);
}
});
}
}
$('img.thread-image').each(getThreadInfo);
}
else if (active_page == 'index' || active_page == 'thread') {
var animateGif = function () {
if ($(this).children('img.post-image').attr('src') != '/static/spoiler.png')
$(this).children('img.post-image').attr('src', $(this).attr('href'));
}
$('div.file').children('a[href*=".gif"]').each(animateGif);
$(document).on('new_post', function (e, post) {
$(post).find('div.file').children('a[href*=".gif"]').each(animateGif);
});
}
});