82 lines
2.7 KiB
Vue
82 lines
2.7 KiB
Vue
/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
|
|
* This program are made available under the terms of the Apache License, Version 2.0
|
|
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
(function () {
|
|
var r = new RegExp("(^|(.*?\\/))(include-plot\.js)(\\?|$)"),
|
|
s = document.getElementsByTagName('script'), targetScript;
|
|
for (var i = 0; i < s.length; i++) {
|
|
var src = s[i].getAttribute('src');
|
|
if (src) {
|
|
var m = src.match(r);
|
|
if (m) {
|
|
targetScript = s[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function inputScript(url) {
|
|
var script = '<script type="text/javascript" src="' + url + '"><' + '/script>';
|
|
document.writeln(script);
|
|
}
|
|
|
|
function inputCSS(url) {
|
|
var css = '<link rel="stylesheet" href="' + url + '">';
|
|
document.writeln(css);
|
|
}
|
|
|
|
function inArray(arr, item) {
|
|
for (i in arr) {
|
|
if (arr[i] == item) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function supportES6() {
|
|
var code = "'use strict'; class Foo {}; class Bar extends Foo {};";
|
|
try {
|
|
(new Function(code))();
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
if (!Array.from) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//加载类库资源文件
|
|
function load() {
|
|
var includes = (targetScript.getAttribute('include') || "").split(",");
|
|
var excludes = (targetScript.getAttribute('exclude') || "").split(",");
|
|
// if (!inArray(excludes, 'leaflet')) {
|
|
// inputCSS('../leaflet/libs/leaflet/1.3.1/leaflet.css');
|
|
// inputScript('../leaflet/libs/leaflet/1.3.1/leaflet.js');
|
|
// }
|
|
|
|
// iclient
|
|
// if (!inArray(excludes, 'iclient-leaflet')) {
|
|
// if (supportES6()) {
|
|
// inputScript("../leaflet/dist/leaflet/iclient9-leaflet-es6.js");
|
|
// } else {
|
|
// inputScript("../leaflet/dist/leaflet/iclient9-leaflet.min.js");
|
|
// }
|
|
// }
|
|
if (inArray(includes, 'iclient-plot-leaflet')) {
|
|
inputCSS("../plotting/iclient-plot-leaflet/iclient-plot-leaflet.css");
|
|
if (supportES6()) {
|
|
inputScript("../plotting/iclient-plot-leaflet/iclient-plot-leaflet-es6.min.js");
|
|
} else {
|
|
inputScript("../plotting/iclient-plot-leaflet/iclient-plot-leaflet.min.js");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
load();
|
|
window.isLocal = false;
|
|
window.server = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : document.location.protocol + "//" + document.location.host;
|
|
})();
|