Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. function searchAvailability()
  2. {
  3.  
  4. var resname=document.getElementById("resNameA").value;
  5. var reslocation=document.getElementById("resLocationA").value;
  6. var rescompany="Book A Meeting Room"
  7. var resfulltext=document.getElementById("resFulltextA").value;
  8.  
  9. $.ajax({
  10. type: 'POST',
  11. url: 'booking/getavailability_search_XML.php',
  12. data: {
  13. name: encodeURIComponent(resname),
  14. location: encodeURIComponent(reslocation),
  15. company: "Book A Meeting Room",
  16. fulltext: encodeURIComponent(resfulltext),
  17. type: "a17joare" // Filter out bookings made from other applications application.
  18. // Most commonly user name of student
  19. },
  20. success: showAvailability,
  21. error: errormsg
  22. });
  23. }
  24.  
  25. function showAvailability(returnedData)
  26. {
  27.  
  28. // Fix characters in XML notation to HTML notation
  29. fixChars(returnedData);
  30.  
  31. // An XML DOM document is returned from AJAX
  32. var resultset=returnedData.childNodes[0];
  33. var output="<table class='availResults' align='center'>";
  34. var elseoutput="<h2>Inga lediga tider</h2>";
  35.  
  36. //var thead = "<th>bajs</th>";
  37. var dateSelectionFrom=new Date(document.getElementById("datepickerStart").value).valueOf();
  38. var dateSelectionTo= new Date(document.getElementById("datepickerEnd").value).valueOf();
  39.  
  40. // Iterate over all nodes in root node (i.e. resources)
  41. for (i = 0; i < resultset.childNodes.length; i++) {
  42.  
  43. // Iterate over all child nodes of that node that are resource nodes
  44. if(resultset.childNodes.item(i).nodeName=="availability"){
  45. // Retrieve data from resource nodes
  46. var avail=resultset.childNodes.item(i);
  47. var name = avail.attributes['name'].nodeValue;
  48. var dateFrom = new Date(avail.attributes['date'].nodeValue).valueOf();
  49. var dateTo = new Date(avail.attributes['dateto'].nodeValue).valueOf();
  50. // thead;
  51. if (dateFrom >=dateSelectionFrom && dateTo <= dateSelectionTo) {
  52. output+="<tr class='actiontablerow' onclick='alert(\""+avail.attributes['resourceID'].value+"\")'>";
  53. output+="<th>"+avail.attributes['name'].nodeValue+"</th>";
  54. output+="<td>"+avail.attributes['location'].nodeValue+"</td>";
  55. output+="<td>"+avail.attributes['size'].nodeValue+"</td>";
  56. output+="<td>"+avail.attributes['cost'].nodeValue+"</td>";
  57. output+="<td>"+avail.attributes['date'].nodeValue+"</td>";
  58. output+="<td>"+avail.attributes['dateto'].nodeValue+"</td>";
  59. output+="</tr>";
  60. }
  61. }
  62. }
  63.  
  64. output+="</table>"
  65. var div=document.getElementById("OutputDivSearchA");
  66. div.innerHTML=output;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement