index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2020 Alexey Edelev <semlanik@gmail.com>
  5. *
  6. * This file is part of gostfix project https://git.semlanik.org/semlanik/gostfix
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. var currentFolder = '';
  26. var currentPage = 0;
  27. var currentMail = '';
  28. var mailbox = null;
  29. var pageMax = 10;
  30. const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  31. const emailEndRegex = /[;,\s]/g;
  32. var folders = new Array();
  33. var notifierSocket = null;
  34. var toEmailList = new Array();
  35. var toEmailIndex = 0;
  36. var toEmailPreviousSelectionPosition = 0;
  37. $(window).click(function(e){
  38. var target = $(e.target);
  39. var isDropDown = false;
  40. for (var i = 0; i < target.parents().length; i++) {
  41. isDropDown = target.parents()[i].classList.contains('dropbtn');
  42. if (isDropDown) {
  43. break;
  44. }
  45. }
  46. if (!e.target.matches('.dropbtn') && !isDropDown) {
  47. $('.dropdown-content').hide();
  48. }
  49. })
  50. $(document).ready(function(){
  51. $.ajaxSetup({
  52. global: false,
  53. type: 'POST'
  54. });
  55. urlPaths = $(location).attr('pathname').split('/');
  56. if (urlPaths != null && urlPaths.length >= 2 && urlPaths[1] == 'm') {
  57. mailbox = urlPaths[2];
  58. } else {
  59. mailbox = null;
  60. }
  61. $(window).bind('hashchange', onHashChanged);
  62. onHashChanged();
  63. loadFolders();
  64. loadStatusLine();
  65. $('#mailNewButton').click(mailNew);
  66. connectNotifier();
  67. $('#toEmailField').on('input', toEmailFieldChanged);
  68. $('#toEmailField').keydown(function(e){
  69. var actualText = $('#toEmailField').val();
  70. const selectionPosition = e.target.selectionStart;
  71. switch(e.keyCode) {
  72. case 8:
  73. if (toEmailPreviousSelectionPosition == 0 && e.target.selectionStart == 0
  74. && toEmailList.length > 0 && $('#toEmailList').children().length > 1) {
  75. removeToEmail($('#toEmailList').children()[$('#toEmailList').children().length - 2].id, toEmailList[toEmailList.length - 1]);
  76. }
  77. break;
  78. case 13:
  79. case 9:
  80. addToEmail(actualText.slice(0, selectionPosition));
  81. $('#toEmailField').val(actualText.slice(selectionPosition + 1, actualText.length));
  82. break;
  83. }
  84. toEmailPreviousSelectionPosition = e.target.selectionStart;
  85. })
  86. resetSelectionList();
  87. })
  88. function toEmailFieldChanged(e) {
  89. const selectionPosition = e.target.selectionStart - 1;
  90. var actualText = $('#toEmailField').val();
  91. if (actualText.length <= 0 || selectionPosition < 0) {
  92. return;
  93. }
  94. var lastChar = actualText[selectionPosition];
  95. if (emailEndRegex.test(lastChar)) {
  96. addToEmail(actualText.slice(0, selectionPosition));
  97. $('#toEmailField').val(actualText.slice(selectionPosition + 1, actualText.length));
  98. }
  99. }
  100. function addToEmail(toEmail) {
  101. if (toEmail.length <= 0) {
  102. return;
  103. }
  104. var style = emailRegex.test(toEmail) ? 'valid' : 'invalid';
  105. $('<div class="'+ style + ' toEmail" id="toEmail' + toEmailIndex + '">' + toEmail + '<img class="iconBtn" style="height: 12px; margin-left:10px; margin: auto;" onclick="removeToEmail(\'toEmail' + toEmailIndex + '\', \'' + toEmail + '\');" src="/assets/cross.svg"/></div>').insertBefore('#toEmailField');
  106. toEmailIndex++;
  107. toEmailList.push(toEmail);
  108. checkSendDisabled();
  109. }
  110. function removeToEmail(id, email) {
  111. const index = toEmailList.indexOf(email);
  112. if (index >= 0) {
  113. toEmailList.splice(index, 1);
  114. checkSendDisabled();
  115. }
  116. $('#' + id).remove();
  117. }
  118. function checkSendDisabled() {
  119. if (toEmailList.length > 0) {
  120. $('#sendButton').removeClass('disabled');
  121. } else {
  122. $('#sendButton').addClass('disabled');
  123. }
  124. }
  125. function mailNew(e) {
  126. window.location.hash = currentFolder + currentPage + '/mailNew';
  127. }
  128. function mailOpen(id) {
  129. window.location.hash = currentFolder + currentPage + '/' + id;
  130. }
  131. function openFolder(folder) {
  132. resetSelectionList();
  133. window.location.hash = folder;
  134. }
  135. function onHashChanged() {
  136. var hashLocation = window.location.hash;
  137. if (hashLocation == '') {
  138. setDetailsVisible(false);
  139. openFolder('Inbox');
  140. return;
  141. }
  142. hashRegex = /^#([a-zA-Z]+)(\d*)\/?([A-Fa-f\d]*)/g;
  143. hashParts = hashRegex.exec(hashLocation);
  144. page = 0;
  145. if (hashParts.length >= 3 && hashParts[2] != '') {
  146. page = parseInt(hashParts[2]);
  147. if (typeof page != 'number' || page > pageMax || page < 0) {
  148. page = 0;
  149. }
  150. }
  151. if (hashParts.length >= 2 && (hashParts[1] != currentFolder || currentPage != page) && hashParts[1] != '') {
  152. updateMailList(hashParts[1], page);
  153. }
  154. if (hashParts.length >= 4 && hashParts[3] != "" && hashParts[3] != '/mailNew') {
  155. if (currentMail != hashParts[3]) {
  156. requestMail(hashParts[3]);
  157. }
  158. } else {
  159. setDetailsVisible(false);
  160. }
  161. hashParts = hashLocation.split('/');
  162. if (hashParts.length == 2 && hashParts[1] == 'mailNew') {
  163. setMailNewVisible(true);
  164. } else {
  165. setMailNewVisible(false);
  166. }
  167. }
  168. function requestMail(mailId) {
  169. if (mailId != "") {
  170. $.ajax({
  171. url: '/mail/' + mailId,
  172. type: 'GET',
  173. success: function(result) {
  174. currentMail = mailId;
  175. if ($('#readListIcon'+mailId)) {
  176. $('#readListIcon'+mailId).attr('src', '/assets/read.svg');
  177. }
  178. $('#mail'+mailId).removeClass('unread');
  179. $('#mail'+mailId).addClass('read');
  180. $('#mailDetails').html(result);
  181. setDetailsVisible(true);
  182. folderStat(currentFolder);//TODO: receive statistic from websocket
  183. checkMailUnread();
  184. },
  185. error: function(jqXHR, textStatus, errorThrown) {
  186. $('#mailDetails').html(textStatus);
  187. setDetailsVisible(true);
  188. showToast(Severity.Critical, 'Unable to open mail: ' + errorThrown + ' ' + textStatus);
  189. }
  190. });
  191. }
  192. }
  193. function loadFolders() {
  194. if (mailbox === null) {
  195. return
  196. }
  197. $.ajax({
  198. url: '/m/' + mailbox + '/folders',
  199. success: function(result) {
  200. folderList = jQuery.parseJSON(result);
  201. for(var i = 0; i < folderList.folders.length; i++) {
  202. folders.push(folderList.folders[i].name);
  203. folderStat(folderList.folders[i].name);
  204. }
  205. $('#folders').html(folderList.html);
  206. },
  207. error: function(jqXHR, textStatus, errorThrown) {
  208. showToast(Severity.Critical, 'Unable to update folder list: ' + errorThrown + ' ' + textStatus);
  209. }
  210. });
  211. }
  212. function folderStat(folder) {
  213. if (mailbox === null) {
  214. return
  215. }
  216. $.ajax({
  217. url: '/m/' + mailbox + '/folderStat',
  218. data: {
  219. folder: folder
  220. },
  221. success: function(result) {
  222. var stats = jQuery.parseJSON(result);
  223. if (stats.unread > 0) {
  224. $('#folderStats'+folder).text(stats.unread);
  225. $('#folder'+folder).addClass('unread');
  226. } else {
  227. $('#folder'+folder).removeClass('unread');
  228. $('#folderStats'+folder).text("");
  229. }
  230. },
  231. error: function(jqXHR, textStatus, errorThrown) {
  232. showToast(Severity.Critical, 'Unable to update folder list: ' + errorThrown + ' ' + textStatus);
  233. }
  234. });
  235. }
  236. function closeDetails() {
  237. window.location.hash = currentFolder + currentPage;
  238. }
  239. function closeMailNew() {
  240. window.location.hash = currentFolder + currentPage;
  241. }
  242. function loadStatusLine() {
  243. if (mailbox === null) {
  244. return
  245. }
  246. $.ajax({
  247. url: '/m/' + mailbox + '/statusLine',
  248. success: function(result) {
  249. $('#statusLine').html(result);
  250. },
  251. error: function(jqXHR, textStatus, errorThrown) {
  252. showToast(Severity.Critical, 'Unable to load status line: ' + errorThrown + ' ' + textStatus);
  253. }
  254. });
  255. }
  256. function localDate(elementToChange, timestamp) {
  257. var today = new Date();
  258. var date = new Date(timestamp * 1000);
  259. dateString = '';
  260. if (today.getDay() == date.getDay()
  261. && today.getMonth() == date.getMonth()
  262. && today.getFullYear() == date.getFullYear()) {
  263. dateString = date.toLocaleTimeString('en-US');
  264. } else if (today.getFullYear() == date.getFullYear()) {
  265. const options = { day: 'numeric', month: 'short' };
  266. dateString = date.toLocaleDateString('en-US', options);
  267. } else {
  268. dateString = date.toLocaleDateString('en-US');
  269. }
  270. $('#'+elementToChange).text(dateString);
  271. }
  272. function setRead(mailId, read) {
  273. $.ajax({
  274. url: '/mail/'+mailId,
  275. type: 'PATCH',
  276. data: {read: read},
  277. success: function(result) {
  278. if (read) {
  279. if ($('#readIcon'+mailId)) {
  280. $('#readIcon'+mailId).attr('src', '/assets/read.svg');
  281. }
  282. if ($('#readListIcon'+mailId)) {
  283. $('#readListIcon'+mailId).attr('src', '/assets/read.svg');
  284. }
  285. $('#mail'+mailId).removeClass('unread');
  286. $('#mail'+mailId).addClass('read');
  287. } else {
  288. if ($('#readIcon'+mailId)) {
  289. $('#readIcon'+mailId).attr('src', '/assets/unread.svg');
  290. }
  291. if ($('#readListIcon'+mailId)) {
  292. $('#readListIcon'+mailId).attr('src', '/assets/unread.svg');
  293. }
  294. $('#mail'+mailId).removeClass('read');
  295. $('#mail'+mailId).addClass('unread');
  296. }
  297. folderStat(currentFolder);//TODO: receive statistic from websocket
  298. checkMailUnread();
  299. },
  300. error: function(jqXHR, textStatus, errorThrown) {
  301. }
  302. });
  303. }
  304. function toggleRead(mailId) {
  305. var read = $('#mail'+mailId).hasClass('read');
  306. setRead(mailId, !read);
  307. }
  308. function removeMail(mailId, callback) {
  309. var method = 'PATCH';
  310. var data = { trash: 'true' };
  311. if (currentFolder == 'Trash') {
  312. method = 'DELETE';
  313. data = null;
  314. }
  315. $.ajax({
  316. url: '/mail/'+mailId,
  317. type: method,
  318. data: data,
  319. success: function() {
  320. removeFromSelectionList(mailId);
  321. $('#mail'+mailId).remove();
  322. if (callback) {
  323. callback(mailId);
  324. }
  325. folderStat(currentFolder);//TODO: receive statistic from websocket
  326. folderStat('Trash');//TODO: receive statistic from websocket
  327. },
  328. error: function(jqXHR, textStatus, errorThrown) {
  329. showToast(Severity.Critical, 'Unable to remove mail: ' + errorThrown + ' ' + textStatus);
  330. }
  331. });
  332. }
  333. function restoreMail(mailId, callback) {
  334. $.ajax({
  335. url: '/mail/'+mailId,
  336. type: 'PATCH',
  337. data: {trash: 'false'},
  338. success: function() {
  339. if (currentFolder == 'Trash') {
  340. $('#mail'+mailId).remove();
  341. removeFromSelectionList(mailId);
  342. }
  343. if (callback) {
  344. callback();
  345. }
  346. for (var i = 0; i < folders.length; i++) {
  347. folderStat(folders[i]);
  348. }
  349. },
  350. error: function(jqXHR, textStatus, errorThrown) {
  351. showToast(Severity.Critical, 'Unable to restore mail: ' + errorThrown + ' ' + textStatus);
  352. }
  353. });
  354. }
  355. function downloadAttachment(attachmentId, filename) {
  356. $.ajax({
  357. url: '/attachment/' + attachmentId,
  358. type: 'GET',
  359. xhrFields: {
  360. responseType: 'blob'
  361. },
  362. success: function (data) {
  363. // Ah-ha-ha-ha html and web is piece of shit full of hacks...
  364. var a = document.createElement('a');
  365. var url = window.URL.createObjectURL(data);
  366. a.href = url;
  367. a.download = filename;
  368. document.body.append(a);
  369. a.click();
  370. a.remove();
  371. window.URL.revokeObjectURL(url);
  372. },
  373. error: function(jqXHR, textStatus, errorThrown) {
  374. showToast(Severity.Critical, 'Unable to download attachment: ' + errorThrown + ' ' + textStatus);
  375. }
  376. });
  377. }
  378. function setDetailsVisible(visible) {
  379. if (visible) {
  380. $('#mailDetails').show();
  381. $('#mailList').css({pointerEvents: 'none'});
  382. } else {
  383. currentMail = '';
  384. $('#mailDetails').hide();
  385. $('#mailDetails').html('');
  386. $('#mailList').css({pointerEvents: 'auto'});
  387. }
  388. }
  389. function setMailNewVisible(visible) {
  390. if (visible) {
  391. $('#mailNew').show();
  392. $('#mailList').css({pointerEvents: 'none'});
  393. } else {
  394. currentMail = '';
  395. $('#mailNew').hide();
  396. $('#mailList').css({pointerEvents: 'auto'});
  397. }
  398. while (toEmailList.length > 0 && $('#toEmailList').children().length > 1) {
  399. removeToEmail($('#toEmailList').children()[$('#toEmailList').children().length - 2].id, toEmailList[toEmailList.length - 1]);
  400. }
  401. toEmailList = new Array();
  402. $('#newMailEditor').val('');
  403. $('#newMailSubject').val('');
  404. $('#newMailTo').val('');
  405. $('#toEmailField').val('');
  406. }
  407. function updateMailList(folder, page) {
  408. if (mailbox === null) {
  409. return
  410. }
  411. if (folder == '') {
  412. if ($('#mailList')) {
  413. $('#mailList').html('Unable to load message list');
  414. }
  415. return;
  416. }
  417. $.ajax({
  418. url: '/m/' + mailbox + '/mailList',
  419. data: {
  420. folder: folder,
  421. page: page
  422. },
  423. success: function(result) {
  424. var data = jQuery.parseJSON(result);
  425. pageMax = Math.floor(data.total/50);
  426. if ($('#mailList')) {
  427. $('#mailList').html(data.html);
  428. }
  429. currentFolder = folder;
  430. enableRestoreFunctionality();
  431. currentPage = page;
  432. resetSelectionList();
  433. if ($('#currentPageIndex')) {
  434. $('#currentPageIndex').text(currentPage + 1);
  435. }
  436. if ($('#totalPageCount')) {
  437. $('#totalPageCount').text(pageMax + 1);
  438. }
  439. },
  440. error: function(jqXHR, textStatus, errorThrown) {
  441. if ($('#mailList')) {
  442. $('#mailList').html('Unable to load message list');
  443. }
  444. }
  445. });
  446. }
  447. function nextPage() {
  448. var newPage = currentPage < (pageMax - 1) ? currentPage + 1 : pageMax;
  449. window.location.hash = currentFolder + newPage;
  450. }
  451. function prevPage() {
  452. var newPage = currentPage > 0 ? currentPage - 1 : 0;
  453. window.location.hash = currentFolder + newPage;
  454. }
  455. function toggleDropDown(dd) {
  456. $('#'+dd).toggle();
  457. }
  458. function sendNewMail(force) {
  459. if (mailbox === null) {
  460. return
  461. }
  462. if (toEmailList.length <= 0) {
  463. return;
  464. }
  465. if (!force) {
  466. //TODO: Check if subject or body empty and display popup here
  467. // return
  468. }
  469. var composedEmailString = toEmailList[0];
  470. for (var i = 1; i < toEmailList.length; i++) {
  471. composedEmailString += "," + toEmailList[i];
  472. }
  473. $('#newMailTo').val(composedEmailString);
  474. var formValue = $('#mailNewForm').serialize();
  475. $.ajax({
  476. url: '/m/' + mailbox + '/sendNewMail',
  477. data: formValue,
  478. success: function() {
  479. $('#newMailEditor').val('');
  480. $('#newMailSubject').val('');
  481. $('#newMailTo').val('');
  482. closeMailNew();
  483. showToast(Severity.Normal, 'Email succesfully send');
  484. },
  485. error: function(jqXHR, textStatus, errorThrown) {
  486. showToast(Severity.Critical, 'Unable to send email: ' + errorThrown + ' ' + textStatus);
  487. }
  488. });
  489. }
  490. function logout() {
  491. window.location.href = '/logout';
  492. }
  493. function settings() {
  494. window.location.href = '/settings';
  495. }
  496. function connectNotifier() {
  497. if (notifierSocket != null) {
  498. return;
  499. }
  500. var protocol = 'wss://';
  501. if (window.location.protocol !== 'https:') {
  502. protocol = 'ws://';
  503. }
  504. notifierSocket = new WebSocket(protocol + window.location.host + '/m/' + mailbox + '/notifierSubscribe');
  505. notifierSocket.onmessage = function (ev) {
  506. jsonData = JSON.parse(ev.data);
  507. switch (jsonData.type) {
  508. case 'mail':
  509. $('#mailList').prepend(jsonData.data.html);
  510. for (var i = 0; i < folders.length; i++) {
  511. if (folders[i] == jsonData.data.folder) {
  512. folderStat(folders[i]);
  513. }
  514. }
  515. break;
  516. }
  517. }
  518. }
  519. $(window).on('beforeunload', function(){
  520. if (notifierSocket != null) {
  521. notifierSocket.close();
  522. notifierSocket = null;
  523. }
  524. });
  525. function toggleMailSelection(id) {
  526. var currentState = $('#mailCheckbox'+id).prop('checked')
  527. if (currentState) {
  528. addToSelectionList(id);
  529. } else {
  530. removeFromSelectionList(id);
  531. }
  532. }
  533. function toogleMailSelection() {
  534. var currentState = $('#selectAllCheckbox').prop('checked');
  535. currentState = !currentState;
  536. resetSelectionList();
  537. if (!currentState) {
  538. $('[id^="mailCheckbox"]').each(function() {
  539. addToSelectionList(this.id.replace('mailCheckbox', ''));
  540. })
  541. }
  542. }
  543. function removeSelection() {
  544. for (var i = 0; i < selectionList.length; ++i) {
  545. removeMail(selectionList[i], function(){});
  546. }
  547. }
  548. function restoreSelection() {
  549. for (var i = 0; i < selectionList.length; ++i) {
  550. restoreMail(selectionList[i], function(){});
  551. }
  552. }
  553. function toggleSelectionRead() {
  554. var read = checkMailUnread();
  555. for (var i = 0; i < selectionList.length; ++i) {
  556. setRead(selectionList[i], read);
  557. }
  558. }
  559. function checkMailUnread() {
  560. for (var i = 0; i < selectionList.length; ++i) {
  561. if ($('#mail'+selectionList[i]).hasClass('unread')) {
  562. $('#multiActionsRead').attr('src', '/assets/unread.svg');
  563. return true;
  564. }
  565. }
  566. $('#multiActionsRead').attr('src', '/assets/read.svg');
  567. return false;
  568. }
  569. //Mail selection list operations
  570. var selectionList = new Array();
  571. function addToSelectionList(mailId) {
  572. const i = selectionList.indexOf(mailId);
  573. if (i >= 0) {
  574. return;
  575. }
  576. selectionList.push(mailId);
  577. $('#mailCheckbox'+mailId).prop('checked', true);
  578. $('#multiActionsControls').css('display', 'flex');
  579. $('#selectAllCheckbox').prop('checked', true);
  580. checkMailUnread();
  581. }
  582. function removeFromSelectionList(mailId) {
  583. const i = selectionList.indexOf(mailId);
  584. if (i < 0) {
  585. console.log('Mail with id ' + mailId + ' is not in list');
  586. return;
  587. }
  588. selectionList.splice(i, 1);
  589. $('#'+mailId).prop('checked', false);
  590. if (selectionList.length <= 0) {
  591. $('#multiActionsControls').css('display', 'none');
  592. $('#selectAllCheckbox').prop('checked', false);
  593. }
  594. checkMailUnread();
  595. }
  596. function resetSelectionList() {
  597. for (var i = 0; i < selectionList.length; ++i) {
  598. $('#mailCheckbox'+selectionList[i]).prop('checked', false);
  599. }
  600. selectionList = new Array();
  601. $('#selectAllCheckbox').prop('checked', false);
  602. $('#multiActionsControls').css('display', 'none');
  603. }
  604. function enableRestoreFunctionality() {
  605. if (currentFolder == 'Trash') {
  606. $('#multiActionsRestore').css('display', 'block');
  607. $('[id^="restoreListIcon"]').css('display', 'block');
  608. } else {
  609. $('#multiActionsRestore').css('display', 'none');
  610. $('[id^="restoreListIcon"]').css('display', 'none');
  611. }
  612. }