Project Team
|
Erik consults with companies big and small to help them create interactive and engaging digital experiences that their customers love.
http://erikburns.com
|
|
Michael is a mad JavaScript hacker and networking genius from the San Francisco Bay Area. He's quick, creative and technically deep. When he's not creating something new in code, he likes to color with markers, and drink flower-infused martinis.
http://michaelrienstra.com
|
|
Dave is the driving force behind Lumieria, a multidisciplinary technology design firm operating in multiple areas -- think media, interactive and design meets software, electronics and sculpture. When he's not working on a creative project, he's out playing music, dancing or riding a motorcycle.
http://lumieria.com
|
//
// DAVES NOTE
// Despite what is said above, I plan to have multiple AJAX queries fired off from my page (one for each section)
// I'm going to use a function
function getAjaxRequest(url)
{
var request = false;
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = false;
}
}
}
if (!request)
alert("Error initializing XMLHttpRequest!");
return request;
}
// This section done with the help of...
// http://knol.google.com/k/gimme-some-closure-object-oriented-javascript-ajax-callbacks#
// I'm using OO JavaScript to create an object named PageDivObj... here is the notation
// NOTE: BAD things to watch out for...
//
// KEY POINT: The garbage collection mechanisms from the DOM, and from JavaScript are SEPARATE. Which means...
// Do not keep member variables of DOM objects in JavaScript objects. And vice-versa. This means, any JS callbacks
// on DOM objects should be cleared before the DOM object is deleted, by removeChild or the setting of innerHtml on
// any ancestor (see purgeDom fn below)
// from: http://javascript.crockford.com/memory/leak.html
// d is a dom obj
function purgeDom(d) {
if (!d)
return;
var a = d.attributes, i, l, n;
if (a) {
for (i = a.length - 1; i >= 0; i -= 1) {
n = a[i].name;
if (typeof d[n] === 'function') {
d[n] = null;
}
}
}
a = d.childNodes;
if (a) {
l = a.length;
for (i = 0; i < l; i += 1) {
purgeDom(d.childNodes[i]);
}
}
}
function onReadyStateChangeCb( r )
{
if (r) {
//console.log( "status = " + r.status + "response = " + r.responseText );
// server fullfilled the request => readystate 4
if (r.readyState == 4) {
// r status == 200 => requested data is ready
if (r.status == 200)
{
//alert("Server is done!");
//var xml = r.responseXml; // - get XHTML result
var txt = r.responseText; // - get result in text
//console.log("got good response" + txt);
}
}
}
}
//When using XMLHttpRequest to get the HTML of a remote webpage, it is often advantageous to turn that HTML string into DOM for easier manipulation. However, there are potential dangers involved in injecting remote content in a privileged context in your extension, so it can be desirable to parse the HTML safely.
//The function below will safely parse simple HTML and return a DOM object which can be manipulated like web page elements. This will remove tags like