Changeset 33291 for main/trunk/greenstone3
- Timestamp:
- 2019-07-03T18:42:59+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
r33290 r33291 571 571 return; 572 572 } 573 573 574 var doc; 574 575 var visibleMarkers = new Array(); 575 576 for(var i = 0; i < _docList.ids.length; i++) 576 577 { 577 var doc = _docList.getDocByIndex(i); 578 //var doc = _docList.getDocByIndex(i); 579 // NOTE: in JavaScript, "local" vars have function scope, not mere block level scope. Wherever declared inside a function, they get hoisted to function top. 580 // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var 581 // But this feature is confusing, so have now declared var doc nearer to function top, at function level so outside current local block, and am assigning here: 582 doc = _docList.getDocByIndex(i); 578 583 if(typeof doc.shapes !== 'undefined') { 579 584 for(var x = 0; x < doc.shapes.length; x++) { … … 608 613 } 609 614 610 var doc = visibleMarkers[_docList.loopIndex]; 611 elem = gs.jqGet("div" + doc.nodeID); // TODO: this used to redefine elem by doing var elem = <....> 615 //var doc = visibleMarkers[_docList.loopIndex]; // See NOTE above. 616 doc = visibleMarkers[_docList.loopIndex]; 617 elem = gs.jqGet("div" + doc.nodeID); // This used to redefine elem by doing var elem = <....> 618 // This worked because "If you re-declare a JavaScript variable, it will not lose its value." See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var 612 619 if(elem.length) 613 620 { … … 617 624 _docList.loopIndex ++; 618 625 } 619 //console.log("@@@@ DOC:"); 620 //console.log(doc);621 626 627 _gsDebug("@@@ loopThroughmarkers() - DOC:", doc); 628 622 629 if(doc.marker) { 623 630 doc.marker.markerInfo.open(_map, doc.marker); // TODO: how does doc have a value here? Where is the value set at this block level?
Note:
See TracChangeset
for help on using the changeset viewer.