| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <head> |
| <title></title> |
| </head> |
| <body> |
| |
| <b> Register Host Description </b> |
| <br/> |
| |
| Host Name : <input type="text" name="hostName" id="hostName1" size="75"> |
| <br/> |
| Host Address : <input type="text" name="hostAddress" id="hostAddress1" size="75"> |
| <br/> |
| Host Type : <select name="drop1"> |
| <option selected="true">Local</option> |
| <option>Globus</option> |
| </select> |
| <br/> |
| <div id="div"> |
| Host Endpoint : <input type="text" name="hostEndpoint" id="hostEndpoint1" size="75"> |
| <br/> |
| Gatekeeper Endpoint : <input type="text" name="gatekeeperEndpoint" id="gatekeeperEndpoint1" size="75"> |
| <br/> |
| </div> |
| |
| <button name="btn2">Save Host</button> |
| |
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script> |
| <script> |
| function xmlToString(xml) { |
| var xmlData = $(xml); |
| var xmlString; |
| if (window.ActiveXObject) { |
| xmlString = xmlData.xml; |
| } else { |
| var oSerializer = new XMLSerializer(); |
| xmlString = oSerializer.serializeToString(xmlData[0]); |
| } |
| console.log(xmlString); |
| return xmlString; |
| } |
| |
| $(document).ready(function(){ |
| $(window).load(function () { |
| $("div").hide(); |
| }); |
| |
| $("select[name='drop1']").change(function() { |
| //alert($(this).val()); |
| if("Local" == $(this).val()) { |
| $("div").hide(); |
| } else { |
| $("div").show(); |
| } |
| }); |
| |
| $('[name="btn2"]').click(function(){ |
| //alert($(this).val()); |
| var hostName = $("#hostName1").val(); |
| var hostAddress = $("#hostAddress1").val(); |
| var hostEndpoint = $("#hostEndpoint1").val(); |
| alert(hostEndpoint); |
| alert(hostEndpoint); |
| alert("hostEndpoint null :" + hostEndpoint == null); |
| alert("hostEndpoint empty :" + hostEndpoint == ""); |
| var gatekeeperEndpoint = $("#gatekeeperEndpoint1").val(); |
| var xml = $('<type:hostDescription xmlns:type="http://schemas.airavata.apache.org/gfac/type"><type:hostName>' + hostName + '</type:hostName><type:hostAddress>' + hostAddress + '</type:hostAddress></type:hostDescription>'); |
| |
| var xmlData= $(xml); |
| var xmlString; |
| if (window.ActiveXObject){ |
| xmlString = xmlData.xml; |
| } else { |
| var oSerializer = new XMLSerializer(); |
| xmlString = oSerializer.serializeToString(xmlData[0]); |
| } |
| console.log(xmlString); |
| |
| alert(hostName); |
| alert(hostAddress); |
| alert(xmlString); |
| |
| // if ($("select[name='drop1']").val() == "Local") { |
| if (("" == hostEndpoint) || ("" == gatekeeperEndpoint)) { |
| alert("if Case"); |
| $.ajax({ |
| headers: { |
| Accept : "text/plain; charset=utf-8" |
| }, |
| /*beforeSend: function(xhr, s) { |
| xhr.setRequestHeader("Accept-Encoding" ,""); |
| xhr.setRequestHeader("Content-Type", "text/xml"); |
| },*/ |
| |
| type: "POST", |
| url: "http://localhost:7080/airavata-registry-rest-services/registry/api/hostdescriptor/save/test", |
| data: { |
| hostName: hostName, |
| hostAddress: hostAddress |
| } |
| }).done(function( msg ) { |
| alert( "Data Saved: " + msg ); |
| }); |
| } else { |
| alert("end Case"); |
| $.ajax({ |
| headers: { |
| Accept : "text/plain; charset=utf-8" |
| }, |
| /*beforeSend: function(xhr, s) { |
| xhr.setRequestHeader("Accept-Encoding" ,""); |
| xhr.setRequestHeader("Content-Type", "text/xml"); |
| },*/ |
| |
| type: "POST", |
| url: "http://localhost:7080/airavata-registry-rest-services/registry/api/hostdescriptor/save/test", |
| data: { |
| hostName: hostName, |
| hostAddress: hostAddress, |
| hostEndpoint : hostEndpoint, |
| gatekeeperEndpoint : gatekeeperEndpoint |
| } |
| }).done(function( msg ) { |
| alert( "Data Saved: " + msg ); |
| }); |
| } |
| |
| }); |
| }); |
| </script> |
| |
| </body> |
| </html> |