Created
September 24, 2013 18:04
-
-
Save rjcorwin/6688856 to your computer and use it in GitHub Desktop.
This file assumes it's living in a CouchDB doc and will find and save the file to be transformed to the CouchDB Doc that it is sitting in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Find and Replace</title> | |
| <script src="http://code.jquery.com/jquery-2.0.3.js"></script> | |
| </head> | |
| <body> | |
| click me to transform | |
| </body> | |
| <script> | |
| $(document).ready(function() { | |
| var find = 'find me' | |
| var replace = 'I\nam\nthe\nreplacement' | |
| var fileName = 'transformMe.txt' | |
| $('body').click(function() { | |
| $.get(fileName, function(transformFile) { | |
| var transformedFile = transformFile.replace(find, replace) | |
| $.getJSON('./', function(response){ | |
| $.ajax({ | |
| type: 'PUT', | |
| url: 'transformedFile.txt?rev=' + response._rev, | |
| data: transformedFile | |
| }).done(function() { | |
| $('body').html('<a href="transformedFile.txt">Check out the tranformed file</a>') | |
| }) | |
| }) | |
| }) | |
| }) | |
| }) | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment