Login

Admin Word Count

Author:
bahoo
Posted:
October 6, 2010
Language:
HTML/template
Version:
1.2
Tags:
jquery change-form word-count
Score:
1 (after 1 ratings)

I'm on my own personal writing challenge (see 750words.com for inspiration). I needed a way to get a dynamic word count, so I threw this together. Tied into django-basic-blog easily.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Anywhere in a settings.TEMPLATE_DIRS directory:

# ./admin/<app>/change_form.html:
****************************************************

{% block extrahead %}
  {{ block.super }}
  <style>label b{font-weight:normal;font-size:0.75em;color:#888;display:block;margin-top:120px;}</style>
  <script type="text/javascript">
    
    django.jQuery(document).ready(function(){
        django.jQuery('#id_body').keypress(function(){
            django.jQuery('label[for=id_body]').html("Body:<b>Word count: " + this.value.split(" ").length + "</b>");
        });
    });
  </script>
{% endblock %}

More like this

  1. truncatehtml_at_word by zakj 6 years, 6 months ago
  2. Truncate string after a given number of chars keeping whole words by rix 6 years, 5 months ago
  3. Truncate words by characters by trodrigues 7 years ago
  4. Clean text pasted from word into RTE by rodrigoc 5 years, 11 months ago
  5. Audit word filter by shinyzhu 5 years, 3 months ago

Comments

Please login first before commenting.