1
Fork 0

Began to add support for markdown modification

This commit is contained in:
Jake Howard 2015-08-25 12:12:13 +01:00
parent d46934cdb9
commit 23df00a0df
2 changed files with 17 additions and 1 deletions

View file

@ -14,6 +14,20 @@ function inject_image(ident, classes) {
}); });
} }
function markdown_injector(ident) {
console.log("Modifying markdown of " + ident);
decoder = image_decoder.images;
for (var i = 0; i < decoder.length; i++) {
raw_key = Object.keys(decoder[i]);
image = decoder[i][raw_key];
key = "(" + raw_key + ")";
$(ident).text($(ident).text().replace(key,
"![" + raw_key + "](" + image + ")"
));
}
}
console.log("Injection"); console.log("Injection");
var image_decoder = %image_decoder% var image_decoder = %image_decoder%

View file

@ -6,12 +6,14 @@ function change_readme() {
inject_image('#readme'); inject_image('#readme');
} }
$('#partial-new-comment-form-actions').append('<button id="#markdown-inject-btn" class="btn">Inject Emoticons</button>');
$("button.btn[name='comment_and_close']").prev().on('click', change_comments); $("button.btn[name='comment_and_close']").prev().on('click', change_comments);
$('.js-comment-container').on('load change', change_comments); $('.js-comment-container').on('load change', change_comments);
$('#readme').on('load change', change_readme); $('#readme').on('load change', change_readme);
$('#markdown-inject-btn').on('click', function() { markdown_injector('#new-comment-field');})
change_comments(); change_comments();
change_readme(); change_readme();