-
Notifications
You must be signed in to change notification settings - Fork 0
/
structurizr-confluence.js
39 lines (35 loc) · 1.3 KB
/
structurizr-confluence.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function getUrlParameter(param) {
var codedParam = (new RegExp(param + '=([^&]*)')).exec(window.location.search)[1];
return decodeURIComponent(codedParam);
}
function getMacroParameter(macro, name, defaultValue) {
if (macro.parameters[name] && macro.parameters[name].value) {
return macro.parameters[name].value;
} else {
return defaultValue;
}
}
StructurizrEmbed.resizeEmbeddedDiagram = function (elementId) {
var structurizrEmbed = document.getElementById(elementId);
var width = structurizrEmbed.offsetWidth;
var aspectRatio = StructurizrEmbed.aspectRatios[elementId];
var addition = StructurizrEmbed.additions[elementId];
var height = Math.floor((width / aspectRatio)) + addition;
structurizrEmbed.height = height + "px";
AP.resize("100%", (height + 4) + "px"); // the 4 pixels extra stops a scrollbar from showing :-/
};
function main() {
AP.require("request", function(request) {
var pageId = getUrlParameter("pageId");
var pageVersion = getUrlParameter("pageVersion");
var macroId = getUrlParameter("macroId");
request({
url: "/rest/api/content/" + pageId +
"/history/" + pageVersion +
"/macro/id/" + macroId,
success: function(response) {
embedDiagram(JSON.parse(response));
}
});
});
}