Skip to content

Commit 9ee7da0

Browse files
committed
Resolve some shadow variables
1 parent 0e5bc74 commit 9ee7da0

File tree

7 files changed

+126
-120
lines changed

7 files changed

+126
-120
lines changed

modules/gpad/TPadPainter.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,9 @@ class TPadPainter extends ObjectPainter {
11081108
* @private */
11091109
findInPrimitives(objname, objtype) {
11101110
const match = obj => obj && (obj?.fName === objname) && (objtype ? (obj?._typename === objtype) : true),
1111-
snap = this._snap_primitives?.find(snap => match((snap.fKind === webSnapIds.kObject) ? snap.fSnapshot : null));
1112-
if (snap) return snap.fSnapshot;
1111+
snap = this._snap_primitives?.find(s => match((s.fKind === webSnapIds.kObject) ? s.fSnapshot : null));
11131112

1114-
return this.pad?.fPrimitives?.arr.find(match);
1113+
return snap ? snap.fSnapshot : this.pad?.fPrimitives?.arr.find(match);
11151114
}
11161115

11171116
/** @summary Try to find painter for specified object
@@ -1880,8 +1879,8 @@ class TPadPainter extends ObjectPainter {
18801879

18811880
// here the case of normal drawing, will be handled in promise
18821881
if (((snap.fKind === webSnapIds.kObject) || (snap.fKind === webSnapIds.kSVG)) && (snap.fOption !== '__ignore_drawing__')) {
1883-
return this.drawObject(this, snap.fSnapshot, snap.fOption).then(objpainter => {
1884-
this.addObjectPainter(objpainter, lst, indx);
1882+
return this.drawObject(this, snap.fSnapshot, snap.fOption).then(objpainter2 => {
1883+
this.addObjectPainter(objpainter2, lst, indx);
18851884
return this.drawNextSnap(lst, pindx, indx);
18861885
});
18871886
}

modules/gui/HierarchyPainter.mjs

Lines changed: 81 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,21 @@ async function drawList(dom, lst, opt) {
104104
return null;
105105

106106
const handle = {
107-
dom, lst, opt,
108-
indx: -1, painter: null,
109-
draw_next() {
110-
while (++this.indx < this.lst.arr.length) {
111-
const item = this.lst.arr[this.indx],
112-
opt = (this.lst.opt && this.lst.opt[this.indx]) ? this.lst.opt[this.indx] : this.opt;
113-
if (!item) continue;
114-
return draw(this.dom, item, opt).then(p => {
115-
if (p && !this.painter) this.painter = p;
116-
return this.draw_next(); // reenter loop
117-
});
118-
}
119-
return this.painter;
120-
}
107+
dom, lst, opt,
108+
indx: -1, painter: null,
109+
draw_next() {
110+
while (++this.indx < this.lst.arr.length) {
111+
const item = this.lst.arr[this.indx],
112+
opt2 = (this.lst.opt && this.lst.opt[this.indx]) ? this.lst.opt[this.indx] : this.opt;
113+
if (!item)
114+
continue;
115+
return draw(this.dom, item, opt2).then(p => {
116+
if (p && !this.painter) this.painter = p;
117+
return this.draw_next(); // reenter loop
118+
});
119+
}
120+
return this.painter;
121+
}
121122
};
122123

123124
return handle.draw_next();
@@ -799,52 +800,55 @@ class HierarchyPainter extends BasePainter {
799800
folder._had_direct_read = false;
800801
// this is central get method, item or itemname can be used, returns promise
801802
folder._get = function(item, itemname) {
802-
if (item?._readobj)
803-
return Promise.resolve(item._readobj);
804-
805-
if (item) itemname = painter.itemFullName(item, this);
806-
807-
const readFileObject = file => {
808-
if (!this._file) this._file = file;
809-
810-
if (!file) return Promise.resolve(null);
811-
812-
return file.readObject(itemname).then(obj => {
813-
// if object was read even when item did not exist try to reconstruct new hierarchy
814-
if (!item && obj) {
815-
// first try to found last read directory
816-
const d = painter.findItem({ name: itemname, top: this, last_exists: true, check_keys: true });
817-
if ((d?.last !== undefined) && (d.last !== this)) {
818-
// reconstruct only sub-directory hierarchy
819-
const dir = file.getDir(painter.itemFullName(d.last, this));
820-
if (dir) {
821-
d.last._name = d.last._keyname;
822-
const dirname = painter.itemFullName(d.last, this);
823-
keysHierarchy(d.last, dir.fKeys, file, dirname + '/');
824-
}
825-
} else {
826-
// reconstruct full file hierarchy
827-
keysHierarchy(this, file.fKeys, file, '');
803+
if (item?._readobj)
804+
return Promise.resolve(item._readobj);
805+
806+
if (item)
807+
itemname = painter.itemFullName(item, this);
808+
809+
const readFileObject = file2 => {
810+
if (!this._file)
811+
this._file = file2;
812+
813+
if (!file2)
814+
return Promise.resolve(null);
815+
816+
return file2.readObject(itemname).then(obj => {
817+
// if object was read even when item did not exist try to reconstruct new hierarchy
818+
if (!item && obj) {
819+
// first try to found last read directory
820+
const d = painter.findItem({ name: itemname, top: this, last_exists: true, check_keys: true });
821+
if ((d?.last !== undefined) && (d.last !== this)) {
822+
// reconstruct only sub-directory hierarchy
823+
const dir = file2.getDir(painter.itemFullName(d.last, this));
824+
if (dir) {
825+
d.last._name = d.last._keyname;
826+
const dirname = painter.itemFullName(d.last, this);
827+
keysHierarchy(d.last, dir.fKeys, file2, dirname + '/');
828828
}
829-
item = painter.findItem({ name: itemname, top: this });
830-
}
831-
832-
if (item) {
833-
item._readobj = obj;
834-
// remove cycle number for objects supporting expand
835-
if ('_expand' in item) item._name = item._keyname;
829+
} else {
830+
// reconstruct full file hierarchy
831+
keysHierarchy(this, file2.fKeys, file2, '');
836832
}
833+
item = painter.findItem({ name: itemname, top: this });
834+
}
837835

838-
return obj;
839-
});
840-
};
836+
if (item) {
837+
item._readobj = obj;
838+
// remove cycle number for objects supporting expand
839+
if ('_expand' in item) item._name = item._keyname;
840+
}
841841

842-
if (this._file) return readFileObject(this._file);
843-
if (this._localfile) return openFile(this._localfile).then(f => readFileObject(f));
844-
if (this._fullurl) return openFile(this._fullurl).then(f => readFileObject(f));
845-
return Promise.resolve(null);
842+
return obj;
843+
});
846844
};
847845

846+
if (this._file) return readFileObject(this._file);
847+
if (this._localfile) return openFile(this._localfile).then(f => readFileObject(f));
848+
if (this._fullurl) return openFile(this._fullurl).then(f => readFileObject(f));
849+
return Promise.resolve(null);
850+
};
851+
848852
keysHierarchy(folder, file.fKeys, file, '');
849853

850854
return folder;
@@ -2473,7 +2477,7 @@ class HierarchyPainter extends BasePainter {
24732477
if (items[cnt] === null) continue; // ignore completed item
24742478
if (items_wait[cnt] && items.indexOf(items[cnt]) === cnt) {
24752479
items_wait[cnt] = false;
2476-
return h.display(items[cnt], options[cnt], doms[cnt]).then(painter => dropNextItem(cnt, painter));
2480+
return h.display(items[cnt], options[cnt], doms[cnt]).then(drop_painter => dropNextItem(cnt, drop_painter));
24772481
}
24782482
}
24792483
}
@@ -2682,17 +2686,20 @@ class HierarchyPainter extends BasePainter {
26822686
return;
26832687
}
26842688

2685-
if (hitem._obj) promise = doExpandItem(hitem, hitem._obj);
2689+
if (hitem._obj)
2690+
promise = doExpandItem(hitem, hitem._obj);
26862691
}
26872692

26882693
return promise.then(res => {
2689-
if (res !== -1) return res; // done
2694+
if (res !== -1)
2695+
return res; // done
26902696

26912697
showProgress('Loading ' + itemname);
26922698

2693-
return this.getObject(itemname, silent ? 'hierarchy_expand' : 'hierarchy_expand_verbose').then(res => {
2699+
return this.getObject(itemname, silent ? 'hierarchy_expand' : 'hierarchy_expand_verbose').then(res2 => {
26942700
showProgress();
2695-
if (res.obj) return doExpandItem(res.item, res.obj).then(res => { return (res !== -1) ? res : undefined; });
2701+
if (res2.obj)
2702+
return doExpandItem(res2.item, res2.obj).then(res3 => { return res3 !== -1 ? res3 : undefined; });
26962703
});
26972704
});
26982705
}
@@ -2737,17 +2744,17 @@ class HierarchyPainter extends BasePainter {
27372744
this.forEachJsonFile(item => { if (item._jsonfile === filepath) isfileopened = true; });
27382745
if (isfileopened) return;
27392746

2740-
return httpRequest(filepath, 'object').then(res => {
2741-
if (!res) return;
2742-
const h1 = { _jsonfile: filepath, _kind: prROOT + res._typename, _jsontmp: res, _name: filepath.split('/').pop() };
2743-
if (res.fTitle) h1._title = res.fTitle;
2747+
return httpRequest(filepath, 'object').then(res2 => {
2748+
if (!res2) return;
2749+
const h1 = { _jsonfile: filepath, _kind: prROOT + res2._typename, _jsontmp: res2, _name: filepath.split('/').pop() };
2750+
if (res2.fTitle) h1._title = res2.fTitle;
27442751
h1._get = function(item /* ,itemname */) {
27452752
if (item._jsontmp)
27462753
return Promise.resolve(item._jsontmp);
27472754
return httpRequest(item._jsonfile, 'object')
2748-
.then(res => {
2749-
item._jsontmp = res;
2750-
return res;
2755+
.then(res3 => {
2756+
item._jsontmp = res3;
2757+
return res3;
27512758
});
27522759
};
27532760
if (!this.h)
@@ -2868,13 +2875,13 @@ class HierarchyPainter extends BasePainter {
28682875
h._childs.push({
28692876
_name: fname, _title: dirname + fname, _jsonfile: dirname + fname, _can_draw: true,
28702877
_get: item => {
2871-
return httpRequest(item._jsonfile, 'object').then(res => {
2872-
if (res) {
2873-
item._kind = prROOT + res._typename;
2874-
item._jsontmp = res;
2878+
return httpRequest(item._jsonfile, 'object').then(res2 => {
2879+
if (res2) {
2880+
item._kind = prROOT + res2._typename;
2881+
item._jsontmp = res2;
28752882
this.updateTreeNode(item);
28762883
}
2877-
return res;
2884+
return res2;
28782885
});
28792886
}
28802887
});
@@ -4009,16 +4016,16 @@ async function drawInspector(dom, obj, opt) {
40094016
if (sett.opts) {
40104017
menu.addDrawMenu('nosub:Draw', sett.opts, arg => {
40114018
if (!hitem?._obj) return;
4012-
const obj = hitem._obj;
4019+
const obj2 = hitem._obj;
40134020
let ddom = this.selectDom().node();
40144021
if (isFunc(this.removeInspector)) {
40154022
ddom = ddom.parentNode;
40164023
this.removeInspector();
40174024
if (arg.indexOf(kInspect) === 0)
4018-
return this.showInspector(arg, obj);
4025+
return this.showInspector(arg, obj2);
40194026
}
40204027
cleanup(ddom);
4021-
draw(ddom, obj, arg);
4028+
draw(ddom, obj2, arg);
40224029
});
40234030
}
40244031
};

modules/gui/display.mjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,8 @@ class FlexibleDisplay extends MDIDisplay {
817817
/** @summary change frame state */
818818
changeFrameState(frame, newstate, no_redraw) {
819819
const main = d3_select(frame.parentNode),
820-
state = main.property('state'),
821-
top = this.selectDom().select('.jsroot_flex_top');
820+
state = main.property('state'),
821+
top = this.selectDom().select('.jsroot_flex_top');
822822

823823
if (state === newstate)
824824
return false;
@@ -859,7 +859,6 @@ class FlexibleDisplay extends MDIDisplay {
859859
// adjust position of new minified rect
860860
if (newstate === 'min') {
861861
const rect = this.getFrameRect(frame),
862-
top = this.selectDom().select('.jsroot_flex_top'),
863862
ww = top.node().clientWidth,
864863
hh = top.node().clientHeight,
865864
arr = [], step = 4,
@@ -969,25 +968,26 @@ class FlexibleDisplay extends MDIDisplay {
969968

970969
if (detectRightButton(evnt.sourceEvent)) return;
971970

972-
const main = d3_select(this.parentNode);
973-
if (!main.classed('jsroot_flex_frame') || (main.property('state') === 'max')) return;
971+
const mframe = d3_select(this.parentNode);
972+
if (!mframe.classed('jsroot_flex_frame') || (mframe.property('state') === 'max'))
973+
return;
974974

975975
doing_move = !d3_select(this).classed('jsroot_flex_resize');
976-
if (!doing_move && (main.property('state') === 'min')) return;
976+
if (!doing_move && (mframe.property('state') === 'min')) return;
977977

978-
mdi.activateFrame(main.select('.jsroot_flex_draw').node());
978+
mdi.activateFrame(mframe.select('.jsroot_flex_draw').node());
979979

980-
moving_div = top.append('div').attr('style', main.attr('style')).style('border', '2px dotted #00F');
980+
moving_div = top.append('div').attr('style', mframe.attr('style')).style('border', '2px dotted #00F');
981981

982-
if (main.property('state') === 'min') {
983-
moving_div.style('width', main.node().clientWidth + 'px')
984-
.style('height', main.node().clientHeight + 'px');
982+
if (mframe.property('state') === 'min') {
983+
moving_div.style('width', mframe.node().clientWidth + 'px')
984+
.style('height', mframe.node().clientHeight + 'px');
985985
}
986986

987987
evnt.sourceEvent.preventDefault();
988988
evnt.sourceEvent.stopPropagation();
989989

990-
moving_frame = main;
990+
moving_frame = mframe;
991991
current = [];
992992
}).on('drag', function(evnt) {
993993
if (!moving_div) return;

modules/gui/menu.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,14 +1378,14 @@ class StandaloneMenu extends JSRootMenu {
13781378

13791379
hovArea.appendChild(text);
13801380

1381-
function changeFocus(item, on) {
1381+
function changeFocus(fitem, on) {
13821382
if (on) {
1383-
item.classList.add(clfocus);
1384-
item.style['background-color'] = 'rgb(220, 220, 220)';
1385-
} else if (item.classList.contains(clfocus)) {
1386-
item.style['background-color'] = null;
1387-
item.classList.remove(clfocus);
1388-
item.querySelector(`.${clname}`)?.remove();
1383+
fitem.classList.add(clfocus);
1384+
fitem.style['background-color'] = 'rgb(220, 220, 220)';
1385+
} else if (fitem.classList.contains(clfocus)) {
1386+
fitem.style['background-color'] = null;
1387+
fitem.classList.remove(clfocus);
1388+
fitem.querySelector(`.${clname}`)?.remove();
13891389
}
13901390
}
13911391

modules/hist/RH1Painter.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class RH1Painter extends RH1Painter2D {
3939

4040
return pr.then(() => this.drawingBins(reason)).then(() => {
4141
// called when bins received from server, must be reentrant
42-
const main = this.getFramePainter();
42+
const fp = this.getFramePainter();
4343

4444
drawBinsLego(this, true);
4545
this.updatePaletteDraw();
46-
main.render3D();
47-
main.addKeysHandler();
46+
fp.render3D();
47+
fp.addKeysHandler();
4848
return this;
4949
});
5050
}

modules/hist/RH2Painter.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ class RH2Painter extends RH2Painter2D {
6060

6161
return pr.then(() => this.drawingBins(reason)).then(() => {
6262
// called when bins received from server, must be reentrant
63-
const main = this.getFramePainter();
63+
const fp = this.getFramePainter();
6464

6565
this.draw3DBins();
66-
main.render3D();
67-
main.addKeysHandler();
66+
fp.render3D();
67+
fp.addKeysHandler();
6868

6969
return this;
7070
});

0 commit comments

Comments
 (0)