// Ignore Poster app Version 0.1 // // namespace: ban // This class represents a post in the thread // // class ban_Post // { // id should reference an id value for the table containing the post. // doc is an option value. Defaults to global document. function ban_Post(id, doc) { if(!doc) doc = document; this.id = id; this.doc = doc; this.table = doc.getElementById(id); this.tableBackup = null; this.memberId = this.getMemberId(); this.showing = true; } ban_Post.prototype.createBackup = function() { this.tableBackup = this.table.cloneNode(true); } ban_Post.prototype.hide = function() { if(!this.showing) return; this.table.innerHTML = '<tr><td><center>Poster banned. <a id="ban_link' + ++ban_linkNum + '" href="javascript:;">unban</a></center></td></tr>'; this.showing = false; var post = this; this.doc.getElementById("ban_link" + ban_linkNum).onclick = function() { var id = post.memberId; if(id.length) ban_setBanned(id, false); post.show(); } } ban_Post.prototype.show = function() { if(this.showing) return; this.table.parentNode.replaceChild(this.tableBackup.cloneNode(true), this.table); this.showing = true; } // Returns true if this post should be banned or false otherwise ban_Post.prototype.isBanned = function() { var id = this.getMemberId(); return id.length ? ban_isBanned(id) : false; } ban_Post.prototype.getMemberId = function() { var str = this.table.className.toString(); var end = str.indexOf(' '); if(end == -1) return ""; var ret = str.substring(1, end); if(ret == null) ret = ""; return ret; } ban_Post.prototype.getHeader = function() { var divs = this.table.getElementsByTagName("DIV"); for(var i = 0; i < divs.length; i++) if(divs[i].className == "header") return divs[i].innerHTML; return null; } ban_Post.prototype.setHeader = function(header) { var divs = this.table.getElementsByTagName("DIV"); for(var i = 0; i < divs.length; i++) if(divs[i].className == "header") divs[i].innerHTML = header; } // } // Returns true if the member with id 'memberId' is banned. // isBanned finds this information in the cookies function ban_isBanned(memberId) { return ban_readCookie("ban_" + memberId) != null; } // Sets the member with id 'memberId' to either banned or // not banned depending on if 'isBanned' is true or false // respectively. function ban_setBanned(memberId, isBanned) { if(isBanned == null || isBanned) ban_createCookie("ban_" + memberId, 1); else ban_eraseCookie("ban_" + memberId); ban_updateBans(); } // Returns a list of ban_Post instances that have been found // doc is the document to search, defaults to the global document function ban_findPosts(doc) { if(!doc) doc = document; var tables = doc.getElementsByTagName("table"); var posts = new Array; for(var i = 0; i < tables.length; i++) if(tables[i].id.indexOf("post-") == 0) posts[posts.length] = new ban_Post(tables[i].id, doc); return posts; } var ban_linkNum = 0; function ban_updateBans() { if(posts == null) return; for(var i = 0; i < posts.length; i++) if(posts[i].isBanned()) posts[i].hide(); else posts[i].show(); } var posts = null; function ban_load_helper(aTag) { aTag.onclick = function() { if(this.ban_memberId) ban_setBanned(this.ban_memberId); } } function ban_load() { posts = ban_findPosts(document); for(var i = 0; i < posts.length; i++) { posts[i].setHeader(posts[i].getHeader() + '<a id="ban_link' + ++ban_linkNum + '" href="javascript:;">Ban</a>'); var a = document.getElementById("ban_link" + ban_linkNum); if(a != null) { a.ban_memberId = posts[i].memberId; ban_load_helper(a); } posts[i].createBackup(); if(posts[i].isBanned()) posts[i].hide(); } } doc.add_onLoad(ban_load); // Cookies! // { function ban_createCookie(name,value,days) { if(days == null) days = 365; var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); document.cookie = name+"="+value+expires+"; path=/"; } function ban_readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function ban_eraseCookie(name) { ban_createCookie(name,"",-1); } // }Then navigate to the extensions page and select the bottom text box with your mouse and paste (control + V). You must be logged in to navigate to this page.
Dustin, how nice of you to choose me as the example
. Or did I just say "Poster banned. unban"?
Sorry, what was that now?
Does this work in practise? What if you have a problem which the banned user answers. Then you write something like "Anyone?" after he has given the answer. It will look strange anyway.
Pretty cool, thanks Dustin!
kentl: Look at the screenshot
kentl: Look at the screenshot
Yes I looked at it before I posted.
What about it?
It says poster banned when a banned poster posts (man, that sounded like a nursery rhyme or something). So you won't just be oblivious to someone posting. And you can unban them just as easily.
But when would you actually keep someone banned? It could get strange in almost every kind of situation if you miss a post by someone. And if you always have to switch between banned and unbanned it sounds like it will get tedious and more annoying than just skimming through uninteresting posts.
I guess a cooler, but not necessarily any more usable approach would be to show the post as normal, but hide the whole thing with the poster blocked message, then provide a link to view the post anyway (without unblocking them).
Also, block is the correct word here, because you aren't really banning them, just blocking them.
Funny. Allegro.cc is one of the only boards I'm on where I wouldn't even consider blocking someone.
Also, block is the correct word here, because you aren't really banning them, just blocking them.
Yes but isn't "banning" someone a tad more satisfying?