- Timestamp:
- 07/19/11 16:59:59 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyCreationTool.php
r23 r24 9 9 class SurveyCreationTool { 10 10 11 public function __construct( ) {11 public function __construct($survey = null, $timeStamp = null) { 12 12 SurveyCreationTool::javascript(); 13 13 ?> 14 14 15 <div id="surveyCreation"><form action="submitsurvey.php" method="post">15 <div id="surveyCreation"><form id="survey" action="submitsurvey.php" method="post"> 16 16 <?php 17 SurveyCreationTool::titleBox(); 18 SurveyCreationTool::descriptionBox(); 17 SurveyCreationTool::surveyHead($timeStamp); 19 18 SurveyCreationTool::questionCreationForm(); 20 19 SurveyCreationTool::addQuestionButton(); … … 28 27 ?> 29 28 <script type="text/javascript"> 30 var questionCount = 1; 31 29 /* autosave every 3 minutes */ 30 setTimeout("save()", 180000); 31 32 var questionCount = 1; 33 32 34 function getNewQuestion() 33 35 { … … 52 54 "<div id='answersDiv" + questionCount + "' class='answersDiv'></div>" + 53 55 "</div>"; 54 56 55 57 questionDiv.innerHTML = htmlStr; 56 58 57 59 return questionDiv; 58 60 } 59 61 60 62 function handleFocus(input) 61 63 { … … 67 69 } 68 70 } 69 71 70 72 function handleBlur(input) 71 73 { 72 74 var surveyTitle = document.getElementById('surveyTitle'); 73 75 var surveyDescription = document.getElementById('surveyDescription'); 74 76 75 77 if (input.value == "") 76 78 { 77 79 input.style.color = "gray"; 78 80 input.clicked = null; 79 81 80 82 if (input == surveyTitle) 81 83 { … … 88 90 } 89 91 } 90 92 91 93 function handleType(select) 92 94 { … … 95 97 answersDiv.answerCount = 1; 96 98 answersDiv.clicked = null; 97 99 98 100 switch (type) { 99 101 case 'mc': 100 102 answersDiv.innerHTML = ""; 101 103 addOption(select.id); 102 104 103 105 break; 104 106 case 'text': … … 124 126 125 127 } 126 127 128 129 128 130 function addOption(questionNumber) 129 131 { … … 132 134 var answerDiv = document.createElement("div"); 133 135 answerDiv.className = "answerDiv"; 134 136 135 137 var htmlStr = "<input type='text' name='q" + 136 138 questionNumber + "ans" + answerCount + "' value='Option " + answerCount + "' />"; 137 139 138 140 if (answersDiv.clicked == null) 139 141 { … … 141 143 + " class='surveyButton' onclick='addOption(" + questionNumber + ")' value='Add Option' />" + 142 144 "<input type='button' class='surveyButton' onclick='removeOption(" + questionNumber + ")' value='x' />"; 143 145 144 146 answersDiv.clicked = true; 145 147 } 146 148 147 149 answerDiv.innerHTML = htmlStr; 148 150 149 151 answerDiv.prev = answersDiv.lastAnswer; //singly linked list 150 152 answersDiv.lastAnswer = answerDiv; 151 153 152 154 answersDiv.appendChild(answerDiv); 153 155 answersDiv.answerCount++; 154 156 } 155 157 156 158 function removeOption(questionNumber) 157 159 { 158 160 var answersDiv = document.getElementById("answersDiv" + questionNumber); 159 161 160 162 if (answersDiv.lastAnswer.prev != null) 161 163 { … … 165 167 } 166 168 } 167 169 168 170 function minMax(questionNumber) 169 171 { 170 172 var answersDiv = document.getElementById("answersDiv" + questionNumber); 171 173 172 174 var answerDiv = document.createElement("div"); 173 175 174 176 answerDiv.className = "answerDiv"; 175 177 answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' name='q" + questionNumber + "ans1' />" + 176 178 "<label for='max'>Max</label><input type='text' name='q" + questionNumber + "ans2' />"; 177 179 178 180 answersDiv.appendChild(answerDiv); 179 181 } 180 182 181 183 function minMaxIncr(questionNumber) 182 184 { 183 185 var answersDiv = document.getElementById("answersDiv" + questionNumber); 184 186 185 187 var answerDiv = document.createElement("div"); 186 188 answerDiv.className = "answerDiv"; … … 188 190 "<label>Right label</label><input type='text' name='q" + questionNumber + "ans2' />" + 189 191 "<label>Scale count</label><input type='text' name='q" + questionNumber + "ans3' />"; 190 192 191 193 answersDiv.appendChild(answerDiv); 192 194 } 193 194 195 196 195 197 function addQuestion() 196 198 { 197 199 var questionsDiv = document.getElementById('questionsDiv'); 198 200 var newQuestion = getNewQuestion(); 199 201 200 202 201 203 newQuestion.prev = document.lastQuestion; … … 205 207 questionCount++; 206 208 } 207 209 208 210 function removeLastQuestion() 209 211 { 210 212 var questionsDiv = document.getElementById('questionsDiv'); 211 213 212 214 if (document.lastQuestion.prev != null) 213 215 { … … 221 223 } 222 224 } 223 224 225 225 226 function save() 227 { 228 var form = document.getElementById('survey'); 229 var questionsDiv = document.getElementById('questionsDiv'); 230 form.action = "surveycreation.php"; 231 232 /* extra time stamp */ 233 var date = new Date(); 234 var timeStamp = date.getHours() + ":" + date.getUTCMinutes(); 235 var timeStampInput = document.createElement("input"); 236 timeStampInput.name = "timeStamp"; 237 timeStampInput.value = timeStamp; 238 timeStampInput.type = "hidden"; 239 240 questionsDiv.appendChild(timeStampInput); 241 form.submit(); 242 } 243 244 226 245 </script> 227 246 <?php 228 247 } 229 248 249 private static function surveyHead($timeStamp = null) { 250 ?><div id="surveyHead"> 251 <?php 252 SurveyCreationTool::titleBox(); 253 SurveyCreationTool::saveSurvey($timeStamp); 254 SurveyCreationTool::descriptionBox(); 255 ?></div> 256 <?php 257 } 258 230 259 private static function titleBox() { 231 260 ?> 232 <input type="text" id="surveyTitle" name="surveyTitle" value="Untitled Survey" size="30" onblur="handleBlur(this)" onfocus="handleFocus(this)" /> 261 <input type="text" id="surveyTitle" name="surveyTitle" value="Untitled Survey" onblur="handleBlur(this)" onfocus="handleFocus(this)" /> 262 <?php 263 } 264 265 private static function saveSurvey($timeStamp = null) { 266 if (isset($timeStamp)) 267 echo "<div id='timeStamp'>Last saved " . $timeStamp . '</div>'; 268 ?> 269 <input id="surveySaveButton" type="button" onclick="save()" class='surveyButton' value='Save' /> 233 270 <?php 234 271 } … … 236 273 private static function descriptionBox() { 237 274 ?> 238 <textarea id="surveyDescription" rows="3" cols="80"name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)">Write a helpful description for this survey here.</textarea>275 <textarea id="surveyDescription" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)">Write a helpful description for this survey here.</textarea> 239 276 <?php 240 277 } -
Dev/trunk/css/style.css
r23 r24 78 78 } 79 79 80 #surveyHead { 81 position: relative; 82 width: 100%; 83 } 84 80 85 #surveyTitle { 86 width: 20em; 81 87 font-size: large; 82 88 color: gray; … … 89 95 #surveyDescription { 90 96 display: block; 97 width: 35em; 98 max-width: 35em; 91 99 font-family: sans-serif; 92 100 color: gray; 101 } 102 103 #timeStamp { 104 position: absolute; 105 color: gray; 106 font-size: small; 107 right: 6em; 108 top: 0; 109 line-height: 2.3em; 110 } 111 112 #surveySaveButton { 113 position: absolute; 114 top: 0; 115 right: 0; 116 width: 5em; 93 117 } 94 118 … … 124 148 .surveyButton { 125 149 126 color: gray; 150 color: #888; 151 font-weight: bold; 127 152 background-color: #fff; 128 border: 1px solid #ddd;153 border: 2px solid #aaa; 129 154 -moz-border-radius: 8px; 130 155 border-radius: 8px; 131 -moz-box-shadow: 1px 1px 1px #555;132 -webkit-box-shadow: 1px 1px 1px #555;133 box-shadow: 1px 1px 1px #555;134 156 } 135 157 136 158 .surveyButton:hover { 137 159 background-color: white; 138 color: # 333;160 color: #555; 139 161 border-color: deepskyblue; 140 162 } -
Dev/trunk/surveycreation.php
r10 r24 1 <?php require 'classes/master.php'; ?> 1 <?php require 'classes/master.php'; 2 3 if (isset($_POST['timeStamp'])) 4 $timeStamp = $_POST['timeStamp']; 5 else { 6 $timeStamp = null; 7 } 8 9 ?> 2 10 3 11 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" … … 18 26 <div id="content"> 19 27 <?php 20 new SurveyCreationTool( );28 new SurveyCreationTool(null, $timeStamp); 21 29 ?> 22 30 </div>
Note: See TracChangeset
for help on using the changeset viewer.