- Timestamp:
- 11/23/11 17:15:20 (13 years ago)
- Location:
- Dev/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/pipelineSequencer.php
r164 r166 1 1 <?php 2 3 2 /* 4 3 * To change this template, choose Tools | Templates … … 27 26 $stringPipelineUpdated = ""; 28 27 $numberOfSteps = 0; 29 28 30 29 if (is_array($this->loadedSession->pipeline)) { 31 30 foreach ($this->loadedSession->pipeline as $object) { 32 31 $stringPipeline .= "$object->uid,"; 33 $stringPipelineType .= get_class($object) .",";32 $stringPipelineType .= get_class($object) . ","; 34 33 $stringPipelineUpdated .= "1,"; 35 34 $numberOfSteps++; 36 37 35 } 38 $stringPipeline = rtrim($stringPipeline, ",");39 $stringPipelineType = rtrim($stringPipelineType, ",");40 $stringPipelineUpdated = rtrim($stringPipelineUpdated, ",");41 42 36 } else { 43 37 $stringPipeline = $this->loadedSession->pipeline; … … 69 63 <input type="hidden" name="pipelineUpDated" id="pipelineUpdatedField" value="<?php echo $stringPipelineUpdated; ?>" /> 70 64 <input type="hidden" name="numSteps" id="numSteps" value="<?php echo $numberOfSteps; ?>" /> 65 <input type="hidden" name="session" id="sessionField" value="<?php echo $this->loadedSession->uid; ?>" /> 71 66 </div> 72 67 </fieldset> … … 108 103 if (isset($_SESSION['updateNeeded'])) { // user has performed an operation that flags session to be reloaded from DB, or is first load of page for that session 109 104 $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession)); 110 105 111 106 if (count($sessionResults) > 0) { 112 107 $_SESSION['localSessionCopy'] = $sessionResults[0]; … … 116 111 } 117 112 } 118 //var_dump($_SESSION['localSessionCopy']); 119 113 120 114 if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { 121 115 122 116 $this->loadedSession = $_SESSION['localSessionCopy']; 123 117 unset($_SESSION['updateNeeded']); 124 118 } 125 126 119 } 127 120 … … 180 173 } 181 174 182 183 175 } 184 176 ?> -
Dev/trunk/createObject.php
r165 r166 8 8 } 9 9 else { 10 die ("Invalid arguments passed!");10 //die ("Invalid arguments passed!"); 11 11 } 12 12 } 13 13 else { 14 die ("No arguments passed!");14 //die ("No arguments passed!"); 15 15 } 16 16 … … 21 21 } 22 22 else { 23 die ("Invalid creator, make sure you are logged in!");23 //die ("Invalid creator, make sur0e you are logged in!"); 24 24 } 25 25 … … 40 40 break; 41 41 default: 42 die ("Variable \$otc: $otc does not match a compatible object type!");42 //die ("Variable \$otc: $otc does not match a compatible object type!"); 43 43 break; 44 44 } -
Dev/trunk/js/sequencerScripts.js
r165 r166 25 25 } 26 26 27 /* 28 function SubmitToolbox() { 29 document.forms['toolbox'].submit(); 30 } 31 */ 27 function removeNL(s){ 28 return s.replace(/[\n\r\t]/g,""); 29 } 30 32 31 function SubmitToolbox(type) { 33 32 var c = "objectToCreate="+type; … … 39 38 40 39 newAjaxRequest(c, u, function(result){ 41 var resultUid = result.responseText; 42 console.log(resultUid); 43 console.log("lol"); 44 console.log(resultUid); 45 pipeline.value += ","+resultUid; 46 pipelineType += ","+type; 47 pipelineUpdated += ",0"; 40 var resultUid = removeNL(result.responseText); 41 //resultUid.replace("\n","").replace("\r",""); 42 43 pipeline.value += resultUid+","; 44 pipelineType.value += type+","; 45 pipelineUpdated.value += "0,"; 48 46 updateSequencer(); 49 47 }, a); … … 74 72 var nodes = document.getElementById("seqContent").childNodes; 75 73 for (var i = 0; i < nodes.length; i++) { //loop through childNodes. Skip first node (whitespace) 76 //debugger;77 74 if (hasClass(nodes[i], "displayStep")) { //check if current childNode is a displayStep, not divider or text. 78 75 if (nodes[i].id == uid) { … … 96 93 } 97 94 98 99 /*100 * This function allows for simple use of AJAX requests.101 * Calling format:102 *103 * var c[] = "uid=123";104 * var c[] = "name=tschipper";105 * var u = "getResult.php";106 * newAjaxRequest(c, u, function(xml) {107 * <!--Do something-->108 * });109 *110 * It is of course also possible to refer to an external function instead of111 * defining function(xml){} in the call itself, as below:112 *113 * newAjaxRequest(c, u, externalFunction(xml));114 */115 116 95 function newAjaxRequest(c, u, cb, async) { 117 96 … … 145 124 } 146 125 } 147 else { 126 else { // single parameter or string already formatted by calling function 148 127 contentString = content; 149 128 } 150 129 // finally send the formatted request 151 //alert(contentString);152 130 xml.send(contentString); 153 131 } … … 183 161 var pipeline = document.getElementById("pipelineStringField").value; 184 162 var pipelineTypes = document.getElementById("pipelineTypeField").value; 185 pipeline = pipeline.replace(/,/g , ",divider,"); //regex search for commas, global (repeat), to represent them with visual dividers. 186 pipelineTypes = pipelineTypes.replace(/,/g, ",divider,"); 187 ajaxStepRequest(pipeline, pipelineTypes); 163 var numSteps = document.getElementById("numSteps").value; 164 if (numSteps > 0) { 165 pipeline = pipeline.replace(/,/g , ",divider,"); //regex search for commas, global (repeat), to represent them with visual dividers. 166 pipelineTypes = pipelineTypes.replace(/,/g, ",divider,"); 167 ajaxStepRequest(pipeline, pipelineTypes); 168 } 188 169 } 189 170 … … 192 173 var plTypeString = document.getElementById("pipelineTypeField").value; 193 174 var plUpdatedString = document.getElementById("pipelineUpdatedField").value; 194 195 var pl = plString.split(","); 196 var plType = plTypeString.split(","); 197 var plUpdated = plUpdatedString.split(","); 198 //console.log(plUpdated); 199 175 176 177 var pl = stringToArray(plString, ","); 178 var plType = stringToArray(plTypeString, ","); 179 var plUpdated = stringToArray(plUpdatedString, ","); 180 181 var count = pl.length; 182 183 document.getElementById("numSteps").value = count; 200 184 201 185 for (var i = 0; i < pl.length; i++) { // loop through pipeline contents … … 204 188 var seqContent = document.getElementById("seqContent"); 205 189 var element = document.getElementById(pl[i]); 206 var nextElement = element.nextSibling; 190 if (element == null) { 191 element = document.createElement("div"); 192 element.name = "placeholder"; 193 seqContent.appendChild(element); 194 } 195 if (element.nextSibling) { 196 var nextElement = element.nextSibling; 197 } 198 else { 199 var nextElement = document.createElement("div"); 200 nextElement.name = "placeholderNext"; 201 seqContent.appendChild(nextElement); 202 } 207 203 208 204 // now request a new step representation and insert it after previousElement 209 205 var holderDiv = document.createElement("div"); 210 206 var requestString = "uids="+pl[i]; 211 var resultText; 207 208 if (plType[i]) { 209 requestString += "&types="+plType[i]; 210 } 211 // globally declare newDiv so it can be passed to the updateDividers function 212 var newDiv; 213 212 214 newAjaxRequest(requestString, "returnStep.php", function(result) { 213 holderDiv.innerHTML = result.responseText; 215 holderDiv.innerHTML = result.responseText; 216 newDiv = holderDiv.childNodes[1]; 217 seqContent.replaceChild(newDiv, element); 218 if (nextElement.name == "placeholderNext") { 219 seqContent.removeChild(nextElement); 220 } 221 plUpdated[i] = "1"; 214 222 }, false); 215 223 216 //debugger; 217 while (holderDiv.childNodes.length == 1) { 218 // wait for response 219 } 220 var newDiv = holderDiv.childNodes[1]; 221 seqContent.replaceChild(newDiv, element); 222 plUpdated[i] = "1"; 223 // ALTERNATIVE METHOD TO REPLACECHILD!!! 224 //seqContent.removeChild(element); 225 //seqContent.insertBefore(newDiv, nextElement); 226 227 228 } 229 else { 230 231 } 232 } 233 234 // afterwards, convert the arrays back to strings 235 var newUpdatedString = ""; 236 237 for (var i = 0; i < plUpdated.length; i++) { 238 newUpdatedString += plUpdated[i]+","; 239 } 240 241 if (newUpdatedString.substring(newUpdatedString.length - 1) == ",") { // remove comma at the end of string! 242 newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1); 243 244 } 224 225 // ALTERNATIVE METHOD TO REPLACECHILD!!! 226 //seqContent.removeChild(element); 227 //seqContent.insertBefore(newDiv, nextElement); 228 229 // Now check if dividers are necessary. 230 231 //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!"); 232 updateDividers(newDiv); 233 } 234 } 235 236 // afterwards, convert the arrays back to strings and set to appropriate fields 237 var newUpdatedString = arrayToString(plUpdated, ","); 245 238 document.getElementById("pipelineUpdatedField").value = newUpdatedString; 246 239 247 240 } 241 242 243 244 245 246 247 function updateDividers (element) { 248 var seqContent = document.getElementById("seqContent"); 249 250 if (element.nextSibling){ 251 var nextElement = element.nextSibling; 252 } 253 if (element.previousSibling) { 254 var previousElement = element.previousSibling; 255 } 256 257 if (nextElement){ 258 if (!hasClass(nextElement, "divider")) { 259 var holderDiv = document.createElement("div"); 260 newAjaxRequest("uids=divider&types=divider", "returnStep.php", function(result) { 261 holderDiv.innerHTML = result.responseText; 262 var newDivider = holderDiv.childNodes[1]; 263 seqContent.insertBefore(newDivider, nextElement); 264 }, false); 265 } 266 } 267 268 if (previousElement){ 269 if (!hasClass(previousElement, "divider")) { 270 var holderDiv = document.createElement("div"); 271 newAjaxRequest("uids=divider&types=divider", "returnStep.php", function(result) { 272 holderDiv.innerHTML = result.responseText; 273 var newDivider = holderDiv.childNodes[1]; 274 seqContent.insertBefore(newDivider, element); 275 }, false); 276 } 277 } 278 279 } 280 281 282 283 284 248 285 249 286 function savePipeline() { 250 287 var answer = confirm("Save changes to pipeline?"); 251 288 if (answer) { 252 newAjaxRequest("", "savesession.php", function(){}, false); 253 alert("Saved!"); 289 var pipeline = document.getElementById("pipelineStringField").value; 290 pipeline = pipeline.slice(0, pipeline.length - 1); 291 var types = document.getElementById("pipelineTypeField").value; 292 types = types.slice(0, types.length - 1); 293 var session = document.getElementById("sessionField").value; 294 var requestString = "uids="+pipeline+"&types="+types+"&sessionUid="+session; 295 //console.log(requestString); 296 297 298 var success; 299 newAjaxRequest(requestString, "savesession.php", function(result){ 300 success = result.responseText; 301 }, false); 302 console.log(success); 254 303 } 255 304 } … … 268 317 var plUpdatedString = document.getElementById("pipelineUpdatedField").value; 269 318 270 var pl = plString.split(","); 271 var plType = plTypeString.split(","); 272 var plUpdated = plUpdatedString.split(","); 273 274 319 320 var pl = stringToArray(plString, ","); 321 var plType = stringToArray(plTypeString, ","); 322 var plUpdated = stringToArray(plUpdatedString, ","); 275 323 276 324 // set the targeted element's tag for "Needs updating" 277 for (var i = 0; i < pl.length; i++) { 278 if (pl[i] == uid) { 279 plUpdated[i] = 0; 280 } 281 } 325 plUpdated[pl.indexOf(uid)] = "0"; 282 326 283 327 // then rewrite the content strings and set them to the appropriate fields 284 285 var newUpdatedString = ""; 286 for (var i = 0; i < pl.length; i++) { 287 newUpdatedString += plUpdated[i]+","; 288 } 289 if (newUpdatedString.substring(newUpdatedString.length-1) == ",") { 290 newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1); 291 } 292 293 328 var newUpdatedString = arrayToString(plUpdated, ","); 294 329 document.getElementById("pipelineUpdatedField").value = newUpdatedString; 295 //alert("OOD set"); 296 } 330 } 331 332 function stringToArray(s, c) { 333 var a = s.split(c); 334 for (var i = 0; i < a.length; i++) { // remove empty items 335 if (a[i] == "") { 336 a.splice(i, 1); 337 i--; 338 } 339 } 340 return a; 341 } 342 343 function arrayToString(a, c) { 344 var s = ""; 345 for (var i = 0; i < a.length; i++) { 346 if (a[i] != "") { 347 s += a[i]+c; 348 } 349 } 350 return s; 351 } -
Dev/trunk/savesession.php
r164 r166 3 3 require 'classes/master.php'; //should be at top of every page 4 4 5 $session = $_SESSION['localSessionCopy']; 6 $dbi = new DatabaseInterface(); 7 $dbi->set($session); 5 if (isset($_POST['uids']) && isset($_POST['types']) && isset($_POST['sessionUid'])) { 6 if (!empty($_POST['uids']) && !empty($_POST['types']) && !empty($_POST['sessionUid'])) { 7 // user has passed a pipeline/type string from javascript in order to save the session. 8 $pl = explode(",", $_POST['uids']); 9 $t = explode(",", $_POST['types']); 8 10 9 redirect('pipelineEditor.php'); 11 $sessionUid = $_POST['sessionUid']; 12 //var_dump($t); 13 $dbi = new DatabaseInterface(); 14 $session_results = $dbi->get("Session", array("uid" => $sessionUid)); 15 if (count($session_results) > 0) { 16 $session = $session_results[0]; 17 } else { 18 echo "!!!!!!!!!!!!!!!!!!!!!!NO SESSION FOUND!!!!!!!!!!!!!!!!!!!!"; 19 die(); 20 } 21 if (count($pl) == count($t)) { 22 $count = count($pl); 23 } else { 24 echo "!!!!!!!!!!!!!!!!!NON MATCHING ARGUMENTS PASSED!!!!!!!!!!!!!!!"; 25 die(); 26 } 27 for ($i = 0; $i < count($pl); $i++) { 28 $results = $dbi->get($t[$i], array("uid" => $pl[$i])); 29 if (count($results) > 0) { 30 $result = $results[0]; 31 } 32 $session->pipeline[] = $result; 33 } 34 35 $dbi->set($session); 36 echo "true"; 37 } 38 } 10 39 ?> -
Dev/trunk/selectSession.php
r163 r166 22 22 // make new session! 23 23 unset($matching); 24 $session = new Session(null, $_POST['newSessionName'], $_SESSION['username'], new DateTime(), null, null); 24 $creators = $dbi->get("User", array("username"=>$_SESSION['username'])); 25 $creator = $creators[0]; 26 $session = new Session(null, $_POST['newSessionName'], $creator, new DateTime(), null, null); 25 27 $dbi->set($session); 26 28 } else {
Note: See TracChangeset
for help on using the changeset viewer.