billing/articles.html

<HTML>

<HEAD>

<script>var dFrameFilePath = '../../../../'</script>

<script language="Javascript" src="../../../../lib/dFrameAPI.js"></script>

<script language="Javascript">

//Global

var baseAll, dFrameDetail, dFrameList

var dbDomTree

var gCurrentArticleOrdinal = 0;

var gCurrentArticle

//var mainPage = null

//additional library

DynAPI.setLibraryPath('../../../../dynapi/src/lib/');

DynAPI.include("dynapi.gui.list.js")

//Style

if (window.parent && window.parent != self && window.parent.getDFrameValues) {

//Setup mainPage

window.parent.getDFrameValues()

dFrameStyle = mainPage.dFrameStyle

} else DFrameAPI.include('styles/blue/styleBlue.js')

//XML for <SCRIPT>

DFrameAPI.include('ext/xml_for_script-2.0/jsXMLParser/xmldom.js')

DFrameAPI.onLoad = function(){

//if (mainPage != null) {

// alert('squeeze style')

// dFrameStyle = mainPage.dFrameStyle

// alert(dFrameStyle.getContentBgColor())

//}

baseAll = new DFrame([3, 3, 97, 97], 'articles.html', dFrameStyle);

baseAll.setTitleBar(false)

//Create at one the DFrame that will receive the list

//and insert a "blank" document in it to create a IFrame

dFrameList = new DFrame(['10', '10', '350', 97], 'Articles list',dFrameStyle, baseAll)

dFrameList.setTitleBar(false)

dFrameList.setURL('./blank.html')

var position = [0, '10', 97, 97]

position[0] = [dFrameList, 'Right', 0]

dFrameDetail = new DFrame(position, 'Article detail',dFrameStyle, baseAll)

dFrameDetail.setTitleBar(false)

dFrameDetail.bubbleKey = 'dFrameDetail'

dFrameDetail.addButton('First', 'displayArticles("first")')

dFrameDetail.addButton('Previous', 'displayArticles("previous")')

dFrameDetail.addButton('Next', 'displayArticles("next")')

dFrameDetail.addButton('Last', 'displayArticles("last")')

dFrameDetail.setDragEnabled(true)

dFrameDetail.show()

DFrameAPI.getContent('./articles/articles_XML.html', 'load1')

}

DFrameAPI.onContentLoad = function(contentValue, key) {

if (key == 'load1') {

XMLString = contentValue.slice(1)

dbDom = new XMLDoc(XMLString, xmlError);

dbDomTree = dbDom.docNode;

displayArticlesAsAList()

}

}

function displayArticlesAsAList() {

articlesList = new List()

articlesList.moveTo(10,10)

articlesList.setWidth(dFrameList.getWidth()-40)

articlesList.setBgColor('#000000')

articlesList.boldOnSelect(true)

var l = new EventListener(articlesList);

l.onmousedown = function(e) {

var o = e.getTarget();

var i = o.getSelectedIndex()

showArticleDetail(i)

}

articlesList.addEventListener(l)

objUser = navigateUserList("first");

while(objUser != null) {

code = trim(objUser.getElements(cTCC("CODE"))[0].getText(),true, true);

designation = trim(objUser.getElements(cTCC("DESIGNATION"))[0].getText(), true, true);

articlesList.add(designation + ' ' + code,1)

objUser = navigateUserList("next");

status = ''

}

DynDoc = dFrameList.createDynAPIDocument()

DynDoc.addChild(articlesList)

}

function displayArticles(direction) {

objUser = navigateUserList(direction);

if (objUser!= null) {

displayUserData(objUser);

articlesList.select(articlesList.items[gCurrentArticleOrdinal])

}

}

function showArticleDetail(i) {

objUser = getArticleByOrdinalValue(i)

if (objUser!= null) {

displayUserData(objUser);

gCurrentArticle = objUser

}

}

function displayUserData(objUser) {

var txt = formatXML(objUser)

dFrameDetail.alert(txt)

dFrameDetail.show(true)

}

function formatXML(objUser) {

code = trim(objUser.getElements(cTCC("CODE"))[0].getText(),true, true);

designation = trim(objUser.getElements(cTCC("DESIGNATION"))[0].getText(), true, true);

description = trim(objUser.getElements(cTCC("DESCRIPTION"))[0].getText(), true, true);

var font = '<font size=2 color=white face=Arial>'

var txt = '<table width=' + (dFrameDetail.getWidth() - 50) + '><tr><td>' + font + '<b>Code:</b> ' + code + '</td></tr><tr><td>' + font + '<b>Designation</b>: ' + designation + '</td></tr><tr><td>' + font + '<b>Description: </b>:' + description + '</td></tr></table>'

return txt

}

function selectArticle() {

baseAll.getParentDFrame().receiveData(gCurrentArticle)

}

function cTCC (string) {

//cTCC: convertToCorrectCase = lowerCase for NS6

if (is.ns6) return string.toLowerCase()

else return string

}

/************************************************************************

From formFunction.js

************************************************************************/

function xmlError(e) {

alert("There has been an error accessing the XML Database. The error is:\n" + e)

}

function navigateUserList(direction) {

var objUser;

switch (direction) {

case "next":

objUser = getArticleByOrdinalValue(gCurrentArticleOrdinal + 1);

break;

case "previous":

objUser = getArticleByOrdinalValue(gCurrentArticleOrdinal - 1);

break;

case "first":

objUser = getArticleByOrdinalValue(0);

break;

case "last":

objUser = getArticleByOrdinalValue(dbDomTree.getElements(cTCC("CONTACT")).length -1);

break;

case "current":

objUser = getArticleByOrdinalValue(gCurrentArticleOrdinal);

break;

} // end switch

//set the global currently displayed user

gCurrentArticle = objUser;

return (objUser)

}

function getArticleByOrdinalValue(value){

var tmpNode = dbDomTree.getElements(cTCC("ARTICLE"))[value];

gCurrentArticleOrdinal = value;

return tmpNode;

}

</script>

</HEAD>

</HTML>