Skip to content

Commit

Permalink
Merge pull request #311 from olinlibrary/osteele/fixes
Browse files Browse the repository at this point in the history
Fix lint issues, and then #310
  • Loading branch information
osteele authored May 9, 2018
2 parents 0be80c0 + 0202397 commit cf73917
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 148 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static/vendor/**/*.js
52 changes: 36 additions & 16 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,44 @@ parserOptions:
extends:
- eslint:recommended

# see https://eslint.org/docs/user-guide/configuring#specifying-globals
globals:
db: false

rules:
no-console: warn
no-unused-vars: [error, { argsIgnorePattern: "^_" }]
no-useless-escape: warn # TODO: remove (so this is an error)
no-useless-escape: warn # TODO: remove (so this is an error)

# Server-side:
overrides:
files: [ "*.js", "models/*.js", "routes/*.js", "scripts/*.js" ]
env:
browser: false
node: true
globals:
Promise: false
module: false
require: false
rules:
no-console: off
# Client:
- files: [ "routes/*.js", "static/**/*.js" ]
globals:
$: false
ABE_API_URI: false
SUBMIT_URL: true
db: false
showdown: false
# defined and used in admin.js:
tableColumns: true
# defined in server.js:
io: true
# defined and used in board_carousel:
$activeItem: true
$carousel: true
carouselSelector: true
# defined in vendor files:
Cookies: false
Dropzone: false
rules:
# FIXME: remove these exceptions, to turn them back into errors
no-undef: warn
no-unused-vars: warn
no-redeclare: warn
# Server:
- files: [ "server.js", "models/*.js", "routes/*.js", "scripts/*.js" ]
env:
browser: false
node: true
globals:
Promise: false
module: false
require: false
rules:
no-console: off
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FUTUREboard

