comparison ape.js @ 2:955d229b8a02

function loadProjectSpec will parse XML project specification and build interface. Still needs full work. Interface is loaded in ape.js
author Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk>
date Sun, 08 Mar 2015 18:58:06 +0000
parents
children 1b01b7443a46
comparison
equal deleted inserted replaced
1:d7d1aa6d3558 2:955d229b8a02
1 /**
2 * ape.js
3 * Create the APE interface
4 */
5
6 // Once this is loaded and parsed, begin execution
7 loadInterface(projectXML);
8
9 function loadInterface(xmlDoc) {
10
11 var width = window.innerWidth;
12 var height = window.innerHeight;
13
14 // Set background to grey #ddd
15 document.getElementsByTagName('body')[0].style.backgroundColor = '#ddd';
16
17 // The injection point into the HTML page
18 var insertPoint = document.getElementById("topLevelBody");
19
20 // Decode parts of the xmlDoc that are needed
21 // xmlDoc MUST already be parsed by jQuery!
22 var xmlSetup = xmlDoc.find('setup');
23 // Should put in an error function here incase of malprocessed or malformed XML
24
25 // Create the top div for the Title element
26 var titleAttr = xmlSetup[0].attributes['title'];
27 var title = document.createElement('div');
28 title.className = "title";
29 title.align = "center";
30 var titleSpan = document.createElement('span');
31
32 // Set title to that defined in XML, else set to default
33 if (titleAttr != undefined) {
34 titleSpan.innerText = titleAttr.value;
35 } else {
36 titleSpan.innerText = 'APE Tool';
37 }
38 // Insert the titleSpan element into the title div element.
39 title.appendChild(titleSpan);
40
41 // Now create the slider and HTML5 canvas boxes
42
43 var sliderBox = document.createElement('div');
44 sliderBox.className = 'sliderCanvasDiv';
45 sliderBox.id = 'sliderCanvasHolder'; // create an id so we can easily link to it later
46 sliderBox.align = 'center';
47
48 var canvas = document.createElement('canvas');
49 canvas.id = 'slider';
50 canvas.width = width - 100;
51 canvas.height = 150;
52 canvas.style.backgroundColor = '#eee';
53
54 sliderBox.appendChild(canvas);
55
56
57 // Inject into HTML
58 insertPoint.innerHTML = null; // Clear the current schema
59 insertPoint.appendChild(title); // Insert the title
60 insertPoint.appendChild(sliderBox);
61 }