notification-center.tt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. [%
  2. USE Whostmgr;
  3. USE JSON;
  4. IF locale.get_html_dir_attr() == 'rtl';
  5. SET rtl_bootstrap = Whostmgr.find_file_url('/3rdparty/bootstrap-rtl/optimized/dist/css/bootstrap-rtl.min.css');
  6. END;
  7. SET styleSheets = [
  8. rtl_bootstrap,
  9. theme_magic_url('libraries/bootstrap/optimized/css/bootstrap.min.css')
  10. theme_magic_url('/libraries/fontawesome/css/font-awesome.min.css')
  11. ];
  12. WRAPPER 'master_templates/master.tmpl'
  13. app_key = 'Notification Center'
  14. header = locale.maketext('Notification Center')
  15. icon = '/addon_plugins/nfcenter.png'
  16. breadcrumburl = '/cgi/addon_notification-center.cgi'
  17. theme = "bootstrap"
  18. stylesheets = styleSheets
  19. %]
  20. <table id="notificationsTable" class="table table-striped responsive-table" border="1" cellspacing="0" cellpadding="2" >
  21. <thead>
  22. <tr>
  23. <td>[% locale.maketext('Notification') %]</td>
  24. <td>[% locale.maketext('Time Occurred') %]</td>
  25. <td>[% locale.maketext('Show/Hide') %]</td>
  26. </tr>
  27. </thead>
  28. <tbody>
  29. [% FOREACH notification IN data.notifications.keys.sort %]
  30. <tr>
  31. <td>[% data.notifications.$notification.subject %]</td>
  32. <td class="timestamp">[% notification %]</td>
  33. <td><a class="button" href="javascript:toggleContentDisplay('[% notification %]')">Show/Hide</a></td>
  34. </tr>
  35. <tr style="display:none" id="[% notification %]">
  36. <td colspan=3 class="notificationDisplay">
  37. <div style="margin: 0 auto; width: 700px">
  38. [% data.notifications.$notification.html %]
  39. </div>
  40. </td>
  41. </tr>
  42. [% END %]
  43. </tbody>
  44. </table>
  45. <script type="text/javascript">
  46. //Localize all the timestamps on the page
  47. var timestamps = document.querySelectorAll('.timestamp');
  48. for (var i=0; i < timestamps.length; i++) {
  49. var timestamp = timestamps[i].innerText;
  50. var t = new Date(0)
  51. t.setUTCSeconds(timestamp);
  52. timestamps[i].innerText = t.toLocaleDateString() + " " + t.toLocaleTimeString();
  53. }
  54. function toggleContentDisplay(id) {
  55. var dstatus = document.getElementById(id).style.display;
  56. var newstatus = dstatus === '' ? 'none' : ''
  57. document.getElementById(id).style.display = newstatus;
  58. }
  59. </script>
  60. [% END #wrapper -%]