Post by Peter on Oct 6, 2006 16:37:11 GMT -8
It is nearly done, I haven't added support for the code, quote, and table tags just yet. Also, glow and shadow are stripped out as they should be
Just need a few people to test it to see if there are any bugs.
To use it place it into your global footer, then goto to a thread, there will be a new button next to the quote button. When you click on the new button, it will enable that post to be included into the multi quoting list, once you have selected a few posts to quote, just click the reply button.
Note: This is a beta script, so it would be best to not use it on a live forum.
The code...
<script type="text/javascript">
<!--
/********************************************
*
* Multi Quote - Beta
*
* Created By Peter
* Copyright © 2005 - 2006 pixelDepth.net
* All rights reserved
*
*
**********************************************/
// Multi quote image URL
var multi_image = "http://www.pixeldepth.elixant.com/ProBoards/Multi_Quote/multi_quote.gif";
var multi = {
init: function(){
if(location.href.match(/=display/i)){
this.set_quote_button();
} else {
this.populate_msg();
}
window.name = "";
},
tn: function(t){
return document.createTextNode(t);
},
set_quote_button: function(){
var links = document.getElementsByTagName("a");
for(a = 0; a < links.length; a ++){
if(links.item(a).href.match(/quote=(\d+)/i) && links.item(a).firstChild && links.item(a).firstChild.nodeName.toLowerCase() == "img" && links.item(a).firstChild.alt == "[Quote]"){
var mImg = document.createElement("img");
mImg.src = multi_image;
mImg.border = "0";
mImg.id = links.item(a).href;
mImg.onclick = function(){
var href = this.id;
multi.set_opacity(this, href);
this.blur();
return false;
}
mImg.onmouseover = function(){
this.style.cursor = "pointer";
}
links.item(a).parentNode.insertBefore(mImg, links.item(a));
}
}
},
set_opacity: function(obj, mhref){
if(obj && mhref){
var op = 1;
if(obj.attributes.getNamedItem("opset")){
op = 1;
obj.removeAttribute("opset");
multi.remove_quote_info(mhref);
} else {
op = .3;
obj.setAttribute("opset", "true");
multi.collect_quote_info(mhref);
}
obj.style.opacity = op;
obj.style.filter = "alpha(opacity=" + (op * 100) + ")";
}
},
collect_quote_info: function(mhref){
if(mhref){
var board_id = mhref.match(/board=(\w+)/i)[1];
var topic_id = mhref.match(/thread=(\d+)/i)[1];
var post_id = mhref.match(/quote=(\d+)/i)[1];
// Get author and post content
var returned = multi.get_author_post(post_id);
var author = returned.author;
var post = this.convert_html(returned.post_content);
multi.store({
board: board_id,
topic: topic_id,
postid: post_id,
author: author,
post: post
}, false);
}
},
remove_quote_info: function(mhref){
var post_id = mhref.match(/quote=(\d+)/i)[1];
this.store(true, post_id);
},
get_author_post: function(pid){
var return_values = {
author: "unknown",
post_content: "No Post Content"
};
if(pid){
var cell = document.getElementsByTagName("td");
for(c = 0; c < cell.length; c ++){
if(cell.item(c).width == "20%" && cell.item(c).className.match(/windowbg/i) && cell.item(c).getElementsByTagName("a").item(0)){
if(cell.item(c).getElementsByTagName("a").item(0).name == pid){
var cLinks = cell.item(c).getElementsByTagName("a");
if(cLinks.item(1) && cLinks.item(1).href.match(/user=(\w+)/i)){
return_values.author = RegExp.$1;
} else {
return_values.author = cell.item(c).childNodes.item(1).data;
}
var pCell = cell.item(c).parentNode.cells.item(1);
return_values.post_content = pCell.innerHTML.split("<!-- google_ad_section_start -->")[1].split("<!-- google_ad_section_end -->")[0];
break;
}
}
}
}
return return_values;
},
escape_chars: function(str){
var str = (str)? str : "";
str = str.replace(/"/g, '\\"').replace(/\n/g, "").replace(/<br\s?\/?>/gi, "\\n");
return str;
},
store: function(m, r){
var data = (window.name)? eval("(" + window.name + ")") : false;
if(m){
var new_data = "{\n";
if(r){
delete data["p" + r];
}
if(data){
for(key in data){
new_data += '"' + key + '": [';
for(e = 0; e < data[key].length; e ++){
new_data += '"' + data[key][e].replace(/\n/g, "\\n").replace(/"/g, '\\"') + '"';
if(e < (data[key].length - 1)){
new_data += ", ";
}
}
new_data += "],\n";
}
}
if(!data["p" + m.postid]){
if(!r){
new_data += '"p' + m.postid + '": ["' + this.escape_chars(m.board) + '", "' + m.topic + '", "' + m.postid + '", "' + this.escape_chars(m.author) + '", "' + this.escape_chars(m.post) + '"]';
}
}
new_data += "\n}";
window.name = new_data;
}
},
convert_html: function(html){
var html = (html)? html : "";
var container = document.createElement("span");
var basic_patterns = /(<|&alt;)(\/?)(tt|b|i|u|s|sup|sub|pre|blockquote|center)(>|>)/ig;
container.innerHTML = html;
container.innerHTML = container.innerHTML.replace(basic_patterns, "[$2$3]");
while(container.getElementsByTagName("img").length > 0){
var i = container.getElementsByTagName("img").item(0);
if(i && i.alt.match(/image/i)){
container.replaceChild(this.tn("[img]" + i.src + "[/img]"), i);
} else if(i){
container.replaceChild(this.tn(i.alt), i);
}
}
while(container.getElementsByTagName("script").length > 0){
var s = container.getElementsByTagName("script").item(0);
if(s){
container.removeChild(s);
}
}
var patterns = [
[/<a href=\W?mailto:([^"]+)\W?.*?>(.*?)<\/a>/gim, "[email=$1]$1[/email]"],
[/<\/a>/gi, "[/url]"],
[/<a href=\W?(ftp:\/\/)?([^"]+)\W?.*?>/gim, "[url=$1$2]"],
[/<font color=\W?#?([0-9A-F]{6}|[a-z]+)\W?>(.*?)<\/font>/gim, "[color=$1]$2[/color]"],
[/<font face=\W?([\w\s]+)\W?>(.*?)<\/font>/gim, "[font=$1]$2[/font]"],
[/<font size=\W?([13-9]|\d{2,})\W?>(.*?)<\/font>/gim, "[size=$1]$2[/size]"],
[/<marquee>(.*?)<\/marquee>/gim, "[move]$1[/move]"],
[/<(\/)?font.*?>/gim, ""],
[/<div.*?(filter:.*?;)?width:.*?\W?>(.*?)<\/div>/gim, "$2"],
[/<hr.*?>/gim, "[hr]"],
[/<(\/)?ul>/gim, "[$1list]"],
[/<li>/gim, "[/li][li]"],
[/<\/li>/gim, ""]
];
for(p = 0; p < patterns.length; p ++){
while(container.innerHTML.match(patterns
[0])){
container.innerHTML = container.innerHTML.replace(patterns
[0], patterns
[1]);
}
}
return container.innerHTML;
},
populate_msg: function(){
if(location.href.match(/action=post&thread=\d+/i) && document.postForm && window.name.length > 1){
var data = eval("(" + window.name + ")");
var msg_data = "";
if(data){
for(key in data){
msg_data += '[quote';
msg_data += ' author=' + data[key][3];
msg_data += ' board=' + data[key][0];
msg_data += ' thread=' + data[key][1];
msg_data += ' post=' + data[key][2];
msg_data += ']' + data[key][4] + '
}
document.postForm.message.value = msg_data;
}
}
}
}
multi.init();
//-->
</script>[/size]
Comments and suggestions welcome