Altes Köln

Widget:Zeitleiste: Unterschied zwischen den Versionen

Aus Altes Köln
Wechseln zu:Navigation, Suche
Keine Bearbeitungszusammenfassung
Markierung: 2017-Quelltext-Bearbeitung
Keine Bearbeitungszusammenfassung
Markierung: 2017-Quelltext-Bearbeitung
 
(11 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 23: Zeile 23:
font-size: 16px;
font-size: 16px;
color: #495057;
color: #495057;
}


.ak-timeline-article-content {
display: none;
display: none;
}
}


.ak-timeline-widget_article-focussed .ak-timeline-article {
.ak-timeline-widget_article-focussed .ak-timeline-article-content {
display: block;
display: block;
}
.ak-timeline-widget_article-focussed .ak-timeline-explanation {
display: none;
}
.ak-timeline-article h3,
.ak-timeline-article h4 {
padding: 0;
}
.ak-timeline-article-date-range {
font-style: italic;
}
.ak-timeline-article-details {
margin-top: 1em;
}
}


Zeile 59: Zeile 78:
} else {
} else {
return null;
return null;
}
}
function renderDate(date) {
if (date.precision === Histropedia.PRECISION_DAY) {
return '' + date.day + '.' + date.month + '.' + date.year;
} else if (date.precision === Histropedia.PRECISION_MONTH) {
return '' + date.month + '.' + date.year;
} else if (date.precision === Histropedia.PRECISION_YEAR) {
return '' + date.year;
} else {
return '';
}
}
}
}