[![Build Status](https://travis-ci.org/olinlibrary/futureboard.svg?branch=dev)](https://travis-ci.org/olinlibrary/futureboard?branch=dev)

FUTUREboard is a digital signage platform for sharing of media – including
images, GIFs, and videos — supplemented by information about events happening on
campus.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"markdownlint-cli": "^0.8.1"
},
"scripts": {
"lint": "eslint --cache *.js lambda models routes scripts && markdownlint README.md",
"lint": "eslint --cache *.js lambda models routes scripts static && markdownlint README.md",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
Expand Down
9 changes: 7 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ if(process.env.NODE_ENV === 'production'){
}

const port = process.env.PORT || 8080;
http.listen(port, function() {
console.log("FORWARDboard running over http on port", port);
const server = http.listen(port, function() {
let host = server.address().address;
// replace IPv6 wildcard by a recognizable URL, that can be used in a browser
// address bar
host = host.replace(/^::$/, '0.0.0.0');
// Printed thus, some terminals display a clickable link
console.log('FORWARDboard is running at http://%s:%s/', host, server.address().port);
});


Expand Down
4 changes: 2 additions & 2 deletions static/js/board_carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function carouselControl(direction){
} else if (direction == "right") {
$('#slideshow').carousel('next', 1); // Move next n times.
}
};
}

/**
* Resets time interval for the main carousel
Expand All @@ -251,7 +251,7 @@ function resetInterval() {
carouselInterval = setInterval(function() {
$('#slideshow').carousel('next');
}, 12000);
};
}

/**
* Listens on jQuery events for keyboard controls
Expand Down
64 changes: 30 additions & 34 deletions static/js/board_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
* @param {Object[]} eventsData - list of JSON events data
*/
function populateEvents(eventsData) {
let $eventsToday = $('#eventsToday');
let $featuredEvents = $('#featuredEvents');
let $addedFeaturedEventsTitles = [];
for (var i = 0; i < eventsData.length ; i++) {
let featured = (($.inArray("featured", eventsData[i].labels)) >= 0);
let eventStart = Date.parse(eventsData[i].start).toString("YYMMdd");
let today = Date.today().toString("YYMMdd");
const $eventsToday = $('#eventsToday');
const $featuredEvents = $('#featuredEvents');
const $addedFeaturedEventsTitles = [];
eventsData.forEach((event) => {
const featured = (($.inArray("featured", event.labels)) >= 0);
const eventStart = Date.parse(event.start).toString("YYMMdd");
const today = Date.today().toString("YYMMdd");
if (today === eventStart){
let $newEvent = createEventObject(eventsData[i]);
let $newEvent = createEventObject(event);
$eventsToday.append($newEvent);
}
if (featured && (Date.today().compareTo(Date.parse(eventsData[i].start)) == -1)){
if (featured && (Date.today().compareTo(Date.parse(event.start)) == -1)){
// checks for recurring events, adds only the first instance of recurring events
if ($.inArray(eventsData[i].title, $addedFeaturedEventsTitles) < 0){
let $newEvent = createFeaturedEventObject(eventsData[i]);
if ($.inArray(event.title, $addedFeaturedEventsTitles) < 0){
const $newEvent = createFeaturedEventObject(event);
$featuredEvents.append($newEvent);
$addedFeaturedEventsTitles.push(eventsData[i].title);
$addedFeaturedEventsTitles.push(event.title);
}
}
}
});
$('#eventsToday > li').sortElements(function(a, b){
return $(a).find('.rawDate').text() > $(b).find('.rawDate').text() ? 1 : -1;
});
Expand All @@ -37,26 +37,24 @@ function populateEvents(eventsData) {
*/
function createEventObject(eventData) {
var converter = new showdown.Converter(); // markdown converter
let location = "";
if(eventData.location != null){
var location = "@ " + eventData.location.substring(0, 30);
}
else {
var location = "";
}
if(eventData.title.length > 40){
var title = eventData.title.substring(0, 40) + "...";
location = "@ " + eventData.location.substring(0, 30);
}
else {
title = eventData.title;
let title = eventData.title;
if(title.length > 40){
title = eventData.title.substring(0, 40) + "…";
}
var $html = $('<li>', {
// addHours(-4) to adjust timezone(UTC) to Eastern Time:
const endHours = Date.parse(eventData.end.replace(/\.\d+$/, '')).addHours(-4).toString("hh:mm tt");
const $html = $('<li>', {
id: eventData.id,
class: "collection-item"
})
.append($('<span>', { class: 'title', text: title}))
.append($('<p>', { class: 'location', text: location }))
.append($('<p>', { class: 'rawDate', text: Date.parse(eventData.start).addHours(-4).toString("yyyyMMddHHmmss"), style: 'display:none'})) // addHours(-4) to adjust timezone(UTC) to Eastern Time
.append($('<p>', { class: 'date', text: Date.parse(eventData.start).addHours(-4).toString("hh:mm tt") + " - " + Date.parse(eventData.end).addHours(-4).toString("hh:mm tt") })) // addHours(-4) to adjust timezone(UTC) to Eastern Time
.append($('<p>', { class: 'date', text: Date.parse(eventData.start).addHours(-4).toString("hh:mm tt") + " - " + endHours }))
.append(converter.makeHtml(eventData.description))
.append($('<span/>', {class: "clear"}));
return $html;
Expand All @@ -68,26 +66,24 @@ function createEventObject(eventData) {
*/
function createFeaturedEventObject(eventData) {
var converter = new showdown.Converter(); // markdown converter
let location = "";
if(eventData.location != null){
var location = "@ " + eventData.location.substring(0, 30);
}
else {
var location = "";
}
if(eventData.title.length > 40){
var title = eventData.title.substring(0, 40) + "...";
location = "@ " + eventData.location.substring(0, 30);
}
else{
title = eventData.title;
let title = eventData.title;
if(title.length > 40){
title = eventData.title.substring(0, 40) + "…";
}
// addHours(-4) to adjust timezone(UTC) to Eastern Time:
const endHours = Date.parse(eventData.end.replace(/\.\d+$/, '')).addHours(-4).toString("hh:mm tt, dddd, MMM dd ");
var $html = $('<li>', {
id: eventData.id,
class: "collection-item"
})
.append($('<span>', { class: 'title', text: title}))
.append($('<p>', { class: 'location', text: location }))
.append($('<p>', { class: 'rawDate', text: Date.parse(eventData.start).addHours(-4).toString("yyyyMMddHHmmss"), style: 'display:none'})) // addHours(-4) to adjust timezone(UTC) to Eastern Time
.append($('<p>', { class: 'date', text: Date.parse(eventData.start).addHours(-4).toString("hh:mm tt") + " - " + Date.parse(eventData.end).addHours(-4).toString("hh:mm tt, dddd, MMM dd ") })) // addHours(-4) to adjust timezone(UTC) to Eastern Time
.append($('<p>', { class: 'date', text: Date.parse(eventData.start).addHours(-4).toString("hh:mm tt") + " - " + endHours }))
.append(converter.makeHtml(eventData.description))
.append($('<span/>', {class: "clear"}));

Expand Down
1 change: 0 additions & 1 deletion static/js/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function update(){
var dayOfWeek = days[date.getDay()];
var month = months[date.getMonth()];
var day = date.getDate();
var year = date.getFullYear();

var dateString = dayOfWeek + ', ' + month + ' ' + day;

Expand Down
Loading

0 comments on commit cf73917

Please sign in to comment.