// This file was generated by Dashcode from Apple Inc.
// You may edit this file to customize your web application.
var listController = {
// This object acts as a controller for the list UI.
// It implements the dataSource methods for the list.
// This dataSource uses fixed data for the content of the list. Some applications may have such static data for their lists, others will want to replace this with information fetched remotely via XMLHttpRequest.
_rowData: null,
loadCategoryData : function() {
// Values you provide
var feedURL = "some url here....";
// XMLHttpRequest setup code
var xmlRequest = new XMLHttpRequest();
xmlRequest.onreadystatechange= function()
{
var result= null;
switch(xmlRequest.readyState)
{
case 4:
if(xmlRequest.status==200)
{
// parse it...
// dumpResponseXML(responseXML);
listController._rowData= new Array();
var nodelist= xmlRequest.responseXML.getElementsByTagName('ResultItem');
for(var ii= 0; ii<nodelist.length; ii++)
{
listController._rowData.push(new ResultItem(
nodelist[ii].getAttribute('Title'),
nodelist[ii].getAttribute('Description'),
nodelist[ii].getAttribute('OnClick'),
nodelist[ii].getAttribute('HREF'),
nodelist[ii].getAttribute('ImageHREF'),
nodelist[ii].getAttribute('MediaType')));
}
// now tell us to reload!
var list= document.getElementById('list');
list.object.reloadData();
}
break;
case 3:
break;
default:
break;
}
}
xmlRequest.open("POST", feedURL);
xmlRequest.setRequestHeader("Content-type", "text/xml; charset=utf-8");
xmlRequest.setRequestHeader("SOAPAction", "SOAP Request header info here...");
xmlRequest.send(buildXMLRequest('cat', 'XXXX', '', '', ''));
},
numberOfRows: function() {
// The List calls this dataSource method to find out how many rows should be in the list.
if(this._rowData==null)
{
return 1; // Loading text...
} else {
return this._rowData.length;
}
},
prepareRow: function(rowElement, rowIndex, templateElements) {
if(this._rowData != null)
{
// The List calls this dataSource method for every row. templateElements contains references to all elements inside the template that have an id. We use it to fill in the text of the rowTitle element.
if (templateElements.rowTitle) {
templateElements.rowTitle.innerText = this._rowData[rowIndex].Title;
}
// We also assign an onclick handler that will cause the browser to go to the detail page.
var self = this;
var handler = function() {
var resort = self._rowData[rowIndex];
categoryController.setRepresentedObject(resort);
var browser = document.getElementById('browser').object;
// The Browser's goForward method is used to make the browser push down to a new level. Going back to previous levels is handled automatically.
browser.goForward(document.getElementById('categoryLevel'), resort.Title);
/*
detailController.setRepresentedObject(resort);
var browser = document.getElementById('browser').object;
// The Browser's goForward method is used to make the browser push down to a new level. Going back to previous levels is handled automatically.
browser.goForward(document.getElementById('detailLevel'), resort);
*/
};
rowElement.onclick = handler;
} else {
if (templateElements.rowTitle) {
templateElements.rowTitle.innerText = "Loading...";
}
}
}
};
var detailController = {
// This object acts as a controller for the detail UI.
setRepresentedObject: function(representedObject) {
this._representedObject = representedObject; // a ResultItem.
// load the list for this here...
// categoryObject is a node...
// Values you provide
var feedURL = "asmx service feed is here....";
// XMLHttpRequest setup code
var xmlRequest = new XMLHttpRequest();
xmlRequest.onreadystatechange= function()
{
var result= null;
switch(xmlRequest.readyState)
{
case 4:
if(xmlRequest.status==200)
{
// parse it...
// dumpResponseXML(responseXML);
detailController._rowData= new Array();
var nodelist= xmlRequest.responseXML.getElementsByTagName('ResultItem');
for(var ii= 0; ii<nodelist.length; ii++)
{
detailController._rowData.push(new ResultItem(
nodelist[ii].getAttribute('Title'),
nodelist[ii].getAttribute('Description'),
nodelist[ii].getAttribute('OnClick'),
nodelist[ii].getAttribute('HREF'),
nodelist[ii].getAttribute('ImageHREF'),
nodelist[ii].getAttribute('MediaType')));
}
// now tell us to reload!
// we don't have to reload, we just have to change out our fields...
// var list= document.getElementById('categoryList');
// list.object.reloadData();
// When the represented object is set, this controller also updates the DOM for the detail page appropriately. As you customize the design for the detail page, you will want to extend this code to make sure that the correct information is populated into the detail UI.
r= detailController._rowData[0];
var parts= r.Title.split("|");
var detailText = document.getElementById('detailText');
detailText.innerHTML = parts[0];
var authorText = document.getElementById('authorText');
authorText.innerHTML = parts[1];
var durationText = document.getElementById('durationText');
durationText.innerHTML = parts[2];
var descriptionText = document.getElementById('descriptionText');
descriptionText.innerHTML= r.Description;
var videoBox= document.getElementById('videoBox');
videoBox.innerHTML= '<embed src="'+r.ImageHREF+'" href="'+r.HREF+
'" type="video/x-m4v" target="myself" scale="1" width="128px" height="128px" />';
}
break;
case 3:
break;
default:
break;
}
}
xmlRequest.open("POST", feedURL);
xmlRequest.setRequestHeader("Content-type", "text/xml; charset=utf-8");
xmlRequest.setRequestHeader("SOAPAction", "blam blam blam");
var parameters= representedObject.OnClick.split("|");
xmlRequest.send(buildXMLRequest(parameters[0], parameters[1],
parameters[2], parameters[3], parameters[4]));
}
};
//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{
setupParts();
listController.loadCategoryData();
}
// This object implements the dataSource methods for the list.
var categoryController = {
// Sample data for the content of the list.
// Your application may also fetch this data remotely via XMLHttpRequest.
_rowData: null,
// The List calls this method to find out how many rows should be in the list.
numberOfRows: function() {
if(this._rowData==null)
{
return 1;
} else {
return this._rowData.length;
}
},
setRepresentedObject: function(categoryObject)
{
// load the list for this here...
// categoryObject is a node...
// Values you provide
var feedURL = "SOAP service feed url here.";
// XMLHttpRequest setup code
var xmlRequest = new XMLHttpRequest();
xmlRequest.onreadystatechange= function()
{
var result= null;
switch(xmlRequest.readyState)
{
case 4:
if(xmlRequest.status==200)
{
// parse it...
// dumpResponseXML(responseXML);
categoryController._rowData= new Array();
var nodelist= xmlRequest.responseXML.getElementsByTagName('ResultItem');
for(var ii= 0; ii<nodelist.length; ii++)
{
categoryController._rowData.push(new ResultItem(
nodelist[ii].getAttribute('Title'),
nodelist[ii].getAttribute('Description'),
nodelist[ii].getAttribute('OnClick'),
nodelist[ii].getAttribute('HREF'),
nodelist[ii].getAttribute('ImageHREF'),
nodelist[ii].getAttribute('MediaType')));
}
// now tell us to reload!
var list= document.getElementById('categoryList');
list.object.reloadData();
}
break;
case 3:
break;
default:
break;
}
}
// voodoo.
xmlRequest.open("POST", feedURL);
xmlRequest.setRequestHeader("Content-type", "text/xml; charset=utf-8");
xmlRequest.setRequestHeader("SOAPAction", "Soap action header here.");
var parameters= categoryObject.OnClick.split("|");
xmlRequest.send(buildXMLRequest(parameters[0], parameters[1],
parameters[2], parameters[3], parameters[4]));
},
// The List calls this method once for every row.
prepareRow: function(rowElement, rowIndex, templateElements) {
var title= "";
if(this._rowData!=null)
{
title= this._rowData[rowIndex].Title;
// Assign a click event handler for the row.
var self = this;
rowElement.onclick = function(event) {
// Do something interesting
var resort = self._rowData[rowIndex];
detailController.setRepresentedObject(resort);
var browser = document.getElementById('browser').object;
// The Browser's goForward method is used to make the browser push down to a new level. Going back to previous levels is handled automatically.
browser.goForward(document.getElementById('detailLevel'), resort.Title);
}
} else {
title= "Loading..."
}
// templateElements contains references to all elements that have an id in the template row.
// Ex: set the value of an element with id="label".
if (templateElements.label) {
templateElements.label.innerText = title;
}
}
};
function buildXMLRequest(verb, companyCode, category, searchString, showCode)
{
return "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""+" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<soap:Body>"+
"<GetResults xmlns=\"blahblahblah/\">"+
"<password>XXX</password>"+
"<verb>"+verb+"</verb>"+ // cat
"<companyCode>"+companyCode+"</companyCode>"+
"<category>"+category+"</category>"+
"<searchString>"+searchString+"</searchString>"+
"<showCode>"+showCode+"</showCode>"+
"</GetResults>"+
"</soap:Body>"+
"</soap:Envelope>";
}
function ResultItem(title, description, onclick, href, imagehref, result_type)
{
this.Title= title;
this.Description= description;
this.OnClick= onclick;
this.HREF= href;
this.ImageHREF= imagehref;
this.Type= result_type;
return this;
}