1mmLoader = { 2 queuedMiniMaps: [], 3 isInitialized: false, 4 isDebug: false, // NOTE: debug mode doesn't work with version 2.5 and 2.6 5 scriptOrigin: "", 6 7 getScriptOrigin: function (scriptname) { 8 var scriptOrigin = ""; 9 var scriptRegex = new RegExp("(^|(.*?\\/))" + scriptname + "(\\?|$)"); 10 11 var scripts = document.getElementsByTagName('script'); 12 for (var i = 0, len = scripts.length; i < len; i++) { 13 var src = scripts[i].getAttribute('src'); 14 if (src) { 15 var match = src.match(scriptRegex); 16 if (match) { 17 var originRegex = new RegExp("^((http:|https:|)//[^/]+/).*" + scriptname + "(\\?|$)"); 18 match = src.match(originRegex); 19 if (match) 20 scriptOrigin = match[1]; 21 this.isDebug = src.split("?debug=")[1] === "true"; 22 break; 23 } 24 } 25 } 26 27 if (scriptOrigin === "") { 28 scriptOrigin = window.location.origin + "/"; 29 } 30 31 return scriptOrigin; 32 }, 33 34 loadAPI: function (version) { 35 var location = this.scriptOrigin; 36 37 var script = document.createElement("script"); 38 39 if (this.isDebug) { 40 script.src = location + "clientapi/minimap2/" + version + ".x/minimap.debug.js"; 41 } else { 42 script.src = location + "clientapi/minimap2/" + version + ".x/minimap.js"; 43 } 44 45 document.head.appendChild(script); 46 var done = false; 47 script.onload = script.onreadystatechange = function () { 48 if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { 49 var event = new CustomEvent("MINIMAP_API_LOADED"); // use 'new CustomEvent' because 'new Event' isn't supported in IE9,IE10, and IE11. 50 window.dispatchEvent(event); // fire event to let custom implementation know that the API has been loaded. 51 52 done = true; 53 if (this.messageElement) { 54 this.messageElement.parentElement.removeChild(this.messageElement); 55 } 56 57 for (var i = 0; i < this.queuedMiniMaps.length; i++) { 58 new MiniMap.Widget(this.queuedMiniMaps[i]); 59 } 60 //cleanup 61 delete window.mmLoader; 62 } 63 }.bind(this); 64 }, 65 66 init: function (options) { 67 this.options = options; 68 69 //create a element for loading and error messages 70 this.messageElement = document.createElement("p"); 71 var mapDiv = document.getElementById(this.options.mapDiv); 72 73 if (mapDiv) { 74 this.messageElement.setAttribute("style", "position: relative; top: 48%; left: 50%"); 75 76 mapDiv.appendChild(this.messageElement); 77 78 this.browserLang = navigator.language ? navigator.language.substring(0, 2) : "en"; 79 80 if (!this.isBrowserSupported()) { 81 this.messageBrowserNotSupported(); 82 return; 83 } 84 } else if (this.options.mapDiv !== undefined) { 85 console.error("Could not find the element %o. Please check if it exist and that is has been loaded into the DOM.", this.options.mapDiv) 86 } 87 88 if (options && options.host) { 89 if (options.host[options.host.length -1] === '/') { 90 this.scriptOrigin = options.host; 91 } else { 92 this.scriptOrigin = options.host + '/'; 93 } 94 } else { 95 this.scriptOrigin = this.getScriptOrigin("mmloader.js"); 96 } 97 var url = this.scriptOrigin + "spatialmap?page=minimap2.get-version-by-id&id=" + this.options.minimapId; 98 99 this.messageLoadingMap(); 100 101 //create page request to retrieve minimap version by the minimap id. 102 var xhr = new XMLHttpRequest(); 103 xhr.open("GET", url); 104 105 xhr.onload = function () { 106 if (xhr.status === 200) { 107 var response; 108 109 try { 110 response = JSON.parse(xhr.response); 111 } 112 catch (e) { 113 // We get here when server returns xml error message. 114 console.error("Unable to load the Minimap with id: " + this.options.minimapId + ". Server response: \n%o", xhr.response); 115 this.messageGeneralError(); 116 return; 117 } 118 119 if (response.length === 0) { 120 console.error("Unable to load the Minimap with id: " + this.options.minimapId + ". It could not be found on the server.") 121 this.messageIdNotFound(); 122 return; 123 } 124 125 this.mmVersionLoaded(response); 126 } 127 }.bind(this) 128 129 xhr.send(); 130 }, 131 132 messageLoadingMap: function () { 133 var loadingMessage = "Loading map..."; 134 if (this.browserLang === "da") { 135 loadingMessage = "Henter kort..." 136 } else if (this.browserLang === "sv") { 137 loadingMessage = "Laddar karta..."; 138 } 139 this.messageElement.textContent = loadingMessage; 140 }, 141 142 messageBrowserNotSupported: function () { 143 var errorMessage = "The map is not supported by your browser."; 144 if (this.browserLang === "da") { 145 errorMessage = "Kortet er ikke understøttet af din browser."; 146 } else if (this.browserLang === "sv") { 147 errorMessage = "Kartan understöds inte av denna browser"; 148 } 149 this.messageElement.innerHTML = errorMessage; 150 }, 151 152 messageGeneralError: function () { 153 var errorMessage = "The map could not be loaded."; 154 if (this.browserLang === "da") { 155 errorMessage = "Kortet kunne ikke indlæses." 156 } else if (this.browserLang === "sv") { 157 errorMessage = "Kartan kunde inte laddas."; 158 } 159 this.messageElement.innerHTML = errorMessage; 160 }, 161 162 messageIdNotFound: function () { 163 var errorMessage = ""; 164 if (this.browserLang === "da") { 165 errorMessage = "Kortet blev ikke fundet på serveren." 166 } else if (this.browserLang === "sv") { 167 errorMessage = "Kartan kunde inte hittas på servern"; 168 } else { 169 errorMessage = "The map could not be found on the server."; 170 } 171 this.messageElement.innerHTML = errorMessage; 172 }, 173 174 mmVersionLoaded: function (response) { 175 if (response.exception) { 176 console.error(response.exception); 177 this.messageGeneralError(); 178 return; 179 } 180 181 if (response.length === 0) { 182 console.error("Unable to load the Minimap with id: " + this.options.minimapId + " could not be found on the server."); 183 this.messageIdNotFound(); 184 return; 185 } 186 187 var version = response[0].version; 188 this.loadAPI(version); 189 }, 190 191 isBrowserSupported: function () { 192 // We currently support Chrome, Firefox, Edge, and IE11. 193 var _nua = navigator.userAgent || navigator.vendor || window.opera; 194 195 // Check if the user is running a IE older than version 11. 196 var isIE = _nua.indexOf("MSIE") > 1; 197 if (isIE) { 198 var version = parseInt(_nua.substring(_nua.indexOf("MSIE ") + 5, _nua.indexOf(".", _nua.indexOf("MSIE ")))); 199 return version > 10; 200 } 201 202 return true; 203 } 204}; 205 206MiniMap = {}; 207 208MiniMap.Widget = function (options) { 209 // new MiniMap.Widget is deprecated. Please use MiniMap.CreateMiniMap instead. 210 mmLoader.queuedMiniMaps.push(options); 211 if (!mmLoader.isInitialized) { 212 mmLoader.isInitialized = true; 213 mmLoader.init(options); 214 } 215}; 216 217MiniMap.createMiniMap = function (options) { 218 mmLoader.queuedMiniMaps.push(options); 219 if (!mmLoader.isInitialized) { 220 mmLoader.isInitialized = true; 221 mmLoader.init(options); 222 } 223}; 224 225window.addEventListener("load", function () { 226 // If a div in the page has class minimapwidget the mmloader should be initialized with that minimapId and mapDiv. 227 // Only one minimap version is supported on each page, so we can initialize with the first div found. 228 var minimapElements = document.querySelectorAll(".minimapwidget"); 229 if (window.mmLoader !== undefined && minimapElements[0]) { 230 var options = { 231 minimapId: minimapElements[0].getAttribute("minimapId"), 232 mapDiv: minimapElements[0].getAttribute("id") 233 }; 234 235 if (!mmLoader.isInitialized) { 236 mmLoader.isInitialized = true; 237 mmLoader.init(options); 238 } 239 } 240});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.