Advertisement
Guest User

sendy-toHTML

a guest
Nov 17th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.67 KB | None | 0 0
  1. diff -ur sendy/create.php sendy-modified/create.php
  2. --- sendy/create.php    2014-10-07 18:34:42.000000000 +0200
  3. +++ sendy-modified/create.php   2014-11-17 21:48:12.941103603 +0100
  4. @@ -98,6 +98,7 @@
  5.                         <div class="controls">
  6.                           <textarea class="input-xlarge" id="plain" name="plain" rows="10" placeholder="<?php echo _('Plain text of this email');?>"></textarea>
  7.                         </div>
  8. +                        <button type="button" class="btn btn-mail-reply" id="fromHtml"><span class="icon icon-retweet"></span> <?php echo _('Create from HTML'); ?></button>
  9.                     </div>
  10.                    
  11.                     <label class="control-label" for="attachments"><?php echo _('Attachments');?></label>
  12. diff -ur sendy/edit.php sendy-modified/edit.php
  13. --- sendy/edit.php  2014-10-07 18:34:44.000000000 +0200
  14. +++ sendy-modified/edit.php 2014-11-17 22:47:59.153282207 +0100
  15. @@ -131,6 +131,7 @@
  16.                         <div class="controls">
  17.                           <textarea class="input-xlarge" id="plain" name="plain" rows="10" placeholder="<?php echo _('Plain text of this email');?>"><?php echo get_saved_data('plain_text');?></textarea>
  18.                         </div>
  19. +                        <button type="button" class="btn btn-mail-reply" id="fromHtml"><span class="icon icon-retweet"></span> <?php echo _('Create from HTML'); ?></button>
  20.                     </div>
  21.                    
  22.                     <label class="control-label" for="attachments"><?php echo _('Attachments');?></label>
  23. diff -ur sendy/js/main.js sendy-modified/js/main.js
  24. --- sendy/js/main.js    2014-03-25 01:00:14.000000000 +0100
  25. +++ sendy-modified/js/main.js   2014-11-17 23:14:04.625360172 +0100
  26. @@ -51,4 +51,32 @@
  27.             selection.addRange(range);
  28.         }
  29.     };
  30. -});
  31. \ No newline at end of file
  32. +
  33. +    //HTML to Plain
  34. +    $("#fromHtml").click(function(e) {
  35. +        e.preventDefault();
  36. +
  37. +        var $plain = $("#plain");
  38. +        var $html = $("#html");
  39. +
  40. +        var val = $html.val();
  41. +        var hdi = val.indexOf('</head>');
  42. +        val = val
  43. +            .substr(hdi >= 0 ? hdi : 0)
  44. +            .replace(/(.+)<\/head>/gi, '')
  45. +            .replace(/<br[/]?>/gi, '\n')
  46. +            .replace(/<a.+href=\"([^\"]+)\".*>(.*)<\/a>/gi, '$2 [$1]')
  47. +            .replace(/<\/unsubscribe>/gi, ' [[unsubscribe]]')
  48. +            .replace(/<\/webversion>/gi, ' [[webversion]]')
  49. +            .replace(/<h([1-6])>(.+)<\/h([1-6])>/gi, function(m, p1, p2, p3) { return '\n' + p2.toUpperCase() + '\n' } )
  50. +            .replace(/<li>([^ <]+)/gi, '<li>* $1')
  51. +            .replace(/[ |\t]+</gi, '<')
  52. +            .replace(/<[^>]+>/gi, '')
  53. +            .replace(/[\n]{3,}/gi, '\n\n')
  54. +            .trim()
  55. +        ;
  56. +
  57. +        $plain.val(val);
  58. +    });
  59. +});
  60. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement