AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Forum [code] sections: green comments and scrollbars
Goto page 1, 2, 3 ... 15, 16, 17  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 304
Location: US

PostPosted: Thu Nov 23, 2006 5:51 pm    Post subject: Forum [code] sections: green comments and scrollbars Reply with quote

(Note from moderator: This topic's original subject line was [codebox] command)

I've seen this used in an HTML forum website, and it really helps when people use huge codes and take up a mile and a half of space when posting a code. The little BBcode thing should have [codebox] in it, which means you can scroll down in that little window of code. It only takes up about 3 inches before you start needing to scroll down in the codebox.
Back to top
View user's profile Send private message
xXJa50nXx



Joined: 19 Oct 2006
Posts: 32
Location: mo

PostPosted: Fri Nov 24, 2006 3:21 am    Post subject: Reply with quote

Take that up with the people at http://www.phpbb.com/
That does sound like a good idea though
Back to top
View user's profile Send private message Send e-mail
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Fri Nov 24, 2006 9:53 am    Post subject: Reply with quote

Already discussed, I don't like this idea, it make posts unprintable, hard to read, etc.
Perhaps more useful would be a link to the next message, and / or a button to fold (hide) a code section and / or a whole message. Very easy to do with a bit of JavaScript, and really useful.
Hey, I could try to add these with GreaseMonkey, at least as proof of concept.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3624
Location: Belgrade

PostPosted: Fri Nov 24, 2006 10:13 am    Post subject: Reply with quote

I don't agree with PhiLho.

I alrady suggested such feature. THe code larger then half a screen should be boxed. It makes posts printable if some button is there to expand all boxes (also via javascript), The code will be easier to read, etc...

This is good idea, and if it can be done in GraseMonkey, so PhiLho, I can't wait to see results.
_________________
Back to top
View user's profile Send private message MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Nov 25, 2006 3:21 am    Post subject: Reply with quote

I like the idea of a scrollable text area, but only as a new/additional option (not to replace code sections). This is mostly because I've heard that textareas are very limited, such as having no ability to set a custom tab stop/width, and perhaps no ability to wrap text.

As for the JavaScript ideas mentioned, I don't know enough about JavaScript to comment; but I'd like to see a demo. One of the main issues tends to be browser compatibilty, such as getting it to work in reasonably recent versions of Firefox, Opera, and MSIE all at the same time.

Another issue is time: I don't wish to spend much time adding new features to the forum over the next few months because that would distract from other planned features such as v2. So if you have a great idea, you might want to postpone it until phpBB v3 comes out (it's currently in beta) and/or do as much up-front work as you can so that it wouldn't take me long to apply it.

Thanks.
Back to top
View user's profile Send private message Send e-mail
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 304
Location: US

PostPosted: Sun Dec 03, 2006 5:48 pm    Post subject: Reply with quote

I just saw it on an html site (www.w3schools.com/forums, I think that's the URL, maybe not) and I tried manualy just trying to do [codebox] and that didn't work. Just a way for people with really big scripts to let people try to save a lot of space.
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Sun Dec 03, 2006 9:33 pm    Post subject: Reply with quote

I'd prefer if this wasn't implemented. I find this annoying on other sites. I already have to scroll down the page. I don't want to have to scroll down the page and also have to scroll code sections too. The other issue that usually happens is when scrolling down the page using a mouse wheel. The page stops scrolling when it gets to the code section and the code section starts scrolling instead if the cursor ends up over the code section. This gets annoying very quickly. Especially when multiple code sections appear on the same page...
Back to top
View user's profile Send private message Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5048
Location: imaginationland

PostPosted: Mon Dec 04, 2006 2:44 pm    Post subject: Reply with quote

majkinetor wrote:
This is good idea, and if it can be done in GraseMonkey, so PhiLho, I can't wait to see results.

Here's a standard non-firefox-exclusive javascript (I know you're an opera fan):
Code:
function codeblock() {
   var cont = 'td', cls = 'code', i = 0
      , e = document.getElementsByTagName('body')[0].getElementsByTagName(cont);
   this.set = function(n) {
      if (!/<div/i.test(e[n].innerHTML)) e[n].innerHTML = '<div>' + e[n].innerHTML + '</div>';
      var d = e[n].getElementsByTagName('div')[0], h = d.style.height, s = '12.5em';
      d.style.height = h == s ? '100%' : s, d.style.overflow = 'auto';
      d.ondblclick = /* why cant i refer to this anonymous function lol? */codeblock; }
   for(i in e) if(e[i].className == cls) set(i);
}
window.addEventListener ? window.addEventListener('load', codeblock, false) : window.attachEvent('onload', codeblock);

Double click any code section to expand/collapse them (only works in IE atm.). It can be extended to support cookies, etc. like the comments js. The results are brilliant in pages with a lot of code like the BF2 thread.
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Dec 04, 2006 3:34 pm    Post subject: Reply with quote

corrupt wrote:
I don't want to have to scroll down the page and also have to scroll code sections too. The other issue that usually happens is when scrolling down the page using a mouse wheel. The page stops scrolling when it gets to the code section and the code section starts scrolling instead if the cursor ends up over the code section.
Of course, you can keep the mouse cursor on left or right, so it won't hover over code sections, but we don't always remember that...

