Skip to content

Latest commit

 

History

History
executable file
·
94 lines (92 loc) · 2.27 KB

File metadata and controls

executable file
·
94 lines (92 loc) · 2.27 KB
layout events
permalink /events/index.html
title イベント
description
tags
image
feature
head.jpg
<style> .event { border: 1px gray solid; margin-bottom: 12px; padding: 8px; height: auto; overflow: auto; font-size: .8rem; } .event-title { font-weight: bold; display: block; font-size: 1.4rem; margin-bottom: 8px; } .event-date, .event-location { font-weight: bold; margin-bottom: 8px; } .event-date > div { display: inline; margin: 3px; } </style>
{% raw %}
{{evt.title}}
日時:
{{evt.from|date:'yyyy/MM/dd HH:mm'}}
-
{{evt.to|date:'HH:mm'}}
{{evt.to|date:'yyyy/MM/dd HH:mm'}}
場所: {{evt.location}}
{{evt.description}}
{% endraw %}
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script> <script> var app = angular.module('evtApp', []); app.controller('EventListCtrl', function($scope, $http) { var eventURL = 'http://reading.fxos.org/api/events/gcal'; $http({method: 'GET', url: eventURL, responseType: 'json'}). success(function(data, status) { var events = []; if (status == 200) { data.items.forEach(function(item) { var from = new Date(item.start.dateTime); var to = new Date(item.end.dateTime); var desc = parseDesc(item.description); events.push({ title: item.summary, from: from, to: to, location: item.location, isOneDay: isSameDate(from, to), url: desc.url, description: desc.description, }); }); } $scope.events = events; }); }); function isSameDate(from, to) { return (from.getYear() === to.getYear() && from.getMonth() === to.getMonth() && from.getDate() === to.getDate()); } function parseDesc(desc) { var lines = desc.split('\n'); var ret = {}; if (lines.length >=1 && lines[0].match(/^(http|https):\/\//)) { ret.url = lines[0]; ret.description = lines.slice(1).join(' '); } else { ret.url = null; ret.description = lines.join(' '); } return ret; } </script>