artdaq_node_server  v1_00_09
 All Classes Namespaces Files Variables Pages
viewer.js
1 var hpainter;
2 
3 function getUrlParameter(sParam) {
4  var sPageURL = window.location.search.substring(1);
5  var sURLVariables = sPageURL.split('&');
6  for (var i = 0; i < sURLVariables.length; i++) {
7  var sParameterName = sURLVariables[i].split('=');
8  if (sParameterName[0] == sParam) {
9  return sParameterName[1];
10  }
11  }
12 }
13 
14 function updateGUI() {
15  var key = getUrlParameter("pad");
16  var partition = getUrlParameter("partition");
17 
18  if (hpainter == null) hpainter = new JSROOT.HierarchyPainter('root', 'wd1div');
19  hpainter.SetDisplay("grid1x1", 'wd0div');
20 
21  hpainter.OpenRootFile("P"+partition+"/artdaqdemo_onmon.root", function () {
22  hpainter.displayAll([key]);
23  });
24 }
25 
26 
27 (function ($, sr) {
28 
29  // debouncing function from John Hann
30  // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
31  var debounce = function (func, threshold, execAsap) {
32  var timeout;
33 
34  return function debounced() {
35  var obj = this, args = arguments;
36  function delayed() {
37  if (!execAsap)
38  func.apply(obj, args);
39  timeout = null;
40  } ;
41 
42  if (timeout)
43  clearTimeout(timeout);
44  else if (execAsap)
45  func.apply(obj, args);
46 
47  timeout = setTimeout(delayed, threshold || 100);
48  };
49  }
50  // smartresize
51  jQuery.fn[sr] = function (fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
52 
53 })(jQuery, 'smartresize');
54 
55 $(document).ready(function () {
56  JSROOT.AssertPrerequisites('2d;io;', updateGUI);
57  $(window).smartresize(function () {
58  $("#wd0div").width($(window).width());
59  $("#wd0div").height($(window).height());
60  updateGUI();
61  });
62 });