Widget:Zeitleiste: Unterschied zwischen den Versionen
Simon (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung Markierung: 2017-Quelltext-Bearbeitung |
Simon (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung Markierung: 2017-Quelltext-Bearbeitung |
||
Zeile 3: | Zeile 3: | ||
<script type="text/javascript" src="https://cdn.histropedia.com/histropedia-1.2.0.min.js"></script> | <script type="text/javascript" src="https://cdn.histropedia.com/histropedia-1.2.0.min.js"></script> | ||
<script> | <script> | ||
document.addEventListener( | function parseDate(date) { | ||
var timelineContainerElements = document.getElementsByClassName( | 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; | |||
} | |||
} | |||
document.addEventListener('DOMContentLoaded', function(event) { | |||
var timelineContainerElements = document.getElementsByClassName('ak-timeline'); | |||
var akTimeline = new Histropedia.Timeline(timelineContainerElements.item(0), { | var akTimeline = new Histropedia.Timeline(timelineContainerElements.item(0), { | ||
initialDate: { | |||
year: 1820, | |||
month: 1, | |||
day: 1 | |||
}, | |||
onArticleClick: function(article) { | |||
if (article.targetUrl) { | |||
location.href = article.targetUrl; | |||
} | |||
} | |||
}); | |||
var timelineDataTables = document.getElementsByClassName('ak-timeline-datatable'); | |||
var articles = []; | |||
for (var i = 0; i < timelineDataTables.length; i++) { | |||
var dataTable = timelineDataTables.item(i); | |||
var rows = dataTable.querySelectorAll('tbody tr'); | |||
for (var j = 0; j < rows.length; j++) { | |||
var row = rows.item(i); | |||
var cells = rows.children; | |||
if (cells.length) { | |||
if (cells.item(0).tagName.toLowerCase() === 'tr') { | |||
continue; | |||
} | |||
var article = { | |||
id: cells.item(0).innerText | |||
}; | |||
if (cells.item(1).innerText.trim() !== '') { | |||
article.title = cells.item(1).innerText; | |||
} | |||
if (cells.item(2).innerText.trim() !== '') { | |||
article.subtitle = cells.item(2).innerText; | |||
} | |||
var from = parseDate(cells.item(3).innerText); | |||
article.from = from; | |||
var to = parseDate(cells.item(4).innerText); | |||
if (to != null) { | |||
article.to = to; | |||
} | |||
if (cells.item(5).innerText.trim() !== '') { | |||
article.imageUrl = cells.item(5).innerText; | |||
} | |||
if (cells.item(6).innerText.trim() !== '') { | |||
article.rank = cells.item(6).innerText; | |||
} | |||
if (cells.item(7).innerText.trim() !== '') { | |||
article.targetUrl = cells.item(7).innerText; | |||
} | |||
articles.push(article); | |||
} | |||
} | |||
} | |||
akTimeline.load(articles); | |||
}); | }); | ||
</script> | </script> | ||
<div class="ak-timeline"></div> | <div class="ak-timeline"></div> |
Version vom 7. November 2020, 20:21 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> <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; } }
document.addEventListener('DOMContentLoaded', function(event) { var timelineContainerElements = document.getElementsByClassName('ak-timeline'); var akTimeline = new Histropedia.Timeline(timelineContainerElements.item(0), { initialDate: { year: 1820, month: 1, day: 1 }, onArticleClick: function(article) { if (article.targetUrl) { location.href = article.targetUrl; } } });
var timelineDataTables = document.getElementsByClassName('ak-timeline-datatable'); var articles = []; for (var i = 0; i < timelineDataTables.length; i++) { var dataTable = timelineDataTables.item(i); var rows = dataTable.querySelectorAll('tbody tr'); for (var j = 0; j < rows.length; j++) { var row = rows.item(i); var cells = rows.children; if (cells.length) { if (cells.item(0).tagName.toLowerCase() === 'tr') { continue; }
var article = { id: cells.item(0).innerText }; if (cells.item(1).innerText.trim() !== ) { article.title = cells.item(1).innerText; } if (cells.item(2).innerText.trim() !== ) { article.subtitle = cells.item(2).innerText; } var from = parseDate(cells.item(3).innerText); article.from = from; var to = parseDate(cells.item(4).innerText); if (to != null) { article.to = to; } if (cells.item(5).innerText.trim() !== ) { article.imageUrl = cells.item(5).innerText; } if (cells.item(6).innerText.trim() !== ) { article.rank = cells.item(6).innerText; } if (cells.item(7).innerText.trim() !== ) { article.targetUrl = cells.item(7).innerText; } articles.push(article); } } } akTimeline.load(articles); }); </script>