literyzjs-timeline/demo-test.html
2023-10-03 00:04:03 +01:00

173 lines
4.1 KiB
HTML

<!doctype html>
<html lang="en-GB">
<head>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html" charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="keyword" content="" />
<!-- <script src="http://cdn.hiimray.co.uk/8206c600-707c-469e-8d49-a76ae35782af/bootstrap/5.3.0/dist/js/bootstrap.bundle.min.js"></script> -->
<!-- <link href="http://cdn.hiimray.co.uk/8206c600-707c-469e-8d49-a76ae35782af/bootstrap/5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> -->
<script src="bbtimeline.js"></script>
<!-- <script src="bbtimeline.min.js"></script> -->
<title></title>
</head>
<body>
<canvas id="myCanvas"></canvas>
<p>
<button onclick="Clear()">Clear</button>
<button onclick="LoadDemo()">Load Demo Events</button>
<button onclick="ToggleDebug()">Toggle Debug</button>
</p>
<p>
<button onclick="LoadToday()">Show Today</button>
<button onclick="LoadPrevious()">Show Previous Month</button>
<button onclick="LoadNext()">Show Next Month</button>
</p>
<p>
<button onclick="UpdateLabel()">Update Label</button>
<button onclick="UpdateMarker()">Update Marker</button>
<button onclick="DeleteMarker()">Delete Marker</button>
</p>
<p>
<button onclick="GetDisplayedDateRange()">Get Displayed Date Range</button>
<button onclick="FindEvent()">Find Event</button>
<button onclick="FindDatePosition()">Find Date Position</button>
<button onclick="FindVisibleEvents()">Find Visible Events</button>
</p>
<style>
body {
padding: 20px;
}
canvas {
border-style: solid;
border-width: 1px;
border-color: #000000;
width: 100%;
height: 300px;
padding: 0;
margin: 0;
}
</style>
<script>
var timeline1 = new BBTimeline("myCanvas");
timeline1.OnEventClick = function(e) {
// console.log(e);
}
LoadDemo();
LoadToday();
function Clear()
{
timeline1.Clear(true);
}
function LoadDemo()
{
timeline1.AddEvent("2023-10-05", "hello", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-06", "hello", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-06", null, { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-16", "hello", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-06", "hello 2", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-06", null, { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-20", "hello hello hello", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-21", "hello", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-23", "hello", { Title: Math.random(), Description: Math.random() });
timeline1.AddEvent("2023-10-26", "hello", { Title: Math.random(), Description: Math.random() });
LoadToday();
timeline1.Invalidate(false, true);
}
function ToggleDebug()
{
timeline1.Debug = !timeline1.Debug;
timeline1.Invalidate(true, true);
}
function LoadToday()
{
const date = timeline1.DateToString(new Date(), "yyyy-MM-dd");
timeline1.Load(date);
}
function LoadPrevious()
{
timeline1.ShowPrevious();
}
function LoadNext()
{
timeline1.ShowNext();
}
function UpdateLabel()
{
timeline1.UpdateLabel("2023-10-21", "hello world");
}
function UpdateMarker()
{
timeline1.UpdateMarker("2023-10-21", "#E68422", "#FAE7D3");
}
function DeleteMarker()
{
timeline1.DeleteMarker("2023-10-06");
timeline1.Invalidate(false, true);
}
function GetDisplayedDateRange()
{
alert(timeline1.ShowDate + " - " + timeline1.LastDate);
}
function FindEvent()
{
const result = timeline1.FindEvent("2023-10-26");
console.log(result);
alert(JSON.stringify(result));
}
function FindDatePosition()
{
const result = timeline1.FindDatePosition("2023-10-26");
console.log(result);
alert(JSON.stringify(result));
}
function FindVisibleEvents()
{
const result = timeline1.FindVisibleEvents()
console.log(result);
alert(JSON.stringify(result));
}
</script>
</body>
</html>