mirror of
https://github.com/moparisthebest/mail
synced 2024-12-23 15:58:49 -05:00
[WO-64] fix newline in reader and text parser in writer
This commit is contained in:
parent
5c7eb7052d
commit
4e6f9b9bbf
@ -15,18 +15,20 @@ define(function(require) {
|
|||||||
firstSelect = true;
|
firstSelect = true;
|
||||||
|
|
||||||
emailDao = appController._emailDao;
|
emailDao = appController._emailDao;
|
||||||
|
if (emailDao) {
|
||||||
|
emailDao.onIncomingMessage = function(email) {
|
||||||
|
if (email.subject.indexOf(str.subjectPrefix) === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emailDao.onIncomingMessage = function(email) {
|
// sync
|
||||||
if (email.subject.indexOf(str.subjectPrefix) === -1) {
|
$scope.synchronize(function() {
|
||||||
return;
|
// show notification
|
||||||
}
|
notificationForEmail(email);
|
||||||
|
});
|
||||||
// sync
|
};
|
||||||
$scope.synchronize(function() {
|
chrome.notifications.onClicked.addListener(notificationClicked);
|
||||||
// show notification
|
}
|
||||||
notificationForEmail(email);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function notificationClicked(uidString) {
|
function notificationClicked(uidString) {
|
||||||
var email, uid = parseInt(uidString, 10);
|
var email, uid = parseInt(uidString, 10);
|
||||||
@ -43,7 +45,6 @@ define(function(require) {
|
|||||||
$scope.select(email);
|
$scope.select(email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chrome.notifications.onClicked.addListener(notificationClicked);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// scope functions
|
// scope functions
|
||||||
@ -55,7 +56,13 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
// split text only emails into parts for easier rendering
|
// split text only emails into parts for easier rendering
|
||||||
if (!email.html && typeof email.body === 'string') {
|
if (!email.html && typeof email.body === 'string') {
|
||||||
email.bodyDisplayParts = email.body.split('\n');
|
email.bodyDisplayParts = [];
|
||||||
|
var parts = email.body.split('\n');
|
||||||
|
parts.forEach(function(part) {
|
||||||
|
if (part.trim().length > 0) {
|
||||||
|
email.bodyDisplayParts.push(part);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
$scope.selected = email;
|
$scope.selected = email;
|
||||||
// set selected in parent scope ro it can be displayed in the read view
|
// set selected in parent scope ro it can be displayed in the read view
|
||||||
|
@ -6,6 +6,7 @@ define(function(require) {
|
|||||||
aes = require('cryptoLib/aes-cbc'),
|
aes = require('cryptoLib/aes-cbc'),
|
||||||
util = require('cryptoLib/util'),
|
util = require('cryptoLib/util'),
|
||||||
str = require('js/app-config').string,
|
str = require('js/app-config').string,
|
||||||
|
$ = require('jquery'),
|
||||||
emailDao;
|
emailDao;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -129,9 +130,8 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
body = $scope.body;
|
|
||||||
// remove generated html from body
|
// remove generated html from body
|
||||||
body = parseBody(body);
|
body = parseBody($scope.body);
|
||||||
|
|
||||||
email = {
|
email = {
|
||||||
to: [], // list of receivers
|
to: [], // list of receivers
|
||||||
@ -165,23 +165,12 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function parseBody(body) {
|
function parseBody(body) {
|
||||||
function has(substr) {
|
var regex = /(\r\n|\n|\r)/gm;
|
||||||
return (body.indexOf(substr) !== -1);
|
|
||||||
}
|
|
||||||
while (has('<div><br>')) {
|
|
||||||
body = body.replace('<div><br>', '\n');
|
|
||||||
}
|
|
||||||
while (has('<div>')) {
|
|
||||||
body = body.replace('<div>', '\n');
|
|
||||||
}
|
|
||||||
while (has('<br>')) {
|
|
||||||
body = body.replace('<br>', '\n');
|
|
||||||
}
|
|
||||||
while (has('</div>')) {
|
|
||||||
body = body.replace('</div>', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
return body;
|
var text = body.replace(regex, '').split('<div><br>').join('\n').split('<div>').join('\n').split('<br>').join('\n');
|
||||||
|
var html = '<p>' + text + '</p>';
|
||||||
|
|
||||||
|
return $(html).text();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -24,10 +24,6 @@
|
|||||||
<iframe ng-switch-when="true" sandbox="allow-same-origin" srcdoc="{{selected.body}}" seamless frame-load></iframe>
|
<iframe ng-switch-when="true" sandbox="allow-same-origin" srcdoc="{{selected.body}}" seamless frame-load></iframe>
|
||||||
|
|
||||||
<!-- Render parts of a text only email in paragraphs for easier styling -->
|
<!-- Render parts of a text only email in paragraphs for easier styling -->
|
||||||
<p ng-repeat="part in selected.bodyDisplayParts track by $index">
|
<p ng-repeat="part in selected.bodyDisplayParts track by $index">{{part}}</p>
|
||||||
<span ng-switch="part.length !== 0">
|
|
||||||
<span ng-switch-when="true">{{part}}</span>
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</div><!--/.body-->
|
</div><!--/.body-->
|
||||||
</div><!--/.view-read-->
|
</div><!--/.view-read-->
|
Loading…
Reference in New Issue
Block a user