Stephanie Leary

Writer and WordPress consultant

  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Fascism Watch (2016-17)
    • Content Modeling for WordPress series
    • WordPress Hidden Gems series
  • Work
    • Portfolio
    • Services
    • WordPress Plugins
    • WordPress Themes
    • Presentations and Interviews
    • on GitHub →
  • About
    • Press Kit
  • Contact
    • Mailing List

JavaScript goodies: track changes and word count

January 30, 2008 Stephanie Leary 3 Comments

I’ve finally gotten around to adding my two JavaScript projects to the code page. Word count adds a little counter to every textarea on a page. There’s also an option, which is just on in the demo, to have it ignore HTML. This script works in all browsers except IE for the time being. If you have tips on how to work around IE’s broken-ass event handling, I’d love to hear them. Specifically, I cannot get it to add the onkeyup attribute to a previously generated element.

Track changes started out as a pure CSS exercise. I thought it would be simple to have a style switcher that would show or hide <del> and <ins> tags by changing the display property. It was, but I ran into a problem: when the text was copied to the clipboard, the deleted items were included. After some hair-pulling, I decided the best workaround would be to clone the content and remove the <del> elements from the DOM when changes were hidden. I’d seen an excellent example of cloning content to toggle it, and I modified it to handle the <del> elements.

Web Design

Comments

  1. Sancho says

    January 31, 2008 at 9:08 pm

    I know it’s probably out of scope, but it’d be pretty spiffy if it could track multiple changes–e.g. by using an attribute like rev:

    blahblah

    Reply
  2. Sancho says

    January 31, 2008 at 9:09 pm

    Uh oh–blog ate my tags :(

    <ins rev=2>blahblah</ins>

    I think that should work….

    Reply
  3. steph says

    January 31, 2008 at 9:14 pm

    Sorry about that!

    Those two tags do support the cite attribute for date/time and author info, so it should be relatively easy to pull that out and make use of it… I’ll experiment sometime.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Fascism Watch

The Fascism Watch is a daily(ish) news roundup. View all the previous Fascism Watch posts »

Latest WordPress Book

Content Strategy for WordPress

A short book for content strategists and managers on implementing a complete content strategy in WordPress: evaluation, analysis, content modeling, editing and workflows, and long-term planning and maintenance.

Read the sample chapter

Kindle Nook iBooks Kobo Smashwords

WordPress for Web Developers

WordPress for Web Developers (9781430258667)

This is a book for professional web designers and developers who already know HTML and CSS, and want to learn to build sites with WordPress. The book begins with a detailed tour of the administration screens and settings, then digs into server-side topics like performance and security. The second half of the book is devoted to development: learning to build WordPress themes and plugins.

This is the second, much-revised and updated edition of Beginning WordPress 3, with a more accurate title. Everything’s been updated for WordPress 3.6.

WordPress for Web Developers is out now. See what's inside...

The best WordPress features you’ve never noticed

  • WordPress Hidden Gems: Screen Options
  • WordPress Hidden Gems: Bulk Edit
  • WordPress Hidden Gems: Private Status
  • WordPress Hidden Gems: Dashboard Feed Readers
  • WordPress Hidden Gems: Options.php

Content Modeling for WordPress series

  • Content modeling for WordPress, part 1: analyze content
  • Content modeling for WordPress, part 2: functional and organizational requirements
  • Content modeling for WordPress, part 3: a sample content model

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.

Copyright © 2021 Stephanie Leary