“MediaWiki:Common.js”的版本间的差异
来自Whiteverse Library
跳到导航跳到搜索第16行: | 第16行: | ||
} | } | ||
appendTimeline(); | appendTimeline(); | ||
document.addEventListener("DOMContentLoaded", function() { | |||
// 获取所有具有指定类的元素 | |||
var containers = document.getElementsByClassName("visualization"); | |||
for (var i = 0; i < containers.length; i++) { | |||
var container = containers[i]; | |||
// 解析项目和日期 | // 解析项目和日期 | ||
var itemsArray = container.getAttribute("data-items").split(";"); | |||
var items = new vis.DataSet(itemsArray.map(function(item, index) { | |||
var parts = item.split(","); | |||
var content = parts[0].trim(); | |||
var start = parts[1].trim(); | |||
return { id: index + 1, content: content, start: start }; | |||
})); | |||
// Configuration for the Timeline | // Configuration for the Timeline | ||
var options = {}; | |||
// Create a Timeline | // Create a Timeline | ||
var timeline = new vis.Timeline(container, items, options); | |||
} | } | ||
}); | }); |
2024年10月24日 (四) 11:47的版本
/* 这里的任何JavaScript将为所有档案员在每次页面载入时加载。 */ function appendCSS() { var link = document.createElement('link'); link.rel = 'stylesheet'; link.href = '/extensions/Whiteverse/font/stylesheet.css'; document.head.appendChild(link); } appendCSS(); // 引入 Vis Timeline 库 function appendTimeline() { var script = document.createElement('script'); script.src = 'https://unpkg.com/vis-timeline@7.7.3/standalone/umd/vis-timeline-graph2d.min.js'; document.head.appendChild(script); } appendTimeline(); document.addEventListener("DOMContentLoaded", function() { // 获取所有具有指定类的元素 var containers = document.getElementsByClassName("visualization"); for (var i = 0; i < containers.length; i++) { var container = containers[i]; // 解析项目和日期 var itemsArray = container.getAttribute("data-items").split(";"); var items = new vis.DataSet(itemsArray.map(function(item, index) { var parts = item.split(","); var content = parts[0].trim(); var start = parts[1].trim(); return { id: index + 1, content: content, start: start }; })); // Configuration for the Timeline var options = {}; // Create a Timeline var timeline = new vis.Timeline(container, items, options); } });