notification-center.tt 2.0 KB

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