Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.58 KB | None | 0 0
  1. $(function() {
  2. $('.drop-down').setDropDown();
  3.  
  4. if ($('@trace-panel_nodes-elements input').size() < 3) {
  5. $('@trace-panel_nodes-elements input').iCheck('disable');
  6. }
  7. if ($('@trace-panel_protocols-elements input').size() < 3) {
  8. $('@trace-panel_protocols-elements input').iCheck('disable');
  9. }
  10.  
  11. $('#export_pdf').click(function() {
  12. var view = $('#trace-panel_switch-view').find('.switcher-button_selected').attr('data-view');
  13. if (view === 'list') {
  14. $('.trace-panel_switch-button_tree').trigger('click');
  15. }
  16. var html_source = $('@calltrace-frame').html();
  17. $('@export_pdf_html').val(html_source);
  18. $('@export_pdf_form').submit();
  19. if (view === 'list') {
  20. $('.trace-panel_switch-button_list').trigger('click');
  21. }
  22. return false;
  23. });
  24.  
  25. if (!$('#trace-panel_switch-view').length) {
  26. return false;
  27. }
  28. $('#trace-panel_switch-view').setSwitcher().addHandler(function() {
  29. switch ($(this).attr('data-view')) {
  30. case 'tree':
  31. switchTree();
  32. break;
  33. case 'list':
  34. switchList();
  35. break;
  36. }
  37. });
  38.  
  39. var calltraceFrame = $('@calltrace-frame'),
  40. topFrame = $('@top-frame'),
  41. middleFrame = $('@middle-frame'),
  42. bottomFrame = $('@bottom-frame'),
  43. xdrId = $('@xdr_id').val(),
  44. table = $('@table').val(),
  45. probeid = $('@probeid').val(),
  46. Calltrace,
  47. PacketsXdr,
  48. PacketsPdu,
  49. PacketsPduDetails,
  50. i, max,
  51.  
  52. _templateNodeListItem = App.getTemplate('template_node_list-item'),
  53. _templateProtocolItem = App.getTemplate('template_protocol-item'),
  54.  
  55. fieldsXDR = [],
  56. textFieldsXDR = $(App.stringToXML($('#xdr-fields-data').html())).find('div'),
  57. xdrList,
  58. pduList,
  59. detailsPdu,
  60. chunks;
  61.  
  62.  
  63. calltraceFrame.on("startLoading", function() {
  64. var $holder = $(".calltrace-view"),
  65. $topPanel = $("#top-panel"),
  66. $frame = $holder.find("@calltrace-frame"),
  67. $packetAnalyzer = $(".packet-analyzer"),
  68.  
  69. topPanelHeight = $topPanel.height(),
  70. windowHeight = $(window).height();
  71.  
  72. if ($frame.children().length > 0) {
  73. return;
  74. }
  75.  
  76. $packetAnalyzer.hide();
  77. $holder.css({
  78. height: windowHeight - topPanelHeight
  79. }).addClass("calltrace-view_loading");
  80. }).trigger("startLoading");
  81.  
  82. calltraceFrame.on("stopLoading", function() {
  83. var $holder = $(".calltrace-view"),
  84. $packetAnalyzer = $(".packet-analyzer");
  85.  
  86. $packetAnalyzer.show();
  87. $holder.removeAttr("style").removeClass("calltrace-view_loading");
  88. });
  89.  
  90.  
  91. for (i = 0, max = textFieldsXDR.length; i < max; i += 1) {
  92. fieldsXDR.push({
  93. display: textFieldsXDR[i].childNodes[0].nodeValue,
  94. rank: textFieldsXDR[i].getAttribute('rank'),
  95. column: textFieldsXDR[i].getAttribute('column')
  96. });
  97. }
  98.  
  99. var getChunkByXdrId = function(id) {
  100. var ids = [];
  101.  
  102. for (var i in chunks) {
  103. if (chunks[i].xdr_id === (id + '')) {
  104. ids.push(i.toLowerCase());
  105. }
  106. }
  107.  
  108. return ids;
  109. };
  110.  
  111. var switchList = function() {
  112. calltraceFrame.empty().hide();
  113. PacketsXdr = topFrame.show().PacketsXdr({
  114. showLoaders: false,
  115. fields: fieldsXDR
  116. });
  117. PacketsPdu = middleFrame.show().PacketsPdu({
  118. showLoaders: false
  119. });
  120. PacketsPduDetails = bottomFrame.show().PacketsPduDetails();
  121. PacketsPdu.on('selectRow', function(packetId, chunk, probeid) {
  122. PacketsPduDetails.get(packetId, chunk, probeid);
  123. });
  124. PacketsXdr.on('selectRow', function(params) {
  125. var chunkIds = getChunkByXdrId(params.id);
  126.  
  127. PacketsPdu.lightReset();
  128. for (var i = 0; i < chunkIds.length; i += 1) {
  129. PacketsPdu.lightRow(middleFrame.find('tr.data[data-id="' + chunkIds[i] + '"]'));
  130. }
  131. });
  132. PacketsXdr.pasteFromArray(xdrList);
  133. PacketsPdu.pasteFromXml(pduList.stdout, chunks, function() {
  134. PacketsPdu.selectRow(middleFrame.find('tr.data').first());
  135. });
  136. updateFrames();
  137. };
  138. var switchTree = function() {
  139. if (!calltraceFrame) {
  140. App.showError('No data');
  141. return false;
  142. }
  143. Calltrace = calltraceFrame.show().Calltrace();
  144. PacketsPduDetails = bottomFrame.show().PacketsPduDetails();
  145. Calltrace.on('selectPacket', function(packetId, chunk, probeid) {
  146. PacketsPduDetails.get(packetId, chunk, probeid);
  147. });
  148. $('@trace-panel_nodes-elements').empty();
  149. Calltrace.on('addNode', function(node) {
  150. $('@trace-panel_nodes-elements').append(_templateNodeListItem(node)); //.iCheck();
  151. $('@trace-panel_nodes-elements input[type=checkbox]').iCheck();
  152. });
  153. $('@trace-panel_protocols-elements').empty();
  154. Calltrace.on('addProtocol', function(protocol) {
  155. $('@trace-panel_protocols-elements').append(_templateProtocolItem({
  156. protocol: protocol
  157. }));
  158. $('@trace-panel_protocols-elements input[type=checkbox]').iCheck();
  159. });
  160. Calltrace.on('blockProtocols', function() {
  161. $('@trace-panel_protocols-elements input').each(function() {
  162. if ($(this).is(':checked')) {
  163. $(this).iCheck('disable');
  164. }
  165. });
  166. });
  167. Calltrace.on('unblockProtocols', function() {
  168. $('@trace-panel_protocols-elements input').each(function() {
  169. if ($(this).is(':checked')) {
  170. $(this).iCheck('enable');
  171. }
  172. });
  173. });
  174. Calltrace.on('blockNodes', function() {
  175. $('@trace-panel_nodes-elements input').each(function() {
  176. if ($(this).is(':checked')) {
  177. $(this).iCheck('disable');
  178. }
  179. });
  180. });
  181. Calltrace.on('unblockNodes', function() {
  182. $('@trace-panel_nodes-elements input').each(function() {
  183. if ($(this).is(':checked')) {
  184. $(this).iCheck('enable');
  185. }
  186. });
  187. });
  188. Calltrace.pasteFromXml(detailsPdu.stdout, chunks);
  189. Calltrace.selectNode($('.packets-trace_item').first());
  190. topFrame.empty().hide();
  191. middleFrame.empty().hide();
  192. updateFrames();
  193. };
  194.  
  195. $.post(App.baseURL() + 'calltrace/get_pdu_by_xdr/', {
  196. id: xdrId,
  197. table: table,
  198. probeid: probeid
  199. }, function(result) {
  200. if (result.error) {
  201. App.showError(result.error);
  202. return;
  203. }
  204. xdrList = result.xdr_list;
  205. pduList = result.list_pdu;
  206. detailsPdu = result.details_pdu;
  207. chunks = result.chunks;
  208. switchTree();
  209. calltraceFrame.trigger('stopLoading');
  210. }, 'json').error(function(xhr) {
  211. App.showError(xhr);
  212. });
  213.  
  214. $('@trace-panel_show_name-protocol').on('ifClicked', function() {
  215. if (!$(this).is(':checked')) {
  216. Calltrace.showNameProtocol();
  217. } else {
  218. Calltrace.hideNameProtocol();
  219. }
  220. });
  221. $('@trace-panel_show_name-message').on('ifClicked', function() {
  222. if (!$(this).is(':checked')) {
  223. Calltrace.showNameMessage();
  224. } else {
  225. Calltrace.hideNameMessage();
  226. }
  227. });
  228. $('@trace-panel_show_remainig-time').on('ifClicked', function() {
  229. if (!$(this).is(':checked')) {
  230. Calltrace.showRemainingTime();
  231. } else {
  232. Calltrace.hideRemainingTime();
  233. }
  234. });
  235.  
  236. $('@trace-panel_show_absolute-time').on('ifClicked', function() {
  237. if (!$(this).is(':checked')) {
  238. Calltrace.showAbsoluteTime();
  239. } else {
  240. Calltrace.hideAbsoluteTime();
  241. }
  242. });
  243. $('@trace-panel_nodes-elements input[type=checkbox]').iCheck();
  244. $('@trace-panel_nodes-elements')
  245. .on('ifChecked', 'input', function() {
  246. Calltrace.showNode($(this).attr('data-node'));
  247. })
  248. .on('ifUnchecked', 'input', function() {
  249. Calltrace.hideNode($(this).attr('data-node'));
  250. });
  251.  
  252. $('@trace-panel_protocols-elements')
  253. .on('ifChecked', 'input', function() {
  254. Calltrace.showProtocol($(this).attr('data-protocol'));
  255. })
  256. .on('ifUnchecked', 'input', function() {
  257. Calltrace.hideProtocol($(this).attr('data-protocol'));
  258. });
  259.  
  260. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement