notification-center.tt 2.2 KB

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