DCODR is a cool javascript lib that converts (X)HTML to DCODE format and can even intercept "CTRL+C" events.
The "CTRL+C" events thinger allows your visitors to copy your pages content in the usual manner (select and hit CTRL+C) but instead of pasting plain text, they paste fully formatted DCODE text!
Try selecting a big chunk of this page and hitting CTRL+C, when you paste (into the handy <textarea> below) you will paste DCODE formatted text!
Here's a few of the features of DCODR
Some of the reasons for writing DCODR
You can paste your findings into here to see the result!
Pretty swanky eh? Note that it degrades into regular copy paste functionality, and works on most modern browsers. Check the compatibility table below for more.
...is very straightforward. Assuming you have uploaded the kit somewhere to your server, you simply need to include the DCODR Javascript file like so:
<script type="text/javascript" src="/dcode/dcodr.js"></script>
Bunnggg! You're done!
This feature can be turned off by adding a parameter to the src atrribute of the script tag. The parameter is:
For example
<script type="text/javascript" src="/dcode/dcodr.js?nocopyevents"></script>
If you want to use the parser directly in your own Javascript project, the function you want is DCODR.formatHTML (html [, fixIE] ) which will return nice clean DCODE formatted text.
Note: that the second parameter, fixIE, defaults to false, and should be set to true whenever dealing with ranges or innerHTML for this reason.