/* * Scripts needed for operation of the survey editor */ var surveyEditor = { uid: "", // the uid of the currently opened survey title: "No title", // the name of the currently opened survey description: "No description", // the description of the currently opened survey numQuestions: 0, // the number of questions contained in this survey questions: [], // the array containing question objectliterals/uids state: { // used for checks in onClick events editing: false, // whether or not a question is currently being edited editUid: "" // the uid of the question being edited, if any } } function loadSurvey() { /* * Take the values from the hiddenfields on the page, load them into the object literal defined at the top of this script, * Then delete these fields from the HTML page, since they are not needed anymore. * This is possibly more secure than leaving them on the page, and results in cleaner HTML markup */ debugger; var fTitle = document.getElementById("surveyTitle"); if (fTitle != undefined && fTitle.value != "") { surveyEditor.title = fTitle.value; } else { surveyEditor.title = "Undefined title"; } var fNumQuestions = document.getElementById("numQuestions"); if (fNumQuestions != undefined && fNumQuestions.value != "") { surveyEditor.numQuestions = fNumQuestions; } else { surveyEditor.numQuestions = 0; return; } var fQuestions = document.getElementById("questionUids"); if (fQuestions != undefined && surveyEditor.numQuestions > 0) { surveyEditor.questions = stringToArray(fQuestions.value, ","); if (surveyEditor.questions.length != surveyEditor.numQuestions) { alert("numQuestions and the questions array passed do not match!"); return; } } else { alert("Questions field not found!"); return; } } function drawQuestions(firstTime) { var length = surveyEditor.questions.length; if (length <= 0) return; var container = document.getElementById("surveyEditorContent"); if (firstTime == true) { // Loop through questions, add a new smallFrame div for each question with id=question->uid // do this via AJAX calls, returnQuestion.php // dependencies: stringToArray/arrayToString var requestString = "uids="; requestString += arrayToString(surveyEditor.questions, ","); newAjaxRequest(requestString, "returnQuestionDisplay.php", function(result) { //var holderDiv = document.createElement("div"); //holderDiv.innerHTML = result.responseText; container.innerHTML = result.responseText; }); } }