package com.gwidgets.leaflet.test;


import elemental2.dom.DomGlobal;
import elemental2.dom.Element.OnloadCallbackFn;
import elemental2.dom.HTMLLinkElement;
import elemental2.dom.HTMLScriptElement;

public class InjectedLeafletResources {
	

public static void whenReady(OnloadCallbackFn function){
		
		HTMLScriptElement leafletScript = (HTMLScriptElement) DomGlobal.document.createElement("script");
		leafletScript.src="http://unpkg.com/leaflet@1.0.0/dist/leaflet.js";
		leafletScript.type="text/javascript";
		
		HTMLLinkElement leafletStyle = (HTMLLinkElement) DomGlobal.document.createElement("link");
		leafletStyle.href="http://unpkg.com/leaflet@1.0.0/dist/leaflet.css";
		leafletStyle.rel="stylesheet";
		
		
		DomGlobal.document.head.appendChild(leafletScript);
		DomGlobal.document.head.appendChild(leafletStyle);
		
		leafletScript.onload = function;

	}

}

@@ -236,11 +236,8 @@
 s %7B%0A
-%09%0A%0A
 publ
@@ -288,17 +288,16 @@
 nction)%7B
-%0A
 %09%09%0A%09%09HTM
@@ -416,36 +416,58 @@
 rc=%22http
+s
 ://
-unpkg.com
+cdnjs.cloudflare.com/ajax/libs
 /leaflet
 @1.0.0/d
@@ -454,36 +454,31 @@
 libs/leaflet
-@
+/
 1.0.0/
-dist/
 leaflet.js%22;
@@ -524,319 +524,59 @@
 ;%0A%09%09
-%0A%09%09HTMLLinkElement leafletStyle = (HTMLLinkElement) DomGlobal.document.createElement(%22link%22);%0A%09%09leafletStyle.href=%22http://unpkg.com/leaflet@1.0.0/dist/leaflet.css%22;%0A%09%09leafletStyle.rel=%22stylesheet%22;%0A%09%09%0A%09%09%0A%09%09DomGlobal.document.head.appendChild(leafletScript);%0A%09%09DomGlobal.document.head.appendChild(leafletStyle);%0A
+DomGlobal.document.head.appendChild(leafletScript);
 %09%09%0A%09
@@ -613,11 +613,8 @@
 on;%0A
-%0A
 %09%7D%0A
-%0A%7D%0A
+%7D

update test resource script url and polish