/* * To change this template, choose Tools | Templates * and open the template in the editor. */ function IsItemSelected(check, target) { if (check.value) { target.disabled = false; } else { target.disabled = true; } } function IsCheckEnabled(check, target) { if (check.checked) { target.disabled = false; this.removeClass(target, "dis"); } else { target.disabled = true; this.addClass(target, "dis"); } } function SubmitToolbox() { document.forms['toolbox'].submit(); } // Class manipulation function hasClass(ele,cls) { return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); } function addClass(ele,cls) { if (!this.hasClass(ele,cls)) ele.className += " "+cls; } function removeClass(ele,cls) { if (hasClass(ele,cls)) { var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); ele.className=ele.className.replace(reg,' '); } } //new scripts! //start here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! function selectStep(uid) { document.getElementById(uid).addClass("selected"); var selectedInfo = document.getElementById("selectedStepField"); if (selectedInfo == null) { // This is the first time a step is selected after a reload of the page, therefore a hidden input field is not yet present. selectedInfo = document.createElement("input") selectedInfo.setAttribute("type","hidden"); selectedInfo.setAttribute("id","selectedStepField"); selectedInfo.setAttribute("value",uid); var hiddenInputFields = document.getElementById("hiddenInputs"); hiddenInputFields.appendChild(selectedInfo); } else { // There already exists a hidden input field with id selectedStepField, therefore we only change the value of this field. var hiddenInput = document.getElementById("selectedStepField"); hiddenInput.value = uid; } } /* * This function allows for simple use of AJAX requests. * Calling format: * * var c[] = "uid=123"; * var c[] = "name=tschipper"; * var u = "getResult.php"; * newAjaxRequest(c, u, function(xml) { * * }); * * It is of course also possible to refer to an external function instead of * defining function(xml){} in the call itself, as below: * * newAjaxRequest(c, u, externalFunction(xml)); */ function newAjaxRequest(c, u, cb) { var xml; var content = c; //an array of strings, in "key=value" format. // assign a compatible request format if (window.XMLHttpRequest) { //Not IE5, IE6 xml = new XMLHttpRequest(); } else { //IE5, IE6 xml = new ActiveXObject("Microsoft.XMLHTTP"); } // subscribe the callback function to a response event xml.onreadystatechange = function() { if (xml.readyState == 4 && xml.status == 200) { //alert("Received!"); cb(xml); } }; // initialize XMLRequest xml.open("POST", u, true); xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var contentString = ""; //iterate through parameters passed in variable c if (typeof(content)=='object'&&(input instanceof Array)) { // parameters were passed as an array of key=value strings for (var i = 0; i < content.length; i++) { contentString += content[i]; if (i != (content.length - 1)) { contentString += "&"; } } } else { // single parameter or string already formatted by calling function contentString = content; } // finally send the formatted request //alert(contentString); xml.send(contentString); } /* * ajaxStepRequest gets the markup for displaying a step in the sequencer from returnStep.php * Using ajax principle allows for editing of pipeline without constantly refreshing the page. */ function ajaxStepRequest(UID) { var c = "uid="+UID; var u = "returnStep.php"; newAjaxRequest(c, u, function(result) { var newDiv = document.createElement("div"); newDiv.innerHTML = result.responseText; document.getElementById("seqContent").appendChild(newDiv); }); } function ajaxInfoRequest(id, el) { var uid = id; var c = "uid="+uid; var u = "getInfo.php"; newAjaxRequest(c, u, function(result) { el.innerHTML = result.responseText; }); } function drawSteps() { var content = document.getElementById("seqContent"); var pipeline = document.getElementById("pipelineStringField").value; var copy = pipeline; pipeline = copy.split(","); // then do an xmlhttp request for each step to be added to the sequencer var numberOfSteps = pipeline.length; for (var i = 0; i < numberOfSteps; i++) { ajaxStepRequest(pipeline[i]); if (i < (numberOfSteps-1)) { ajaxStepRequest("divider"); } } } function updatePipelineHidden (pipelineString) { }