2 /// \ingroup tutorial_http
10 if (typeof JSROOT != "object") {
11 var e1 = new Error("httptextlog.js requires JSROOT to be already loaded");
12 e1.source = "httptextlog.js";
16 function MakeMsgListRequest(hitem, item) {
17 // this function produces url for http request
18 // here one provides id of last string received with previous request
20 var arg = "&max=1000";
21 if ('last-id' in item) arg+= "&id="+item['last-id'];
22 return 'exe.json.gz?method=Select' + arg;
25 function AfterMsgListRequest(hitem, item, obj) {
26 // after data received, one replaces typename for produced object
28 if (item==null) return;
31 delete item['last-id'];
34 // ignore all other classes
35 if (obj['_typename'] != 'TList') return;
37 // change class name - it is only important for drawing
38 obj['_typename'] = "TMsgList";
40 if (obj.arr.length>0) {
41 item['last-id'] = obj.arr[0].fString;
43 // add clear function for item
44 if (!('clear' in item))
45 item['clear'] = function() { delete this['last-id']; }
50 function DrawMsgList(divid, lst, opt) {
52 var painter = new JSROOT.TBasePainter();
53 painter.SetDivId(divid);
55 painter.Draw = function(lst) {
56 if (lst == null) return;
58 var frame = d3.select("#" + this.divid);
60 var main = frame.select("div");
62 main = frame.append("div")
63 .style('max-width','100%')
64 .style('max-height','100%')
65 .style('overflow','auto');
67 var old = main.selectAll("pre");
68 var newsize = old.size() + lst.arr.length - 1;
70 // in the browser keep maximum 1000 entries
72 old.select(function(d,i) { return i < newsize - 1000 ? this : null; }).remove();
74 for (var i=lst.arr.length-1;i>0;i--)
75 main.append("pre").html(lst.arr[i].fString);
77 // (re) set painter to first child element
78 this.SetDivId(this.divid);
81 painter.RedrawObject = function(obj) {
87 return painter.DrawingReady();
90 JSROOT.addDrawFunc({name:"TMsgList", icon:"img_text", make_request:MakeMsgListRequest, after_request:AfterMsgListRequest, func:DrawMsgList, opt:"list"});