I've definitely made the transition from grudging Javascript hacker to coder: I'm building reusable tools. To whit, here's a very helpful logging utility that shows messages in a separate window refreshed on each hit:
var log_span;
function log(msg) {
if (!log_span) {
var log_window = window.open("", "log", "status,width=700,height=300");
log_window.document.write('<h2>JS Log</h2><span id=log></span>');
log_window.document.close();
log_span = log_window.document.getElementById("log");
log_span.innerHTML = "";
}
var d = new Date();
log_span.innerHTML += "[" + d.toLocaleString() + "] " +
msg + "<br>";
}
Before I came up with that one I was using alert() for confessional debugging which is a complete pain.
I've also learned how to create my own classes in Javascript which allows for much cleaner code than my previous practice. Of course, Javascript doesn't really have classes, it uses prototype-based inheritence instead. It's weird by servicable once I got the syntax right.
Another big factor in my increasing Javascript confidence is the Emacs ecmascript-mode I found on the EmacsWiki. It looks and feels so much like cperl-mode that I can't help but feel at home.
-sam
Looks familiar (Score:2)
Hey, looks familiar:
It's also really useful for debugging long running flash movies (In our case from a couple of weeks, to a couple of years). The substr helps keep the ram usage down :)
Re:Looks familiar (Score:1)
Re:Looks familiar (Score:2)
Yes, we will use it for distributed "live" display of a lottery, that has draws every 3 minutes on terminals distributed throughout northern Germany. Sometimes the terminals might be turned off at night, but other terminals might run basically forever. We have zero leakage, so there is really to reason to ever restart the thing.
Recommended change (Score:1)
That way you can scroll and/or resize the log window as needed.
Re:Recommended change (Score:2)
-sam
You have... (Score:1)
After a distance further along the curve: (Score:1)