Titan, I tested your script on FF2 and IE6. I had to add a semi-colon at the end of the anonymous function definition (both where complaining).
It works fine on both browsers, including the double-click to extend/collapse.
But as I feared, printouts are truncated. It can be a good or bad thing, depending on intent of user. Perhaps the style should be restricted to display media only.
With this good idea of allow to expand, it became usable: one defaults to quickly scroll through the page, and to inspect a long code block conveniently, just double-click it (or add a button or something).
I forgot this topic, so I didn't worked on a GM script, but I can use your to see if I can get used to it...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3624
Location: Belgrade

PostPosted: Mon Dec 04, 2006 3:45 pm    Post subject: Reply with quote

Quote:
I know you're an opera fan

So, the obvious question is Smile, can you make it to work with Opera.
It doesn't now. I started both with and without .user in scritps file name (witch, as we know, signfy grasemonkey notation)


BTW, does Explorer 7 has integrated user js or no ?
_________________
Back to top
View user's profile Send private message MSN Messenger
Titan



Joined: 11 Aug 2004
Posts: 5048
Location: imaginationland

PostPosted: Mon Dec 04, 2006 3:53 pm    Post subject: Reply with quote

PhiLho wrote:
Titan, I tested your script on FF2 and IE6. I had to add a semi-colon at the end of the anonymous function definition (both where complaining).
What, where? FF2 and IE7 reported no errors or warnings.

PhiLho wrote:
It works fine on both browsers
Not for me Sad

PhiLho wrote:
But as I feared, printouts are truncated.
That's shouldn't be a problem, javascript can add print-media css overrides.

PhiLho wrote:
With this good idea of allow to expand, it became usable
Yep, that was the idea. I was going to add a copy to clipboard feature and a whole bunch of other DHTML stuff but I wasn't sure Chris would even implement it so I left it at that.

PhiLho wrote:
I didn't worked on a GM script, but I can use your to see if I can get used to it...
(deja vu Razz)

majkinetor wrote:
can you make it to work with Opera
Opera is arguably the most standard compliant browser, I'm surprised it doesn't work. When I pick up the courage to install it I'll do some further testing.
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3624
Location: Belgrade

PostPosted: Mon Dec 04, 2006 4:05 pm    Post subject: Reply with quote

Quote:
Opera is arguably the most standard compliant browser

Maybe I fuked up. I will check at home also.
_________________
Back to top
View user's profile Send private message MSN Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Dec 04, 2006 4:17 pm    Post subject: Reply with quote

Titan wrote:
What, where? FF2 and IE7 reported no errors or warnings.
I first tested it as a bookmarklet:
Quote:
Erreur : missing ; before statement
Fichier source : javascript:function codeblock(){var cont='td',cls='code',i=0,e=document.getElementsByTagName('body')[0].getElementsByTagName(cont); this.set=function(n){if(!/<div/i.test(e[n].innerHTML))e[n].innerHTML='<div>'+e[n].innerHTML+'</div>';var d=e[n].getElementsByTagName('div')[0],h=d.style.height,s='12.5em';d.style.height=h==s?'100%':s,d.style.overflow='auto';} for(i in e)if(e[i].className==cls)set(i);} codeblock();
Ligne : 1, Colonne : 91
Code source :
iv')[0],h=d.style.height,s='12.5em';d.style.height=h==s?'100%':s,d.style.overflow='auto';} for(i in e)if(e[i].className==cls)set(i);} codeblock();


Quote:
PhiLho wrote:
It works fine on both browsers
Not for me Sad
Have we the same FF2? Wink

It has a side-effect of growing little code blocks! Annoying. Can we get the actual size of the div before changing it?
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on Mon Dec 04, 2006 4:37 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5048
Location: imaginationland

PostPosted: Mon Dec 04, 2006 4:27 pm    Post subject: Reply with quote

PhiLho wrote:
d.style.overflow='auto';}
You must've changed it, I don't see the event registration statement that's in my script.

PhiLho wrote:
Not for me :(Have we the same FF2? Wink
I'm using Mozilla/5.0 en-GB Gecko/20061010 Firefox/2.0. Maybe the French version parses differently?

PhiLho wrote:
It has a side-effect of growing little code blocks!
No it doesn't Confused Can you explain, perhaps with a screenshot?

PhiLho wrote:
Can we get the actual size of the div before changing it?
Yes it's already there on line 6: var d = e[n].getElementsByTagName('div')[0], h = d.style.height ...

Also, the neat thing about wrapping in divs is that text can be wrapped... in all browsers! I'll add this style in the next version (if Chris has any interest in it).
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Dec 04, 2006 4:50 pm    Post subject: Reply with quote

Titan wrote:
I'm using Mozilla/5.0 en-GB Gecko/20061010 Firefox/2.0. Maybe the French version parses differently?
I doubt it!
Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0

Quote:
PhiLho wrote:
It has a side-effect of growing little code blocks!
No it doesn't Confused Can you explain, perhaps with a screenshot?

PhiLho wrote:
Can we get the actual size of the div before changing it?
Yes it's already there on line 6: var d = e[n].getElementsByTagName('div')[0], h = d.style.height ...
On my tests, h is undefined here. Perhaps that explains the grown little boxes.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page 1, 2, 3 ... 15, 16, 17  Next
Page 1 of 17

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group