summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2018-03-28 07:01:22 -0700
committerAaron Parecki <aaron@parecki.com>2018-03-28 07:01:22 -0700
commit4a0cb5a5b3f3a8e1e4dfd8665c8982a48e92f90a (patch)
tree26fad26baf7a95bf520cab575bf08fee62940ee5
parentb143cb94f3f8ae140eed623c90b56391067a2f0a (diff)
typing a backtick when replying to a github url switches to markdown
-rw-r--r--views/new-post.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/views/new-post.php b/views/new-post.php
index a2ec757..030ca61 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -316,6 +316,9 @@ function restoreNoteState() {
}
});
$("#note_content").change();
+ if($("#note_content").val().match(/`/)) {
+ switchToMarkdown();
+ }
activateTokenField();
} else {
activateTokenField();
@@ -453,13 +456,17 @@ $(function(){
}
// Easter egg: press ctrl+shift+m to switch to markdown
if(e.keyCode == 77 && e.ctrlKey && e.shiftKey) {
- $("#content-type-selection select").val("text/markdown");
- $("#content-type-selection").removeClass("hidden");
+ switchToMarkdown();
}
});
});
+function switchToMarkdown() {
+ $("#content-type-selection select").val("text/markdown");
+ $("#content-type-selection").removeClass("hidden");
+}
+
function refreshPhotoPreviews() {
$("#photo-previews").html("");
for(i=0; i<photos.length; i++) {
@@ -534,12 +541,18 @@ $(function(){
saveNoteState();
});
- $("#note_content").on('keyup', function(){
+ $("#note_content").on('keyup', function(e){
var scrollHeight = document.getElementById("note_content").scrollHeight;
var currentHeight = parseInt($("#note_content").css("height"));
if(Math.abs(scrollHeight - currentHeight) > 20) {
$("#note_content").css("height", (scrollHeight+30)+"px");
}
+ // If you type a backtick in the content, and are replying to a github issue, switch to markdown
+ if(e.key == '`') {
+ if($("#note_in_reply_to").val().match(/github\.com/)) {
+ switchToMarkdown();
+ }
+ }
});
$("#expand-reply").click(function(){