ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
httptextlog.js
Go to the documentation of this file.
1 (function(){
2 
3  if (typeof JSROOT != "object") {
4  var e1 = new Error("httptextlog.js requires JSROOT to be already loaded");
5  e1.source = "httptextlog.js";
6  throw e1;
7  }
8 
9  function MakeMsgListRequest(hitem, item) {
10  // this function produces url for http request
11  // here one provides id of last string received with previous request
12 
13  var arg = "&max=1000";
14  if ('last-id' in item) arg+= "&id="+item['last-id'];
15  return 'exe.json.gz?method=Select' + arg;
16  }
17 
18  function AfterMsgListRequest(hitem, item, obj) {
19  // after data received, one replaces typename for produced object
20 
21  if (item==null) return;
22 
23  if (obj==null) {
24  delete item['last-id'];
25  return;
26  }
27  // ignore all other classes
28  if (obj['_typename'] != 'TList') return;
29 
30  // change class name - it is only important for drawing
31  obj['_typename'] = "TMsgList";
32 
33  if (obj.arr.length>0) {
34  item['last-id'] = obj.arr[0].fString;
35 
36  // add clear function for item
37  if (!('clear' in item))
38  item['clear'] = function() { delete this['last-id']; }
39  }
40  }
41 
42 
43  function DrawMsgList(divid, lst, opt) {
44 
45  var painter = new JSROOT.TBasePainter();
46  painter.SetDivId(divid);
47 
48  painter.Draw = function(lst) {
49  if (lst == null) return;
50 
51  var frame = d3.select("#" + this.divid);
52 
53  var main = frame.select("div");
54  if (main.empty())
55  main = frame.append("div")
56  .style('max-width','100%')
57  .style('max-height','100%')
58  .style('overflow','auto');
59 
60  var old = main.selectAll("pre");
61  var newsize = old.size() + lst.arr.length - 1;
62 
63  // in the browser keep maximum 1000 entries
64  if (newsize > 1000)
65  old.select(function(d,i) { return i < newsize - 1000 ? this : null; }).remove();
66 
67  for (var i=lst.arr.length-1;i>0;i--)
68  main.append("pre").html(lst.arr[i].fString);
69 
70  // (re) set painter to first child element
71  this.SetDivId(this.divid);
72  }
73 
74  painter.RedrawObject = function(obj) {
75  this.Draw(obj);
76  return true;
77  }
78 
79  painter.Draw(lst);
80  return painter.DrawingReady();
81  }
82 
83  JSROOT.addDrawFunc({name:"TMsgList", icon:"img_text", make_request:MakeMsgListRequest, after_request:AfterMsgListRequest, func:DrawMsgList, opt:"list"});
84 
85 })();
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
th1 Draw()
null_t< F > null()
int d
Definition: tornado.py:11
void Error(const char *location, const char *msgfmt,...)
double func(double *x, double *p)
Definition: stressTF1.cxx:213
#define name(a, b)
Definition: linkTestLib0.cpp:5
TObject * obj