Skip to content

Commit f4db169

Browse files
committed
working on issue #70, not done yet
1 parent 10b2315 commit f4db169

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

flat/style/flat.viewer.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ function renderglobannotations(all) {
845845

846846
}
847847

848-
containers[containerkey].push_back({
848+
containers[containerkey].push({
849849
'html': s,
850850
'annotation': annotation,
851851
'target': target,
@@ -875,34 +875,33 @@ function renderglobannotations(all) {
875875
//find maximum slot and gather targets
876876
var maxslot = 0;
877877
var targets = [];
878-
for (var i = 0; i < containers[containerkey.length]; i++) {
879-
if (containers[i].slot > maxslot) {
880-
maxslot = containers[i].slot;
878+
containers[containerkey].forEach(function(container){
879+
if (container.slot > maxslot) {
880+
maxslot = container.slot;
881881
}
882-
if (targets.indexOf(containers[i].target) == -1) {
883-
targets.push(containers[i].target);
882+
if (targets.indexOf(container.target) === -1) {
883+
targets.push(container.target);
884884
}
885-
}
885+
});
886886

887887
//iterate over targets
888-
for (var i = 0; i < targets.length; i++) {
889-
var target = targets[i];
888+
targets.forEach(function(target){
890889
targetabselection = $('#' + valid(target) + " span.ab");
891890
targetabselection.append("<span class=\"abc\"></span>");
892891
var abcs = $('#' + valid(target) + " span.ab span.abc");
893892
var displaycontainer = abcs[abcs.length-1]; //nasty patch cause I can't get last() to work
894893

895894
//fill the slots in order
896895
var displaycontainer_html = "";
897-
for (var slot = 0; slot <= maxslot; slot++) {
896+
var slot;
897+
for (slot = 0; slot <= maxslot; slot++) {
898898
var found = false;
899-
for (var j = 0; j < containers[containerkey.length]; j++) {
900-
if ((containers[j].target === target) && (containers[j].slot === slot)) {
901-
displaycontainer_html = containers[j].html + displaycontainer_html;
899+
containers[containerkey].forEach(function(container){
900+
if ((container.target === target) && (container.slot === slot)) {
901+
displaycontainer_html = container.html + displaycontainer_html;
902902
found = true;
903-
break;
904903
}
905-
}
904+
});
906905
if (!found) {
907906
//free slot
908907
displaycontainer_html = "<span>&nbsp;</span>";
@@ -914,11 +913,14 @@ function renderglobannotations(all) {
914913
if (displaycontainers[containerkey] === undefined) {
915914
displaycontainers[containerkey] = {};
916915
}
917-
displaycontainers[containerkey][target] = displaycontainer;
916+
if (displaycontainers[containerkey][target] === undefined) {
917+
displaycontainers[containerkey][target]= [];
918+
}
919+
displaycontainers[containerkey][target].push(displaycontainer);
918920

919921
//show the annotation box
920922
targetabselection.css('display','block');
921-
}
923+
});
922924
});
923925

924926

0 commit comments

Comments
 (0)