|
@@ -36,77 +36,73 @@
|
|
|
AC.logError(message, url, linenumber, colno, err);
|
|
|
};
|
|
|
|
|
|
- var xdm_e = AC.getSiteUrl();
|
|
|
var baseUrl = AC.getBaseUrl();
|
|
|
- var license = AC.getUrlParam('lic', false);
|
|
|
var connectUrl = baseUrl + '/atlassian-connect';
|
|
|
var head = document.getElementsByTagName('head')[0];
|
|
|
- var licenseValid = true;
|
|
|
+
|
|
|
|
|
|
var script = document.createElement('script');
|
|
|
script.setAttribute('data-options', 'resize:false;margin:false');
|
|
|
-
|
|
|
- if (license != null && xdm_e != null)
|
|
|
+
|
|
|
+ // Main
|
|
|
+ script.onload = function()
|
|
|
{
|
|
|
- if (license == 'none')
|
|
|
+ var xdm_e = AC.getSiteUrl();
|
|
|
+ var license = AC.getUrlParam('lic', false);
|
|
|
+
|
|
|
+ if (license != null && xdm_e != null)
|
|
|
{
|
|
|
- var hostParse = document.createElement('a');
|
|
|
- hostParse.href = xdm_e;
|
|
|
- var hostname = hostParse.hostname;
|
|
|
-
|
|
|
- if (hostname != null)
|
|
|
+ if (license == 'none')
|
|
|
{
|
|
|
- if (hostname.indexOf('.ngrok.io') > -1)
|
|
|
- {
|
|
|
- console.log("License status = ", license);
|
|
|
- }
|
|
|
- else
|
|
|
+ var hostParse = document.createElement('a');
|
|
|
+ hostParse.href = xdm_e;
|
|
|
+ var hostname = hostParse.hostname;
|
|
|
+
|
|
|
+ if (hostname != null)
|
|
|
{
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
-
|
|
|
- xhr.onreadystatechange = function()
|
|
|
+ if (hostname.indexOf('.ngrok.io') > -1)
|
|
|
{
|
|
|
- if (xhr.readyState == XMLHttpRequest.DONE && xhr.status >= 200 && xhr.status <= 299)
|
|
|
- {
|
|
|
- var resp = xhr.responseText;
|
|
|
-
|
|
|
- if (resp != null && resp.length > 0)
|
|
|
- {
|
|
|
- var lic = JSON.parse(resp);
|
|
|
+ console.log("License status = ", license);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AP.request({
|
|
|
+ type: 'GET',
|
|
|
+ url: '/rest/atlassian-connect/1/addons/com.mxgraph.confluence.plugins.diagramly',
|
|
|
+ contentType: 'application/json;charset=UTF-8',
|
|
|
+ success: function (resp)
|
|
|
+ {
|
|
|
+ resp = JSON.parse(resp);
|
|
|
+
|
|
|
+ var xhr = new XMLHttpRequest();
|
|
|
|
|
|
- if (lic != null && lic.atlasCloudLic != null)
|
|
|
+ xhr.onreadystatechange = function()
|
|
|
{
|
|
|
- licenseValid = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- xhr.open('POST', '/license?domain=' + hostname, true);
|
|
|
- xhr.send(null);
|
|
|
+ if (xhr.readyState == XMLHttpRequest.DONE && xhr.status >= 200 && xhr.status <= 299)
|
|
|
+ {
|
|
|
+ var resp = xhr.responseText;
|
|
|
+
|
|
|
+ if (resp != null && resp.length > 0)
|
|
|
+ {
|
|
|
+ var lic = JSON.parse(resp);
|
|
|
+
|
|
|
+ if (lic != null && lic.atlasCloudLic != null)
|
|
|
+ {
|
|
|
+ // decide whether valid and close if not
|
|
|
+ // AP.dialog.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.open('POST', '/license?domain=' + hostname + '&confLicense=' + license + '&SEN=' + resp.license? resp.license.supportEntitlementNumber : 'Unlicensed', true);
|
|
|
+ xhr.send(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- licenseValid = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Main
|
|
|
- script.onload = function()
|
|
|
- {
|
|
|
- if (!licenseValid)
|
|
|
- {
|
|
|
- setTimeout(function()
|
|
|
- {
|
|
|
- if (!licenseValid)
|
|
|
- {
|
|
|
- alert("Please install a license for the draw.io app");
|
|
|
- AP.dialog.close();
|
|
|
- }
|
|
|
- }, 3000);
|
|
|
- }
|
|
|
|
|
|
AP.resize('100%', '100%');
|
|
|
|