Skip to content

Commit cd5ecfb

Browse files
committed
use special method to produce URL for online item
itemname not always can be used for requesting object from the server
1 parent 4c43478 commit cd5ecfb

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

scripts/JSRootCore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
}
7575
} (function(JSROOT) {
7676

77-
JSROOT.version = "dev 20/07/2015";
77+
JSROOT.version = "dev 22/07/2015";
7878

7979
JSROOT.source_dir = "";
8080
JSROOT.source_min = false;

scripts/JSRootPainter.jquery.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,11 @@
752752

753753
// ========== performs tree drawing on server ==================
754754

755-
JSROOT.TTreePlayer = function(itemname) {
755+
JSROOT.TTreePlayer = function(itemname, url) {
756756
JSROOT.TBasePainter.call(this);
757757
this.SetItemName(itemname);
758-
this.hpainter = null;
758+
this.url = url;
759+
this.hist_painter = null;
759760
return this;
760761
}
761762

@@ -803,7 +804,7 @@
803804

804805
var frame = $("#" + this.divid);
805806

806-
var url = this.GetItemName() + '/exe.json.gz?compact=3&method=Draw';
807+
var url = this.url + '/exe.json.gz?compact=3&method=Draw';
807808
var expr = frame.find('.treedraw_varexp').val();
808809
var hname = "h_tree_draw";
809810

@@ -838,12 +839,11 @@
838839

839840
var player = this;
840841

841-
var req = JSROOT.NewHttpRequest(url, 'object', function(res) {
842-
if (res==0) return;
842+
JSROOT.NewHttpRequest(url, 'object', function(res) {
843+
if (res==null) return;
843844
$("#"+player.drawid).empty();
844-
player.hpainter = JSROOT.draw(player.drawid, res)
845-
});
846-
req.send();
845+
player.hist_painter = JSROOT.draw(player.drawid, res)
846+
}).send();
847847
}
848848

849849
JSROOT.TTreePlayer.prototype.CheckResize = function(force) {
@@ -852,12 +852,16 @@
852852
var h0 = $("#" + this.divid +" .treedraw_buttons").height();
853853
if (h>h0+30) $("#" + this.drawid).height(h - 1 - h0);
854854

855-
if (this.hpainter) {
856-
this.hpainter.CheckResize(force);
855+
if (this.hist_painter) {
856+
this.hist_painter.CheckResize(force);
857857
}
858858
}
859859

860860
JSROOT.drawTreePlayer = function(hpainter, itemname) {
861+
862+
var url = hpainter.GetOnlineItemUrl(itemname);
863+
if (url == null) return null;
864+
861865
var mdi = hpainter.GetDisplay();
862866
if (mdi == null) return null;
863867

@@ -866,7 +870,7 @@
866870

867871
var divid = d3.select(frame).attr('id');
868872

869-
var player = new JSROOT.TTreePlayer(itemname);
873+
var player = new JSROOT.TTreePlayer(itemname, url);
870874
player.Show(divid);
871875
return player;
872876
}

scripts/JSRootPainter.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8326,15 +8326,22 @@
83268326
obj['_typename'] = 'TStreamerInfoList';
83278327
}
83288328

8329+
JSROOT.HierarchyPainter.prototype.GetOnlineItemUrl = function(item) {
8330+
// returns URL, which could be used to request item from the online server
8331+
if ((item!=null) && (typeof item == "string")) item = this.Find(item);
8332+
if (item==null) return null;
8333+
var top = item;
8334+
while ((top!=null) && (!('_online' in top))) top = top._parent;
8335+
return this.itemFullName(item, top);
8336+
}
8337+
83298338
JSROOT.HierarchyPainter.prototype.GetOnlineItem = function(item, itemname, callback, option) {
83308339
// method used to request object from the http server
83318340

83328341
var url = itemname, h_get = false, req = "", req_kind = "object", pthis = this, draw_handle = null;
83338342

83348343
if (item != null) {
8335-
var top = item;
8336-
while ((top!=null) && (!('_online' in top))) top = top._parent;
8337-
url = this.itemFullName(item, top);
8344+
url = this.GetOnlineItemUrl(item);
83388345
var func = null;
83398346
if ('_kind' in item) draw_handle = JSROOT.getDrawHandle(item._kind);
83408347

0 commit comments

Comments
 (0)