Hi,
I have following code and it works if i click on Create Issues while i look at an issue. If i click on Create Issue on the dashboard it does not work.
If i cancel the create dialog and click Create issue again i hang on the wheel of fortune. What am i doing wrong ?
<script type="text/javascript">
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
$('#summary').keyup(function() {
var text = $(this).val(),
count = encodeURIComponent(text).replace(/%[A-F\d]{2}/g, 'U').length;
switch (true)
{
case (count<50):
$('#count').text("Characters: " + count);
break;
case (count>50 && count<60):
$('#count').css("color","green");
$('#count').text("Seems like a good length of a summary!");
break;
case (count>60 && count<80):
$('#count').css("color","green");
$('#count').text("You done ?");
break;
case (count>80):
$('#count').css("color","red");
$('#count').text("Hey! You can use the description field, it's just below, use it!");
break;
}
});
});
</script>
<div id="count"></div>
Summary
/donnib
@Lukas Maruniak thank you but i don't quite follow you. I tried reading the link u gave me but i don't see anywhere they discuss atlassian-plugin.xml. Is that a file i need to create ? How do i link the JavaScript with the summary field ?
Well, it's the main descpriptor file in which are defined all plugin modules which you created.
I think this could be helpfull for you -> https://developer.atlassian.com/display/DOCS/Set+up+the+Atlassian+Plugin+SDK+and+Build+a+Project
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would like to recommend you to use your javascript as webresource - >
First try to move your js to separate file(e.g. summary.js) :
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
$('#summary').keyup(function() {
var text = $(this).val(),
count = encodeURIComponent(text).replace(/%[A-F\d]{2}/g, 'U').length;
switch (true)
{
case (count<50):
$('#count').text("Characters: " + count);
break;
case (count>50 && count<60):
$('#count').css("color","green");
$('#count').text("Seems like a good length of a summary!");
break;
case (count>60 && count<80):
$('#count').css("color","green");
$('#count').text("You done ?");
break;
case (count>80):
$('#count').css("color","red");
$('#count').text("Hey! You can use the description field, it's just below, use it!");
break;
}
});
});
And then define it in atlassian-plugin.xml ->
<web-resource name="Resources" key="resources">
<context>atl.general</context>
<resource name="summary.js" type="download" location="summary.js"></resource>
</web-resource>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also there is another event - > JIRA.Events.NEW_PAGE_ADDED - so try it with this also - maybe it's better for your purpose.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.