2013-06-24 15:02:12 +02:00
|
|
|
|
function phGetCookieName(board, id) {
|
|
|
|
|
return "ph_hide_" + board + "_" + id;
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
2013-06-24 15:02:12 +02:00
|
|
|
|
function phPostHidden(board, id) {
|
|
|
|
|
return (localStorage.getItem(phGetCookieName(board, id)) != null);
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
2013-06-24 15:02:12 +02:00
|
|
|
|
function phPostToggle(board, id) {
|
|
|
|
|
if(phPostHidden(board, id)) { localStorage.removeItem(phGetCookieName(board, id)); }
|
|
|
|
|
else { localStorage.setItem(phGetCookieName(board, id),"yes"); }
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
2013-06-24 15:02:12 +02:00
|
|
|
|
function phGetInnerText(board, id) {
|
|
|
|
|
if(phPostHidden(board, id)) { return "[+]"; }
|
|
|
|
|
else { return "[–]"; }
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
|
|
|
|
function phGetOpID(element) {
|
2013-07-20 06:06:41 +02:00
|
|
|
|
return Number(element.children("div.post.op").children("p.intro").children("a.post_no.p2").text());
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
2013-06-24 15:02:12 +02:00
|
|
|
|
function phGetOpBoard(element) {
|
|
|
|
|
return element.data("board");
|
|
|
|
|
}
|
2012-12-24 13:03:07 +01:00
|
|
|
|
function phPostHandle(element) {
|
|
|
|
|
var id = phGetOpID(element);
|
2013-06-24 15:02:12 +02:00
|
|
|
|
var board = phGetOpBoard(element);
|
2012-12-24 13:03:07 +01:00
|
|
|
|
var preplies = element.children("div.post.reply");
|
|
|
|
|
var pbody = element.children("div.post.op").children("div.body");
|
|
|
|
|
var pimage = element.children("a:first").children("img");
|
|
|
|
|
var pbutton = element.children("div.post.op").children("p.intro").children("a.posthider");
|
2012-12-24 13:17:54 +01:00
|
|
|
|
var pomitted = element.children("div.post.op").children("span.omitted");
|
2013-06-24 15:02:12 +02:00
|
|
|
|
if(phPostHidden(board, id)) { element.addClass("thread-hidden"); pomitted.hide(); preplies.hide(); pbody.hide(); pimage.hide(); pbutton.text("[+]"); }
|
|
|
|
|
else { element.removeClass("thread-hidden"); pomitted.show(); preplies.show(); pbody.show(); pimage.show(); pbutton.text("[–]"); }
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 15:05:33 +02:00
|
|
|
|
function phHandleThread(index, element) {
|
|
|
|
|
// Get thread ID.
|
|
|
|
|
var pin = $(this).children("div.post.op").children("p.intro");
|
|
|
|
|
var tid = phGetOpID($(this));
|
|
|
|
|
if(tid != NaN) {
|
|
|
|
|
$("<a href='javascript:;' class='posthider'>[?]</a>").insertAfter(pin.children('a:last')).click(function(e) {
|
|
|
|
|
var eO = $(e.target);
|
|
|
|
|
var par = eO.parent().parent().parent();
|
|
|
|
|
phPostToggle(phGetOpBoard(par), phGetOpID(par));
|
|
|
|
|
phPostHandle(par);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
phPostHandle($(this));
|
|
|
|
|
}
|
2012-12-24 13:03:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
2013-06-24 15:05:33 +02:00
|
|
|
|
if (active_page != "thread") {
|
|
|
|
|
$('form[name="postcontrols"] > div[id^="thread"]').each(phHandleThread);
|
|
|
|
|
}
|
2012-12-24 13:03:07 +01:00
|
|
|
|
});
|