summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-06-24 09:02:12 -0400
committerczaks <marcin@6irc.net>2013-06-24 09:02:12 -0400
commit0cae0d70b8a25264871a0d39dc1bfdbfa53e44dd (patch)
tree4bdf14c086aa19480d19aa4da7ab3d02bfcce89e /js
parent802fd16d46c8fb19382f4c81cf1642d3d7ae9744 (diff)
post-hider.js: fixed multiple board issues; eg. you could hide a thread on one board, and threads from other boards with the same id would have been hidden too
Diffstat (limited to 'js')
-rw-r--r--js/post-hider.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/js/post-hider.js b/js/post-hider.js
index 0a2e3c1a..02a421fe 100644
--- a/js/post-hider.js
+++ b/js/post-hider.js
@@ -1,33 +1,37 @@
-function phGetCookieName(id) {
- return "ph_hide_" + id;
+function phGetCookieName(board, id) {
+ return "ph_hide_" + board + "_" + id;
}
-function phPostHidden(id) {
- return (localStorage.getItem(phGetCookieName(id)) != null);
+function phPostHidden(board, id) {
+ return (localStorage.getItem(phGetCookieName(board, id)) != null);
}
-function phPostToggle(id) {
- if(phPostHidden(id)) { localStorage.removeItem(phGetCookieName(id)); }
- else { localStorage.setItem(phGetCookieName(id),"yes"); }
+function phPostToggle(board, id) {
+ if(phPostHidden(board, id)) { localStorage.removeItem(phGetCookieName(board, id)); }
+ else { localStorage.setItem(phGetCookieName(board, id),"yes"); }
}
-function phGetInnerText(id) {
- if(phPostHidden(id)) { return "[+]"; }
- else { return "[-]"; }
+function phGetInnerText(board, id) {
+ if(phPostHidden(board, id)) { return "[+]"; }
+ else { return "[–]"; }
}
function phGetOpID(element) {
return Number(element.children("div.post.op").children("p.intro").children("a.post_no:eq(1)").text());
}
+function phGetOpBoard(element) {
+ return element.data("board");
+}
function phPostHandle(element) {
var id = phGetOpID(element);
+ var board = phGetOpBoard(element);
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");
var pomitted = element.children("div.post.op").children("span.omitted");
- if(phPostHidden(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("[-]"); }
+ 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("[–]"); }
}
$(document).ready(function(){
- $('div[id^="thread"]').each(function(index, element){
+ $('form[name="postcontrols"] > div[id^="thread"]').each(function(index, element){
// Get thread ID.
var pin = $(this).children("div.post.op").children("p.intro");
var tid = phGetOpID($(this));
@@ -35,7 +39,7 @@ $(document).ready(function(){
$("<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(phGetOpID(par));
+ phPostToggle(phGetOpBoard(par), phGetOpID(par));
phPostHandle(par);
return false;
});