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