mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-29 09:44:28 +01:00
toggle tree view
This commit is contained in:
parent
666a7f760d
commit
2da17bfebe
@ -31,27 +31,41 @@ $(function() {
|
|||||||
|
|
||||||
if (active_page == 'thread')
|
if (active_page == 'thread')
|
||||||
$(function() {
|
$(function() {
|
||||||
|
var treeview_on = false;
|
||||||
var treeview = function() {
|
var treeview = function() {
|
||||||
$('.post.reply').each(function(){
|
if (!treeview_on) {
|
||||||
var references = [];
|
treeview_on = true;
|
||||||
$(this).find('.body a').each(function(){
|
$('.post.reply').each(function(){
|
||||||
if ($(this).html().match('^>>[0-9]+$')) {
|
var references = [];
|
||||||
references.push(parseInt($(this).html().replace('>>', '')));
|
$(this).find('.body a').each(function(){
|
||||||
}
|
if ($(this).html().match('^>>[0-9]+$')) {
|
||||||
});
|
references.push(parseInt($(this).html().replace('>>', '')));
|
||||||
var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0);
|
}
|
||||||
|
});
|
||||||
var parent_post = $("#reply_"+maxref);
|
var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0);
|
||||||
if (parent_post.length == 0) return;
|
|
||||||
|
|
||||||
var margin = parseInt(parent_post.css("margin-left"))+32;
|
|
||||||
|
|
||||||
var post = $(this);
|
|
||||||
var br = post.next();
|
|
||||||
|
|
||||||
post.detach().css("margin-left", margin).insertAfter(parent_post.next());
|
var parent_post = $("#reply_"+maxref);
|
||||||
br.detach().insertAfter(post);
|
if (parent_post.length == 0) return;
|
||||||
});
|
|
||||||
|
var margin = parseInt(parent_post.css("margin-left"))+32;
|
||||||
|
|
||||||
|
var post = $(this);
|
||||||
|
var br = post.next();
|
||||||
|
|
||||||
|
post.detach().css("margin-left", margin).insertAfter(parent_post.next());
|
||||||
|
br.detach().insertAfter(post);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
treeview_on = false;
|
||||||
|
$('.post.reply').sort(function(a,b) {
|
||||||
|
return parseInt(a.id.replace('reply_', '')) > parseInt(b.id.replace('reply_', ''));
|
||||||
|
}).each(function () {
|
||||||
|
var post = $(this);
|
||||||
|
var br = post.next();
|
||||||
|
post.detach().css('margin-left', '0').appendTo('.thread');
|
||||||
|
br.detach().insertAfter(post);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (localStorage.treeview === 'true') {
|
if (localStorage.treeview === 'true') {
|
||||||
treeview();
|
treeview();
|
||||||
|
Loading…
Reference in New Issue
Block a user