/* name: model_Comment purpose: model comment data */ function model_Comment(oManager) { //properties this.manager = oManager; this.xml; this.loaded; //boolean this.parent; this.listeners = new Array(); this.state = "uninitialized"; //methods this.setId = _model_Comment_setId; this.update = _model_Comment_update; this.setParent = _model_Comment_setParent; this.updateCount= _model_Comment_updateCount; this.addListener = _model_Comment_addListener; this.notify = _model_Comment_notify; this.updateStatus= _model_Comment_updateStatus; } function _model_Comment_updateStatus(status) { this.state = status; this.notify(); } function _model_Comment_addListener(ob) { this.listeners[this.listeners.length] = ob; } function _model_Comment_notify() { var arr = this.listeners; for (var i=0; i < arr.length; i++) { var ob = arr[i]; ob.update(this); } } function _model_Comment_setParent(mdl) { if (!this.parent) this.parent = mdl; } function _model_Comment_setId(id) { this.id = id; } function _model_Comment_update(node) { this.xml = node; this.subject = getElementTextNS("", "post_subject", node, 0); this.body = getElementTextNS("", "post_text", node, 0); this.id = getElementTextNS("", "post_id", node, 0); this.author = getElementTextNS("", "username", node, 0); this.time = getElementTextNS("", "post_time", node, 0); this.forum_id = getElementTextNS("", "forum_id", node, 0); this.topic_id = getElementTextNS("", "topic_id", node, 0); this.last_id = getElementTextNS("", "last_id", node, 0); this.parent_id = getElementTextNS("", "parent_id", node, 0); this.post_path = getElementTextNS("", "post_path", node, 0); this.author_is_reporter = getElementTextNS("", "is_reporter", node, 0); if (this.author_is_reporter==0 || this.author_is_reporter=="n/a") this.author_is_reporter = false; else this.author_is_reporter = true; reply_count = getElementTextNS("", "replies", node, 0); this.updateCount(reply_count); if (this.body!="" && this.body!="n/a") { this.loaded = true; } this.updateStatus("loaded"); } function _model_Comment_updateCount(newCount) { //this should do something to recursively update the parent counts this.reply_count = newCount; }