Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Forum [code] sections: green comments and scrollbars


  • Please log in to reply
180 replies to this topic
Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
(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.

xXJa50nXx
  • Members
  • 32 posts
  • Last active: Jul 19 2007 03:29 AM
  • Joined: 19 Oct 2006
Take that up with the people at <!-- m -->http://www.phpbb.com/<!-- m -->
That does sound like a good idea though

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
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.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
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.
Posted Image

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
I just saw it on an html site (<!-- w -->www.w3schools.com/forums<!-- w -->, 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.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
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...

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

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):
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.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

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...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

I know you're an opera fan

So, the obvious question is :), 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 ?
Posted Image

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

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.

It works fine on both browsers

Not for me :(

But as I feared, printouts are truncated.

That's shouldn't be a problem, javascript can add print-media css overrides.

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.

I didn't worked on a GM script, but I can use your to see if I can get used to it...

(deja vu :p)

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.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

Opera is arguably the most standard compliant browser

Maybe I fuked up. I will check at home also.
Posted Image

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

What, where? FF2 and IE7 reported no errors or warnings.

I first tested it as a bookmarklet:

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();


It works fine on both browsers

Not for me :(

Have we the same FF2? ;-)

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

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

d.style.overflow='auto';}

You must've changed it, I don't see the event registration statement that's in my script.

Not for me :(Have we the same FF2? ;-)

I'm using Mozilla/5.0 en-GB Gecko/20061010 Firefox/2.0. Maybe the French version parses differently?

It has a side-effect of growing little code blocks!

No it doesn't :? Can you explain, perhaps with a screenshot?

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).

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

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

It has a side-effect of growing little code blocks!

No it doesn't :? Can you explain, perhaps with a screenshot?

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.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")