The Document Version Switcher
People handle web page updates in different ways. Some add extra text and bold it so people know it's been updated. Others use
del tags to highlight changes. Others couldn't be bothered, make their updates and move on.
Allow me to present a new approach: The Document Version Switcher. The premise is simple. A control on the page allows users to "go back in time" and view previous versions of a document.
To do this, any time we make a change to our document, we mark those changes up with the appropriate
del elements. We add a version class to each one so that we can track the changes over time.
Here's an example:
...pellentesque <ins class="ver1">turpis</ins>. Maecenas <del class="ver1">elementum</del> enim ut <ins class="ver2">sem</ins>. Sed non erat quis diam c...
del elements on the page and sets the display on or off based on the version number based through to our version switcher function.
See the code in action.
While this example does what I had intended it to do, it's not the most eloquent solution. There are a number of ways that this functionality can be improved:
- The function doesn't do any multi-class checking. Therefore, the version class has to be the first class in the list.
- I'd actually like to do away with using classes and instead, use the more semantically filled
datetimeattribute. The script could then dynamically build a control with a list of dates and times to revert back to.
- Further to that last point, the function could accept any datetime parameter and display anything inserted or deleted up to that point.
When I have time, I'll look at turning this into a more solid solution.