Monday, December 8, 2008

"Got to here" or a Javascript Debugger written with prototype.js

Maybe I'll use this instead of interspersed lines of alert('got to here').

// ---------- ---------- ---------- dbgCursorSet
function dbgCursorSet(evt, mouseAction) {
if (mouseAction == 'over') {
evt.element().setStyle({cursor:"pointer"});
}
else if (mouseAction == 'out') {
evt.element().setStyle({cursor:"default"});
}
}

// ---------- ---------- ---------- Debbuger class
var Debugger = Class.create ({

// ---------- ---------- ---------- initialize
initialize: function() {
this.on = 0;
this.msg = '';

this.dbgHeader = '
' +
'Debug  ' +
'[resume]  ' +
'[pause]  ' +
'[clear]
';

this.dbgMsgLines = $A();

this.lineTemplate = '
#{msg}
';
this.tpl = new Template(this.lineTemplate);

this.divMain = document.createElement('div');
Element.extend(this.divMain);
this.divMain.id = "dbgDivMain";
},

// ---------- ---------- ---------- On
On: function() {
this.on = 1;
document.body.appendChild(this.divMain).show();
if ($('dbgPause')) {
$('dbgPause').setStyle({ color: '#333333' });
}
if ($('dbgResume')) {
$('dbgResume').setStyle({ color: '#cccccc' });
}
},

// ---------- ---------- ---------- Off
Off: function() {
this.on = 0;

if ($('dbgPause')) {
$('dbgPause').setStyle({ color: '#cccccc' });
}
if ($('dbgResume')) {
$('dbgResume').setStyle({ color: '#333333' });
}
},

// ---------- ---------- ---------- Clear
Clear: function() {
this.dbgMsgLines.clear();
this.Write('', true);
},

// ---------- ---------- ---------- Write
Write: function(s, override) {
if (this.on == 1 || override) {
this.msg = s;

this.dbgMsgLines.push(this.tpl.evaluate(this));
var divUpdated = this.dbgHeader;
this.dbgMsgLines.each(function(s) {
divUpdated += s;
})

$('dbgDivMain').update(divUpdated);

$$('.dbgLink').each ( function(ele) {
$(ele).observe ('mouseover', dbgCursorSet.bindAsEventListener(this, 'over'));
$(ele).observe ('mouseout', dbgCursorSet.bindAsEventListener(this, 'out'));
});

if (this.on == 1) {
$('dbgPause').setStyle({ color: '#333333' });
$('dbgResume').setStyle({ color: '#cccccc' });
}
else {
$('dbgPause').setStyle({ color: '#cccccc' });
$('dbgResume').setStyle({ color: '#333333' });
}

$('dbgClear').observe ('click', this.Clear.bindAsEventListener(this));
$('dbgPause').observe ('click', this.Off.bindAsEventListener(this));
$('dbgResume').observe ('click', this.On.bindAsEventListener(this));
}
},

});

Tuesday, December 2, 2008

HTML

Colors


http://www.geocities.com/SiliconValley/Network/2397/

http://www.vmunix.com/~gabor/html_colors.html

Validator


http://validator.w3.org/#validate_by_upload

Doc Types


http://www.w3schools.com/tags/tag_DOCTYPE.asp


HTML


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

XHTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Wednesday, October 1, 2008

Where Do I Put the Semi-Colons

All programming can be boiled down to 4 things:
  • assignments
  • decisions
  • loops
  • functions
So whatever language you might be coding in, it's just a question of where you put the semi-colons.

That's why I like the 'Cookbook' style programming books that have simple examples for how to do smallish, specific tasks. In other words, quick examples of where to put the semi-colons.

Maybe that's how I'll use this blog -- as my personal collection of code recipes. Ingredients from my past and current interests include c#, java, perl, c++, prototype.js, and tdd among others.