Commits

Anonymous committed 2e50225

add defaultForm()

  • Participants
  • Parent commits a804716

Comments (0)

Files changed (1)

File public/troll.js

   };
 }, 500);
 
+function defaultForm() {
+    $('form#reply textarea').val('');
+    $('form#reply input[name="p"]').val('');
+    $('article').before($('form#reply'));
+}
+
 $('a.reply').live('click', function() {
     $(this).after($('form#reply'));
     $('form#reply input[name="p"]').val($(this).parents('div').attr('id'));
     return false;
 });
 
-
 $('form#reply textarea').keydown(function (e) {
     if(e.ctrlKey && e.keyCode == 13 && $(this).val().trim()) $('form#reply').submit();
-    if(e.keyCode == 27 && !$(this).val().trim()) {
-        $(this).val('');
-        $('article').before($('form#reply'));
-    }
+    if(e.keyCode == 27 && !$(this).val().trim()) defaultForm();
 });
 
 $('form#reply').submit(function() {
     $.post('/', $(this).serialize());
-    $('article').before($('form#reply'));
-    $('form#reply textarea').val('');
-    $('form#reply input[name="p"]').val('');
+    defaultForm();
     return false;
 });