function applyArticleToArticleElement(article, timelineArticleElement) {
function applyArticleToArticleElement(article, timelineArticleElement) {
timelineArticleElement.getElementsByClassName('ak-timeline-article-title').item(0).textContent = article.title;
var titleElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-title')[0];
timelineArticleElement.getElementsByClassName('ak-timeline-article-subtitle').item(0).textContent = article.subtitle;
if (article.title) {
titleElement.textContent = article.title;
} else {
titleElement.textContent = '';
}
var subtitleElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-subtitle')[0];
if (article.subtitle) {
subtitleElement.textContent = article.subtitle;
} else {
subtitleElement.textContent = '';
}


// TODO
var dateRangeElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-date-range')[0];
var dateRangeElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-date-range').item(0);
var dateString = renderDate(article.from);
//var fromDate = new Date();
if (article.isToPresent) {
if (article.isToPresent) {
// TODO
dateString += ' - heute';
} else if (article.to) {
dateString += ' - ' + renderDate(article.to);
}
}
dateRangeElement.textContent = dateString;


// TODO
var detailsElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-details')[0];
var detailsElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-details').item(0);
detailsElement.innerHTML = '';
if (article.details) {
for (var i = 0; i < article.details.length; i++) {
var dt = document.createElement('dt');
dt.textContent = article.details[i].label;
detailsElement.insertAdjacentElement('beforeend', dt);
var dd = document.createElement('dd');
dd.innerHTML = article.details[i].value;
detailsElement.insertAdjacentElement('beforeend', dd);
}
}
}
 
function getOuterWidth(element) {
var style = window.getComputedStyle ? getComputedStyle(element, null) : element.currentStyle;
return element.offsetWidth + (parseInt(style.marginLeft) || 0) + (parseInt(style.marginRight) || 0);
}
 
function getHeaderNames(tableElement) {
var headerElements = tableElement.querySelectorAll('tbody tr th');
var headerNames = [];
for (var i = 0; i < headerElements.length; i++) {
headerNames.push(headerElements[i].innerText.trim());
}
return headerNames;
}
 
// Polyfill "Element.closest"
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
if (!Element.prototype.closest) {
Element.prototype.closest = function(s) {
var el = this;
 
do {
if (Element.prototype.matches.call(el, s)) {
return el;
}
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
}


Zeile 84: Zeile 171:
var dataTable = timelineDataTables.item(i);
var dataTable = timelineDataTables.item(i);
var rows = dataTable.querySelectorAll('tbody tr');
var rows = dataTable.querySelectorAll('tbody tr');
var headerNames = getHeaderNames(dataTable);
for (var j = 0; j < rows.length; j++) {
for (var j = 0; j < rows.length; j++) {
var row = rows.item(j);
var row = rows.item(j);
var cells = row.children;
var cells = row.children;
if (cells.length) {
if (cells.length) {
if (cells.item(0).tagName.toLowerCase() === 'th') {
if (cells[0].tagName.toLowerCase() === 'th') {
continue;
continue;
}
}


var article = {
var article = {
id: cells.item(0).innerText,
id: cells[0].innerText,
starred: false
starred: false
};
};
if (cells.item(1).innerText.trim() !== '') {
 
article.title = cells.item(1).innerText;
if (cells[1].innerText.trim() !== '') {
article.title = cells[1].innerText;
}
}
if (cells.item(2).innerText.trim() !== '') {
 
article.subtitle = cells.item(2).innerText;
if (cells[2].innerText.trim() !== '') {
article.subtitle = cells[2].innerText;
}
}
var from = parseDate(cells.item(3).innerText);
 
var from = parseDate(cells[3].innerText);
if (from.year < earliestYear) {
if (from.year < earliestYear) {
earliestYear = from.year;
earliestYear = from.year;
}
}
article.from = from;
article.from = from;
var to = parseDate(cells.item(4).innerText);
 
if (to != null) {
var toText = cells[4].innerText;
article.to = to;
if (toText.trim() === 'heute') {
article.isToPresent = true;
} else {
var to = parseDate(toText);
if (to != null) {
article.to = to;
}
}
}
if (cells.item(5).innerText.trim() !== '') {
 
article.imageUrl = cells.item(5).innerText;
if (cells[5].innerText.trim() !== '') {
article.imageUrl = cells[5].innerText;
}
}
if (cells.item(6).innerText.trim() !== '') {
 
article.rank = cells.item(6).innerText;
if (cells[6].innerText.trim() !== '') {
article.rank = cells[6].innerText;
}
}
if (cells.item(7).innerText.trim() !== '') {
 
article.targetUrl = cells.item(7).innerText;
if (cells.length > 7) {
article.details = [];
for (var k = 7; k < cells.length; k++) {
if (k < headerNames.length) {
article.details.push({
label: headerNames[k],
value: cells[k].innerHTML
});
}
}
}
}
articles.push(article);
articles.push(article);
}
}
Zeile 125: Zeile 234:
}
}


var timelineContainerElement = document.getElementsByClassName('ak-timeline-container').item(0);
var timelineContainerElement = document.getElementsByClassName('ak-timeline-container')[0];
var timelineWidgetElement = timelineContainerElement.parentElement;
var timelineWidgetElement = timelineContainerElement.parentElement;
var timelineArticleElement = timelineWidgetElement.getElementsByClassName('ak-timeline-article').item(0);
var timelineArticleElement = timelineWidgetElement.getElementsByClassName('ak-timeline-article')[0];
 
var timelineWidth = 800;
var mainGridElement = timelineContainerElement.closest('ak-main-grid');
if (mainGridElement) {
timelineWidth = mainGridElement.clientWidth - getOuterWidth(timelineArticleElement);
}
 
var zoom = timelineContainerElement.dataset.zoom;
var zoom = timelineContainerElement.dataset.zoom;
if (zoom === '') {
if (zoom === '') {
Zeile 134: Zeile 250:
zoom = parseInt(zoom, 10);
zoom = parseInt(zoom, 10);
}
}
var akTimeline = new Histropedia.Timeline(timelineContainerElement, {
var akTimeline = new Histropedia.Timeline(timelineContainerElement, {
width: timelineWidth,
height: 500,
initialDate: {
initialDate: {
year: earliestYear - 5,
year: earliestYear - 5,
Zeile 146: Zeile 265:
applyArticleToArticleElement(article.data, timelineArticleElement);
applyArticleToArticleElement(article.data, timelineArticleElement);
timelineWidgetElement.classList.add('ak-timeline-widget_article-focussed');
timelineWidgetElement.classList.add('ak-timeline-widget_article-focussed');
},
onArticleDoubleClick: function(article) {
if (article.data.targetUrl) {
window.open(article.data.targetUrl, '_blank');
}
}
}
});
});
Zeile 160: Zeile 274:
<div class="ak-timeline-container" data-zoom="<!--{$zoom|escape:'html'}-->"></div>
<div class="ak-timeline-container" data-zoom="<!--{$zoom|escape:'html'}-->"></div>
<div class="ak-timeline-article">
<div class="ak-timeline-article">
<h3 class="ak-timeline-article-title"></h3>
<div class="ak-timeline-article-content">
<h4 class="ak-timeline-article-subtitle"></h4>
<h3 class="ak-timeline-article-title"></h3>
<div class="ak-timeline-article-date-range"></div>
<h4 class="ak-timeline-article-subtitle"></h4>
<dl class="ak-timeline-article-details"></dl>
<div class="ak-timeline-article-date-range"></div>
<dl class="ak-timeline-article-details"></dl>
</div>
<div class="ak-timeline-explanation">
<p>Klicken Sie ein Element an, um hier Details darüber zu lesen oder es verschieben zu können.</p>
<p>Mit dem Mausrad können Sie in der Zeitleiste zoomen, durch Drag&amp;Drop können Sie die Zeitleiste verschieben.</p>
</div>
</div>
</div>
</div>
</div>

Aktuelle Version vom 13. November 2020, 18:11 Uhr

<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> <script type="text/javascript" src="/alteskoeln/jquery.mousewheel-3.1.13.min.js"></script> <script type="text/javascript" src="https://cdn.histropedia.com/histropedia-1.2.0.min.js"></script>

<style type="text/css"> .ak-timeline-widget { display: flex; }

.ak-timeline-article { box-sizing: border-box; width: 20vw; min-width: 300px; height: 500px; margin: 0 0 0 2em; padding: 1em; border: 1px solid #ced4da; border-radius: 4px; box-shadow: 0px 3px 12px rgba(0,0,0,0.1); overflow-y: auto;

font-family: Arial, sans-serif; font-size: 16px; color: #495057; }

.ak-timeline-article-content { display: none; }

.ak-timeline-widget_article-focussed .ak-timeline-article-content { display: block; }

.ak-timeline-widget_article-focussed .ak-timeline-explanation { display: none; }

.ak-timeline-article h3, .ak-timeline-article h4 { padding: 0; }

.ak-timeline-article-date-range { font-style: italic; }

.ak-timeline-article-details { margin-top: 1em; }

</style>

<script> function parseDate(date) { if (date.trim() === ) { return null; } var dateParts = date.split('-'); if (dateParts.length === 1) { return { year: parseInt(dateParts[0], 10), precision: Histropedia.PRECISION_YEAR } } else if (dateParts.length === 2) { return { year: parseInt(dateParts[0], 10), month: parseInt(dateParts[1], 10), precision: Histropedia.PRECISION_MONTH } } else if (dateParts.length === 3) { return { year: parseInt(dateParts[0], 10), month: parseInt(dateParts[1], 10), day: parseInt(dateParts[2], 10), precision: Histropedia.PRECISION_DAY } } else { return null; } }

function renderDate(date) { if (date.precision === Histropedia.PRECISION_DAY) { return + date.day + '.' + date.month + '.' + date.year; } else if (date.precision === Histropedia.PRECISION_MONTH) { return + date.month + '.' + date.year; } else if (date.precision === Histropedia.PRECISION_YEAR) { return + date.year; } else { return ; } }

function applyArticleToArticleElement(article, timelineArticleElement) { var titleElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-title')[0]; if (article.title) { titleElement.textContent = article.title; } else { titleElement.textContent = ; } var subtitleElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-subtitle')[0]; if (article.subtitle) { subtitleElement.textContent = article.subtitle; } else { subtitleElement.textContent = ; }

var dateRangeElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-date-range')[0]; var dateString = renderDate(article.from); if (article.isToPresent) { dateString += ' - heute'; } else if (article.to) { dateString += ' - ' + renderDate(article.to); } dateRangeElement.textContent = dateString;

var detailsElement = timelineArticleElement.getElementsByClassName('ak-timeline-article-details')[0]; detailsElement.innerHTML = ; if (article.details) { for (var i = 0; i < article.details.length; i++) { var dt = document.createElement('dt'); dt.textContent = article.details[i].label; detailsElement.insertAdjacentElement('beforeend', dt); var dd = document.createElement('dd'); dd.innerHTML = article.details[i].value; detailsElement.insertAdjacentElement('beforeend', dd); } } }

function getOuterWidth(element) { var style = window.getComputedStyle ? getComputedStyle(element, null) : element.currentStyle; return element.offsetWidth + (parseInt(style.marginLeft) || 0) + (parseInt(style.marginRight) || 0); }

function getHeaderNames(tableElement) { var headerElements = tableElement.querySelectorAll('tbody tr th'); var headerNames = []; for (var i = 0; i < headerElements.length; i++) { headerNames.push(headerElements[i].innerText.trim()); } return headerNames; }

// Polyfill "Element.closest" if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; } if (!Element.prototype.closest) { Element.prototype.closest = function(s) { var el = this;

do { if (Element.prototype.matches.call(el, s)) { return el; } el = el.parentElement || el.parentNode; } while (el !== null && el.nodeType === 1); return null; }; }

document.addEventListener('DOMContentLoaded', function(event) { var timelineDataTables = document.getElementsByClassName('ak-timeline-datatable'); var articles = []; var earliestYear = 2000; for (var i = 0; i < timelineDataTables.length; i++) { var dataTable = timelineDataTables.item(i); var rows = dataTable.querySelectorAll('tbody tr'); var headerNames = getHeaderNames(dataTable); for (var j = 0; j < rows.length; j++) { var row = rows.item(j); var cells = row.children; if (cells.length) { if (cells[0].tagName.toLowerCase() === 'th') { continue; }

var article = { id: cells[0].innerText, starred: false };

if (cells[1].innerText.trim() !== ) { article.title = cells[1].innerText; }

if (cells[2].innerText.trim() !== ) { article.subtitle = cells[2].innerText; }

var from = parseDate(cells[3].innerText); if (from.year < earliestYear) { earliestYear = from.year; } article.from = from;

var toText = cells[4].innerText; if (toText.trim() === 'heute') { article.isToPresent = true; } else { var to = parseDate(toText); if (to != null) { article.to = to; } }

if (cells[5].innerText.trim() !== ) { article.imageUrl = cells[5].innerText; }

if (cells[6].innerText.trim() !== ) { article.rank = cells[6].innerText; }

if (cells.length > 7) { article.details = []; for (var k = 7; k < cells.length; k++) { if (k < headerNames.length) { article.details.push({ label: headerNames[k], value: cells[k].innerHTML }); } } }

articles.push(article); } } }

var timelineContainerElement = document.getElementsByClassName('ak-timeline-container')[0]; var timelineWidgetElement = timelineContainerElement.parentElement; var timelineArticleElement = timelineWidgetElement.getElementsByClassName('ak-timeline-article')[0];

var timelineWidth = 800; var mainGridElement = timelineContainerElement.closest('ak-main-grid'); if (mainGridElement) { timelineWidth = mainGridElement.clientWidth - getOuterWidth(timelineArticleElement); }

var zoom = timelineContainerElement.dataset.zoom; if (zoom === ) { zoom = 34; } else { zoom = parseInt(zoom, 10); }

var akTimeline = new Histropedia.Timeline(timelineContainerElement, { width: timelineWidth, height: 500, initialDate: { year: earliestYear - 5, month: 1, day: 1 }, zoom: { initial: zoom }, onArticleClick: function(article) { applyArticleToArticleElement(article.data, timelineArticleElement); timelineWidgetElement.classList.add('ak-timeline-widget_article-focussed'); } }); akTimeline.load(articles); }); </script>

Klicken Sie ein Element an, um hier Details darüber zu lesen oder es verschieben zu können.

Mit dem Mausrad können Sie in der Zeitleiste zoomen, durch Drag&Drop können Sie die Zeitleiste verschieben.

Cookies helfen uns bei der Bereitstellung von Altes Köln. Durch die Nutzung von Altes Köln erklärst du dich damit einverstanden, dass wir Cookies speichern.