|
|
第4行: |
第4行: |
| (function() { | | (function() { |
| var hm = document.createElement("script"); | | var hm = document.createElement("script"); |
| hm.src = "https://hm.baidu.com/hm.js?78ca329a3fecd1dcb9111ff260d46658"; | | hm.src = "https://unpkg.com/vis-timeline/standalone/umd/vis-timeline-graph2d.min.js"; |
| var s = document.getElementsByTagName("script")[0]; | | var s = document.getElementsByTagName("script")[0]; |
| s.parentNode.insertBefore(hm, s); | | s.parentNode.insertBefore(hm, s); |
第15行: |
第15行: |
| appendCSS(); | | appendCSS(); |
| // 引入 Vis Timeline 库 | | // 引入 Vis Timeline 库 |
| mw.loader.load("https://unpkg.com/vis-timeline/standalone/umd/vis-timeline-graph2d.min.js");
| |
|
| |
| $(document).ready(function() {
| |
| const container = document.getElementById("visualization");
| |
|
| |
| // 解析项目和日期
| |
| const itemsArray = $("#visualization").data("items").split(";");
| |
| const items = new vis.DataSet(itemsArray.map((item, index) => {
| |
| const [content, start] = item.split(",");
| |
| return { id: index + 1, content: content.trim(), start: start.trim() };
| |
| }));
| |
|
| |
| // Configuration for the Timeline
| |
| const options = {};
| |
|
| |
| // Create a Timeline
| |
| const timeline = new vis.Timeline(container, items, options);
| |
| });
| |