[146] | 1 | /* |
---|
| 2 | * To change this template, choose Tools | Templates |
---|
| 3 | * and open the template in the editor. |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | function IsItemSelected(check, target) { |
---|
| 7 | if (check.value) { |
---|
| 8 | target.disabled = false; |
---|
| 9 | } |
---|
| 10 | else { |
---|
| 11 | target.disabled = true; |
---|
| 12 | } |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | function IsCheckEnabled(check, target) { |
---|
| 16 | if (check.checked) { |
---|
| 17 | target.disabled = false; |
---|
| 18 | this.removeClass(target, "dis"); |
---|
| 19 | |
---|
| 20 | } |
---|
| 21 | else { |
---|
| 22 | target.disabled = true; |
---|
| 23 | this.addClass(target, "dis"); |
---|
| 24 | } |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | function SubmitToolbox() { |
---|
| 28 | document.forms['toolbox'].submit(); |
---|
| 29 | } |
---|
| 30 | |
---|
[152] | 31 | // Class manipulation |
---|
[146] | 32 | |
---|
[152] | 33 | function hasClass(ele,cls) { |
---|
[154] | 34 | if (ele.className) |
---|
| 35 | return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); |
---|
[152] | 36 | } |
---|
| 37 | |
---|
| 38 | function addClass(ele,cls) { |
---|
| 39 | if (!this.hasClass(ele,cls)) ele.className += " "+cls; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | function removeClass(ele,cls) { |
---|
| 43 | if (hasClass(ele,cls)) { |
---|
| 44 | var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); |
---|
| 45 | ele.className=ele.className.replace(reg,' '); |
---|
| 46 | } |
---|
| 47 | } |
---|
[146] | 48 | |
---|
[152] | 49 | //new scripts! |
---|
| 50 | //start here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 51 | |
---|
| 52 | function selectStep(uid) { |
---|
[154] | 53 | var nodes = document.getElementById("seqContent").childNodes; |
---|
| 54 | for (var i = 0; i < nodes.length; i++) { //loop through childNodes. Skip first node (whitespace) |
---|
| 55 | //debugger; |
---|
| 56 | if (hasClass(nodes[i], "displayStep")) { //check if current childNode is a displayStep, not divider or text. |
---|
| 57 | if (nodes[i].id == uid) { |
---|
| 58 | addClass(nodes[i], "selected"); |
---|
| 59 | } |
---|
| 60 | else { |
---|
| 61 | removeClass(nodes[i], "selected"); |
---|
| 62 | } |
---|
| 63 | } |
---|
[153] | 64 | } |
---|
[154] | 65 | |
---|
| 66 | // Update selected step field with uid of currently selected step. |
---|
| 67 | var selectedStepField = document.getElementById("selectedStepField"); |
---|
| 68 | selectedStepField.value = uid; |
---|
| 69 | |
---|
[152] | 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
[146] | 73 | /* |
---|
[152] | 74 | * This function allows for simple use of AJAX requests. |
---|
| 75 | * Calling format: |
---|
| 76 | * |
---|
| 77 | * var c[] = "uid=123"; |
---|
| 78 | * var c[] = "name=tschipper"; |
---|
| 79 | * var u = "getResult.php"; |
---|
| 80 | * newAjaxRequest(c, u, function(xml) { |
---|
| 81 | * <!--Do something--> |
---|
| 82 | * }); |
---|
| 83 | * |
---|
| 84 | * It is of course also possible to refer to an external function instead of |
---|
| 85 | * defining function(xml){} in the call itself, as below: |
---|
| 86 | * |
---|
| 87 | * newAjaxRequest(c, u, externalFunction(xml)); |
---|
| 88 | */ |
---|
[146] | 89 | |
---|
[152] | 90 | function newAjaxRequest(c, u, cb) { |
---|
| 91 | |
---|
| 92 | var xml; |
---|
| 93 | var content = c; //an array of strings, in "key=value" format. |
---|
| 94 | // assign a compatible request format |
---|
| 95 | if (window.XMLHttpRequest) { //Not IE5, IE6 |
---|
| 96 | xml = new XMLHttpRequest(); |
---|
| 97 | } |
---|
| 98 | else { //IE5, IE6 |
---|
| 99 | xml = new ActiveXObject("Microsoft.XMLHTTP"); |
---|
| 100 | } |
---|
| 101 | // subscribe the callback function to a response event |
---|
| 102 | xml.onreadystatechange = function() { |
---|
| 103 | if (xml.readyState == 4 && xml.status == 200) { |
---|
| 104 | //alert("Received!"); |
---|
| 105 | cb(xml); |
---|
| 106 | } |
---|
| 107 | }; |
---|
| 108 | // initialize XMLRequest |
---|
| 109 | xml.open("POST", u, true); |
---|
| 110 | xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
| 111 | var contentString = ""; |
---|
| 112 | //iterate through parameters passed in variable c |
---|
| 113 | if (typeof(content)=='object'&&(input instanceof Array)) { // parameters were passed as an array of key=value strings |
---|
| 114 | for (var i = 0; i < content.length; i++) { |
---|
| 115 | contentString += content[i]; |
---|
| 116 | if (i != (content.length - 1)) { |
---|
| 117 | contentString += "&"; |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | else { // single parameter or string already formatted by calling function |
---|
| 122 | contentString = content; |
---|
| 123 | } |
---|
| 124 | // finally send the formatted request |
---|
| 125 | //alert(contentString); |
---|
| 126 | xml.send(contentString); |
---|
| 127 | } |
---|
[153] | 128 | |
---|
[154] | 129 | |
---|
[153] | 130 | /* |
---|
| 131 | * ajaxStepRequest gets the markup for displaying a step in the sequencer from returnStep.php |
---|
| 132 | * Using ajax principle allows for editing of pipeline without constantly refreshing the page. |
---|
| 133 | */ |
---|
| 134 | |
---|
[154] | 135 | function ajaxStepRequest(UIDS) { |
---|
| 136 | var c = "uids="+UIDS; |
---|
[153] | 137 | var u = "returnStep.php"; |
---|
| 138 | newAjaxRequest(c, u, function(result) { |
---|
[154] | 139 | document.getElementById("seqContent").innerHTML = result.responseText; |
---|
[153] | 140 | }); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | function ajaxInfoRequest(id, el) { |
---|
| 144 | var uid = id; |
---|
| 145 | var c = "uid="+uid; |
---|
| 146 | var u = "getInfo.php"; |
---|
| 147 | newAjaxRequest(c, u, function(result) { |
---|
| 148 | el.innerHTML = result.responseText; |
---|
| 149 | }); |
---|
| 150 | } |
---|
[152] | 151 | |
---|
[146] | 152 | |
---|
[153] | 153 | |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | |
---|
[152] | 158 | function drawSteps() { |
---|
[153] | 159 | var content = document.getElementById("seqContent"); |
---|
| 160 | var pipeline = document.getElementById("pipelineStringField").value; |
---|
[154] | 161 | pipeline = pipeline.replace(/,/g , ",divider,"); //regex search for commas, global (repeat), to represent them with visual dividers. |
---|
| 162 | ajaxStepRequest(pipeline); |
---|
[146] | 163 | } |
---|
| 164 | |
---|
[153] | 165 | function updatePipelineHidden (pipelineString) { |
---|
| 166 | |
---|
[154] | 167 | } |
---|