summaryrefslogtreecommitdiff
path: root/views/new-post.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2016-04-07 16:45:15 -0700
committerAaron Parecki <aaron@parecki.com>2016-04-07 16:45:15 -0700
commit9662af5a17a660a6c921be72a370b3e14cdd08a4 (patch)
tree5aac707a282785177d86b88dc9298edd46e8bbad /views/new-post.php
parent42a5e44d176869053db5bc451f4cd0c4a11b8a74 (diff)
set category from hashtags in post
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();
}