Monday, July 7, 2008

[ - Tutorials - ] The With()

http://www.kirupa.com/developer/actionscript/with.htm

One of my tutorials regarding the with() statement. Yes, this is a throwback entry. :)

Saturday, July 5, 2008

[ - Coding - ] Getting Over 's in AJAX/PHP

Something that has tripped me up ever since I started getting into AJAX is the ' rendering. I have seen this devil in most of my work as of late, especially with a recent project I have had. In this project, I created an editing trick similar to the Status field on Facebook. This grabs the previously written text, and ID of the item, and allows you to edit it right on the spot by putting it into the text field necessary.

In HTML


<a onclick="'editItem('My">My Work's Great</a>




From PHP, I would just allow the response text to go through without any sort of escape towards it. Not very good.



echo "<a href onclick ='editItem('My Work's Great',45)' >My Work's Great</a>
";




The issue is that the ' character is not escaped, causing the Javascript to produce an error on the call back. The rendering, of the response text, is mostly at fault because how this is handled. So if you look at Harley's Boys, from the PHP response, it'll come out as Harley="s Boys".

A workaround is to throw in extra slashes with the PHP function, addslashes, into your responses wherever you know that you will be using 's. This works because this will escape the characters for you.




$strResp = "<a href onclick ='editItem('My Work's Great',45)' >My Work's Great</a>
";

echo addslashes($strResp);



In the response code, you'll get:



"<a href onclick ='editItem('My Work's Great',45)' >My Work's Great</a>"

Instead of the weird looking response we used to get.

Better off putting responses through addslashes, than attempting to pull the escaping through Javascript, because the server side would have difficulty translating this into proper text. URLEncode won't work here, either.


Tuesday, June 17, 2008

[ - The Toolbox - ] Firefox 3 Released

Firefox 3, Mozilla's browser, is making an appearance to the big screen.

Yep, the big screen.

Your PC Screen as a final. No more betas it seems.

Looks like you can actually help them break something other than their own program. A Guiness record is up for grabs for the Mozilla camp. Can't wait to see what will happen here.

Saturday, June 14, 2008

[ - The Toolbox - ] X Ray power

http://westciv.com/xray/

For those into the Firebug plug in for Firefox. This is quite the tool. The view covers the basic elements for styled items on the screen such as position, left, right, width, height. I have been using this for divs only, so I would not be able to belch on anything else. This tool is quite handy.

Wednesday, June 4, 2008

[ - The Toolbox - ] I'm Lovin' Dreamweaver CS4

http://youtube.com/watch?v=VhwiddtHVxs

Just so you know, Dreamweaver CS4 and Fireworks CS4 Betas are out in the labs. I'll be throwing up a review of Dreamweaver CS4 with some comments. So far, the title says it all for me. Live View and Live Code are my favourite features so far(and the most frequently used by me). Server rendering without switching to the browser view was something I had always wanted in a tool.

Go get it here and see if you can spot some of the bugs on this release. I had one freeze, but I do not remember the cause.

Thanks to Kirupa for the notice.

Monday, June 2, 2008

[ - Coding - ] Functions

Something I do with Functions to help me remember where and what they do. It's probably something you have already thought of.




function Talk($somebody)
{/* Brief description of the function(pages where we implement this feature)
var $somebody - does something
*/
echo $somebody . " asked you to join the forces";
}



I am using the comments to organize it better. It feels cleaner without all that text in functions.

Friday, May 9, 2008

[ - Practices - ] - Commenting

This is a sample of a commenting system that I would like to adopt. Switching up my style after I realized that I'm quite a messy person. I am not too sure if the Contents Table was necessary. I considered it to be handy. I've asked one person about it, and he says that the Contents Table is overkill. It is a variant of a style I have seen before from another colleague of mine.



/*
=== INFORMATION =====================================================
Template // Actual Name
template.fla // Filename
Kevin Kelly - kk // Creator - Company Designation
May 8th 2008

Notation ------------------------------------------------------------
---------------------------------------------------------------------

Template with good notation and a Contents Table.
Pretty over the top.

---------------------------------------------------------------------

[INC] - Includes
[CLA] - Class Instanitions
[VAR] - Variables
[FUN] - Functions
[RUN] - Run Once or Run Time Functions

*/
// ===[INC]===================== Includes

// ===[CLA]===================== Class Instanitions

// ===[VAR]===================== Variables

// ===[FUN]===================== Functions

// ===[RUN]===================== Runtime or run once

// Just saying hello

trace("Saying Hello.");