Allow full URLs in MyAMS.require function call
authorThierry Florac <tflorac@ulthar.net>
Fri, 26 Jul 2019 12:40:31 +0200
changeset 534 225651b910cf
parent 533 d21c81597338
child 535 618ff34bcd7c
Allow full URLs in MyAMS.require function call
src/pyams_skin/resources/js/myams-loader.js
src/pyams_skin/resources/js/myams-loader.min.js
--- a/src/pyams_skin/resources/js/myams-loader.js	Fri Jul 26 12:38:49 2019 +0200
+++ b/src/pyams_skin/resources/js/myams-loader.js	Fri Jul 26 12:40:31 2019 +0200
@@ -23,7 +23,11 @@
 		for (var index=0; index < packages.length; index++) {
 			var package_name = packages[index];
 			if (loaded_extensions.indexOf(package_name) < 0) {
-				var source = ams.baseURL + 'myams-' + package_name + ams.devext + '.js';
+				if (package_name.startsWith('http://') || package_name.startsWith('https://')) {
+					var source = package_name;
+				} else {
+					source = ams.baseURL + 'myams-' + package_name + ams.devext + '.js';
+				}
 				deferred.push(ams.getScript(source, {async: true}, console.error));
 				loaded_extensions.push(package_name);
 			}
--- a/src/pyams_skin/resources/js/myams-loader.min.js	Fri Jul 26 12:38:49 2019 +0200
+++ b/src/pyams_skin/resources/js/myams-loader.min.js	Fri Jul 26 12:40:31 2019 +0200
@@ -1,1 +1,1 @@
-!function(e,n){var r=n.MyAMS,t=[];r.require=function(n,a){for(var i=[],s=0;s<n.length;s++){var h=n[s];if(t.indexOf(h)<0){var o=r.baseURL+"myams-"+h+r.devext+".js";i.push(r.getScript(o,{async:!0},console.error)),t.push(h)}}i.length>0?e.when.apply(e,i).then(function(){a()}):a()}}(jQuery,this);
+!function(t,e){var r=e.MyAMS,s=[];r.require=function(e,n){for(var h=[],i=0;i<e.length;i++){var a=e[i];if(s.indexOf(a)<0){if(a.startsWith("http://")||a.startsWith("https://"))var f=a;else f=r.baseURL+"myams-"+a+r.devext+".js";h.push(r.getScript(f,{async:!0},console.error)),s.push(a)}}h.length>0?t.when.apply(t,h).then(function(){n()}):n()}}(jQuery,this);