fork download
  1.  
  2.  
  3. function setTable(table) {
  4. if (getRuleCategory() == 'ANM') {
  5. anm_table = table;
  6. } else if (getRuleCategory() == 'VAF') {
  7. vaf_table = table;
  8. } else if (getRuleCategory() == 'DISCOUNT') {
  9. discount_table = table;
  10. }
  11. }
  12.  
  13. $("#seach-form").submit(function(e) {
  14.  
  15. var table = getTable();
  16.  
  17. e.preventDefault();
  18.  
  19. if (!validateOrigin() || !validateDestination()) {
  20. $("#myModal").modal('toggle');
  21. return;
  22. }
  23.  
  24. $('#searchResults').removeClass('hide');
  25. $('#actions').removeClass('hide');
  26.  
  27. if (table) {
  28. table.destroy();
  29. }
  30.  
  31. var formObj = $(this);
  32. var formURL = formObj.attr("action") + "?" + $(this).serialize();
  33. searchParameters = formURL.substring(formURL.indexOf("&"));
  34. var formData = new FormData(this);
  35. if(getRuleCategory() == 'DISCOUNT'){
  36. table = $('#' + getRuleCategory().toLowerCase() + '_rule_table').DataTable({
  37. "serverSide": true,
  38. "paging": true,
  39. "ajax": {
  40. "url": formURL,
  41. "type": "POST",
  42. "cache": false,
  43. "processData" : true,
  44. "error" :function(jqXHR, textStatus, errorThrown) {
  45.  
  46. if (jqXHR.responseText.indexOf("/login") > -1) {
  47. $(location).attr("href", "login");
  48. return;
  49. }
  50.  
  51. alertError(JSON.parse(jqXHR.responseText).errorMessage)
  52. }
  53. },
  54. "rowCallback": function( row, data ) {
  55. if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
  56. $(row).addClass('selected');
  57. }
  58. },
  59. "columns": [
  60. {
  61. data: "segmentationRuleId",
  62. render: function ( data, type, row ) {
  63. if ( type === 'display' ) {
  64. return '<input type="checkbox" class="editor-active select-rule">';
  65. }
  66. return data;
  67. },
  68. className: "dt-body-center",
  69. orderable: false,
  70. width: "2%"
  71. },
  72. { data: "segmentationRuleId",
  73. width: "8%"
  74. },
  75. {
  76. data: "segmentationRuleName",
  77. render: function ( data, type, row ) {
  78. if ( type === 'display' ) {
  79. return '<div title="<strong>Rule ID: </strong>' + row.ruleId +'" data-toggle="popover" data-trigger="focus" data-content="<strong>Status: </strong>' + row.isActive + '<br/><strong>Created by: </strong>' + row.m_creator + '<br/><strong>Created on: </strong>' + row.m_createTime + '<br/><strong>Last modified by: </strong>' + row.m_lastEditor + '<br/><strong>Last modified on: </strong>' + row.m_lastEditTime + '<br/><strong>Description: </strong>' + row.description + '<br/>"><strong>' + data + '</strong></div>';
  80. }
  81. return data;
  82. },
  83. width: "40%",
  84. className: "text-left"
  85. },
  86. { data: "platingCarriers" ,
  87. width: "18%"
  88. },
  89. { data: "channels",
  90. width: "15%"
  91. },
  92. { data: "airportSetInclusion.from",
  93. width: "15%"
  94. },
  95. { data: "airportSetInclusion.to",
  96. width: "15%"
  97. }
  98. ]
  99. });
  100. }else{
  101. table = $('#' + getRuleCategory().toLowerCase() + '_rule_table').DataTable({
  102. "processing": true,
  103. "serverSide": false,
  104. "paging": true,
  105. "ajax": {
  106. "url": formURL,
  107. "type": "POST",
  108. "cache": false,
  109. "processData" :false,
  110. "error" :function(jqXHR, textStatus, errorThrown) {
  111.  
  112. if (jqXHR.responseText.indexOf("/login") > -1) {
  113. $(location).attr("href", "login");
  114. return;
  115. }
  116.  
  117. alertError(JSON.parse(jqXHR.responseText).errorMessage)
  118. }
  119. },
  120. "rowCallback": function( row, data ) {
  121. if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
  122. $(row).addClass('selected');
  123. }
  124. },
  125. "columns": [
  126. {
  127. data: "segmentationRuleId",
  128. render: function ( data, type, row ) {
  129. if ( type === 'display' ) {
  130. return '<input type="checkbox" class="editor-active select-rule">';
  131. }
  132. return data;
  133. },
  134. className: "dt-body-center",
  135. orderable: false,
  136. width: "2%"
  137. },
  138. { data: "segmentationRuleId",
  139. width: "8%"
  140. },
  141. {
  142. data: "segmentationRuleName",
  143. render: function ( data, type, row ) {
  144. if ( type === 'display' ) {
  145. return '<div title="<strong>Rule ID: </strong>' + row.segmentationRuleId +'" data-toggle="popover" data-trigger="focus" data-content="<strong>Status: </strong>' + row.ruleStatus + '<br/><strong>Created by: </strong>' + row.creator + '<br/><strong>Created on: </strong>' + row.createTime + '<br/><strong>Last modified by: </strong>' + row.lastEditor + '<br/><strong>Last modified on: </strong>' + row.lastEditTime + '<br/><strong>Description: </strong>' + row.description + '<br/>"><strong>' + data + '</strong></div>';
  146. }
  147. return data;
  148. },
  149. width: "40%",
  150. className: "text-left"
  151. },
  152. { data: "platingCarriers" ,
  153. width: "18%"
  154. },
  155. { data: "segmentationChannelID",
  156. width: "17%"
  157. },
  158. { data: "origin",
  159. width: "15%"
  160. },
  161. { data: "destination",
  162. width: "15%"
  163. },
  164. { data: "segmentationRuleWeight",
  165. width: "5%"
  166. }
  167. ]
  168. });
  169. }
  170. setTable(table);
  171. });
  172.  
  173. /*$('#discount_rule_table').on( 'page.dt', function () {
  174.   $("#myModal").modal('toggle');
  175.   } );*/
Runtime error #stdin #stdout #stderr 0.01s 30272KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:1:0 ReferenceError: $ is not defined