StructV2/demo/demo.html

86 lines
1.9 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DEMO</title>
<style>
* {
padding: 0;
margin: 0;
user-select: none;
}
.container {
width: 100%;
height: 600px;
background-color: #fafafa;
}
</style>
</head>
<body>
<div class="container" id="container"></div>
<button id="btn">change</button>
2021-04-16 07:38:52 +00:00
<button id="btn-next">reLayout</button>
<button id="btn-set">set</button>
<span id="pos"></span>
<script src="./../dist/sv.js"></script>
2021-04-16 07:38:52 +00:00
<script>
const Engine = SV.Engine,
Group = SV.Group,
Bound = SV.Bound,
2021-04-22 13:39:29 +00:00
G6 = SV.G6,
Vector = SV.Vector;
2021-04-16 07:38:52 +00:00
</script>
<script src="./dataStruct/BinaryTree.js"></script>
2021-04-20 11:12:41 +00:00
<script src="./dataStruct/LinkList.js"></script>
2021-04-16 07:38:52 +00:00
<script src="./dataStruct/Array.js"></script>
2021-04-20 11:12:41 +00:00
<script src="./dataStruct/ChainHashTable.js"></script>
<script src="./dataStruct/Stack.js"></script>
<script src="./dataStruct/LinkStack.js"></script>
2021-04-22 13:39:29 +00:00
<script src="./dataStruct/LinkQueue.js"></script>
<script src="./dataStruct/Graph.js"></script>
<script src="./dataStruct/DirectedGraph.js"></script>
<script>
2021-04-22 13:39:29 +00:00
const engines = [BTree, LList, A, CHT, St, LStack, LQueue, G, DG];
2021-04-16 07:38:52 +00:00
2021-04-22 13:39:29 +00:00
let cur = engines[8](document.getElementById('container'));
2021-04-16 07:38:52 +00:00
cur.engine.render(cur.data[0]);
document.getElementById('btn').addEventListener('click', e => {
cur.engine.render(cur.data[1]);
});
document.getElementById('btn-next').addEventListener('click', e => {
cur.engine.reLayout();
});
document.getElementById('btn-set').addEventListener('click', e => {
let els = cur.engine.getElements();
els.map(item => {
item.set('style', { fill: 'red' });
});
});
const container = document.getElementById('container'),
pos = document.getElementById('pos');
container.addEventListener('mousemove', e => {
let x = e.offsetX, y = e.offsetY;
pos.innerHTML = `${x},${y}`;
});
</script>
</body>
</html>