notification-center.tt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 class="notificationDisplay">
  27. <div style="margin: 0 auto; width: 700px">
  28. [% data.notifications.$notification.html %]
  29. </div>
  30. </td>
  31. </tr>
  32. [% END %]
  33. </tbody>
  34. </table>
  35. <script type="text/javascript">
  36. //Localize all the timestamps on the page
  37. var timestamps = document.querySelectorAll('.timestamp');
  38. for (var i=0; i < timestamps.length; i++) {
  39. var timestamp = timestamps[i].innerText;
  40. var t = new Date(0)
  41. t.setUTCSeconds(timestamp);
  42. timestamps[i].innerText = t.toLocaleDateString() + " " + t.toLocaleTimeString();
  43. }
  44. function toggleContentDisplay(id) {
  45. var dstatus = document.getElementById(id).style.display;
  46. var newstatus = dstatus === '' ? 'none' : ''
  47. document.getElementById(id).style.display = newstatus;
  48. }
  49. </script>
  50. [% END #wrapper -%]