From 23df00a0df1c5fb7d21d67189980d6bee2c3dd2c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 25 Aug 2015 12:12:13 +0100 Subject: [PATCH] Began to add support for markdown modification --- src/image-decoder.js | 14 ++++++++++++++ src/injections/github.js | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/image-decoder.js b/src/image-decoder.js index 9c63f89..c6917f7 100644 --- a/src/image-decoder.js +++ b/src/image-decoder.js @@ -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% \ No newline at end of file diff --git a/src/injections/github.js b/src/injections/github.js index e93f204..6f279cd 100644 --- a/src/injections/github.js +++ b/src/injections/github.js @@ -6,12 +6,14 @@ function change_readme() { inject_image('#readme'); } +$('#partial-new-comment-form-actions').append(''); + $("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(); \ No newline at end of file