mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,20 +1,15 @@
|
|||
|
||||
import window from 'window';
|
||||
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
|
||||
import { pString, pInt, isUnd, isNormal, trim, encodeURIComponent } from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
const
|
||||
ROOT = './',
|
||||
const ROOT = './',
|
||||
HASH_PREFIX = '#/',
|
||||
SERVER_PREFIX = './?',
|
||||
SUB_QUERY_PREFIX = '&q[]=',
|
||||
|
||||
VERSION = Settings.appSettingsGet('version'),
|
||||
|
||||
WEB_PREFIX = Settings.appSettingsGet('webPath') || '',
|
||||
VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/',
|
||||
STATIC_PREFIX = VERSION_PREFIX + 'static/',
|
||||
|
||||
ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'),
|
||||
ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin';
|
||||
|
||||
|
|
@ -23,16 +18,14 @@ let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function populateAuthSuffix()
|
||||
{
|
||||
export function populateAuthSuffix() {
|
||||
AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function subQueryPrefix()
|
||||
{
|
||||
export function subQueryPrefix() {
|
||||
return SUB_QUERY_PREFIX;
|
||||
}
|
||||
|
||||
|
|
@ -40,24 +33,21 @@ export function subQueryPrefix()
|
|||
* @param {string=} startupUrl
|
||||
* @returns {string}
|
||||
*/
|
||||
export function root(startupUrl = '')
|
||||
{
|
||||
export function root(startupUrl = '') {
|
||||
return HASH_PREFIX + pString(startupUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function rootAdmin()
|
||||
{
|
||||
export function rootAdmin() {
|
||||
return ADMIN_HOST_USE ? ROOT : SERVER_PREFIX + ADMIN_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function rootUser()
|
||||
{
|
||||
export function rootUser() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
|
|
@ -67,10 +57,21 @@ export function rootUser()
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentRaw(type, download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentRaw(type, download, customSpecSuffix) {
|
||||
customSpecSuffix = isUnd(customSpecSuffix) ? AUTH_PREFIX : customSpecSuffix;
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + customSpecSuffix + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + download;
|
||||
return (
|
||||
SERVER_PREFIX +
|
||||
'/Raw/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
customSpecSuffix +
|
||||
'/' +
|
||||
type +
|
||||
'/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
download
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,8 +79,7 @@ export function attachmentRaw(type, download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentDownload(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentDownload(download, customSpecSuffix) {
|
||||
return attachmentRaw('Download', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -88,8 +88,7 @@ export function attachmentDownload(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentPreview(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentPreview(download, customSpecSuffix) {
|
||||
return attachmentRaw('View', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -98,8 +97,7 @@ export function attachmentPreview(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentThumbnailPreview(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentThumbnailPreview(download, customSpecSuffix) {
|
||||
return attachmentRaw('ViewThumbnail', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +106,7 @@ export function attachmentThumbnailPreview(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentPreviewAsPlain(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentPreviewAsPlain(download, customSpecSuffix) {
|
||||
return attachmentRaw('ViewAsPlain', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +115,7 @@ export function attachmentPreviewAsPlain(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentFramed(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentFramed(download, customSpecSuffix) {
|
||||
return attachmentRaw('FramedView', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -127,40 +123,35 @@ export function attachmentFramed(download, customSpecSuffix)
|
|||
* @param {string} type
|
||||
* @returns {string}
|
||||
*/
|
||||
export function serverRequest(type)
|
||||
{
|
||||
export function serverRequest(type) {
|
||||
return SERVER_PREFIX + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function upload()
|
||||
{
|
||||
export function upload() {
|
||||
return serverRequest('Upload');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function uploadContacts()
|
||||
{
|
||||
export function uploadContacts() {
|
||||
return serverRequest('UploadContacts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function uploadBackground()
|
||||
{
|
||||
export function uploadBackground() {
|
||||
return serverRequest('UploadBackground');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function append()
|
||||
{
|
||||
export function append() {
|
||||
return serverRequest('Append');
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +159,7 @@ export function append()
|
|||
* @param {string} email
|
||||
* @returns {string}
|
||||
*/
|
||||
export function change(email)
|
||||
{
|
||||
export function change(email) {
|
||||
return serverRequest('Change') + encodeURIComponent(email) + '/';
|
||||
}
|
||||
|
||||
|
|
@ -177,8 +167,7 @@ export function change(email)
|
|||
* @param {string} add
|
||||
* @returns {string}
|
||||
*/
|
||||
export function ajax(add)
|
||||
{
|
||||
export function ajax(add) {
|
||||
return serverRequest('Ajax') + add;
|
||||
}
|
||||
|
||||
|
|
@ -186,26 +175,35 @@ export function ajax(add)
|
|||
* @param {string} requestHash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function messageViewLink(requestHash)
|
||||
{
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ViewAsPlain/' + SUB_QUERY_PREFIX + '/' + requestHash;
|
||||
export function messageViewLink(requestHash) {
|
||||
return (
|
||||
SERVER_PREFIX +
|
||||
'/Raw/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
AUTH_PREFIX +
|
||||
'/ViewAsPlain/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
requestHash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} requestHash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function messageDownloadLink(requestHash)
|
||||
{
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash;
|
||||
export function messageDownloadLink(requestHash) {
|
||||
return (
|
||||
SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {string}
|
||||
*/
|
||||
export function avatarLink(email)
|
||||
{
|
||||
export function avatarLink(email) {
|
||||
return SERVER_PREFIX + '/Raw/0/Avatar/' + encodeURIComponent(email) + '/';
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +211,7 @@ export function avatarLink(email)
|
|||
* @param {string} hash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function publicLink(hash)
|
||||
{
|
||||
export function publicLink(hash) {
|
||||
return SERVER_PREFIX + '/Raw/0/Public/' + hash + '/';
|
||||
}
|
||||
|
||||
|
|
@ -222,16 +219,16 @@ export function publicLink(hash)
|
|||
* @param {string} hash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function userBackground(hash)
|
||||
{
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash;
|
||||
export function userBackground(hash) {
|
||||
return (
|
||||
SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function phpInfo()
|
||||
{
|
||||
export function phpInfo() {
|
||||
return SERVER_PREFIX + '/Info';
|
||||
}
|
||||
|
||||
|
|
@ -240,24 +237,21 @@ export function phpInfo()
|
|||
* @param {boolean} isAdmin
|
||||
* @returns {string}
|
||||
*/
|
||||
export function langLink(lang, isAdmin)
|
||||
{
|
||||
export function langLink(lang, isAdmin) {
|
||||
return SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + VERSION + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function exportContactsVcf()
|
||||
{
|
||||
export function exportContactsVcf() {
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsVcf/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function exportContactsCsv()
|
||||
{
|
||||
export function exportContactsCsv() {
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsCsv/';
|
||||
}
|
||||
|
||||
|
|
@ -265,44 +259,43 @@ export function exportContactsCsv()
|
|||
* @param {boolean} xauth = false
|
||||
* @returns {string}
|
||||
*/
|
||||
export function socialGoogle(xauth = false)
|
||||
{
|
||||
return SERVER_PREFIX + 'SocialGoogle' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '') + (xauth ? '&xauth=1' : '');
|
||||
export function socialGoogle(xauth = false) {
|
||||
return (
|
||||
SERVER_PREFIX +
|
||||
'SocialGoogle' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '') +
|
||||
(xauth ? '&xauth=1' : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function socialTwitter()
|
||||
{
|
||||
return SERVER_PREFIX + 'SocialTwitter' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '');
|
||||
export function socialTwitter() {
|
||||
return SERVER_PREFIX + 'SocialTwitter' + ('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function socialFacebook()
|
||||
{
|
||||
return SERVER_PREFIX + 'SocialFacebook' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '');
|
||||
export function socialFacebook() {
|
||||
return (
|
||||
SERVER_PREFIX + 'SocialFacebook' + ('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {string}
|
||||
*/
|
||||
export function staticPrefix(path)
|
||||
{
|
||||
export function staticPrefix(path) {
|
||||
return STATIC_PREFIX + path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function emptyContactPic()
|
||||
{
|
||||
export function emptyContactPic() {
|
||||
return staticPrefix('css/images/empty-contact.png');
|
||||
}
|
||||
|
||||
|
|
@ -310,40 +303,35 @@ export function emptyContactPic()
|
|||
* @param {string} fileName
|
||||
* @returns {string}
|
||||
*/
|
||||
export function sound(fileName)
|
||||
{
|
||||
export function sound(fileName) {
|
||||
return staticPrefix('sounds/' + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function notificationMailIcon()
|
||||
{
|
||||
export function notificationMailIcon() {
|
||||
return staticPrefix('css/images/icom-message-notification.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function openPgpJs()
|
||||
{
|
||||
export function openPgpJs() {
|
||||
return staticPrefix('js/min/openpgp.min.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function openPgpWorkerJs()
|
||||
{
|
||||
export function openPgpWorkerJs() {
|
||||
return staticPrefix('js/min/openpgp.worker.min.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function openPgpWorkerPath()
|
||||
{
|
||||
export function openPgpWorkerPath() {
|
||||
return staticPrefix('js/min/');
|
||||
}
|
||||
|
||||
|
|
@ -351,11 +339,9 @@ export function openPgpWorkerPath()
|
|||
* @param {string} theme
|
||||
* @returns {string}
|
||||
*/
|
||||
export function themePreviewLink(theme)
|
||||
{
|
||||
export function themePreviewLink(theme) {
|
||||
let prefix = VERSION_PREFIX;
|
||||
if ('@custom' === theme.substr(-7))
|
||||
{
|
||||
if ('@custom' === theme.substr(-7)) {
|
||||
theme = trim(theme.substring(0, theme.length - 7));
|
||||
prefix = WEB_PREFIX;
|
||||
}
|
||||
|
|
@ -367,8 +353,7 @@ export function themePreviewLink(theme)
|
|||
* @param {string} inboxFolderName = 'INBOX'
|
||||
* @returns {string}
|
||||
*/
|
||||
export function inbox(inboxFolderName = 'INBOX')
|
||||
{
|
||||
export function inbox(inboxFolderName = 'INBOX') {
|
||||
return HASH_PREFIX + 'mailbox/' + inboxFolderName;
|
||||
}
|
||||
|
||||
|
|
@ -376,16 +361,14 @@ export function inbox(inboxFolderName = 'INBOX')
|
|||
* @param {string=} screenName = ''
|
||||
* @returns {string}
|
||||
*/
|
||||
export function settings(screenName = '')
|
||||
{
|
||||
export function settings(screenName = '') {
|
||||
return HASH_PREFIX + 'settings' + (screenName ? '/' + screenName : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function about()
|
||||
{
|
||||
export function about() {
|
||||
return HASH_PREFIX + 'about';
|
||||
}
|
||||
|
||||
|
|
@ -393,11 +376,9 @@ export function about()
|
|||
* @param {string} screenName
|
||||
* @returns {string}
|
||||
*/
|
||||
export function admin(screenName)
|
||||
{
|
||||
export function admin(screenName) {
|
||||
let result = HASH_PREFIX;
|
||||
switch (screenName)
|
||||
{
|
||||
switch (screenName) {
|
||||
case 'AdminDomains':
|
||||
result += 'domains';
|
||||
break;
|
||||
|
|
@ -420,28 +401,24 @@ export function admin(screenName)
|
|||
* @param {string=} threadUid = ''
|
||||
* @returns {string}
|
||||
*/
|
||||
export function mailBox(folder, page = 1, search = '', threadUid = '')
|
||||
{
|
||||
export function mailBox(folder, page = 1, search = '', threadUid = '') {
|
||||
page = isNormal(page) ? pInt(page) : 1;
|
||||
search = pString(search);
|
||||
|
||||
let result = HASH_PREFIX + 'mailbox/';
|
||||
|
||||
if ('' !== folder)
|
||||
{
|
||||
if ('' !== folder) {
|
||||
const resultThreadUid = pInt(threadUid);
|
||||
result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
|
||||
}
|
||||
|
||||
if (1 < page)
|
||||
{
|
||||
result = result.replace(/[\/]+$/, '');
|
||||
if (1 < page) {
|
||||
result = result.replace(/[/]+$/, '');
|
||||
result += '/p' + page;
|
||||
}
|
||||
|
||||
if ('' !== search)
|
||||
{
|
||||
result = result.replace(/[\/]+$/, '');
|
||||
if ('' !== search) {
|
||||
result = result.replace(/[/]+$/, '');
|
||||
result += '/' + window.encodeURI(search);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue