summaryrefslogtreecommitdiff
path: root/views/new-post.php
diff options
context:
space:
mode:
Diffstat (limited to 'views/new-post.php')
-rw-r--r--views/new-post.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/views/new-post.php b/views/new-post.php
index 53cb01e..46be7a9 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -133,6 +133,8 @@ function previewPhoto(event) {
$(function(){
+ var userHasSetCategory = false;
+
$("#note_content").on('change keyup', function(e){
var text = $("#note_content").val();
var tweet_length = tw_text_proxy(text).length;
@@ -141,6 +143,11 @@ $(function(){
$("#note_content_remaining span").html(remaining);
$("#note_content_remaining").removeClass("pcheck200 pcheck206 pcheck207 pcheck208 pcheck413");
$("#note_content_remaining").addClass("pcheck"+tweet_check);
+
+ // If the user didn't enter any categories, add them from the post
+ if(!userHasSetCategory) {
+ $("#note_category").val($("#note_content").val().match(/#[a-z0-9]+/g).map(function(tag){ return tag.replace('#',''); }).join(", "));
+ }
});
$("#note_in_reply_to").on('change', function(){
@@ -149,6 +156,15 @@ $(function(){
}
});
+ $("#note_category").on('keydown keyup', function(){
+ userHasSetCategory = true;
+ });
+ $("#note_category").on('change', function(){
+ if($("#note_category").val() == "") {
+ userHasSetCategory = false;
+ }
+ });
+
if($("#note_in_reply_to").val() != "") {
$("#note_in_reply_to").change();
}