mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Small fixes
This commit is contained in:
parent
9ac4d3ac14
commit
3b29e93db1
7 changed files with 117 additions and 279 deletions
|
|
@ -1666,13 +1666,12 @@ Utils.htmlToPlain = function (sHtml)
|
|||
.replace(/[\s]+/gm, ' ')
|
||||
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
|
||||
.replace(/<br\s?\/?>/gmi, '\n')
|
||||
.replace(/<\/h\d>/gi, '\n')
|
||||
.replace(/<\/h[\d]>/gi, '\n')
|
||||
.replace(/<\/p>/gi, '\n\n')
|
||||
.replace(/<\/li>/gi, '\n')
|
||||
.replace(/<\/td>/gi, '\n')
|
||||
.replace(/<\/tr>/gi, '\n')
|
||||
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
|
||||
.replace(/<img [^>]*>/gmi, '')
|
||||
.replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs)
|
||||
.replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n')
|
||||
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
|
||||
|
|
@ -1680,7 +1679,6 @@ Utils.htmlToPlain = function (sHtml)
|
|||
.replace(/<\/div>/gi, '\n')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/"/gi, '"')
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/<[^>]*>/gm, '')
|
||||
;
|
||||
|
||||
|
|
@ -1691,6 +1689,7 @@ Utils.htmlToPlain = function (sHtml)
|
|||
.replace(/[\n]{3,}/gm, '\n\n')
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<')
|
||||
.replace(/&/gi, '&')
|
||||
;
|
||||
|
||||
iPos = 0;
|
||||
|
|
@ -1738,9 +1737,10 @@ Utils.htmlToPlain = function (sHtml)
|
|||
|
||||
/**
|
||||
* @param {string} sPlain
|
||||
* @param {boolean} bLinkify = false
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.plainToHtml = function (sPlain)
|
||||
Utils.plainToHtml = function (sPlain, bLinkify)
|
||||
{
|
||||
sPlain = sPlain.toString().replace(/\r/g, '');
|
||||
|
||||
|
|
@ -1805,14 +1805,29 @@ Utils.plainToHtml = function (sPlain)
|
|||
.replace(/[\-_~]{10,}/g, '<hr />')
|
||||
.replace(/\n/g, '<br />');
|
||||
|
||||
return bLinkify ? Utils.linkify(sPlain) : sPlain;
|
||||
};
|
||||
|
||||
window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain;
|
||||
window.rainloop_Utils_plainToHtml = Utils.plainToHtml;
|
||||
|
||||
/**
|
||||
* @param {string} sHtml
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.linkify = function (sHtml)
|
||||
{
|
||||
if ($.fn && $.fn.linkify)
|
||||
{
|
||||
sPlain = Utils.$div.html(sPlain)
|
||||
.linkify().find('.linkified').removeClass('linkified').end()
|
||||
.html();
|
||||
sHtml = Utils.$div.html(sHtml.replace(/&/ig, 'amp_amp_12345_amp_amp'))
|
||||
.linkify()
|
||||
.find('.linkified').removeClass('linkified').end()
|
||||
.html()
|
||||
.replace(/amp_amp_12345_amp_amp/g, '&')
|
||||
;
|
||||
}
|
||||
|
||||
return sPlain;
|
||||
return sHtml;
|
||||
};
|
||||
|
||||
Utils.resizeAndCrop = function (sUrl, iValue, fCallback)
|
||||
|
|
|
|||
|
|
@ -893,7 +893,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody = null,
|
||||
oTextBody = null,
|
||||
sId = '',
|
||||
sPlainAsHtml = '',
|
||||
sResultHtml = '',
|
||||
bPgpSigned = false,
|
||||
bPgpEncrypted = false,
|
||||
oMessagesBodiesDom = this.messagesBodiesDom(),
|
||||
|
|
@ -929,16 +929,12 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
|
||||
{
|
||||
bIsHtml = true;
|
||||
oBody
|
||||
.html(oData.Result.Html.toString())
|
||||
.linkify().find('.linkified').removeClass('linkified').end()
|
||||
.addClass('b-text-part html')
|
||||
;
|
||||
sResultHtml = oData.Result.Html.toString();
|
||||
}
|
||||
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
|
||||
{
|
||||
bIsHtml = false;
|
||||
sPlainAsHtml = Utils.plainToHtml(oData.Result.Plain.toString());
|
||||
sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false);
|
||||
|
||||
if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().capaOpenPGP())
|
||||
{
|
||||
|
|
@ -954,7 +950,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
$proxyDiv.empty();
|
||||
if (bPgpSigned && oMessage.isPgpSigned())
|
||||
{
|
||||
sPlainAsHtml =
|
||||
sResultHtml =
|
||||
$proxyDiv.append(
|
||||
$('<pre class="b-plain-openpgp signed"></pre>').text(oMessage.plainRaw)
|
||||
).html()
|
||||
|
|
@ -962,7 +958,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
}
|
||||
else if (bPgpEncrypted && oMessage.isPgpEncrypted())
|
||||
{
|
||||
sPlainAsHtml =
|
||||
sResultHtml =
|
||||
$proxyDiv.append(
|
||||
$('<pre class="b-plain-openpgp encrypted"></pre>').text(oMessage.plainRaw)
|
||||
).html()
|
||||
|
|
@ -974,18 +970,17 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oMessage.isPgpSigned(bPgpSigned);
|
||||
oMessage.isPgpEncrypted(bPgpEncrypted);
|
||||
}
|
||||
|
||||
oBody
|
||||
.html(sPlainAsHtml)
|
||||
.linkify().find('.linkified').removeClass('linkified').end()
|
||||
.addClass('b-text-part plain')
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsHtml = false;
|
||||
}
|
||||
|
||||
oBody
|
||||
.html(Utils.linkify(sResultHtml))
|
||||
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'))
|
||||
;
|
||||
|
||||
oMessage.isHtml(!!bIsHtml);
|
||||
oMessage.hasImages(!!bHasExternals);
|
||||
oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue