Skip to content

Instantly share code, notes, and snippets.

@stdavis
Last active December 14, 2015 14:29
Show Gist options
  • Select an option

  • Save stdavis/5101227 to your computer and use it in GitHub Desktop.

Select an option

Save stdavis/5101227 to your computer and use it in GitHub Desktop.
EmbeddedMapLoader.js
(function(){
var server = location.pathname.replace(/\/[^\/]+$/, "");
if (window.jasmine) {
server += '/src';
}
// var server = 'http://mapserv.utah.gov/DEQSpills';
var head = document.getElementsByTagName('head').item(0);
function loadCss(href){
// summary:
// Adds a css link element to the document head with the
// passed in href
console.log(this.declaredClass + "::loadCss", arguments);
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = href;
head.appendChild(link);
}
function loadJavaScript(src){
// summary:
// Adds a script element to the head with the passed
// in src.
console.log(this.declaredClass + "::loadJavaScript", arguments);
document.write("<script type='text/javascript' src='" + src + "'></script>");
}
// load dojo and agrc css
loadCss('http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/claro/claro.css');
loadCss('http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css');
loadCss(server + '/app/resources/app.css');
// load javascript
window.dojoConfig = {
packages: [
{
name: 'app',
location: server + '/app'
},
{
name: 'agrc',
location: server + '/agrc'
},
{
name: 'ijit',
location: server + '/ijit'
}
]
};
loadJavaScript('http://serverapi.arcgisonline.com/jsapi/arcgis/3.3');
function init() {
console.log('init');
require([
'app/App'
],
function (
App
) {
window.AGRC = {};
AGRC.AGRCMap = new App(null, 'AGRCMapDiv');
AGRC.AGRCMap.startup();
});
}
if (window.addEventListener) {
window.addEventListener('load', init, false);
} else if (window.attachEvent) {
window.attachEvent('onload', init);
} else {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = init;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
init();
};
}
}
})();
@rsarijlou

Copy link
Copy Markdown

is this code AMD compliance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment