Created
May 1, 2013 17:02
-
-
Save zachkinstner/5496612 to your computer and use it in GitHub Desktop.
Trello Card JSON to JIRA Markdown
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
function buildJiraMarkdown(card) { | |
var jira = | |
"{panel}\n"+ | |
"h3. [" + card.name + "|" + card.shortUrl + "]\n" + | |
card.desc + "\n\n" + | |
"*Labels:* "; | |
for (var i = 0; i < card.labels.length; ++i) { | |
var label = card.labels[i]; | |
var c = label.color; | |
if (label.color == "yellow") { | |
c = "#aaaa00"; | |
} | |
jira += (i === 0 ? "" : ", ") + "{color:" + c + "}" + label.name + "{color}"; | |
} | |
jira += "\n"; | |
if (card.due) { | |
jira += "*Due:* " + card.due.substr(0, card.due.indexOf("T")) + "\n"; | |
} | |
for (i = 0; i < card.checklists.length; ++i) { | |
var list = card.checklists[i]; | |
var complete = 0; | |
var text = ""; | |
for (var j = 0; j < list.checkItems.length; ++j) { | |
var item = list.checkItems[j]; | |
text += "- " + (item.state == "complete" ? "(/)" : "(x)") + " " + item.name + "\n"; | |
complete += (item.state == "complete" ? 1 : 0); | |
} | |
jira += "\n*" + list.name + "* (" + Math.round(complete / list.checkItems.length * 100) + "% complete)\n"; | |
jira += text; | |
} | |
return jira+"{panel}"; | |
} | |
//////////////////////// | |
//Exported JSON data | |
var trelloCard = | |
{}; | |
alert(buildJiraMarkdown(trelloCard)); |
Various to-do items: include comments, activities, attachments, etc.
Also, update the script to load JSON data directly via Trello URL.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Available at JsFiddle: http://jsfiddle.net/zachkinstner/6AUE6