Began to add support for markdown modification
This commit is contained in:
parent
d46934cdb9
commit
23df00a0df
2 changed files with 17 additions and 1 deletions
|
@ -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");
|
||||
|
||||
var image_decoder = %image_decoder%
|
|
@ -6,12 +6,14 @@ function change_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);
|
||||
|
||||
$('.js-comment-container').on('load change', change_comments);
|
||||
|
||||
$('#readme').on('load change', change_readme);
|
||||
|
||||
|
||||
$('#markdown-inject-btn').on('click', function() { markdown_injector('#new-comment-field');})
|
||||
change_comments();
|
||||
change_readme();
|
Reference in a new issue