1 $(document).ready(createWizardApp);
6 function createWizardApp(event) {
7 $("#srvtype p input").bind("click", serverTypeChange);
8 $("#authentication p input").bind("click", authTypeChange);
9 $("#submit").bind("click", submitWizard);
11 function serverTypeChange(event) {
12 var targetElement = event.target;
13 serverType = targetElement.getAttribute("value");
14 if (serverType == "citadel") {
20 function authTypeChange(event) {
21 var targetElement = event.target;
22 authType = targetElement.getAttribute("value");
24 function submitWizard(event) {
25 $("#input").hide("slow");
26 var server = $("#srvroot").val();
27 var ctdlsrv = $("#ctdlsrv").val();
38 success: successfulSubmit,
41 $("#output").show("slow");
43 function successfulSubmit(data, textStatus) {
45 $("#output").append("<p class=\"big\">Configuration successful</p>");
46 var eventData = eval(data);
47 // Move the template into the output
48 var template = document.getElementById("template");
49 var eventtemplate = document.getElementById("eventresult");
50 template.removeChild(eventtemplate);
51 document.getElementById("output").appendChild(eventtemplate);
52 $.each(eventData, eventItem);
54 function eventItem(i, item) {
55 var eventName = item[0];
56 var eventResult = item[1];
58 var resultTdClass = "";
59 var cellId = "cellr_"+i;
60 var jCellId = "#"+cellId;
61 var errorContainer = null;
62 if (item.length == 3) {
63 resultTdClass = "failure";
64 } else if (eventResult == "Success") {
65 resultTdClass = "success";
67 // Build the row the 'DOM way', because I have had enough of string concatenations today
68 var trNode = document.createElement("tr");
69 var eventNameTd = document.createElement("td");
70 eventNameTd.textContent = eventName;
71 var eventResultTd = document.createElement("td");
72 eventResultTd.setAttribute("class", resultTdClass);
73 if (item.length == 2) {
74 eventResultTd.textContent = eventResult;
76 var resultText = document.createTextNode(eventResult + " ");
77 var hideSmall = document.createElement("small");
78 hideSmall.textContent = "(toggle error details)";
79 hideSmall.addEventListener("click",toggleEventErrorDisplay,false);
80 eventResultTd.appendChild(resultText);
81 eventResultTd.appendChild(hideSmall);
82 var errorDetailsContainer = document.createElement("div");
83 errorDetailsContainer.setAttribute("class", "errorbox");
84 errorDetailsContainer.style.display = 'none';
85 var errorDetailsPre = document.createElement("pre");
86 errorDetailsContainer.appendChild(errorDetailsPre);
87 errorDetailsPre.textContent = item[2];
88 eventResultTd.appendChild(errorDetailsContainer);
90 trNode.appendChild(eventNameTd);
91 trNode.appendChild(eventResultTd);
92 var eventResultTable = document.getElementById("eventresult");
93 eventResultTable.appendChild(trNode);
95 function toggleEventErrorDisplay(event) {
96 var targetElement = event.target;
97 // the above will be a 'small' element, the div to toggle is next to it
98 var targetErrorDisplay = targetElement.nextSibling;
99 var displayMode = targetErrorDisplay.style.display;
100 if (displayMode == "none") {
101 targetErrorDisplay.style.display = 'block';
103 targetErrorDisplay.style.display = 'none';
106 function postFailure(xhttprequest, status, error) {
107 $("#output").empty();
108 $("#output").append("<p class=\"big\">An error was encountered during configuration</p>")
109 $("#output").append("<pre>" + xhttprequest.responseText + "</pre>");