Server Side JavaScript with ASP
code
/**/ /**
* Class Navigator
* @author KimSoft
* @version build 2006-07-09 17:46
* @copyright 2006 KimSoft All Rights Reserved.
*/
function Navigator(boardId) ... {
this._boardId = boardId;
this._db = $singleton(function () ...{return new DB();})();
this._nodes = [];
}
/**/ /**
* @param boardId as board id
* @exception throw it where excute db query
*/
Navigator.prototype.getNodes = function (boardId) ... {
var sql = "select id, parentId, text from board where id=?";
var parentId, text;
try ...{
var rst = this._db.query(sql, boardId);
if (!rst.eof) ...{
parentId = parseInt(rst.fields("parentId").value);
this._nodes[this._nodes.length] = $empty(rst.fields("text").value);
//this._nodes[this._nodes.length] = $empty(rst.fields("text").value).link("post.asp?act=list&boardId=" + boardId);
this.getNodes(parentId);
}
rst.close();
rst = null;
}
catch (e) ...{
if ($debug.flag == true) ...{
throw (e);
}
this._nodes = [];
}
} ;
/**/ /**
* @seperator default as " -> "
* @return string
*/
Navigator.prototype.toString = function (seperator) ... {
this.getNodes(this._boardId);
this._db = null;
delete this._db;
return this._nodes.reverse().join(seperator || " -> ");
} ;
// Response.Write(new Navigator(145).toString()); //for test