Allegro.cc - Online Community

Allegro.cc Forums » Allegro.cc Comments » Auto Quote / Quote Management

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Auto Quote / Quote Management
BAF
Member #2,981
December 2002
avatar

This is still pretty beta, but it should work. It's not tested in anything other than firefox at the moment, but should be pretty standard.

This is a custom user JS that adds a quote button to every post (next to the user profile button). You can toggle quote for a particular post on or off, and when you click in a post box, it will generate quote tags for all the posts. It also filters out useless stuff in quotes, such as other quotes, media, etc. I've added all I've come across as far as HTML->mockup conversion, but there's always a chance I've missed something. If you find anything I've missed or that it doesn't handle right let me know.

Auto quoting does not work with posts from before the new mockup code was set up. - It isn't as straightforward to get the post content from older posts because the HTML is slightly different, and it's not worth the time to code support for it when it will never be used after the current threads have expired.

Installation is easy, go here and paste

document.write("<script type=\"text/javascript\" src=\"http://misc.baf.cc/accjs/quote.js\"></script>");

into the Custom JS box.

Obligatory screenshot:

{"name":"quotess.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/0\/20a1e9437a53b4bad3c3c9bc88eaabb4.png","w":1167,"h":732,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/0\/20a1e9437a53b4bad3c3c9bc88eaabb4"}quotess.png

weapon_S
Member #7,859
October 2006
avatar

BAF said:

<P>This is still pretty beta, but it should work. It's not tested in anything other than firefox at the moment, but should be pretty standard.</P><P>This is a custom user JS that adds a quote button to every post (next to the user profile button). You can toggle quote for a particular post on or off, and when you click in a post box, it will generate quote tags for all the posts. It also filters out useless stuff in quotes, such as other quotes, media, etc. I've added all I've come across as far as HTML->mockup conversion, but there's always a chance I've missed something. If you find anything I've missed or that it doesn't handle right let me know.</P><P><B>Auto quoting does not work with posts from before the new mockup code was set up.</B> - It isn't as straightforward to get the post content from older posts because the HTML is slightly different, and it's not worth the time to code support for it when it will never be used after the current threads have expired.</P><P>Installation is easy, go <A href="http://www.allegro.cc/cc/theme-css">here</A> and paste </P><PRE>document.write("<script type=\"text/javascript\" src=\"<A href='http://misc.baf.cc/accjs/quote.js\"></script>"'>http://misc.baf.cc/accjs/quote.js\"></script>"</A>);</PRE><P> into the Custom JS box.</P><P>Obligatory screenshot:</P><P><SPAN class="remote-thumbnail"><SPAN class="json">{"name":"quotess.png","src":"/images/rcache/2/0/20a1e9437a53b4bad3c3c9bc88eaabb4.png","w":1167,"h":732,"tn":"/images/rcache/2/0/20a1e9437a53b4bad3c3c9bc88eaabb4"}</SPAN><IMG src="/images/rcache/2/0/20a1e9437a53b4bad3c3c9bc88eaabb4-240.jpg" alt="quotess.png"></SPAN>
</P>

weapon_S said:

<P>I'm going to try it, here!
</P>

So it warns and then it clears the message to bring in the quotes from posts you have selected... It doesn't clip (<p>) tags, though... Opera 9.64

Neil Walker
Member #210
April 2000
avatar

It's a bit silly at the minute. If you forget to untick the box, when you go to other threads you end up with massive bits of text in the box, and no easy way to get rid of them.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

bamccaig
Member #7,536
July 2006
avatar

BAF said:

It also filters out useless stuff in quotes, such as other quotes, media, etc.

I actually wish it didn't do this. It's useful to quote these things because it allows people to know what you're responding to. If the user doesn't want these things in the post, he/she can remove them him/herself (odds are he doesn't want to quote the entire post anyway).

BAF said:

<span class="remote-thumbnail">

This was spit out by your auto-quote code. :P Something tells me it wasn't supposed to be. Are we free to reuse your code/icon? I don't really like the idea of using the code directly from your site and there are some improvements I'd like to try to make. For example, the inclusion of all markup, the exclusion of random <span>s. :P Also, I don't like how the only option is to overwrite your existing post with a quote. It would be better if you appended to the existing post when editing, I think. I realize it's not finalized, but I'm still curious.

** EDIT **

It could also use a clear/erase button somewhere. When does it empty itself? :-/

BAF
Member #2,981
December 2002
avatar

weapon_S said:

So it warns and then it clears the message to bring in the quotes from posts you have selected... It doesn't clip (<p>) tags, though... Opera 9.64

It should, that's really wacky. The <p> tags you quoted were uppercase for some reason. Anyway, I did a slight tweak that should fix that.

It's a bit silly at the minute. If you forget to untick the box, when you go to other threads you end up with massive bits of text in the box, and no easy way to get rid of them.

Yeah, I'm going to add a clear button someplace. I use the mini header bar instead of the full forum header, so that's the preferred place for me.

bamccaig said:

I actually wish it didn't do this. It's useful to quote these things because it allows people to know what you're responding to. If the user doesn't want these things in the post, he/she can remove them him/herself (odds are he doesn't want to quote the entire post anyway).

This was spit out by your auto-quote code. :P Something tells me it wasn't supposed to be. Are we free to reuse your code/icon? I don't really like the idea of using the code directly from your site and there are some improvements I'd like to try to make. For example, the inclusion of all markup, the exclusion of random <span>s. :P Also, I don't like how the only option is to overwrite your existing post with a quote. It would be better if you appended to the existing post when editing, I think. I realize it's not finalized, but I'm still curious.

** EDIT **

It could also use a clear/erase button somewhere. When does it empty itself? :-/

Why is it useful to quote stupid crap like other quotes, media, etc? If the context is that ambiguous, they can click to go see it. I could make it copy quotes up to 1 layer deep I suppose.

As far as the span tag, that's an issue with image tags it appears. I'll have to make it support images better. isn't excluded, spans are snipped out because you can't post them anyway. I can't really stop you from stealing the code, and the icon is probably copyrighted (I just stole it from a google image search), but I would ask that if you release the edited copy of it that you mention that and not take full credit.

I'm working on a new version that will only copy selected portions of the post (if you select a portion before hitting the button), appending wouldn't be hard to do though it would require figuring out what quotes are already included. How often do you type out a whole post then go back to add quotes anyway? :P

As far as when it empties itself, it clears the accumulated list any time you submit a new post/edit post form.

bamccaig
Member #7,536
July 2006
avatar

It seems that including your code disables the mouseover profile-preview view-profile.png feature. Maybe that is by design/personal preference, but it's something I'm gonna want back.

BAF said:

Why is it useful to quote stupid crap like other quotes, media, etc? If the context is that ambiguous, they can click to go see it. I could make it copy quotes up to 1 layer deep I suppose.

If the stupid crap like other quotes, media, etc., is relevant to your post then I think it can be relevant to quote. Not every time, but particularly when it's far away or one among many.

BAF said:

I'm working on a new version that will only copy selected portions of the post (if you select a portion before hitting the button),...

I didn't even know that was doable with JavaScript. :o

BAF said:

...appending wouldn't be hard to do though it would require figuring out what quotes are already included.

It might work to remove them from storage after adding them to the post. Or, I was thinking it would be extra snappy if you just added like a toolbox of quotes beside or below the textarea somewhere that users could select from. Just simple <div>s or something that could be clicked or dragged onto the post. Give them a delete button [X] on their right side and let users manage them. This would come in extra handy with the subquote feature because often people want to quote many sections. You could add similar, though minimized, controls beside the quoted posts to manage them (i.e., delete them) from the thread as well. These are just some ideas... One would have to see how they actually semantically work in practice... :-/

???

BAF
Member #2,981
December 2002
avatar

ML did something that broke the JS, at least for my browser, so nothing works for me at the moment (something crashes in the onLoad affecting userSettings or something). - Fixed

I did nothing that would affect the profile previewing on hover.

Most of the time if there was media,etc relevant to the quote (not necessarily sub-quotes, though), anyone reading your reply would have already seen said media if it was useful.

Your toolbox idea actually sounds pretty neat, and it's one I hadn't thought of. That could go along with the selection of what part of the post to quote as well. Hmm, I'll have to play around with that, thanks!

[edit]
Hmm, it does appear on-hover preview is broken. That is strange, I don't touch the profile button at all. I'll have to take a deeper look.

[edit2]
It doesn't work for me whether or not I include my the custom JS.

Matthew Leverton
Supreme Loser
January 1999
avatar

It sounds like some people who use this will end up getting quoting privileges revoked. Overzealous quoting is the reason why this isn't supported.

Quoting is meant to set the context or to make a direct response. Nested quotes are bad enough, but including all the original content? That's ridiculous. If you find yourself quoting in every post or including lots of little quotes, then you are probably missing the big picture and focusing on too many anal details.

Dustin Dettmer
Member #3,935
October 2003
avatar

{"name":"598091","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/a\/8a9893aff7b8810bbe585acc298613a8.png","w":1046,"h":343,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/a\/8a9893aff7b8810bbe585acc298613a8"}598091

Result:

BAF said:

As far as the span tag, that's an issue with image tags it appears. I'll have to make it support images better. isn't excluded, spans are snipped out because you can't post them anyway. I can't really stop you from stealing the code, and the icon is probably copyrighted (I just stole it from a google image search), but I would ask that if you release the edited copy of it that you mention that and not take full credit.

BAF said:

I'm working on a new version that will only copy selected portions of the post (if you select a portion before hitting the button), appending wouldn't be hard to do though it would require figuring out what quotes are already included. How often do you type out a whole post then go back to add quotes anyway? <img name="BAF" src="/forums/smileys/tongue.gif">

Heres the code I wrote. Dump it in firebug after everything is loaded to test it.

#SelectExpand
1function quote_onClick(post) 2{ 3 var cookies = new CookieJar({path: '/'}); 4 var quotedPosts = cookies.get("posts"); 5 6 if(quotedPosts == null) 7 quotedPosts = new Array(); 8 9 if(quotedPosts.indexOf(post) != -1) 10 { 11 // deselect post 12 quotedPosts.splice(quotedPosts.indexOf(post), 1); 13 cookies.remove(post); 14 15 $$('a#' + post + '-button img')[0].src = quote_imageUnsel; 16 var postContent = $$('table#' + post + ' td.content div.mockup')[0]; 17 18 if(postContent && postContent.childNodes) { 19 20 function cb(n){ 21 22 for(var i = 0; i < n.length; i++) { 23 24 if(n[i].style) 25 n[i].style.backgroundColor = ''; 26 27 n[i].quoteMe = false; 28 n[i].onmouseover = null; 29 n[i].onmouseout = null; 30 n[i].onmouseup = null; 31 32 if(n[i].childNodes) 33 arguments.callee(n[i].childNodes); 34 } 35 36 } 37 38 cb(postContent.childNodes); 39 } 40 } 41 else 42 { 43 // select post 44 quotedPosts.push(post); 45 46 var name = $$('table#' + post + ' div.originator')[0].innerHTML; 47 var source = $$('table#' + post + ' div.header span.posted-on a')[0].href; 48 var postContent = $$('table#' + post + ' td.content div.mockup')[0]; 49 50 if(postContent == null) 51 { 52 alert("Auto-quoting does not work with older pre-mockupv2 posts."); 53 return; 54 } 55 56 function f(n){ 57 58 for(var i = 0; i < n.length; i++) { 59 60 n[i].post = post; 61 n[i].source = source; 62 n[i].name = name; 63 n[i].onmouseover = new Function("if(this.quoteMe)return;" 64 + "this.style.backgroundColor='#0F5'"); 65 n[i].onmouseout = new Function("if(this.quoteMe)return;" 66 + "this.style.backgroundColor= ''"); 67 n[i].onclick = new Function("if(this.quoteMe=!this.quoteMe)" 68 + " {this.style.backgroundColor=''; " 69 + "addHtmlToQuote(this.post, this.name, this.source, this.innerHTML);" 70 + " this.style.backgroundColor='#F50';} " 71 + " else {this.style.backgroundColor=''; " 72 + "removeHtmlFromQuote(this.post, this.name, this.source, this.innerHTML);} " 73 + "return false"); 74 75 if(n[i].childNodes) 76 arguments.callee(n[i].childNodes); 77 } 78 79 } 80 81 f(postContent.childNodes); 82 83 $$('a#' + post + '-button img')[0].src = quote_imageSel; 84 } 85 86 cookies.put("posts", quotedPosts); 87 quotesChanged = true; 88} 89 90function addHtmlToQuote(post, name, source, html) 91{ 92 var cookies = new CookieJar({path: '/'}); 93 94 var quote = "\n<quote name=\"" + name + "\" src=\"" + source + "\">\n" + html + "\n</quote>\n"; 95 96 var app = cookies.get(post); 97 98 if(app) 99 quote = app + quote; 100 101 if(!cookies.put(post, quote) || cookies.get(post) == null) 102 { 103 cookies.remove(post); 104 quote = "<quote name=\"" + name + "\" src=\"" + source + "\">\n[Post Truncated]\n</quote>"; 105 106 if(!cookies.put(post, quote) || cookies.get(post) == null) 107 { 108 alert("Error storing quote!"); 109 cookies.remove(post); 110 return; 111 } 112 else 113 alert("Post was too long to auto-quote, so it has been truncated."); 114 } 115} 116 117function removeHtmlFromQuote(post, name, source, html) 118{ 119 var cookies = new CookieJar({path: '/'}); 120 121 var quote = "\n<quote name=\"" + name + "\" src=\"" + source + "\">\n" + html + "\n</quote>\n"; 122 123 var app = cookies.get(post); 124 125 if(!app) 126 return; 127 128 var i; 129 130 if(app == quote) 131 quote = null; 132 else if((i = app.indexOf(quote)) != -1) 133 quote = app.substr(0, i) + app.substr(i - -quote.length); 134 135 if(!cookies.put(post, quote) || cookies.get(post) == null) 136 { 137 cookies.remove(post); 138 139 if(!cookies.put(post, quote) || cookies.get(post) == null) 140 { 141 alert("Error storing quote!"); 142 cookies.remove(post); 143 return; 144 } 145 } 146}

Thomas Fjellstrom
Member #476
June 2000
avatar

It sounds like some people who use this will end up getting quoting privileges revoked

I'll only use it once it supports grabbing the current selection...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Dustin Dettmer
Member #3,935
October 2003
avatar

I'll only use it once it supports grabbing the current selection...

Here is the code I'm using. You can paste this into your custom js and it will support it.
Download Partial Auto-Quoter Code

Thomas Fjellstrom
Member #476
June 2000
avatar

Here is the code I'm using. You can paste this into your custom js and it will support it.<BR><A href="http://www.allegro.cc/files/attachment/598092" target="_blank" name="Dustin Dettmer">Download Partial Auto-Quoter Code</A><SPAN class="url"> [www.allegro.cc]</SPAN>

I'd prefer it actually take the current selection, not let you click dom nodes.

edit:
also it seems a little broken, and it probably shouldn't add a quote button to my own post ;D

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CGamesPlay
Member #2,559
July 2002
avatar

I also find a few members' over-use of quoting to be annoying.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Dustin Dettmer
Member #3,935
October 2003
avatar

Here

doc.add_onLoad(function()
{
  var ds = document.getElementsByTagName('div');

  for(var i = 0; i < ds.length; i++)
    if(ds[i].className && ds[i].className == "quote") {
      ds[i].style.display = 'none';
      var a = ds[i].parentNode.insertBefore(document.createElement('a'), ds[i]);

      a.href = '#';
      a.onclick = new Function("this.nextSibling.style.display=((this.f=!this.f)?'':'none')");
      a.appendChild(document.createTextNode('Toggle Quote'));
    }
});

{"name":"598095","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/1\/e19179a16ad09dcf66b26944a34640c1.png","w":369,"h":310,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/1\/e19179a16ad09dcf66b26944a34640c1"}598095

BAF
Member #2,981
December 2002
avatar

Looks interesting, I was messing around with it but didn't get anything useful. As far as quoting your own post, sometimes it is useful, it's such a tiny detail it doesn't matter much.

Dustin Dettmer
Member #3,935
October 2003
avatar

Are you going to incorporate my changes?

BAF
Member #2,981
December 2002
avatar

Yeah, I probably won't get to it for a little while here though, i'm working on eating then I may or may not go to bed (feeling pretty crappy right now, all congested and sore throat and stuff, can't really focus on much atm).

Neil Walker
Member #210
April 2000
avatar

I don't know if I'm repeating what Thomas has said, having just speed read this whole thread to try and avoid repeating myself, but what would make this the best quoting system ever in the existance of quoting systems on forums is if when you clicked on the icon it quoted what you had currently selected rather than the entire quote.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

BAF
Member #2,981
December 2002
avatar

Yeah, selection is something I'm adding. DDustin wrote code for it which I am going to incorporate.

A quick question for DDustin (I've only glanced at your JS, didn't really read it in detail yet because I haven't been feeling human until just a few hours ago) - when you select just a portion, does it still use the quote button added to each post? The screenshot you posted didn't show a quote button on the post, so I wasn't sure. And if so, does it verify you selected text from that post when you hit the button, to prevent the source argument from being wrong?

Thanks

Thomas Fjellstrom
Member #476
June 2000
avatar

You're not using his code that just selects a single <p> node are you? I don't want anything like that, and I bet most people don't either. We'd rather select a range of text with the mouse. thats what I meant by a "selection".

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

BAF
Member #2,981
December 2002
avatar

Oh, his code only selects a node? I have code that will pull the selected text just fine, but I wanted to make sure it belonged to the post in question before assigning it that person/link. I suppose I could always add a quote button in the mini header toolbar for quoting selection, and it would let ML's code find the appropriate post to link to/etc.

bamccaig
Member #7,536
July 2006
avatar

BAF said:

...and it would let ML's code find the appropriate post to link to/etc.

If I'm going to be using JavaScript to auto-quote I expect it to be 100% correct, whereas Matthew has been straight in saying that his "squirrels" are best guess and not intended to be 100% correct. If I have to check that the quoting is correct I might as well just do it myself the first time.

BAF
Member #2,981
December 2002
avatar

So you want the more complex javascript, which explains why no code fully fitting those requirements has been posted yet. :P

Neil Walker
Member #210
April 2000
avatar

Is your site usually up and running and quite fast? I've noticed my browser is always going to your site whenever I view a thread now. Or is there a way to get it to store the script locally?

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

bamccaig
Member #7,536
July 2006
avatar

Or is there a way to get it to store the script locally?

It should be cached by your browser, but I think that will depend on the headers his server sends. You could just go directly to his URL, copy the source into your custom JS, and let Allegro.cc handle the caching instead; but then you'll have to manually update when BAF makes changes.

 1   2 


Go to: