1// All material copyright ESRI, All Rights Reserved, unless otherwise specified. 2// See http://geoportal.meppen.de/portal/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details. 3�/////////////////////////////////////////////////////////////////////////// 4// Copyright © Esri. All Rights Reserved. 5// 6// Licensed under the Apache License Version 2.0 (the "License"); 7// you may not use this file except in compliance with the License. 8// You may obtain a copy of the License at 9// 10// http://www.apache.org/licenses/LICENSE-2.0 11// 12// Unless required by applicable law or agreed to in writing, software 13// distributed under the License is distributed on an "AS IS" BASIS, 14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15// See the License for the specific language governing permissions and 16// limitations under the License. 17/////////////////////////////////////////////////////////////////////////// 18 19//**************************************************************** 20//The main function of the env.js is to initialize apiUrl and path 21//**************************************************************** 22 23/* jshint unused: false */ 24 25/******************************** 26Global variables: 27 isXT: XT builder or not. This variable is set by builder node server. 28 isBuilder: is builder or app. This flag is used to distinguish the build and app in jimu.js 29 isRunInPortal: whether the app/builder is in portal or not. 30 builderNls: the builder nls bundle 31 portalUrl: the portal url 32 configWindow: in builder only, the config app window object 33 previewWindow: in builder only, the preview app window object 34 setConfigViewerTopic: in builder only, used to communicate between builder and config window 35 setPreviewViewerTopic: in builder only, used to communicate between builder and preview window 36 appId: in builder only, the current opened app id. 37 38 apiUrl: the URL of the ArcGIS API for JavaScript 39 allCookies: all cookies 40 path: the builder/app path section in window.location 41 appPath: the app's path. In app, it's the same with path; In builder, it's not. 42 queryObject: the query parameters 43 jimuNls: the jimu nls bundle 44 isRTL: the language is right to left, 45 wabVersion: the wab version, like 1.1, 1.2 46 productVersion: the product version, like portal10.3, online3.5, developer edition1.0 47 48 dojoConfig: the dojo config object 49 jimuConfig: defined in jimu/main 50 51 weinreUrl: for mobile debug 52 debug: boolean. If it's debug mode, the app will load weinre file 53 54Global functions: 55 loadResource: load JS or CSS 56 loadResources: load array of JS or CSS 57 testLoad: load JS/CSS by condition 58 loadingCallback: the resources loaded callback 59*******************************/ 60/*global testLoad, ActiveXObject */ 61var 62 // the URL of the ArcGIS API for JavaScript, you can change it to point to your own API. 63 apiUrl = null, 64 65 //weinreUrl: String 66 // weinre is a tool which can help debug the app on mobile devices. 67 // Please see: http://people.apache.org/~pmuellr/weinre/docs/latest/Home.html 68 weinreUrl = '//launch.chn.esri.com:8081/target/target-script-min.js', 69 70 //debug: Boolean 71 // If it's debug mode, the app will load weinre file 72 debug = false, 73 74 //deprecated, use appInfo.appPath instead 75 path = null, 76 77 isXT = false, 78 79 allCookies, 80 81 verboseLog = true, 82 83 //This version number will be appended to URL to avoid cache. 84 //The reason we do not use wabVersion is to avoid force user to change wabVersion when they are customizing app. 85 deployVersion = '2.12'; 86 87// console.time('before map'); 88 89/////Builder server will remove this line's comment, so set isXT flag to true 90 91//isXT = true; 92 93///////////////////////////////////// 94 95 96/////Build scripts will uncomment this line to disable verboseLog. 97 98//verboseLog = false; 99 100///////////////////////////////////// 101 102(function(global){ 103 //init API URL 104 var queryObject = getQueryObject(); 105 var apiVersion = '3.28'; 106 107 ////////uncomment the following line when downloading the app 108
109 //apiUrl = 'https://geoportal.meppen.de/portal/jsapi/jsapi'; 110 111 ////////////////////////////////////////////////////////////// 112 allCookies = getAllCookies(); 113 114 if (queryObject.apiurl) { 115 if(!checkApiUrl(queryObject.apiurl)){ 116 console.error('?apiurl must point to an ULR that is in the app or in esri.com/arcgis.com domain.'); 117 return; 118 } 119 apiUrl = queryObject.apiurl; 120 } 121 window.appInfo = {isRunInPortal: !isXT}; 122 if (!apiUrl) { 123 if (isXT) { 124 apiUrl = 'https://js.arcgis.com/' + apiVersion; 125 } else { 126 var portalUrl = getPortalUrlFromLocation(); 127 if (portalUrl.indexOf('arcgis.com') > -1) { 128 if(portalUrl.indexOf('devext.arcgis.com') > -1){ 129 apiUrl = '//jsdev.arcgis.com/' + apiVersion; 130 }else if(portalUrl.indexOf('qa.arcgis.com') > -1){ 131 apiUrl = '//jsqa.arcgis.com/' + apiVersion; 132 }else{ 133 apiUrl = '//js.arcgis.com/' + apiVersion; 134 } 135 136 // apiUrl = 'https://js.arcgis.com/' + apiVersion; 137 } else { 138 apiUrl = portalUrl + 'jsapi/jsapi/'; 139 } 140 } 141 } 142 143 if (apiUrl.substr(apiUrl.length - 1, apiUrl.length) !== '/') { 144 apiUrl = apiUrl + '/'; 145 } 146 147 path = getPath(); 148 149 function getAllCookies(){ 150 var strAllCookie = document.cookie; 151 var cookies = {}; 152 if (strAllCookie) { 153 var strCookies = strAllCookie.split(';'); 154 for(var i = 0; i < strCookies.length; i++){ 155 var splits = strCookies[i].split('='); 156 if(splits && splits.length > 1){ 157 cookies[splits[0].replace(/^\s+|\s+$/gm, '')] = splits[1]; 158 } 159 } 160 } 161 return cookies; 162 } 163 164 function checkApiUrl(url){ 165 if(/^\/\//.test(url) || /^https?:\/\//.test(url)){ 166 return /(?:[\w\-\_]+\.)+(?:esri|arcgis)\.com/.test(url); //api url must be in esri.com or arcgis.com 167 }else{ 168 return true; 169 } 170 } 171 172 function getPortalUrlFromLocation(){ 173 var portalUrl = getPortalServerFromLocation() + getDeployContextFromLocation(); 174 return portalUrl; 175 } 176 177 function getPortalServerFromLocation(){ 178 var server = window.location.protocol + '//' + window.location.host; 179 return server; 180 } 181 182 function getDeployContextFromLocation (){ 183 var keyIndex = window.location.href.indexOf("/home/"); 184 if(keyIndex < 0){ 185 keyIndex = window.location.href.indexOf("/apps/"); 186 } 187 var context = window.location.href.substring(window.location.href.indexOf( 188 window.location.host) + window.location.host.length + 1, keyIndex); 189 if (context !== "/") { 190 context = "/" + context + "/"; 191 } 192 return context; 193 } 194 195 function getPath() { 196 var fullPath, path; 197 198 fullPath = window.location.pathname; 199 if (fullPath === '/' || fullPath.substr(fullPath.length - 1) === '/') { 200 path = fullPath; 201 }else{ 202 var sections = fullPath.split('/'); 203 var lastSection = sections.pop(); 204 if (/\.html$/.test(lastSection) || /\.aspx$/.test(lastSection) || 205 /\.jsp$/.test(lastSection) || /\.php$/.test(lastSection)) { 206 //index.html may be renamed to index.jsp, etc. 207 path = sections.join('/') + '/'; 208 } else { 209 return false; 210 } 211 } 212 return path; 213 } 214 215 function getQueryObject(){ 216 var query = window.location.search; 217 if (query.indexOf('?') > -1) { 218 query = query.substr(1); 219 } 220 var pairs = query.split('&'); 221 var queryObject = {}; 222 for(var i = 0; i < pairs.length; i++){ 223 var splits = decodeURIComponent(pairs[i]).split('='); 224 queryObject[splits[0]] = splits[1]; 225 } 226 return queryObject; 227 } 228 function _loadPolyfills(prePath, cb) { 229 prePath = prePath || ""; 230 var ap = Array.prototype, 231 fp = Function.prototype, 232 sp = String.prototype, 233 loaded = 0, 234 completeCb = function() { 235 loaded++; 236 if (loaded === tests.length) { 237 cb(); 238 } 239 }, 240 tests = [{ 241 test: window.console, 242 failure: prePath + "libs/polyfills/console.js", 243 callback: completeCb 244 }, {
245 test: ap.indexOf && ap.lastIndexOf && ap.forEach && ap.every && ap.some && 246 ap.filter && ap.map && ap.reduce && ap.reduceRight, 247 failure: prePath + "libs/polyfills/array.generics.js", 248 callback: completeCb 249 }, { 250 test: fp.bind, 251 failure: prePath + "libs/polyfills/bind.js", 252 callback: completeCb 253 }, { 254 test: Date.now, 255 failure: prePath + "libs/polyfills/now.js", 256 callback: completeCb 257 }, { 258 test: sp.trim, 259 failure: prePath + "libs/polyfills/trim.js", 260 callback: completeCb 261 }, { 262 test: false, 263 failure: prePath + "libs/polyfills/FileSaver.js", 264 callback: completeCb 265 }, { 266 test: typeof Blob !== 'undefined', 267 failure: prePath + "libs/polyfills/FileSaver.ie9.js", 268 callback: completeCb 269 }, { 270 test: window.Blob, 271 failure: prePath + "libs/polyfills/Blob.js", 272 callback: completeCb 273 }, { 274 test: window.ArrayBuffer, 275 failure: prePath + "libs/polyfills/typedarray.js", 276 callback: completeCb 277 }]; 278 279 for(var i = 0; i < tests.length; i++){ 280 testLoad(tests[i]); 281 } 282 } 283 284 function localeIsSame(locale1, locale2){ 285 return locale1.split('-')[0] === locale2.split('-')[0]; 286 } 287 288 function _setRTL(locale){ 289 var rtlLocales = ["ar", "he"]; 290 var dirNode = document.getElementsByTagName("html")[0]; 291 var isRTLLocale = false; 292 for (var i = 0; i < rtlLocales.length; i++) { 293 if (localeIsSame(rtlLocales[i], locale)) { 294 isRTLLocale = true; 295 } 296 } 297 298 dirNode.setAttribute("lang", locale); 299 if (isRTLLocale) { 300 dirNode.setAttribute("dir", "rtl"); 301 dirNode.className += " esriRtl jimu-rtl"; 302 dirNode.className += " " + locale + " " + 303 (locale.indexOf("-") !== -1 ? locale.split("-")[0] : ""); 304 }else { 305 dirNode.setAttribute("dir", "ltr"); 306 dirNode.className += " esriLtr jimu-ltr"; 307 dirNode.className += " " + locale + " " + 308 (locale.indexOf("-") !== -1 ? locale.split("-")[0] : ""); 309 } 310 311 window.isRTL = isRTLLocale; 312 } 313 314 global._loadPolyfills = _loadPolyfills; 315 global.queryObject = queryObject; 316 global._setRTL = _setRTL; 317 318 global.avoidRequireCache = function(require){ 319 var dojoInject = require.injectUrl; 320 require.injectUrl = function(url, callback, owner){ 321 url = appendDeployVersion(url); 322 dojoInject(url, callback, owner); 323 }; 324 }; 325 326 global.avoidRequestCache = function (aspect, requestUtil){ 327 aspect.after(requestUtil, 'parseArgs', function(args){ 328 args.url = appendDeployVersion(args.url); 329 return args; 330 }); 331 }; 332 333 function appendDeployVersion(url){ 334 if(/^http(s)?:\/\//.test(url) || /^\/proxy\.js/.test(url) || /^\/\//.test(url)){ 335 return url; 336 } 337 if(url.indexOf('?') > -1){ 338 url = url + '&wab_dv=' + deployVersion; 339 }else{ 340 url = url + '?wab_dv=' + deployVersion; 341 } 342 return url; 343 } 344})(window);
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.