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