mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
Use jQuery.slim
Underscore.js _.uniq(_.compact( to native Array.filter((value, index, self) => !!value && self.indexOf(value) == index) Underscore.js _.compact to native Array.filter(value => !!value) Underscore.js _.uniq to native Array.filter((value, index, self) => self.indexOf(value) == index) Underscore.js _.values to native Object.values Underscore.js _.flatten to native Array.flat Underscore.js _.union to native Array.concat + unique filter Underscore.js _.reduce to native Array.reduce Underscore.js _.escape replaced with advanced htmlspecialchars() Underscore.js _.memoize replaced Now Underscore.js is a slim custom version (only _.debounce, _.defer & _.throttle)
This commit is contained in:
parent
996a71ad8a
commit
dca0ff02ed
27 changed files with 515 additions and 353 deletions
|
|
@ -11,13 +11,25 @@ import { jassl } from 'Common/Jassl';
|
|||
|
||||
const trim = $.trim;
|
||||
const isArray = Array.isArray;
|
||||
const isObject = _.isObject;
|
||||
const isFunc = _.isFunction;
|
||||
const isUnd = _.isUndefined;
|
||||
const isObject = v => typeof v === 'object';
|
||||
const isFunc = v => typeof v === 'function';
|
||||
const isUnd = v => undefined === v;
|
||||
const noop = () => {}; // eslint-disable-line no-empty-function
|
||||
const noopTrue = () => true;
|
||||
const noopFalse = () => false;
|
||||
|
||||
var htmlspecialchars = ((de,se,gt,lt,sq,dq,bt) => {
|
||||
return (str, quote_style = 3, double_encode = true) => {
|
||||
str = (''+str)
|
||||
.replace(double_encode?de:se,'&')
|
||||
.replace(gt,'<')
|
||||
.replace(lt,'>')
|
||||
.replace(bt,'`');
|
||||
if (quote_style & 1) { str = str.replace(sq,'''); }
|
||||
return (quote_style & 2) ? str.replace(dq,'"') : str;
|
||||
};
|
||||
})(/&/g,/&(?![\w#]+;)/gi,/</g,/>/g,/'/g,/"/g,/`/g);
|
||||
|
||||
export { trim, isArray, isObject, isFunc, isUnd, noop, noopTrue, noopFalse, jassl };
|
||||
|
||||
/**
|
||||
|
|
@ -167,7 +179,7 @@ export function fakeMd5(len = 32) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function encodeHtml(text) {
|
||||
return isNormal(text) ? _.escape(text.toString()) : '';
|
||||
return isNormal(text) ? htmlspecialchars(text.toString()) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -449,7 +461,7 @@ export function createCommandLegacy(context, fExecute, fCanExecute = true) {
|
|||
* @param {string} theme
|
||||
* @returns {string}
|
||||
*/
|
||||
export const convertThemeName = _.memoize((theme) => {
|
||||
export const convertThemeName = theme => {
|
||||
if ('@custom' === theme.substr(-7)) {
|
||||
theme = trim(theme.substring(0, theme.length - 7));
|
||||
}
|
||||
|
|
@ -458,9 +470,9 @@ export const convertThemeName = _.memoize((theme) => {
|
|||
theme
|
||||
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
||||
.replace(/([A-Z])/g, ' $1')
|
||||
.replace(/[\s]+/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
|
|
@ -713,7 +725,7 @@ export function htmlToPlain(html) {
|
|||
.replace(/[\n]/gm, '<br />')
|
||||
.replace(/[\r]/gm, '')
|
||||
: '',
|
||||
fixAttibuteValue = (...args) => (args && 1 < args.length ? '' + args[1] + _.escape(args[2]) : ''),
|
||||
fixAttibuteValue = (...args) => (args && 1 < args.length ? '' + args[1] + htmlspecialchars(args[2]) : ''),
|
||||
convertLinks = (...args) => (args && 1 < args.length ? trim(args[1]) : '');
|
||||
|
||||
text = html
|
||||
|
|
@ -1384,7 +1396,7 @@ export function mailToHelper(mailToUrl, PopupComposeViewModel) {
|
|||
|
||||
if (!isUnd(params.to)) {
|
||||
to = EmailModel.parseEmailLine(decodeURIComponent(email + ',' + params.to));
|
||||
to = _.values(
|
||||
to = Object.values(
|
||||
to.reduce((result, value) => {
|
||||
if (value) {
|
||||
if (result[value.email]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue