summaryrefslogtreecommitdiff
path: root/roundcubemail/program/js/app.js
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-09-14 08:34:11 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-09-14 08:34:11 +0000
commit5104ceda2d1e526ba2fe5737e1ee2a01b51d3cbe (patch)
tree01ec3f1ed0a47238a6505fac736dd275e2e4557c /roundcubemail/program/js/app.js
parentd8c68ca2ad0b0f38a7dd82ef286f43ea94f4293a (diff)
- use html2text for signatures in Settings/Identities
git-svn-id: https://svn.roundcube.net/trunk@1788 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/js/app.js')
-rw-r--r--roundcubemail/program/js/app.js43
1 files changed, 41 insertions, 2 deletions
diff --git a/roundcubemail/program/js/app.js b/roundcubemail/program/js/app.js
index f4f4fc475..d42b8ede8 100644
--- a/roundcubemail/program/js/app.js
+++ b/roundcubemail/program/js/app.js
@@ -3648,13 +3648,21 @@ function rcube_webmail()
this.toggle_editor = function(checkbox, textAreaId)
{
var ischecked = checkbox.checked;
+ var composeElement = document.getElementById(textAreaId);
+
if (ischecked)
{
- tinyMCE.execCommand('mceAddControl', true, textAreaId);
+ var existingPlainText = composeElement.value;
+ var htmlText = "<pre>" + existingPlainText + "</pre>";
+ composeElement.value = htmlText;
+ tinyMCE.execCommand('mceAddControl', true, textAreaId);
}
else
{
- tinyMCE.execCommand('mceRemoveControl', true, textAreaId);
+ var thisMCE = tinyMCE.get(textAreaId);
+ var existingHtml = thisMCE.getContent();
+ this.html2plain(existingHtml, textAreaId);
+ tinyMCE.execCommand('mceRemoveControl', true, textAreaId);
}
};
@@ -3718,6 +3726,37 @@ function rcube_webmail()
/********************************************************/
+ /********* html to text conversion functions *********/
+ /********************************************************/
+
+ this.html2plain = function(htmlText, id)
+ {
+ var http_request = new rcube_http_request();
+ var url = this.env.bin_path+'html2text.php';
+ var rcmail = this;
+
+ this.set_busy(true, 'converting');
+ console.log('HTTP POST: '+url);
+
+ http_request.onerror = function(o) { rcmail.http_error(o); };
+ http_request.oncomplete = function(o) { rcmail.set_text_value(o, id); };
+ http_request.POST(url, htmlText, 'application/octet-stream');
+ }
+
+ this.set_text_value = function(httpRequest, id)
+ {
+ this.set_busy(false);
+ document.getElementById(id).value = httpRequest.get_text();
+ console.log(httpRequest.get_text());
+ }
+
+ this.handle_conv_error = function(httpRequest)
+ {
+ alert('html2text request returned with error ' + httpRequest.xmlhttp.status);
+ }
+
+
+ /********************************************************/
/********* remote request methods *********/
/********************************************************/