Thank you,
I've tried something like this but still have the error 'wialon' is not defined.
/// Fetch varable from 'GET' request
let get_url_parameter = function (name, def) {
if (!name) {
return null;
}
let pairs = decodeURIComponent(document.location.search.substr(1)).split("&");
for (let i = 0; i < pairs.length; i++) {
let pair = pairs[i].split("=");
if (pair[0] === name) {
pair.splice(0, 1);
return pair.join("=");
}
}
return def || null;
};
/// Load scripts
function load_script(src, callback) {
let script = document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("charset","UTF-8");
script.setAttribute("src", src);
if (callback && typeof callback === "function") {
script.onload = callback;
}
document.getElementsByTagName("head")[0].appendChild(script);
}[/i]
[i]let ready = (callback) => {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}[/i]
[i]//DOM is ready
ready(() => {
let branch = get_url_parameter("b","master");
let url = get_url_parameter("baseUrl",(branch=="develop"?"https://dev-api.wialon.com":"https://hst-api.wialon.com"));
if (!url)
url = get_url_parameter("hostUrl","https://hosting.wialon.com");
if (!url)
return null;
url += "/wsdk/script/wialon.js";
// load wialon sdk
load_script(url, function() {
let session = wialon.core.Session.getInstance();
session.initSession('https://hst-api.wialon.com');
});
});