Chris Pollett > Students >
Rao

    ( Print View )

    [Bio]

    [Project Blog]

    [CS297 Proposal]

    [Del1]

    [Firefox Plugin-PPT]

    [Del2]

    [DOMTest-ZIP]

    [Del3]

    [Del4]

    [Firefox Plugin to match h1 tags-ZIP]

    [CS297-PDF]

    [CS298Proposal-PDF]

    [CS298 Report-PDF]

    [CS298Presentation-PPT]

                          

























Deliverable 2 -- DOM Test

Description:

The second deliverable was to create a test HTML DOM and capture various mouse events such as mouseover and mouseout. A test HTML page was created with various block level elements such as <div>, <p> and <table>.
A test javascript function was called onLoad event of the HTML page. This function registered the mousedown and the mouseup event so that users selection block that includes the start element and the end element is captured. The DOM nodes were then iterated over selecting the parent node till the <body> node was encountered. The path was then alerted to the user. The test was done to determine the uppermost block level element that can be saved. The following listing shows the piece of code that traverses the DOM looking for block level elements and then prompts the user

function calculatePath(tgt) {
	arr = new Array();
	//tgt.setCapture();
	//alert("int tgt " + tgt);
	path=tgt.tagName+" ";
	//alert(path);
	while(tgt.tagName != 'BODY') {
		//alert("inside");
		arr.push(tgt.tagName);
		path=path+ tgt.parentNode.tagName +" -- ";
		tgt = tgt.parentNode;
		//alert(path);
	}
	arr.push('BODY');
	//alert(arr);
	return arr;

}

function capturePathUp(upNode) {
	var selection;
	if(document.selection) {
		selection = document.selection
	} else {
		selection = window.getSelection();
		alert(selection.getRangeAt(0));
	}
	//uparr = calculatePath(upNode);
	//alert("path " + startarr.join(' | '));
	/*var lastpop;
	if(downarr.length > uparr.length) {
		for(i = downarr.length; i >= uparr.length; i--) {
			lastpop = downarr.pop();
		}
	} else if(downarr.length < uparr.length){
	} else {
		pickParentBlockElem(uparr);
	}*/
}