Jump to content

A good idea from some forum members


Alanoll

Recommended Posts


  • 2 weeks later...

Actually, it's not that hard to add at all...

You can save a page locally and see for yourself

Along with any java script somewhere at the top of the page add this:

function CodeToggle(foo) {
if (document.getElementById(foo).style.display == "none") {
 document.getElementById(foo).style.display = "inline";
} else {document.getElementById(foo).style.display = "none"; }}

This is the part that actually shows/hide the CODE sections

Getting there. Now we only miss 2 things for each CODE section generated in php (not that hard to add, either)

1) Right after <b>CODE</b>, make it add:

<a href="javascript:CodeToggle('colexp1');">+-</a>

(with a space before). It will display "+-" as a hyperlink just besides where it says CODE in bold over the code block (this is the link that calls the javascript and that will make it toggle between expanded/collapsed)

2) Almost right after that (past the </td></tr><tr><td id="CODE"><!--ec1--> immediately following it), make it add <span id="colexp1"> and </span> after the post (just before <!--c2--></td></tr> )

Of course colexp1 (named like this as in collapse/expand #1), does have to increment for each code box (numbers only have to be unique, not consecutive or anything). A simple couter could take care of that (or any counter that goes up with each post on the page...)

Tada! 5 minutes and you got the functionnality. (ok, the +- hyperlink isn't the prettiest thing possible, but you can do whatever you want... perhaps make <b>CODE</b> itself the hyperlink - maybe even with no underlining... sky's the limit) It's also very conservative on bandwidth/server resources and will not prevent anything from working with non-CSS compliant browsers or browsers with no JS enabled. Not bad for a 5 minute tweak? :D

CSS+js rocks ;)

I'm not sure of who's the actual webmaster, or if someone can or can't do something like this. I could adapt a copy of the page myself too... I could also provide some screenshots if desired.

Link to comment
Share on other sites

I was going to post screenshots but I'd have to find a place to host them first... at 5:30am (no, not an early bird-quite the contrary). I wish I could just have attached them, they're 1.28kb and 422 byte huge (.png's work well for this). I might post them later today, it looks good enough for me anyways...

Link to comment
Share on other sites

Nevermind... I managed to find and sign up for some quality free hosting in less than 5 mintues, thanks to google :lol:

Here comes the screenshots:

expanded.png

collapsed.png

Hopefully I don't exceed my bandwidth limit hosting such huge files, that's almost 2 whole kilobytes per page load :rolleyes:

[note] I clipped the right... didn't show much anyways. Also note the l33t registry tweak (ok, nm)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...