Marcos Placona Blog

Programming, technology and the taming of the web.

Month: June 2008 (page 1 of 2)

Javascript saves the day again.

Reading time: 4 – 6 minutes

As some of you know, one of my hobbies is electronics with micro controller usage, and I happen to use an electronics forum a lot when I’m losing hair excessively.

One of the functionalities I really miss on this forum (vBulletin), was an option to be able to see the code posted in a bigger version, not by magnifying it, but upsizing the code box, so I didn’t have too much scroll.

I then remembered that GreaseMonkey can be an excellent tool for this cases. I could just talk to the forum admin to see if they could change it, but as not everybody would like the change, I decided to write my own custom script and integrate it into greasemonkey.

Everything seemed to be pretty perfect, except for the fact that greasemonkey doesn’t really like to call functions directly, but needs to have them added with addEventListener().

Shouldn’t be a problem (besided being my first time using this function with JS), except for the fact that addEventListener() is not as straight forward to work as it seems to be.

If you have it on a loop like this:

for (var i = 0; i < 5; i++) {


Youd probably be tempeted to add your code like this:

myLink.addEventListener("click", function(e) {toggle(i);},true);

In case you want to pass the index as an argument to the UDF toggle()

The funny thing is that once it’s completely rendered, you will always have the value “6” being passed on your link.

This really gave me a headache, as I couldn’t understand why in hell the value “6” was passed. In fact, it happens exactly because your code is all rendered, and you don’t have the values from the loop to be working with.

The workaround for this is to use the object id instead of the loop index.

In this case, my links are being created dynamically, and having an id assigned with each iteration of the loop. So by using it like this:

myLink.addEventListener("click", function(e) {toggle(;},true);

I get exactly the value wanted.

Now, a bit of javascript code to show I’ve created this script:

// Bigger Code
// version 0.2 BETA!
// 27/06/2008
// Copyright (c) 2008, Marcos Placona
// Released under the GPL license
// Changelog:
// v0.2
// Added the option to toggle the code and display it if wanted (default no)
// Fixed some bugs with crap greasemonkey JS integration
// Added custom height to boxes
// Added resize option just when necessary
// --------------------------------------------------------------------
// ==UserScript==
// @name          Bigger_Code
// @namespace
// @description   Resize code box
// @include*
// ==/UserScript==
var all, element, counter;
var box = document.getElementsByTagName('pre');
counter = 0;
all = document.getElementsByTagName('*');
for (var i = 0; i < all.length; i++) {
    element = all[i];
    if (element.nodeName == 'DIV') {
            if(element.getAttribute('style')=='margin-bottom: 2px;'){
				if(element.innerHTML == "Code:"){
                element.setAttribute('id', 'box_'+counter);
					if(box[counter].scrollHeight > 178){
						document.getElementById('box_'+counter).innerHTML = 'Code: [toggle]'
						myLinkAddress = 'link_'+counter;
						myLink = document.getElementById(myLinkAddress);
						myLink.addEventListener("click", function(e) {toggle(;},true);
function toggle(box_id){
    theId = box_id.split("_");
    box_id = theId[1];
    height_box = box[box_id].scrollHeight
    part = box[box_id].getAttribute('style').split(';');
    part = part[5].replace("height: ",'')
    part = part.replace("px",'')
        //Set it as default
		box[box_id].setAttribute('style','border: 1px inset;margin:0px;padding: 6px;overflow:auto;width:640px;height:178px;text-align: left;')
		//Set as custom
        if(part >= 178){
			box[box_id].setAttribute('style','border: 1px inset;margin:0px;padding: 6px;overflow:auto;width:640px;height:' + height_box +'px;text-align: left;')

This forum has some very specific configurations and lots of hard coding, so I had to keep them in order to keep the content’s integrity.

I know this may not be of everybody’s interest, but I wrote this one more as a note to self in case I ever need to use addEventListener() again.

I’m now looking into replacing some of the code with some regular expressions to shorten it.


Reading time: 1 – 2 minutes

Yes! It’ll happen again. Following the successful conference that happened in 2006, Nick Tong, Russ Michaels and Richard Cooper has decided to do it again.

This year they are packed with some great speakers, and some of the hottest topics ever.

Just a small compilation of some of the speakers they will have this year:

  1. Aral Balkan
  2. Peter Bell
  3. Sean Corfield
  4. Mark Drew
  5. Hal Helms
  6. Ray Camden (can’t make it)

and much more…

And after all that, you still get to hit the beach, as the conference this year will be happening in Brighton.

So what else do you need to go to cfdevcon’s website and buy your early bird ticket (only till 30th of June)?

On my old post about CFDevcon 2006 you can a bit about what were my impressions about the 2006 conference, and make sure that you’ll most definitely see me there again

More to come….

Cool posts with CFUnited 08 topics

Reading time: < 1 minute

Ken Auenson has been working hard on a nice set of posts about CFUnited 2008. He’s giving away some great information about all the topics.
Check here

What are you doing?

Reading time: 1 – 2 minutes

Well, I decided to start this topic after realizing that us, Adobe / CF developers kinda know each other from other web blogs, twitter, messenger etc, but sometimes don’t know much more than that.

So for the three many people who read my blog, I decided to talk a little bit about me, and would like to encourage all of you (thee guys) to do the same, and link to this post, so I can keep track.

It shouldn’t be like the “about me” section, but more of a “about me now”.
So let’s start:

Current work:
EU Commission;

Team size:
4 here (plus the hundred others in the other buildings)

Main Technologies used:
ColdFusion MX 7 and Oracle;

Mainly internal apps involving a massive CMS, resource management, Action Management and Business Objects;

Current Studies
JQuery, BO

Next Studies
Maybe AIR…

Current Hobbies
Electronics as usual

What will happen next?
Will probably return to UK (as soon as I find a cool job)

ColdFusion 9 (AKA Centaur) to have impressive new features

Reading time: 1 – 2 minutes

I’ve been following closely all the comments and blog posts from the guys at CFUnited 08.
I’ve managed to compile a list with all the new functionalities announced yesterday 18/06/08 for the ColdFusion 9 (codename Centaur).
This is still work in progress, and I’m still scavenging into all the blogs and twitter posts to amend my list, but here are the key points I’ve go so far.
ColdFusion 9 will:

  • have hibernate running native;
  • have implicit get/set methods in CFC’s;
  • have new LOCAL scope in functions;
  • give you the possibility to create CFC’s in cfscript (more on that later);
  • have a 100% free enterprise edition for students and educators;

So far, I’ve been really impressed by all the points here, as some of them are really ticking items on my complaint’s list.
It seems that Adobe is still interested in ColdFusion (contrary to what some people think), and are really investing on it (the free editions for students tells it by itself)
One of my main complaints about ColdFusion was that it wouldn’t let you use OO properly (I’ve mentioned this hundreds of times), and now, it seems to be being addressed in a very gentle way.
Well keep an eye here to read more about the new functionalities for CF9

Older posts