index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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. checkMailUnread();
  183. },
  184. error: function(jqXHR, textStatus, errorThrown) {
  185. $('#mailDetails').html(textStatus);
  186. setDetailsVisible(true);
  187. showToast(Severity.Critical, 'Unable to open mail: ' + errorThrown + ' ' + textStatus);
  188. }
  189. });
  190. }
  191. }
  192. function updateFolderStat(stat) {
  193. var folder = stat.folder
  194. if (stat.unread > 0) {
  195. $('#folderStats'+folder).text(stat.unread);
  196. $('#folder'+folder).addClass('unread');
  197. } else {
  198. $('#folder'+folder).removeClass('unread');
  199. $('#folderStats'+folder).text("");
  200. }
  201. }
  202. function loadFolders() {
  203. if (mailbox === null) {
  204. return
  205. }
  206. $.ajax({
  207. url: '/m/' + mailbox + '/folders',
  208. success: function(result) {
  209. var folderList = jQuery.parseJSON(result);
  210. $('#folders').html(folderList.html);
  211. for(var i = 0; i < folderList.folders.length; i++) {
  212. var folder = folderList.folders[i].name;
  213. folders.push(folder);
  214. updateFolderStat(folderList.stats[i])
  215. }
  216. },
  217. error: function(jqXHR, textStatus, errorThrown) {
  218. showToast(Severity.Critical, 'Unable to update folder list: ' + errorThrown + ' ' + textStatus);
  219. }
  220. });
  221. }
  222. function folderStat(folder) {
  223. if (mailbox === null) {
  224. return
  225. }
  226. $.ajax({
  227. url: '/m/' + mailbox + '/folderStat',
  228. data: {
  229. folder: folder
  230. },
  231. success: function(result) {
  232. var stat = jQuery.parseJSON(result);
  233. updateFolderStat(stat)
  234. },
  235. error: function(jqXHR, textStatus, errorThrown) {
  236. showToast(Severity.Critical, 'Unable to update folder list: ' + errorThrown + ' ' + textStatus);
  237. }
  238. });
  239. }
  240. function closeDetails() {
  241. window.location.hash = currentFolder + currentPage;
  242. }
  243. function closeMailNew() {
  244. window.location.hash = currentFolder + currentPage;
  245. }
  246. function loadStatusLine() {
  247. if (mailbox === null) {
  248. return
  249. }
  250. $.ajax({
  251. url: '/m/' + mailbox + '/statusLine',
  252. success: function(result) {
  253. $('#statusLine').html(result);
  254. },
  255. error: function(jqXHR, textStatus, errorThrown) {
  256. showToast(Severity.Critical, 'Unable to load status line: ' + errorThrown + ' ' + textStatus);
  257. }
  258. });
  259. }
  260. function localDate(elementToChange, timestamp) {
  261. var today = new Date();
  262. var date = new Date(timestamp * 1000);
  263. dateString = '';
  264. if (today.getDay() == date.getDay()
  265. && today.getMonth() == date.getMonth()
  266. && today.getFullYear() == date.getFullYear()) {
  267. dateString = date.toLocaleTimeString('en-US');
  268. } else if (today.getFullYear() == date.getFullYear()) {
  269. const options = { day: 'numeric', month: 'short' };
  270. dateString = date.toLocaleDateString('en-US', options);
  271. } else {
  272. dateString = date.toLocaleDateString('en-US');
  273. }
  274. $('#'+elementToChange).text(dateString);
  275. }
  276. function setRead(mailId, read) {
  277. $.ajax({
  278. url: '/mail/'+mailId,
  279. type: 'PATCH',
  280. data: {read: read},
  281. success: function(result) {
  282. if (read) {
  283. if ($('#readIcon'+mailId)) {
  284. $('#readIcon'+mailId).attr('src', '/assets/read.svg');
  285. }
  286. if ($('#readListIcon'+mailId)) {
  287. $('#readListIcon'+mailId).attr('src', '/assets/read.svg');
  288. }
  289. $('#mail'+mailId).removeClass('unread');
  290. $('#mail'+mailId).addClass('read');
  291. } else {
  292. if ($('#readIcon'+mailId)) {
  293. $('#readIcon'+mailId).attr('src', '/assets/unread.svg');
  294. }
  295. if ($('#readListIcon'+mailId)) {
  296. $('#readListIcon'+mailId).attr('src', '/assets/unread.svg');
  297. }
  298. $('#mail'+mailId).removeClass('read');
  299. $('#mail'+mailId).addClass('unread');
  300. }
  301. checkMailUnread();
  302. },
  303. error: function(jqXHR, textStatus, errorThrown) {
  304. }
  305. });
  306. }
  307. function toggleRead(mailId) {
  308. var read = $('#mail'+mailId).hasClass('read');
  309. setRead(mailId, !read);
  310. }
  311. function removeMail(mailId, callback) {
  312. var method = 'PATCH';
  313. var data = { trash: 'true' };
  314. if (currentFolder == 'Trash') {
  315. method = 'DELETE';
  316. data = null;
  317. }
  318. $.ajax({
  319. url: '/mail/'+mailId,
  320. type: method,
  321. data: data,
  322. success: function() {
  323. removeFromSelectionList(mailId);
  324. $('#mail'+mailId).remove();
  325. if (callback) {
  326. callback(mailId);
  327. }
  328. },
  329. error: function(jqXHR, textStatus, errorThrown) {
  330. showToast(Severity.Critical, 'Unable to remove mail: ' + errorThrown + ' ' + textStatus);
  331. }
  332. });
  333. }
  334. function restoreMail(mailId, callback) {
  335. $.ajax({
  336. url: '/mail/'+mailId,
  337. type: 'PATCH',
  338. data: {trash: 'false'},
  339. success: function() {
  340. if (currentFolder == 'Trash') {
  341. $('#mail'+mailId).remove();
  342. removeFromSelectionList(mailId);
  343. }
  344. if (callback) {
  345. callback();
  346. }
  347. },
  348. error: function(jqXHR, textStatus, errorThrown) {
  349. showToast(Severity.Critical, 'Unable to restore mail: ' + errorThrown + ' ' + textStatus);
  350. }
  351. });
  352. }
  353. function downloadAttachment(attachmentId, filename) {
  354. $.ajax({
  355. url: '/attachment/' + attachmentId,
  356. type: 'GET',
  357. xhrFields: {
  358. responseType: 'blob'
  359. },
  360. success: function (data) {
  361. // Ah-ha-ha-ha html and web is piece of shit full of hacks...
  362. var a = document.createElement('a');
  363. var url = window.URL.createObjectURL(data);
  364. a.href = url;
  365. a.download = filename;
  366. document.body.append(a);
  367. a.click();
  368. a.remove();
  369. window.URL.revokeObjectURL(url);
  370. },
  371. error: function(jqXHR, textStatus, errorThrown) {
  372. showToast(Severity.Critical, 'Unable to download attachment: ' + errorThrown + ' ' + textStatus);
  373. }
  374. });
  375. }
  376. function setDetailsVisible(visible) {
  377. if (visible) {
  378. $('#mailDetails').show();
  379. $('#mailList').css({pointerEvents: 'none'});
  380. } else {
  381. currentMail = '';
  382. $('#mailDetails').hide();
  383. $('#mailDetails').html('');
  384. $('#mailList').css({pointerEvents: 'auto'});
  385. }
  386. }
  387. function setMailNewVisible(visible) {
  388. if (visible) {
  389. $('#mailNew').show();
  390. $('#mailList').css({pointerEvents: 'none'});
  391. } else {
  392. currentMail = '';
  393. $('#mailNew').hide();
  394. $('#mailList').css({pointerEvents: 'auto'});
  395. }
  396. while (toEmailList.length > 0 && $('#toEmailList').children().length > 1) {
  397. removeToEmail($('#toEmailList').children()[$('#toEmailList').children().length - 2].id, toEmailList[toEmailList.length - 1]);
  398. }
  399. toEmailList = new Array();
  400. $('#newMailEditor').val('');
  401. $('#newMailSubject').val('');
  402. $('#newMailTo').val('');
  403. $('#toEmailField').val('');
  404. }
  405. function updateMailList(folder, page) {
  406. if (mailbox === null) {
  407. return
  408. }
  409. if (folder == '') {
  410. if ($('#mailList')) {
  411. $('#mailList').html('Unable to load message list');
  412. }
  413. return;
  414. }
  415. $.ajax({
  416. url: '/m/' + mailbox + '/mailList',
  417. data: {
  418. folder: folder,
  419. page: page
  420. },
  421. success: function(result) {
  422. var data = jQuery.parseJSON(result);
  423. pageMax = Math.floor(data.total/50);
  424. if ($('#mailList')) {
  425. $('#mailList').html(data.html);
  426. }
  427. currentFolder = folder;
  428. enableRestoreFunctionality();
  429. currentPage = page;
  430. resetSelectionList();
  431. if ($('#currentPageIndex')) {
  432. $('#currentPageIndex').text(currentPage + 1);
  433. }
  434. if ($('#totalPageCount')) {
  435. $('#totalPageCount').text(pageMax + 1);
  436. }
  437. },
  438. error: function(jqXHR, textStatus, errorThrown) {
  439. if ($('#mailList')) {
  440. $('#mailList').html('Unable to load message list');
  441. }
  442. }
  443. });
  444. }
  445. function nextPage() {
  446. var newPage = currentPage < (pageMax - 1) ? currentPage + 1 : pageMax;
  447. window.location.hash = currentFolder + newPage;
  448. }
  449. function prevPage() {
  450. var newPage = currentPage > 0 ? currentPage - 1 : 0;
  451. window.location.hash = currentFolder + newPage;
  452. }
  453. function toggleDropDown(dd) {
  454. $('#'+dd).toggle();
  455. }
  456. function sendNewMail(force) {
  457. if (mailbox === null) {
  458. return
  459. }
  460. if (toEmailList.length <= 0) {
  461. return;
  462. }
  463. if (!force) {
  464. //TODO: Check if subject or body empty and display popup here
  465. // return
  466. }
  467. var composedEmailString = toEmailList[0];
  468. for (var i = 1; i < toEmailList.length; i++) {
  469. composedEmailString += "," + toEmailList[i];
  470. }
  471. $('#newMailTo').val(composedEmailString);
  472. var formValue = $('#mailNewForm').serialize();
  473. $.ajax({
  474. url: '/m/' + mailbox + '/sendNewMail',
  475. data: formValue,
  476. success: function() {
  477. $('#newMailEditor').val('');
  478. $('#newMailSubject').val('');
  479. $('#newMailTo').val('');
  480. closeMailNew();
  481. showToast(Severity.Normal, 'Email succesfully send');
  482. },
  483. error: function(jqXHR, textStatus, errorThrown) {
  484. showToast(Severity.Critical, 'Unable to send email: ' + errorThrown + ' ' + textStatus);
  485. }
  486. });
  487. }
  488. function logout() {
  489. window.location.href = '/logout';
  490. }
  491. function settings() {
  492. window.location.href = '/settings';
  493. }
  494. function connectNotifier() {
  495. if (notifierSocket != null) {
  496. return;
  497. }
  498. var protocol = window.location.protocol !== 'https:' ? 'ws://' : 'wss://';
  499. notifierSocket = new WebSocket(protocol + window.location.host + '/m/' + mailbox + '/notifierSubscribe');
  500. notifierSocket.onmessage = function (ev) {
  501. jsonData = JSON.parse(ev.data);
  502. switch (jsonData.type) {
  503. case 'mail':
  504. if (currentFolder == jsonData.data.folder) {
  505. $('#mailList').prepend(jsonData.data.html);
  506. }
  507. break;
  508. case 'stats':
  509. for (var i = 0; i < jsonData.data.length; i++) {
  510. var folder = jsonData.data[i].folder
  511. var unread = jsonData.data[i].unread
  512. if (unread > 0) {
  513. $('#folderStats'+folder).text(unread);
  514. $('#folder'+folder).addClass('unread');
  515. } else {
  516. $('#folder'+folder).removeClass('unread');
  517. $('#folderStats'+folder).text("");
  518. }
  519. }
  520. }
  521. }
  522. }
  523. $(window).on('beforeunload', function(){
  524. if (notifierSocket != null) {
  525. notifierSocket.close();
  526. notifierSocket = null;
  527. }
  528. });
  529. function toggleMailSelection(id) {
  530. var currentState = $('#mailCheckbox'+id).prop('checked')
  531. if (currentState) {
  532. addToSelectionList(id);
  533. } else {
  534. removeFromSelectionList(id);
  535. }
  536. }
  537. function toogleMailSelection() {
  538. var currentState = $('#selectAllCheckbox').prop('checked');
  539. currentState = !currentState;
  540. resetSelectionList();
  541. if (!currentState) {
  542. $('[id^="mailCheckbox"]').each(function() {
  543. addToSelectionList(this.id.replace('mailCheckbox', ''));
  544. })
  545. }
  546. }
  547. function removeSelection() {
  548. for (var i = 0; i < selectionList.length; ++i) {
  549. removeMail(selectionList[i], function(){});
  550. }
  551. }
  552. function restoreSelection() {
  553. for (var i = 0; i < selectionList.length; ++i) {
  554. restoreMail(selectionList[i], function(){});
  555. }
  556. }
  557. function toggleSelectionRead() {
  558. var read = checkMailUnread();
  559. for (var i = 0; i < selectionList.length; ++i) {
  560. setRead(selectionList[i], read);
  561. }
  562. }
  563. function checkMailUnread() {
  564. for (var i = 0; i < selectionList.length; ++i) {
  565. if ($('#mail'+selectionList[i]).hasClass('unread')) {
  566. $('#multiActionsRead').attr('src', '/assets/unread.svg');
  567. return true;
  568. }
  569. }
  570. $('#multiActionsRead').attr('src', '/assets/read.svg');
  571. return false;
  572. }
  573. //Mail selection list operations
  574. var selectionList = new Array();
  575. function addToSelectionList(mailId) {
  576. const i = selectionList.indexOf(mailId);
  577. if (i >= 0) {
  578. return;
  579. }
  580. selectionList.push(mailId);
  581. $('#mailCheckbox'+mailId).prop('checked', true);
  582. $('#multiActionsControls').css('display', 'flex');
  583. $('#selectAllCheckbox').prop('checked', true);
  584. checkMailUnread();
  585. }
  586. function removeFromSelectionList(mailId) {
  587. const i = selectionList.indexOf(mailId);
  588. if (i < 0) {
  589. console.log('Mail with id ' + mailId + ' is not in list');
  590. return;
  591. }
  592. selectionList.splice(i, 1);
  593. $('#'+mailId).prop('checked', false);
  594. if (selectionList.length <= 0) {
  595. $('#multiActionsControls').css('display', 'none');
  596. $('#selectAllCheckbox').prop('checked', false);
  597. }
  598. checkMailUnread();
  599. }
  600. function resetSelectionList() {
  601. for (var i = 0; i < selectionList.length; ++i) {
  602. $('#mailCheckbox'+selectionList[i]).prop('checked', false);
  603. }
  604. selectionList = new Array();
  605. $('#selectAllCheckbox').prop('checked', false);
  606. $('#multiActionsControls').css('display', 'none');
  607. }
  608. function enableRestoreFunctionality() {
  609. if (currentFolder == 'Trash') {
  610. $('#multiActionsRestore').css('display', 'block');
  611. $('[id^="restoreListIcon"]').css('display', 'block');
  612. } else {
  613. $('#multiActionsRestore').css('display', 'none');
  614. $('[id^="restoreListIcon"]').css('display', 'none');
  615. }
  616. }