Commit d2651022 authored by Romain Casati's avatar Romain Casati
Browse files

Support requirejs import.

parent 34c75091
'use strict';
(function (root, factory) {
// requirejs?
if (typeof define === 'function') {
define(['module'], factory);
// TypeScript?
} else if (typeof exports === 'object') {
module.exports = factory();
// default goes to global namespace
} else {
root.Basthon = factory();
}
}(this, function (module) {
'use strict';
/**
* Using the namespace design pattern.
*/
var Basthon = (function() {
let that = {};
/**
......@@ -26,7 +34,14 @@ var Basthon = (function() {
/**
* Get the URL of the current script (usefull for serving basthon.py.js)
*/
that.urlScript = document.currentScript.src;
that.urlScript = (function () {
if( module != null ) {
let url = window.location.origin + window.location.pathname;
url = url.substring(0, url.lastIndexOf('/')) + "/";
return url + module.uri;
} else
return document.currentScript.src;
})();
/**
* Get the URL of Basthon kernel root dir.
......@@ -473,4 +488,4 @@ var Basthon = (function() {
};
return that;
})();
}));
'use strict';
(function (root, factory) {
// requirejs?
if (typeof define === 'function') {
define(['./basthon'], factory);
// TypeScript?
} else if (typeof exports === 'object') {
module.exports = factory();
// default goes to global namespace
} else {
root.Basthon.Goodies = factory(root.Basthon);
}
}(this, function (Basthon) {
'use strict';
/**
* Using the namespace design pattern.
*/
Basthon.Goodies = (function() {
let that = {};
/**
......@@ -107,4 +115,4 @@ Basthon.Goodies = (function() {
};
return that;
})();
}));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment