You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.5 KiB

  1. 'use strict'
  2. /* global alertsData */
  3. import $ from 'jquery'
  4. import _ from 'lodash'
  5. import io from 'socket.io-client'
  6. import Alerts from './components/alerts.js'
  7. import 'jquery-smooth-scroll'
  8. import Sticky from 'sticky-js'
  9. $(() => {
  10. // ====================================
  11. // Scroll
  12. // ====================================
  13. $('a').smoothScroll({
  14. speed: 400,
  15. offset: -70
  16. })
  17. var sticky = new Sticky('.stickyscroll') // eslint-disable-line no-unused-vars
  18. // ====================================
  19. // Notifications
  20. // ====================================
  21. $(window).bind('beforeunload', () => {
  22. $('#notifload').addClass('active')
  23. })
  24. $(document).ajaxSend(() => {
  25. $('#notifload').addClass('active')
  26. }).ajaxComplete(() => {
  27. $('#notifload').removeClass('active')
  28. })
  29. var alerts = new Alerts()
  30. if (alertsData) {
  31. _.forEach(alertsData, (alertRow) => {
  32. alerts.push(alertRow)
  33. })
  34. }
  35. // ====================================
  36. // Establish WebSocket connection
  37. // ====================================
  38. var socket = io(window.location.origin)
  39. require('./components/search.js')(socket)
  40. // ====================================
  41. // Pages logic
  42. // ====================================
  43. require('./pages/view.js')(alerts)
  44. require('./pages/all.js')(alerts, socket)
  45. require('./pages/create.js')(alerts, socket)
  46. require('./pages/edit.js')(alerts, socket)
  47. require('./pages/source.js')(alerts)
  48. require('./pages/admin.js')(alerts)
  49. })