mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Fixed Opening an email with specific content „hangs” RainLoop in the browser (Closes #308)
Code refactoring
This commit is contained in:
parent
af43329902
commit
7a374ebe03
40 changed files with 1100 additions and 181 deletions
|
|
@ -118,7 +118,7 @@
|
|||
/**
|
||||
* @type {*}
|
||||
*/
|
||||
Globals.__APP = null;
|
||||
Globals.__APP__ = null;
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
var
|
||||
_ = require('_'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
|
|
@ -14,19 +15,15 @@
|
|||
*/
|
||||
function Plugins()
|
||||
{
|
||||
this.__boot = null;
|
||||
this.__data = null;
|
||||
this.__remote = null;
|
||||
|
||||
this.oSettings = require('Storage:Settings');
|
||||
|
||||
this.oViewModelsHooks = {};
|
||||
this.oSimpleHooks = {};
|
||||
}
|
||||
|
||||
Plugins.prototype.__boot = null;
|
||||
Plugins.prototype.__data = null;
|
||||
Plugins.prototype.__remote = null;
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.prototype.oSettings = {};
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
|
|
@ -90,9 +87,9 @@
|
|||
*/
|
||||
Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
||||
{
|
||||
if (this.__remote)
|
||||
if (Globals.__APP__)
|
||||
{
|
||||
this.__remote.defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions);
|
||||
Globals.__APP__.remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
Autolinker = require('Autolinker'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
|
|
@ -146,7 +147,7 @@
|
|||
oEmailModel = null,
|
||||
sEmail = sMailToUrl.replace(/\?.+$/, ''),
|
||||
sQueryString = sMailToUrl.replace(/^[^\?]*\?/, ''),
|
||||
EmailModel = require('Model:Email')
|
||||
EmailModel = require('Model/Email')
|
||||
;
|
||||
|
||||
oEmailModel = new EmailModel();
|
||||
|
|
@ -1517,10 +1518,10 @@
|
|||
|
||||
/**
|
||||
* @param {string} sPlain
|
||||
* @param {boolean} bLinkify = false
|
||||
* @param {boolean} bFindEmailAndLinks = false
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.plainToHtml = function (sPlain, bLinkify)
|
||||
Utils.plainToHtml = function (sPlain, bFindEmailAndLinks)
|
||||
{
|
||||
sPlain = sPlain.toString().replace(/\r/g, '');
|
||||
|
||||
|
|
@ -1551,9 +1552,16 @@
|
|||
}
|
||||
else if (!bStart && bIn)
|
||||
{
|
||||
bIn = false;
|
||||
aNextText.push('~~~/blockquote~~~');
|
||||
aNextText.push(sLine);
|
||||
if ('' !== sLine)
|
||||
{
|
||||
bIn = false;
|
||||
aNextText.push('~~~/blockquote~~~');
|
||||
aNextText.push(sLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
aNextText.push(sLine);
|
||||
}
|
||||
}
|
||||
else if (bStart && bIn)
|
||||
{
|
||||
|
|
@ -1578,6 +1586,7 @@
|
|||
sPlain = aText.join("\n");
|
||||
|
||||
sPlain = sPlain
|
||||
// .replace(/~~~\/blockquote~~~\n~~~blockquote~~~/g, '\n')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/>/g, '>').replace(/</g, '<')
|
||||
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
|
||||
|
|
@ -1585,7 +1594,7 @@
|
|||
.replace(/[\-_~]{10,}/g, '<hr />')
|
||||
.replace(/\n/g, '<br />');
|
||||
|
||||
return bLinkify ? Utils.linkify(sPlain) : sPlain;
|
||||
return bFindEmailAndLinks ? Utils.findEmailAndLinks(sPlain) : sPlain;
|
||||
};
|
||||
|
||||
window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain;
|
||||
|
|
@ -1595,17 +1604,25 @@
|
|||
* @param {string} sHtml
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.linkify = function (sHtml)
|
||||
Utils.findEmailAndLinks = function (sHtml)
|
||||
{
|
||||
if ($.fn && $.fn.linkify)
|
||||
{
|
||||
sHtml = Globals.$div.html(sHtml.replace(/&/ig, 'amp_amp_12345_amp_amp'))
|
||||
.linkify()
|
||||
.find('.linkified').removeClass('linkified').end()
|
||||
.html()
|
||||
.replace(/amp_amp_12345_amp_amp/g, '&')
|
||||
;
|
||||
}
|
||||
sHtml = Autolinker.link(sHtml, {
|
||||
'newWindow': true,
|
||||
'stripPrefix': false,
|
||||
'urls': true,
|
||||
'email': true,
|
||||
'twitter': false
|
||||
});
|
||||
|
||||
// if ($.fn && $.fn.linkify)
|
||||
// {
|
||||
// sHtml = Globals.$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 sHtml;
|
||||
};
|
||||
|
|
@ -1936,6 +1953,29 @@
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} sLanguage
|
||||
* @param {Function=} fDone
|
||||
* @param {Function=} fFail
|
||||
* @param {Function=} fAllways
|
||||
*/
|
||||
Utils.reloadLanguage = function (sLanguage, fDone, fFail, fAllways)
|
||||
{
|
||||
$.ajax({
|
||||
'url': require('Common/LinkBuilder').langLink(sLanguage),
|
||||
'dataType': 'script',
|
||||
'cache': true
|
||||
})
|
||||
.done(function () {
|
||||
Utils.i18nReload();
|
||||
(fDone || Utils.emptyFunction)();
|
||||
})
|
||||
.fail(fFail || Utils.emptyFunction)
|
||||
.always(fAllways || Utils.emptyFunction)
|
||||
;
|
||||
};
|
||||
|
||||
module.exports = Utils;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue