Merge branch 'gh-pages'

master
Thierry Degeling 2014-09-21 18:18:31 +02:00
commit f2e43ecad1
5 changed files with 266 additions and 168 deletions

View File

@ -1,10 +1,10 @@
@import url(//fonts.googleapis.com/css?family=Lato|Istok+Web);
body {
font-family: 'Oswald';
font-family: 'Lato', sans-serif;
font-weight: 300;
color: #fff;
opacity: 0.8;
background-color: rgb( 215, 150, 130 );
color: #333333;
background-color: rgb(245, 245, 245);
}
body:after {
@ -14,18 +14,24 @@ body:after {
top: 0;
width: 100%;
height: 100%;
background: url('../images/overlay.png');
z-index: -1;
}
.panel {
font-family: 'Roboto';
font-family: 'Istok Web', sans-serif;
position: relative;
background: #fff;
box-shadow: 0px 1px 0px 0px rgba(0,0,0,0.25);
padding: 0.2em 1em 1em 1em;
color: #777;
margin-bottom: 15px;
overflow: hidden;
}
.panel img {
display: block;
position: absolute;
right: 0;
top: 0;
height: 100%;
}
h1, h2, h3, h4, h5, h6 {
@ -36,29 +42,27 @@ h1, h2, h3, h4, h5, h6 {
.time, .date {
text-align: center;
color: #ffffff;
font-weight: 600;
font-weight: 300;
margin: 0;
}
.time {
font-size: 10em;
font-size: 3em;
}
.date {
font-size: 2em;
margin-top: -30px;
margin-bottom: 30px;
}
.climacon {
margin-top: -0.45em;
font-size: 15em;
font-size: 4em;
margin-bottom: 0;
}
.currentTemp {
margin-top: -0.2em;
font-size: 8em;
font-size: 1em;
text-align: center;
}
.row {
@ -66,29 +70,37 @@ h1, h2, h3, h4, h5, h6 {
}
.weather {
margin-top: 35px;
opacity: 0.8;
}
.logo {
text-align: center;
font-size: 8em;
margin-top: 35px;
opacity: 0.8;
font-size: 4em;
}
.open {
background: #5cb85c;
color: #fff;
background: rgb(150, 199, 80);
}
.closed {
background: #d9534f;
color: #fff;
background: rgb(238, 108, 47);
}
.status {
padding: 1em;
text-align: center;
font-size: 7em;
padding: 0;
}
color: #fff;
font-size: 1.8em;
width: 100%;
height: 100%;
}
.status h1 {
font-size: 4em;
margin: 0;
line-height: 1em;
}
/* Secondary row of boxes */
.busses h1:first-child, .cfl h1:first-child, .events h1:first-child, .news h1:first-child {
border-bottom: 1px solid #333333;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -5,8 +5,6 @@
<head>
<title>Level2</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/climacons-font.css" />
<link rel="stylesheet" href="css/level2.css" />
@ -14,55 +12,62 @@
<meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body>
<div class="container-fluid">
<div class="row hidden-sm hidden-xs">
<div class="col-md-4 logo">
<div class="row">
<div class="col-sm-12 col-md-4 logo">
Level2
</div>
<div class="col-md-4 datetime">
<h1 class="time"></h1>
<h3 class="date"></h3>
<div class="col-sm-6 col-md-4">
<div class="panel status"></div>
</div>
<div class="col-md-4 weather">
<div class="row">
<div class="col-xs-6">
<span class="weatherIcon"></span>
</div>
<div class="col-xs-6">
<h1 class="currentTemp"></h1>
</div>
</div>
<div class="col-sm-6 col-md-4 datetime">
<h1 class="time"></h1>
<h3 class="date"></h3>
<span class="weatherIcon">
<span class="currentTemp"></span>
</span>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-3 events">
</div>
<div class="col-md-4">
<div class="panel status"></div>
<div class="col-sm-6 col-md-3 busses">
</div>
<div class="col-md-4">
<div class="panel busses"></div>
<div class="clearfix visible-sm-block">
</div>
<div class="col-sm-6 col-md-3 cfl">
</div>
<div class="col-md-4 events">
<div class="col-sm-6 col-md-3 news">
</div>
</div>
</div>
</div><!-- end of fluid contianer -->
<script src="js/jquery.min.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/level2.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-30971852-8', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
</html>

View File

@ -1,35 +1,47 @@
!function ($) {
! function($) {
$(function(){
$(function() {
refreshTime();
setInterval( function() {
setInterval(function() {
refreshTime();
}, 59000);
refreshContent();
setInterval( function() {
setInterval(function() {
refreshContent();
}, 60000);
loadWeather();
setInterval( function() {
setInterval(function() {
loadWeather();
}, 900000);
l2status();
setInterval( function() {
setInterval(function() {
l2status();
}, 60000);
l2events();
setInterval( function() {
setInterval(function() {
l2events();
}, 3600000);
wortLuNews();
setInterval(function() {
wortLuNews();
}, 900000);
cflNews();
setInterval(function() {
cflNews();
}, 900000);
});
@ -38,8 +50,8 @@
function refreshTime() {
$('.time').text( moment().format('HH:mm') );
$('.date').text( moment().format('dddd, Do \of MMMM') );
$('.time').text(moment().format('HH:mm')); // 03:37
$('.date').text(moment().format('dddd, D MMMM')); // Sunday, 31 August
}
@ -48,74 +60,75 @@ function refreshContent() {
$('#wrapper').html('');
var request = $.ajax({
type: 'get',
url: 'http://getcontents.herokuapp.com/?url=http%3A%2F%2Ftravelplanner.mobiliteit.lu%2Fhafas%2Fcdt%2Fstboard.exe%2Ffn%3FL%3Dvs_stb%26%26input%3D200404028!%26boardType%3Ddep%26time%3D' + moment().format('HH') + '%3A' + moment().format('mm') + '%26selectDate%3Dtoday%26productsFilter%3D1111111111%26additionalTime%3D0%26start%3Dyes%26requestType%3D0%26disableEquivs%3Dyes%26ignoreMasts%3D1%26outputMode%3Dundefined%26maxJourneys%3D10',
complete: function( response ) {
type: 'get',
url: 'https://getcontents.herokuapp.com/?url=http%3A%2F%2Ftravelplanner.mobiliteit.lu%2Fhafas%2Fcdt%2Fstboard.exe%2Ffn%3FL%3Dvs_stb%26input%3D200404028%26boardType%3Ddep%26time%3D' + moment().format('HH') + '%3A' + moment().format('mm') + '%26selectDate%3Dtoday%26start%3Dyes%26requestType%3D0%26maxJourneys%3D10',
complete: function(response) {
resp = response.responseText.slice(14);
resp = response.responseText.slice(14);
data = JSON.parse( resp );
data = JSON.parse(resp);
busses = data.journey;
busses = data.journey;
var content = '';
var content = '<div class="panel"><h1>Upcoming busses</h1>';
$.each(busses, function(nr, bus) {
$.each(busses, function(nr, bus) {
var name = bus.pr;
var destination = bus.st;
var name = bus.pr;
var destination = bus.st;
if ( bus.rt != false ) {
if (bus.rt != false) {
var time = bus.rt.dlt;
var time = bus.rt.dlt;
} else {
} else {
var time = bus.ti;
var time = bus.ti;
}
}
var timeDifference;
var timeDifference;
var hours = time.substring(0, 2);
var minutes = time.substring(3, 5);
var busTime = moment()
.set('hour', time.substring(0, 2))
.set('minute', time.substring(3, 5));
var busTime = moment().set('hour', hours).set('minute', minutes);
timeDifference = busTime.diff(moment(), 'minutes');
var now = moment();
timeLeftMessage = 'departure in ' + timeDifference + ' minutes';
timeDifference = busTime.diff( now, 'minutes' );
if (timeDifference <= 5 && timeDifference > -1) {
timeLeftMessage = 'departure in ' + timeDifference + ' minutes';
labelColor = "danger";
if ( timeDifference <= 5 && timeDifference > -1 ) {
} else if (timeDifference <= 10 && timeDifference > -1) {
labelColor = "danger";
labelColor = "warning";
} else if ( timeDifference <= 10 && timeDifference > -1 ) {
} else {
labelColor = "warning";
labelColor = "info";
timeLeftMessage = '';
} else {
}
labelColor = "info";
timeLeftMessage = '';
if (name.indexOf("Bus") != -1) {
name = name.slice(name.indexOf("Bus ") + 4);
}
}
content += '<h1>' + time + ' <span class="label label-' + labelColor + ' label-lg">' + name + '</span> ' + destination + '</h1>' + timeLeftMessage;
content += '<h1>' + time + ' <span class="label label-' + labelColor + ' label-lg">' + name + '</span> ' + destination + '</h1>' + timeLeftMessage;
});
});
$('.busses').html('');
$('.busses').append( content );
$('.busses').html('');
$('.busses').append(content);
console.log( moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated busses' );
console.log(moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated busses');
}
}
});
}
@ -123,100 +136,105 @@ function refreshContent() {
function loadWeather() {
var city = 'Bonnevoie';
var country = 'lu';
var country = 'LU';
var appid = '64a2215ad2f5f944abd334578763726e';
var request = $.ajax({
type: 'get',
url: 'http://api.openweathermap.org/data/2.5/weather?units=metric&q=' + city + ',' + country + '&appid=' + appid,
complete: function( response ) {
// fixme: use an api that supports https
url: 'https://getcontents.herokuapp.com/?url=http://api.openweathermap.org/data/2.5/weather?q=' + city + ',' + country + '&units=metric&appid=' + appid,
complete: function(response) {
data = JSON.parse( response.responseText );
data = JSON.parse(response.responseText);
weather = data.weather[0];
var description = weather.description;
var weatherId = weather.icon;
var temperature = formatTemp( data.main.temp );
var description = weather.description;
var weatherId = weather.icon;
var temperature = formatTemp(data.main.temp);
$('.currentTemp').text( temperature );
$('.weatherIcon').attr( 'class', 'climacon ' + OWMIcon( weatherId ) );
$('.currentTemp').text(temperature);
$('.weatherIcon').attr('class', 'climacon ' + OWMIcon(weatherId));
console.log( moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated weather' );
console.log(moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated weather');
}
});
}
function formatTemp( temperature ) {
function formatTemp(temperature) {
temperature = ( temperature ).toFixed(1);
temperature = temperature - 273.15; // K to C
if (temperature > 10 ) {
temperature = Math.round( temperature );
}
return temperature + '°';
temperature = (temperature).toFixed(1); // 1 decimal
if (temperature > 10) {
temperature = Math.round(temperature); // round up to the nearest integer
}
return temperature + '°C';
}
function OWMIcon( imageCode ) {
// Icon Name & Colour Percentage
var b = {
'01d': [ "sun" ],
'01n': [ "moon" ],
function OWMIcon(imageCode) {
// Icon Name & Colour Percentage
var b = {
'01d': ["sun"],
'01n': ["moon"],
'02d': [ "cloud sun" ],
'02n': [ "cloud moon" ],
'02d': ["cloud sun"],
'02n': ["cloud moon"],
'03d': [ "cloud" ],
'03n': [ "cloud" ],
'03d': ["cloud"],
'03n': ["cloud"],
'04d': [ "cloud" ],
'04n': [ "cloud" ],
'04d': ["cloud"],
'04n': ["cloud"],
'09d': [ "showers sun" ],
'09n': [ "showers moon" ],
'09d': ["showers sun"],
'09n': ["showers moon"],
'10d': [ "rain sun" ],
'10n': [ "rain moon" ],
'10d': ["rain sun"],
'10n': ["rain moon"],
'11d': [ "lightning sun" ],
'11n': [ "lightning moon" ],
'11d': ["lightning sun"],
'11n': ["lightning moon"],
'13d': [ "snow sun" ],
'13n': [ "snow moon" ],
'13d': ["snow sun"],
'13n': ["snow moon"],
'50d': [ "fog sun" ],
'50n': [ "fog moon" ]
};
return b[ imageCode ]
'50d': ["fog sun"],
'50n': ["fog moon"]
};
return b[imageCode]
}
function l2status() {
var request = $.ajax({
type: 'get',
url: 'https://www.hackerspace.lu/od/',
complete: function( response ) {
url: 'https://spaceapi.syn2cat.lu/status/json',
complete: function(response) {
var status = JSON.parse( response.responseText );
var status = JSON.parse(response.responseText);
var timeStamp = moment.unix(status.state.lastchange).fromNow();
$('.status').removeClass('open').removeClass('closed');
if ( status.open ) {
$('.status').addClass('open').text('Open');
if (status.state.open) {
$('.status')
.addClass('open')
.html('<h1>Open</h1> Opened ' + timeStamp);
} else {
$('.status').addClass('closed').text('Closed');
$('.status')
.addClass('closed')
.html('<h1>Closed</h1> ' + timeStamp);
}
}
});
console.log( moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated Level2 status' );
console.log(moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated Level2 status');
}
@ -224,31 +242,88 @@ function l2events() {
var request = $.ajax({
type: 'get',
url: 'http://getcontents.herokuapp.com/?url=https%3A%2F%2Fwiki.hackerspace.lu%2Fwiki%2FSpecial%3AAsk%2F-5B-5BCategory%3AEvent-5D-5D-20-5B-5BStartDate%3A%3A-3E' + moment().format('YYYY') + '-2D' + moment().format('MM') + '-2D' + moment().format('DD') + '-5D-5D-20-3Cq-3E-5B-5BHas-20organizer%3A%3AOrganisation%3ASyn2cat-5D-5D-20OR-20-5B-5BIs-20External%3A%3Ano-5D-5D-3C-2Fq-3E-20-5B-5BDo-20Announce%3A%3Ayes-5D-5D%2F-3FStartDate%2F-3FEndDate%2F-3FHas-20subtitle%2F-3FHas-20description%2F-3FIs-20Event-20of-20Type%253DIs-20type%2F-3FHas-20location%2F-3FHas-20picture%2F-3FHas-20cost%2F-3FCategory%2Fformat%253Djson%2Fsort%253DStartDate%2Forder%253Dascending%2Fsearchlabel%253DJSON-20(Internal%2C-20announceable-20events-20only%2C-20only-20upcoming-20events)',
complete: function( response ) {
url: 'https://wiki.hackerspace.lu/wiki/Special:Ask/-5B-5BCategory:Event-5D-5D-20-5B-5BStartDate::-3E' + moment().format('YYYY') + '-2D' + moment().format('MM') + '-2D' + moment().format('DD') + '-5D-5D/-3FStartDate/-3FEndDate/-3FHas-20subtitle/-3FHas-20description/-3FIs-20Event-20of-20Type%3DIs-20type/-3FHas-20location/-3FHas-20picture/-3FHas-20cost/-3FCategory/format%3Djson/sort%3DStartDate/order%3Dascending/searchlabel%3DJSON-20(Internal,-20only-20upcoming-20events)',
complete: function(response) {
var events = JSON.parse( response.responseText );
var l2event_name, l2event_ob;
var output = '';
var events = JSON.parse(response.responseText);
$.each( events.items , function( nr, l2event ) {
var output = '<div class="panel"><h1>Level 2 events</h1>';
console.log( l2event );
for (l2event_name in events.results) {
output += '<div class="panel">'
+ '<h1>' + l2event.label + ' <small>'
+ moment( l2event.startdate, "YYYY-MM-DD HH:mm:ss").format( 'dddd, Do \of MMMM' )
+ '</small></h1>'
+ l2event.has_subtitle
+ '</div>';
var l2event_ob = events.results[l2event_name];
});
output += '<h1>' + l2event_name + ' <small>' + moment.unix(l2event_ob.printouts.StartDate, "YYYY-MM-DD HH:mm:ss").format('dddd, D MMMM HH:mm') + '</small></h1>' + l2event_ob.printouts['Has description'][0];
$('.events').html('').append( output );
};
output += "</div>";
$('.events').html('').append(output);
}
});
console.log( moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated Level2 events' );
console.log(moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated Level2 events');
}
function wortLuNews() {
var request = $.ajax({
type: 'get',
url: 'https://device.wort.lu/api/v303/sites/en/sections/4f4e59a1e4b056b73debc870',
complete: function(response) {
var articles = response.responseJSON.articles;
var output = '<div class="panel"><h1>News</h1>';
for (var ArticleNR = 0; ArticleNR < 5; ArticleNR++) {
var article = articles[ArticleNR];
output += '<h1>' + article.title + '</h1>' + article.teaser;
}
output += '</div>';
$('.news').html('').append(output);
}
});
console.log(moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated WortLu News');
}
function cflNews() {
var request = $.ajax({
type: 'get',
url: 'https://getcontents.herokuapp.com/?url=http%3A%2F%2Fmobile.cfl.lu%2Fbin%2Fhelp.exe%2Fenl%3Ftpl%3Drss_feed_global',
complete: function(response) {
var cfl = response.responseText;
var output = '<div class="panel"><h1>CFL notifications</h1>';
$($.parseXML(cfl))
.find("item")
.each(function() {
output += '<h1>' + $(this).find("title").text() + '</h1>' + $(this).find("description").text();
});
output += "</div>";
$('.cfl').html('').append(output);
}
});
console.log(moment().format('YYYY.MM.DD - HH:mm:ss') + ' updated cfl News');
}

6
js/moment.tz.min.js vendored Normal file
View File

@ -0,0 +1,6 @@
//! moment-timezone.js
//! version : 0.2.1
//! author : Tim Wood
//! license : MIT
//! github.com/moment/moment-timezone
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(["moment"],b):"object"==typeof exports?module.exports=b(require("moment")):b(a.moment)}(this,function(a){"use strict";function b(a){return a>96?a-87:a>64?a-29:a-48}function c(a){var c,d=0,e=a.split("."),f=e[0],g=e[1]||"",h=1,i=0,j=1;for(45===a.charCodeAt(0)&&(d=1,j=-1),d;d<f.length;d++)c=b(f.charCodeAt(d)),i=60*i+c;for(d=0;d<g.length;d++)h/=60,c=b(g.charCodeAt(d)),i+=c*h;return i*j}function d(a){for(var b=0;b<a.length;b++)a[b]=c(a[b])}function e(a,b){for(var c=0;b>c;c++)a[c]=Math.round((a[c-1]||0)+6e4*a[c]);a[b-1]=1/0}function f(a,b){var c,d=[];for(c=0;c<b.length;c++)d[c]=a[b[c]];return d}function g(a){var b=a.split("|"),c=b[2].split(" "),g=b[3].split(""),h=b[4].split(" ");return d(c),d(g),d(h),e(h,g.length),{name:b[0],abbrs:f(b[1].split(" "),g),offsets:f(c,g),untils:h}}function h(a){a&&this._set(g(a))}function i(a){return(a||"").toLowerCase().replace(/\//g,"_")}function j(a){var b,c,d;for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)c=new h(a[b]),d=i(c.name),y[d]=c,n(d)}function k(a){return y[i(a)]||null}function l(){var a,b=[];for(a in y)y.hasOwnProperty(a)&&y[a]&&b.push(y[a].name);return b.sort()}function m(a){var b,c;for("string"==typeof a&&(a=[a]),b=0;b<a.length;b++)c=a[b].split("|"),p(c[0],c[1]),p(c[1],c[0])}function n(a){if(z[a]){var b,c=y[a],d=z[a];for(b=0;b<d.length;b++)o(c,d[b]);z[a]=null}}function o(a,b){var c=y[i(b)]=new h;c._set(a),c.name=b}function p(a,b){a=i(a),y[a]?o(y[a],b):(z[a]=z[a]||[],z[a].push(b))}function q(a){j(a.zones),m(a.links),u.dataVersion=a.version}function r(a){return r.didShowError||(r.didShowError=!0,"undefined"!=typeof console&&"function"==typeof console.error&&console.error("moment.tz.zoneExists('"+a+"') has been deprecated in favor of !moment.tz.zone('"+a+"')")),!!k(a)}function s(a){return!(!a._a||void 0!==a._tzm)}function t(a){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(a)}function u(){var b=Array.prototype.slice.call(arguments,0,-1),c=arguments[arguments.length-1],d=k(c),e=a.utc.apply(null,b);return d&&s(e)&&e.add(d.parse(e),"minutes"),e.tz(c),e}function v(a){return function(){return this._z?this._z.abbr(this):a.call(this)}}function w(a){return function(){return this._z=null,a.apply(this,arguments)}}if(void 0!==a.tz)return a;var x="0.2.1",y={},z={};h.prototype={_set:function(a){this.name=a.name,this.abbrs=a.abbrs,this.untils=a.untils,this.offsets=a.offsets},_index:function(a){var b,c=+a,d=this.untils;for(b=0;b<d.length;b++)if(c<d[b])return b},parse:function(a){var b,c,d,e,f=+a,g=this.offsets,h=this.untils,i=h.length-1;for(e=0;i>e;e++)if(b=g[e],c=g[e+1],d=g[e?e-1:e],c>b&&u.moveAmbiguousForward?b=c:b>d&&u.moveInvalidForward&&(b=d),f<h[e]-6e4*b)return g[e];return g[i]},abbr:function(a){return this.abbrs[this._index(a)]},offset:function(a){return this.offsets[this._index(a)]}},u.version=x,u.dataVersion="",u._zones=y,u._links=z,u.add=j,u.link=m,u.load=q,u.zone=k,u.zoneExists=r,u.names=l,u.Zone=h,u.unpack=g,u.unpackBase60=c,u.needsOffset=s,u.moveInvalidForward=!0,u.moveAmbiguousForward=!1;var A=a.fn;a.tz=u,a.updateOffset=function(a,b){var c;a._z&&(c=a._z.offset(a),Math.abs(c)<16&&(c/=60),a.zone(c,b))},A.tz=function(b){return b?(this._z=k(b),this._z?a.updateOffset(this):t("Moment Timezone has no data for "+b+". See http://momentjs.com/timezone/docs/#/data-loading/."),this):this._z?this._z.name:void 0},A.zoneName=v(A.zoneName),A.zoneAbbr=v(A.zoneAbbr),A.utc=w(A.utc);var B=a.momentProperties;return"[object Array]"===Object.prototype.toString.call(B)?(B.push("_z"),B.push("_a")):B._z=null,a});