Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -ur sendy/create.php sendy-modified/create.php
- --- sendy/create.php 2014-10-07 18:34:42.000000000 +0200
- +++ sendy-modified/create.php 2014-11-17 21:48:12.941103603 +0100
- @@ -98,6 +98,7 @@
- <div class="controls">
- <textarea class="input-xlarge" id="plain" name="plain" rows="10" placeholder="<?php echo _('Plain text of this email');?>"></textarea>
- </div>
- + <button type="button" class="btn btn-mail-reply" id="fromHtml"><span class="icon icon-retweet"></span> <?php echo _('Create from HTML'); ?></button>
- </div>
- <label class="control-label" for="attachments"><?php echo _('Attachments');?></label>
- diff -ur sendy/edit.php sendy-modified/edit.php
- --- sendy/edit.php 2014-10-07 18:34:44.000000000 +0200
- +++ sendy-modified/edit.php 2014-11-17 22:47:59.153282207 +0100
- @@ -131,6 +131,7 @@
- <div class="controls">
- <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>
- </div>
- + <button type="button" class="btn btn-mail-reply" id="fromHtml"><span class="icon icon-retweet"></span> <?php echo _('Create from HTML'); ?></button>
- </div>
- <label class="control-label" for="attachments"><?php echo _('Attachments');?></label>
- diff -ur sendy/js/main.js sendy-modified/js/main.js
- --- sendy/js/main.js 2014-03-25 01:00:14.000000000 +0100
- +++ sendy-modified/js/main.js 2014-11-17 23:14:04.625360172 +0100
- @@ -51,4 +51,32 @@
- selection.addRange(range);
- }
- };
- -});
- \ No newline at end of file
- +
- + //HTML to Plain
- + $("#fromHtml").click(function(e) {
- + e.preventDefault();
- +
- + var $plain = $("#plain");
- + var $html = $("#html");
- +
- + var val = $html.val();
- + var hdi = val.indexOf('</head>');
- + val = val
- + .substr(hdi >= 0 ? hdi : 0)
- + .replace(/(.+)<\/head>/gi, '')
- + .replace(/<br[/]?>/gi, '\n')
- + .replace(/<a.+href=\"([^\"]+)\".*>(.*)<\/a>/gi, '$2 [$1]')
- + .replace(/<\/unsubscribe>/gi, ' [[unsubscribe]]')
- + .replace(/<\/webversion>/gi, ' [[webversion]]')
- + .replace(/<h([1-6])>(.+)<\/h([1-6])>/gi, function(m, p1, p2, p3) { return '\n' + p2.toUpperCase() + '\n' } )
- + .replace(/<li>([^ <]+)/gi, '<li>* $1')
- + .replace(/[ |\t]+</gi, '<')
- + .replace(/<[^>]+>/gi, '')
- + .replace(/[\n]{3,}/gi, '\n\n')
- + .trim()
- + ;
- +
- + $plain.val(val);
- + });
- +});
- +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement