Archive
Calendar for MooTools
Handy JavaScript Components
Via Ajaxian come two handy components this morning,
- First another JavaScript accordion, but this time based off Prototype, which we Seasiders are most familiar with thanks to excellent Scriptaculous integration by Lukas Renglli
- Second, a new upload manager, which might be a nice replacement for SWFUpload if you don’t want to enforce Flash in your applications
Enjoy and please let everyone know if these are any good, as I obviously haven’t used them personally quite yet.
Seaside + Google Analytics
We now return to regularly scheduled programming. First up, adding Google Analytics tracking code to your Seaside application. It’s an absolute must have if you are serious about your application.
- Do you have an Analytics account already?
- Yes – Find your Account ID by clicking on “Edit Analytics Account”
- No – Sign up, it’s free
- On your root component (one that implements #canBeRoot and #initialize) add (or augment) the following three methods,
- updateRoot: root
super updateRoot: root.
root linkToScript: ‘http://ssl.google-analytics.com/urchin.js’. - renderContentOn: html
self renderAnalyticsOn: html. - renderAnalyticsOn: html
html script: ‘_uacct=”UA-XXXXXX”;urchinTracker();’
- updateRoot: root
- Change “UA-XXXXXX” to your actual Account ID from Step 1.
- Change URL in #updateRoot: to “https” if you intend to host your application behind SSL, otherwise most browsers will display a warning about linkage to non-secure content from a secure page.
- Slightly more advanced example for those who care, you can skip it completely if you don’t
- Of many tracking options that Analytics supports, two most commonly used ones are User Defined values and Explicit URLs
- User Defined value is useful if you want to separate users according to some arbitrary criteria, for example if multiple instances of your application live on a single domain (www.domain.com), but different URLs (/live, /demo, /whatnot)
- Explicit URLs are important for Seaside applications if you want to track “Content” which is normally not distinguishable based on Seaside-generated URLs, but implementation will largely depend on your application, consider the following as an example only
- renderAnalyticsOn: html
| ws |
ws := String new writeStream.
ws
nextPutAll: ‘__utmSetVar(“‘;
nextPutAll: self analyticsKeyword;
nextPutAll: ‘”);_uacct=”UA-XXXXXX”;urchinTracker(”’.
crumbs do: [:ea | ws nextPutAll: ea title asAnalyticsURL] separatedBy: [ws nextPut: $/].
ws nextPutAll: ”’);’.
html script: ws contents - String>>asAnalyticsURL
^self asLowercase copyReplace: Character space with: $_
- Of many tracking options that Analytics supports, two most commonly used ones are User Defined values and Explicit URLs
As always, comment if you have any questions please.
2 things you have to have
I’m back after a bit of a hiatus with vacation, Xmas and all, so lets get cranking, shall we?
I’ve been meaning to post about 2 tools that I’ve become addicted to over the past little while, so others could get high on them with me. Chances are you already know about both, but if you don’t you can thank me in the comments :)
Firebug (http://www.getfirebug.com)
Screenshots won’t do it justice, you *have* to check it out. Here’s a short (and incomplete) list of things you can do with it,
- Inspect and edit HTML (live!)
- Inspect and edit CSS (yes, live as well)
- Debug and profile JavaScript (you’ll use this a lot, admit it)
- Monitor network activity (much much better than Google’s page analyzer at that)
- … the list goes on, you have to see it to believe it!
I should point out, that even though its free (as in beer), please chip in with a small donation to ensure continuous improvement (I’m not at the receiving end of it, by the way, just spreading the word), this tool can really change the way you do web development (for the better).
Selenium (http://www.openqa.org/selenium)
SUnit for your web applications that runs directly in the browser(s), need I say more? ;)
Did JavaScript need to be this confusing?
Just noticed this gem over at YUI Blog,
JavaScript is a prototypal language, but it has a new operator that tries to make it look sort of like a classical language. That tends to confuse programmers, leading to some problematic programming patterns.
[...]
There is a time to new, and a time to not.
Check out the rest for an interesting back-and-forth. By the way, this isn’t meant to diss the Yahoo! folks, they’re churning out some amazing libraries, patterns and hints given the constraints they need to work in and articles like this one are much appreciated. Its just that every time I dive in there, I find myself having to learn to swim every time, it really feels like its more convoluted than it needs to be.
