Last active
May 12, 2022 10:42
-
-
Save kevinvalk/ae09e21a522c378b2ceb419cf09a36a7 to your computer and use it in GitHub Desktop.
Can be used to integrate JIRA issue collector as a iframe form in a page where javascript is not allowed. Call like https://cdn.rawgit.com/kevinvalk/ae09e21a522c378b2ceb419cf09a36a7/raw/a57cb1cb788fa6c141893dd1fdcf185d541c22af/issue_collector.html?url=<JIRA URL>#<ISSUE COLLECTOR ID>.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="x-ua-compatible" content="IE=edge"/> | |
<script type="text/javascript"> | |
function getUrlParameter(name) { | |
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | |
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | |
var results = regex.exec(location.search); | |
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
}; | |
function onLoad() { | |
var iframe = document.getElementById('atlwdg-frame'); | |
var url = "https://" + encodeURIComponent(getUrlParameter('url')); | |
iframe.onload = function() { | |
this.contentWindow.postMessage(JSON.stringify({messageType: 'collector.iframe.loaded'}), url); | |
} | |
var id = window.location.hash.substr(1); | |
iframe.src = url + "/rest/collectors/1.0/template/form/" + (id == '' ? '_' : encodeURIComponent(id)) + "?os_authType=none"; | |
} | |
window.addEventListener("message", function(event) { | |
switch(event.data) { | |
case "cancelFeedbackDialog": | |
alert("Your request has successfully been submitted to JIRA, thanks!"); | |
onLoad(); // Restart collector | |
break; | |
}; | |
}, false); | |
</script> | |
<style> | |
html { | |
height: 100%; | |
} | |
body { | |
height: 100%; | |
margin: 0px; | |
padding: 0px; | |
overflow: hidden; | |
} | |
#atlwdg-frame { | |
width: 100%; | |
height: 100%; | |
margin: 0px; | |
padding: 0px; | |
overflow: hidden; | |
} | |
</style> | |
</head> | |
<body onload="onLoad()"><iframe id="atlwdg-frame" scrolling="no" frameborder="0" src=""></iframe></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
Thanks for useful example!
Do you happen to have encountered this kind of error in Chrome/Safari