From 330c4374f6e1824c265fb77ec3ae4e34c297bf85 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 8 Apr 2015 12:57:25 +0200 Subject: Remove spaces from URLs (improve slugs) --- js/campus-coords.js | 6 +++++- js/campus.js | 4 ++-- js/sitemap.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/campus-coords.js b/js/campus-coords.js index 3654a56..fc0f3cc 100644 --- a/js/campus-coords.js +++ b/js/campus-coords.js @@ -1,6 +1,6 @@ define(function() { 'use strict'; - return [ + var buildings = [ { "name": "Students Sports Centre", "description": "Have you ever heard about bossaball, underwater hockey, canoepolo or kempo jitsu? Besides all educational optionalities on the campus, there’s also the Student Sports Centre (SSC) which offers an extensive variety of sports for you to try out and practice, all in order to keep the TU/e-students wholesome. With 70 kinds of sports, special courses, a broad range of facilities, doors that are open 7 days per week, qualified sports instructors, 38 student sports associations and over 11000 members, the SSC is among the largest student collectives in Eindhoven.", @@ -109,4 +109,8 @@ define(function() { ] } ]; + buildings.forEach(function(building) { + building.id = building.name.toLowerCase().replace(/ /g, '-'); + }); + return buildings; }); diff --git a/js/campus.js b/js/campus.js index 234e1b9..8d6846b 100644 --- a/js/campus.js +++ b/js/campus.js @@ -33,7 +33,7 @@ define(['campus-coords', 'd3'], function(coords, d3) { .enter() .append('a') .attr('xlink:href', function(d) { - return '#/campus/' + d.name; + return '#/campus/' + d.id; }) .append('polygon') .attr('class', 'building') @@ -53,7 +53,7 @@ define(['campus-coords', 'd3'], function(coords, d3) { var citems = document.getElementById('campus-items'); coords.forEach(function(building) { var header = document.createElement('h2'); - header.id = '/campus/' + building.name; + header.id = '/campus/' + building.id; header.textContent = building.name; citems.appendChild(header); diff --git a/js/sitemap.js b/js/sitemap.js index 65b05c8..e4c4e77 100644 --- a/js/sitemap.js +++ b/js/sitemap.js @@ -22,7 +22,7 @@ define(['courses', 'campus-coords'], function(courses, campus_coords) { var campus_links = add(links, 'Campus', 'campus'); campus_coords.forEach(function(building) { - add(campus_links, building.name, 'campus/' + building.name); + add(campus_links, building.name, 'campus/' + building.id); }); add(links, 'Career', 'career'); -- cgit v1.2.1