2017-02-08 20:52:37 -05:00
|
|
|
'use strict'
|
2016-08-20 17:20:53 -04:00
|
|
|
|
2017-03-26 22:07:40 -04:00
|
|
|
/* global alertsData */
|
|
|
|
|
2017-04-01 17:07:01 -04:00
|
|
|
import $ from 'jquery'
|
2017-03-26 22:07:40 -04:00
|
|
|
import _ from 'lodash'
|
|
|
|
import io from 'socket.io-client'
|
|
|
|
import Alerts from './components/alerts.js'
|
2017-04-01 17:07:01 -04:00
|
|
|
import 'jquery-smooth-scroll'
|
|
|
|
import Sticky from 'sticky-js'
|
2017-02-09 20:24:28 -05:00
|
|
|
|
2017-04-01 17:07:01 -04:00
|
|
|
$(() => {
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Scroll
|
|
|
|
// ====================================
|
2016-08-27 21:46:10 -04:00
|
|
|
|
2017-02-08 20:52:37 -05:00
|
|
|
$('a').smoothScroll({
|
|
|
|
speed: 400,
|
|
|
|
offset: -70
|
|
|
|
})
|
2016-08-20 17:20:53 -04:00
|
|
|
|
2017-02-09 20:24:28 -05:00
|
|
|
var sticky = new Sticky('.stickyscroll') // eslint-disable-line no-unused-vars
|
2016-08-20 23:28:53 -04:00
|
|
|
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Notifications
|
|
|
|
// ====================================
|
2016-08-28 11:27:05 -04:00
|
|
|
|
2017-02-08 20:52:37 -05:00
|
|
|
$(window).bind('beforeunload', () => {
|
|
|
|
$('#notifload').addClass('active')
|
|
|
|
})
|
|
|
|
$(document).ajaxSend(() => {
|
|
|
|
$('#notifload').addClass('active')
|
|
|
|
}).ajaxComplete(() => {
|
|
|
|
$('#notifload').removeClass('active')
|
|
|
|
})
|
2016-08-27 21:46:10 -04:00
|
|
|
|
2017-02-08 20:52:37 -05:00
|
|
|
var alerts = new Alerts()
|
|
|
|
if (alertsData) {
|
|
|
|
_.forEach(alertsData, (alertRow) => {
|
|
|
|
alerts.push(alertRow)
|
|
|
|
})
|
|
|
|
}
|
2016-08-23 21:09:09 -04:00
|
|
|
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Establish WebSocket connection
|
|
|
|
// ====================================
|
2016-09-05 00:39:59 -04:00
|
|
|
|
2017-04-01 17:07:01 -04:00
|
|
|
var socket = io(window.location.origin)
|
2016-09-05 00:39:59 -04:00
|
|
|
|
2017-04-01 17:07:01 -04:00
|
|
|
require('./components/search.js')(socket)
|
2016-09-05 00:39:59 -04:00
|
|
|
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Pages logic
|
|
|
|
// ====================================
|
2016-08-28 11:27:05 -04:00
|
|
|
|
2017-04-01 17:07:01 -04:00
|
|
|
require('./pages/view.js')(alerts)
|
2017-04-09 21:13:53 -04:00
|
|
|
require('./pages/all.js')(alerts, socket)
|
2017-04-02 19:36:43 -04:00
|
|
|
require('./pages/create.js')(alerts, socket)
|
2017-04-01 17:07:01 -04:00
|
|
|
require('./pages/edit.js')(alerts, socket)
|
|
|
|
require('./pages/source.js')(alerts)
|
|
|
|
require('./pages/admin.js')(alerts)
|
2017-02-08 20:52:37 -05:00
|
|
|
})
|