- Timestamp:
- 2019-05-21T18:45:25+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-editor.js
r33099 r33100 38 38 this.resizable = false; 39 39 this.dontResize = false; 40 41 40 42 41 this.shapeOptions = { … … 182 181 } 183 182 184 185 183 // Ensure only unique labels are added to our autocomplete list 186 184 MapEditor.prototype.addToAutocompleteLabelsList = function (newLabel) { 187 188 185 if (newLabel !== "" && !global_autocompleteLabelsList.includes(newLabel)) { 189 186 // add to autocomplete list and sort alphabetically … … 191 188 global_autocompleteLabelsList.sort(); 192 189 } 193 194 console.log("the added new label to global autocomplete array:"); console.log(global_autocompleteLabelsList);195 190 } 196 191 … … 827 822 828 823 this.mapEditorHistory.presentOverlayPush(); 829 830 824 831 825 // DO NOT assign "this.autocompleteLabelsList = keys(local_labels_hashmap);" … … 840 834 // https://stackoverflow.com/questions/929776/merging-objects-associative-arrays 841 835 // We've decided to use the jQuery based suggested solution for merging hashmaps: 842 // $.extend(obj1, obj2); means obj1 = obj1 + obj2. Overwriting any existing properties in obj1 with new values in obj2. 843 844 console.log("@@@@ Adding local contents to global: "); console.log(local_labels_hashmap); 845 console.log("@@@@ global map before: "); console.log(global_labels_hashmap); 846 847 836 // $.extend(obj1, obj2); means obj1 = obj1 + obj2. Note: it additionally overwrites any existing properties in obj1 with new values in obj2. 848 837 $.extend(global_labels_hashmap, local_labels_hashmap); 849 838 850 console.log("@@@@ global map after: "); console.log(global_labels_hashmap);851 852 839 // important to empty our global autocomplete labels list array 853 // See https://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript854 840 // See https://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript 841 // and https://www.jstips.co/en/javascript/two-ways-to-empty-an-array/ 855 842 global_autocompleteLabelsList.length = 0; 856 843 857 844 var keys = Object.keys(global_labels_hashmap); 858 845 global_autocompleteLabelsList.push.apply(global_autocompleteLabelsList, keys); // addAll keys to our global_autocompleteLabelsList (turns map's keys into array) 859 860 console.log("@@@@ global ARRAY after setting to global map: "); console.log(global_autocompleteLabelsList);861 846 global_autocompleteLabelsList.sort(); 862 847 } … … 902 887 } 903 888 } 904 905 889 906 890 // Having got our unique (set) of descriptions/labels, we're ready to set it up as the source for our autocomplete list
Note:
See TracChangeset
for help on using the changeset viewer.