notification-center.tt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [%
  2. USE Whostmgr;
  3. WRAPPER 'master_templates/master.tmpl'
  4. app_key = 'Notification Center'
  5. header = locale.maketext('Notification Center')
  6. icon = '/addon_plugins/nfcenter.png'
  7. breadcrumburl = '/cgi/addon_notification-center.cgi'
  8. theme = "bootstrap"
  9. %]
  10. <table id="notificationsTable" class="table table-striped">
  11. <thead>
  12. <tr>
  13. <td>[% locale.maketext('Notification') %]</td>
  14. <td>[% locale.maketext('Time Occurred') %]</td>
  15. <td>[% locale.maketext('Show/Hide') %]</td>
  16. </tr>
  17. </thead>
  18. <tbody>
  19. [% FOREACH notification IN data.notifications.keys.sort %]
  20. <tr>
  21. <td>[% data.notifications.$notification.subject %]</td>
  22. <td class="timestamp">[% notification %]</td>
  23. <td><a class="button" href="javascript:toggleContentDisplay('[% notification %]')">Show/Hide</a></td>
  24. </tr>
  25. <tr style="display:none" id="[% notification %]">
  26. <td colspan=3>
  27. <div style="margin: 0 auto; width: 700px">
  28. [% data.notifications.$notification.html %]
  29. </div>
  30. </td>
  31. </tr>
  32. <tr></tr><!--Blank row to ensure table striping works properly-->
  33. [% END %]
  34. </tbody>
  35. </table>
  36. <script type="text/javascript">
  37. //Localize all the timestamps on the page
  38. var timestamps = document.querySelectorAll('.timestamp');
  39. for (var i=0; i < timestamps.length; i++) {
  40. var timestamp = timestamps[i].innerText;
  41. var t = new Date(0)
  42. t.setUTCSeconds(timestamp);
  43. timestamps[i].innerText = t.toLocaleDateString() + " " + t.toLocaleTimeString();
  44. }
  45. function toggleContentDisplay(id) {
  46. var dstatus = document.getElementById(id).style.display;
  47. var newstatus = dstatus === '' ? 'none' : ''
  48. document.getElementById(id).style.display = newstatus;
  49. }
  50. </script>
  51. [% END #wrapper -%]