[278] | 1 | $(function() {
|
---|
[283] | 2 |
|
---|
| 3 | mockup.api.loadSelectedDataList = function() {
|
---|
| 4 | var _select = document.getElementById("select_selectData");
|
---|
| 5 |
|
---|
| 6 | for (var n = 0; n < shoppingCart.contents.titles.length; n++) {
|
---|
| 7 | var opt = document.createElement("option");
|
---|
| 8 | opt.value = shoppingCart.contents.uids[n];
|
---|
| 9 | opt.innerHTML = shoppingCart.contents.titles[n];
|
---|
| 10 | _select.appendChild(opt);
|
---|
| 11 | }
|
---|
| 12 | }
|
---|
[278] | 13 |
|
---|
[283] | 14 | mockup.api.loadSelectedDataList();
|
---|
[278] | 15 |
|
---|
| 16 |
|
---|
[283] | 17 | mockup.api.drawGraphPreview = function(type) {
|
---|
| 18 | debugger;
|
---|
| 19 |
|
---|
| 20 | var selected = false, el = document.getElementById("select_selectData");
|
---|
| 21 | for (var n = 0; n < el.options.length; n++) {
|
---|
| 22 | if (el.options[n].selected == true) {
|
---|
| 23 | selected = true;
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 | if (!selected) return;
|
---|
| 27 |
|
---|
| 28 | mockup.api.graphs.previewGraph = new Graph("graphContainer");
|
---|
| 29 | mockup.api.graphs.previewGraph._container.innerHTML = "";
|
---|
| 30 | mockup.api.graphs.previewGraph.init("previewGraph", [40,50,60], type, [459,250]);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | function initPage() {
|
---|
| 34 | document.getElementById("btnPie").addEventListener("click", function(event) {
|
---|
| 35 | mockup.api.drawGraphPreview("Pie");
|
---|
| 36 | }, true);
|
---|
| 37 |
|
---|
| 38 | document.getElementById("btnRadar").addEventListener("click", function(event) {
|
---|
| 39 | mockup.api.drawGraphPreview("Radar");
|
---|
| 40 | }, true);
|
---|
| 41 |
|
---|
| 42 | document.getElementById("btnRose").addEventListener("click", function(event) {
|
---|
| 43 | mockup.api.drawGraphPreview("Rose");
|
---|
| 44 | }, true);
|
---|
| 45 |
|
---|
| 46 | document.getElementById("btnBar").addEventListener("click", function(event) {
|
---|
| 47 | mockup.api.drawGraphPreview("Bar");
|
---|
| 48 | }, true);
|
---|
| 49 |
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | mockup.api.addToDash = function() {
|
---|
| 53 | debugger;
|
---|
| 54 | var type = mockup.api.graphs.previewGraph.getType();
|
---|
| 55 | var selectedOptions = [];
|
---|
| 56 | var name;
|
---|
| 57 | var el = document.getElementById('select_selectData');
|
---|
| 58 | for (var n = 0; n < el.options.length; n++) {
|
---|
| 59 | if (el.options[n].selected == true) {
|
---|
| 60 | selectedOptions.push(el.options[n]);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | var option = selectedOptions[0] || null;
|
---|
| 64 | var graphs = document.getElementById('selectedGraphsContent');
|
---|
| 65 |
|
---|
| 66 | var newLine = ce("div");
|
---|
| 67 | newLine.className = "shoppingCartItem";
|
---|
| 68 | newLine.id = option.value;
|
---|
| 69 | var icon = ce("image");
|
---|
| 70 | $(icon).css("float", "right");
|
---|
| 71 | icon.src = "images/ui/DeleteIcon.png";
|
---|
| 72 | icon.addEventListener("click", function(event){
|
---|
| 73 | // TODO: Actually write this function
|
---|
| 74 | debugger;
|
---|
| 75 | for (var n = 0; n < mockup.api.graphs.dashboard.length; n++) {
|
---|
| 76 | var name = icon.previousSibling.innerHTML.split(" - ")[0];
|
---|
| 77 | if (mockup.api.graphs.dashboard[n][0] == name) {
|
---|
| 78 | mockup.api.graphs.dashboard.splice(n, 1);
|
---|
| 79 | break;
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | var parent = icon.parentNode;
|
---|
| 83 | parent.parentNode.removeChild(parent);
|
---|
| 84 |
|
---|
| 85 | }, false);
|
---|
| 86 | var titleField = ce("text");
|
---|
| 87 | name = option.innerHTML;
|
---|
| 88 | titleField.innerHTML = name+" - ("+type+")";
|
---|
| 89 | newLine.appendChild(titleField);
|
---|
| 90 | newLine.appendChild(icon);
|
---|
| 91 | graphs.appendChild(newLine);
|
---|
| 92 |
|
---|
| 93 | //Write settings to dashboard array.
|
---|
| 94 | mockup.api.graphs.dashboard.push([name, [40,50,60], type, [459,250]]);
|
---|
| 95 |
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | initPage();
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 |
|
---|
[278] | 102 | }); |
---|