Hi,
I have created a user macro in confluence. The user macro template has custom javascript.
When I placed that javascript in side the HTML Macro, It works fine on the page. But, If I put it in the user macro and include the user macro in the page, it does not work.
Can anyone please let me know what I am doing wrong here...
Script:
<script>
$('.jira-issue-key').ready(measure());
function measure(){
console.log("allu inside measure");
if ($('.jira-issue-key').length > 0 ) {
console.log("nallu");
$(document).ready(function(){
var array = document.getElementsByClassName("jira-issue-key");
var i = 0;
var key = "";
var hreftext = "";
while(!key.includes('FEATURE') && i < array.length ){
hreftext = document.getElementsByClassName("jira-issue-key")[i].href;
key = hreftext.split('/')[(hreftext.split('/')).length - 1];
i++;
}
if(key.includes('FEATURE')) {
$.getJSON(`https://devconfluence2.******.com/plugins/servlet/applinks/proxy?appId=*********&path=https://athenajira.*******.com/rest/api/latest/issue/${key}`, function(data) {
var pathToGA = '';
var techinicalRisk = '';
var targetGaRelease = '';
var changeManagementTier = '';
var serviceline = '';
if(data["fields"]["customfield_15723"]) { pathToGA = data["fields"]["customfield_15723"]["value"]; }
if(data["fields"]["customfield_17105"]) { techinicalRisk = data["fields"]["customfield_17105"]["value"]; }
if(data["fields"]["customfield_16006"]) { targetGaRelease = data["fields"]["customfield_16006"]["value"]; }
if(data["fields"]["customfield_15709"]) { changeManagementTier = data["fields"]["customfield_15709"]["value"]; }
if(data["fields"]["customfield_15722"]) { serviceline = data["fields"]["customfield_15722"]["value"]; }
if(pathToGA) {
document.getElementById("pathToGA").innerHTML = pathToGA;
} else {
document.getElementById("pathToGA").innerHTML = "";
}
if(techinicalRisk) {
document.getElementById("technicalrisk").innerHTML = techinicalRisk;
} else {
document.getElementById("technicalrisk").innerHTML = "";
}
if(targetGaRelease) {
document.getElementById("targetGaRelease").innerHTML = targetGaRelease;
} else {
document.getElementById("targetGaRelease").innerHTML = "";
}
if(changeManagementTier) {
document.getElementById("changeManagementTier").innerHTML = changeManagementTier;
} else {
document.getElementById("changeManagementTier").innerHTML = "";
}
if(serviceline) {
document.getElementById("serviceline").innerHTML = serviceline;
} else {
document.getElementById("serviceline").innerHTML = "";
}
});
}
});
}
}
</script>
User Configuration's Screenshot:
Hi nallu,
I believe you're having an issue with $ being interpreted as a variable in Velocity. Simply replace all your $ signs with the word jQuery (capitalized that way) and your user macro should work.
Hi @nallu ,
I believe this is a bug, please see https://jira.atlassian.com/browse/CONFSERVER-26104.
-Scott
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.