Guest User

Untitled

a guest
Jan 6th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. Hide Expand Copy Code
  2. //Webapi call - To load info status.
  3. function LoadinfoStatus() {
  4. $.ajaxSetup({
  5. beforeSend: function (xhr) {
  6. xhr.setRequestHeader('x-api-key', '9024024A-024-485C024-6BC2024DA');
  7. }
  8. });
  9.  
  10. $.ajax({
  11. type: "GET",
  12. url: "https://mywebsites.net/version1/info/494",
  13.  
  14. contentType: "application/json; charset=utf-8",
  15.  
  16. dataType: "json",
  17. success: function (data) {
  18. // alert(JSON.stringify(data));
  19. $("#DIV").html('');
  20. var DIV = '';
  21.  
  22. //Function to get DateFormat
  23. function getFormattedDate(date) {
  24. // debugger;
  25. var inputdate = new Date(date);
  26. var currentdate = new Date();
  27.  
  28. var strTime = getFormattedTime(inputdate);
  29. var rngStrTime = getFormattedTime(add_minutes(inputdate, 5));
  30.  
  31. if (inputdate > currentdate) {
  32. return inputdate.getDate() + '/' + (inputdate.getMonth() == 0 ? 12 : inputdate.getMonth()) + " " + strTime + " - " + rngStrTime;
  33. }
  34. else {
  35. return strTime + " - " + rngStrTime;
  36. //return day + "/" + month + " - " + strTime;
  37. }
  38. }
  39.  
  40. var add_minutes = function (dt, minutes) {
  41. return new Date(dt.getTime() + minutes * 60000);
  42. }
  43.  
  44. function getFormattedTime(inputdate) {
  45. var day = inputdate.getDate();
  46. var month = inputdate.getMonth() + 1;
  47. var hours = inputdate.getHours();
  48. var minutes = inputdate.getMinutes();
  49. var ampm = hours >= 12 ? 'pm' : 'am';
  50. hours = hours % 12;
  51. hours = hours ? hours : 12;
  52. minutes = minutes < 10 ? '0' + minutes : minutes;
  53.  
  54. return hours + ':' + minutes + ampm;
  55. }
  56.  
  57.  
  58. $.each(data, function (i, item) {
  59.  
  60.  
  61.  
  62. var rows = "<tr ' " + (item.Count > 100 ? "data-id='" + item.orderId + "'" : "") + (item.TakeupType == "Cancelled" ? "style='background-color: gray; color: white'" : "") + " align= 'center' > " +
  63. "" + "" + "" + "" +
  64. "" + item.user.firstName + " " + item.user.lastName.charAt(0) + "." + "" +
  65. "" + item.TakeupType + "" +
  66. "" + (item.Count == undefined ? "$" + " " + 0 : "$" + " " + item.Count) + "" +
  67. "" + getFormattedDate(item.TakeupTimeUtc) + "" +
  68. "= 100 ? "style='background-color: darkorange; color: white'>***" : ">") + "" +
  69. "";
  70.  
  71. var $tbody = $('tblOrders tbody');
  72.  
  73. $('#tblOrders').append(rows);
  74. }); //End of foreach Loop
  75.  
  76.  
  77. registerEvents();
  78. // console.log(data);
  79. }, //End of AJAX Success function
  80.  
  81. failure: function (data) {
  82. alert(data.responseText);
  83. }, //End of AJAX failure function
  84. error: function (data) {
  85. alert(data.responseText);
  86. } //End of AJAX error function
  87.  
  88. });
  89. }
Add Comment
Please, Sign In to add comment