“MediaWiki:Common.js”的版本间的差异
来自Whiteverse Library
跳到导航跳到搜索| 第15行: | 第15行: | ||
} | } | ||
appendTimeline(); | appendTimeline(); | ||
$(document).ready(function() { | |||
// 确保仅在有时间轴的页面中执行 | |||
if ($("#visualization").length) { | |||
const container = document.getElementById("visualization"); | |||
// 解析项目和日期 | |||
const itemsArray = $(container).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); | |||
} | |||
}); | |||
2024年10月24日 (四) 11:30的版本
/* 这里的任何JavaScript将为所有档案员在每次页面载入时加载。 */
function appendCSS(){
var head = document.head || document.getElementsByTagName('head')[0];
head += '<link rel="stylesheet" href="/extensions/Whiteverse/font/stylesheet.css" />';
document.getElementsByTagName('head')[0].innerHTML += head;
}
appendCSS();
// 引入 Vis Timeline 库
function appendTimeline(){
var head = document.head || document.getElementsByTagName('head')[0];
head += '<script src="https://unpkg.com/vis-timeline/standalone/umd/vis-timeline-graph2d.min.js"></script>';
document.getElementsByTagName('head')[0].innerHTML += head;
}
appendTimeline();
$(document).ready(function() {
// 确保仅在有时间轴的页面中执行
if ($("#visualization").length) {
const container = document.getElementById("visualization");
// 解析项目和日期
const itemsArray = $(container).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);
}
});