billingSample.html

<HTML>

<HEAD>

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

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

<script language="Javascript">

//globals

var baseAll, billHead, billBody, dFrameCustomer, dFrameArticle

var articlesList

//Style

DFrameAPI.include('styles/windows/styleWindows.js')

//XML for <SCRIPT>

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

//additional library

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

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

DFrameAPI.onLoad = function(){

dFrameStyle.setIndentX(0)

dFrameStyle.setIndentY(0)

baseAll = new DFrame([0, 0, 100, 100], 'examples.billing.html', dFrameStyle);

baseAll.addButton('Select a customer', 'selectCustomer()');

baseAll.addButton('Select an article', 'selectArticle()');

//baseAll.setURL('./billing/blank.html')

billHead = new DFrame([0, 0, 100, 30], 'Head', dFrameStyle, baseAll);

billHead.show()

var pos = [0, 0, 100, 100]

pos[1] = [billHead, 'Bottom', 5];

billBody = new DFrame(pos, 'Body', dFrameStyle, baseAll);

billBody.setURL('./billing/blank.html')

}

function selectCustomer() {

if (!dFrameCustomer) {

//Create the DFrame for the selection of a customer

//dFrameCustomer = new DFrame([10, 3, 97, 97], 'Select a customer', dFrameStyle, baseAll);

dFrameCustomer = new DFrame([2, 2, 98, 98], 'Select a customer', dFrameStyle, billBody);

dFrameCustomer.receiveData = function (data) {

dFrameCustomer.show(false)

billHead.alert(formatXML(data))

}

}

dFrameCustomer.setURL('./advanced.XML.html')

dFrameCustomer.addSelectButton = true

}

function selectArticle() {

if (!dFrameArticle) {

//dFrameArticle = new DFrame([10, 45, 97, 97], 'Select an article', dFrameStyle, baseAll);

dFrameArticle = new DFrame([2, 2, 98, 98], 'Select an article', dFrameStyle, billBody);

dFrameArticle.onEvent = function(e) {

if (e.action == 'preCreate' && e.dFrame.bubbleKey == 'dFrameDetail') {

var target = e.dFrame

var bar = target.addBar()

bar.addButton('Select', 'selectArticle()')

e.cancelBubble = true

}

}

dFrameArticle.receiveData = function (data) {

dFrameArticle.show(false)

updateArticlesList(data, 'Add')

billBody.show()

}

}

dFrameArticle.setURL('./billing/articles.html')

}

function showArticleDetail(i) {

dFrameArticle.show()

}

function updateArticlesList(objUser, fn) {

if (!articlesList) createArticlesList()

if (fn == 'Add') {

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

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

articlesList.add(lastName + ' ' + firstName,1)

}

}

function createArticlesList() {

articlesList = new mainPage.List()

articlesList.moveTo(10,10)

articlesList.setWidth(billBody.getWidth()/2)

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)

DynDoc = billBody.createDynAPIDocument()

DynDoc.addChild(articlesList)

}

function formatXML(objUser) {

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

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

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

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

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

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

var txt = '<b><font size=3 face=Arial>' + firstName + ' ' + lastName + '<font size=2></b><br>'+ address + ' ' + city + ' ' + state + ' ' + zip

return txt

}

function cTCC (string) {

//cTCC: convertToCorrectCase = lowerCase for NS6

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

else return string

}

</script>

</HEAD>

</HTML>