Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. function getReservationList() {
  2. $.ajax({
  3. cache: false,
  4. url: wcfServiceUrl + "GetReservations",
  5. data: "{}",
  6. type: "GET",
  7. contentType: "application/javascript",
  8. dataType: "jsonp",
  9. error: function (errorDetails) {
  10. alert("GetReservations error!");
  11. console.log(errorDetails);
  12. },
  13. success: function (data) {
  14. if (data != null) {
  15. var deserializedData = JSON.parse(data.DataResponse);
  16. console.log(deserializedData);
  17. reservationList = deserializedData;
  18.  
  19. }
  20. else {
  21. console.log(data.message);
  22. alert(data.Message);
  23. }
  24. }
  25. });
  26. };
  27.  
  28. ____________________________________________________________________________________
  29.  
  30.  
  31.  
  32. var reservationList;
  33.  
  34. $(document).ready(function () {
  35. getReservationList();
  36.  
  37. console.log(reservationList);
  38.  
  39. var coachHTML = "";
  40.  
  41. var sortedCoaches = new Object();
  42.  
  43. for (var i = 0; i < tableData.length; i++) {
  44. sortedCoaches[tableData[i].Coach] = new Array();
  45. }
  46.  
  47. for (var i = 0; i < tableData.length; i++) {
  48. sortedCoaches[tableData[i].Coach].push(tableData[i]);
  49. }
  50.  
  51. console.log(sortedCoaches);
  52.  
  53. var coachList = Object.keys(sortedCoaches);
  54. console.log(coachList);
  55.  
  56. for (var i = 0; i < coachList.length; i++) {
  57. coachHTML += "<div data-role='collapsible'><h3><div style='float:left'>Coach " + coachList[i] + "</div><div style='float: right'>" + sortedCoaches[coachList[i]].length + " " + "Seats Taken" + "</div></h3><p>";
  58. coachHTML += "<table class='reservationsTableCSS'>" +
  59. "<thead >" +
  60. "<tr class='ui-bar-b schedule_row '>" +
  61. "<th>Coach</th>" +
  62. "<th>Seat</th>" +
  63. "<th>Class</th>" +
  64. "<th>Leg</th>" +
  65. "<th>Notes</th>" +
  66. "</tr>" +
  67. "</thead>" +
  68. "<tbody>";
  69.  
  70. for (var s = 0; s < sortedCoaches[coachList[i]].length; s++) {
  71. coachHTML += "<tr id='tablerow'>" +
  72.  
  73. "<td> " + sortedCoaches[coachList[i]][s].Coach + "</td>" +
  74. "<td> " + sortedCoaches[coachList[i]][s].Seat + "</td>" +
  75. "<td> " + sortedCoaches[coachList[i]][s].Class + "</td>" +
  76. "<td> " + sortedCoaches[coachList[i]][s].Leg + "</td>" +
  77. "<td> " + sortedCoaches[coachList[i]][s].Notes + "</td>";
  78.  
  79. coachHTML += "</tr>";
  80. }
  81. coachHTML += "</tbody></table></p></div>";
  82. }
  83. $(".reservationstable").html(coachHTML);
  84. $(".reservationstable").collapsibleset("refresh");
  85.  
  86.  
  87. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement