PageSourceSearch

https://gisservices.cityofmesquite.com/portal/apps/webappviewer/simpleLoader.js

js cityofmesquite.com collected 2026-09-24 09:36:39 UTC 5,235 bytes, 178 lines download raw bytes

1// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
2// See http://gisservices.cityofmesquite.com/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(function(global){
21
22  //load js, css files
23  function loadResources(ress, onOneBeginLoad, onOneLoad, onLoad){
24    var loaded = [];
25    function _onOneLoad(url){
26      //to avoid trigger onload more then one time
27      if(checkHaveLoaded(url)){
28        return;
29      }
30      loaded.push(url);
31      if(onOneLoad){
32        onOneLoad(url, loaded.length);
33      }
34      if(loaded.length === ress.length){
35        if(onLoad){
36          onLoad();
37        }
38      }
39    }
40
41    for(var i = 0; i < ress.length; i ++){
42      loadResource(ress[i], onOneBeginLoad, _onOneLoad);
43    }
44
45    function checkHaveLoaded(url){
46      for(var i = 0; i < loaded.length; i ++){
47        if(loaded[i] === url){
48          return true;
49        }
50      }
51      return false;
52    }
53  }
54
55
56
57  function getExtension(url) {
58    url = url || "";
59    var items = url.split("?")[0].split(".");
60    return items[items.length-1].toLowerCase();
61  }
62
63  function loadResource(url, onBeginLoad, onLoad){
64    if(onBeginLoad){
65      onBeginLoad(url);
66    }
67    var type = getExtension(url);
68    if(type.toLowerCase() === 'css'){
69      loadCss(url);
70    }else{
71      loadJs(url);
72    }
73
74    function createElement(config) {
75      var e = document.createElement(config.element);
76      for (var i in config) {
77        if (i !== 'element' && i !== 'appendTo') {
78          e[i] = config[i];
79        }
80      }
81      var root = document.getElementsByTagName(config.appendTo)[0];
82      return (typeof root.appendChild(e) === 'object');
83    }
84
85    function loadCss(url) {
86      var result = createElement({
87        element: 'link',
88        rel: 'stylesheet',
89        type: 'text/css',
90        href: url,
91        onload: function(){
92          elementLoaded(url);
93        },
94        appendTo: 'head'
95      });
96
97      //for the browser which doesn't fire load event
98      //safari update documents.stylesheets when style is loaded.
99      var ti = setInterval(function() {
100        var styles = document.styleSheets;
101        for(var i = 0; i < styles.length; i ++){
102          // console.log(styles[i].href);
103          if(styles[i].href &&
104            styles[i].href.substr(styles[i].href.indexOf(url), styles[i].href.length) === url){
105            clearInterval(ti);
106            elementLoaded(url);
107          }
108        }
109      }, 500);
110      
111      return (result);
112    }
113
114    function loadJs(url) {
115      var result = createElement({
116        element: 'script',
117        type: 'text/javascript',
118        onload: function(){
119          elementLoaded(url);
120        },
121        onreadystatechange: function(){
122          elementReadyStateChanged(url, this);
123        },
124        src: url,
125        appendTo: 'body'
126      });
127      return (result);
128    }
129
130    function elementLoaded(url){
131      if(onLoad){
132        onLoad(url);
133      }
134    }
135    function elementReadyStateChanged(url, thisObj){
136      if (thisObj.readyState === 'loaded' || thisObj.readyState === 'complete') {
137        elementLoaded(url);
138      }
139    }
140  }
141
142  /***********
143  testLoad({
144    test: window.console,
145    success
146  })
147  ************/
148  function testLoad(testObj){
149    testObj.success = !!testObj.success? isArray(testObj.success)?
150      testObj.success: [testObj.success]: [];
151    testObj.failure = !!testObj.failure?
152      isArray(testObj.failure)? testObj.failure: [testObj.failure]: [];
153
154    if(testObj.test && testObj.success.length > 0){
155      loadResources(testObj.success, null, null, testObj.callback);
156    }else if(!testObj.test && testObj.failure.length > 0){
157      loadResources(testObj.failure, null, null, testObj.callback);
158    }else{
159      testObj.callback();
160    }
161  }
162
163  /* A must read: http://bonsaiden.github.com/JavaScript-Garden
164     ************************************************************/
165  function is(type, obj) {
166    var clas = Object.prototype.toString.call(obj).slice(8, -1);
167    return obj !== undefined && obj !== null && clas === type;
168  }
169
170  function isArray(item) {
171    return is("Array", item);
172  }
173
174  global.loadResources = loadResources;
175  global.loadResource = loadResource;
176  global.testLoad = testLoad;
177}
178)(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.