StructV2/demo/demo.html

138 lines
2.7 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%;
2021-05-17 06:02:19 +00:00
height: 400px;
background-color: #fafafa;
border: 1px solid #ccc;
}
.down {
display: flex;
margin-top: 20px;
}
#freed {
width: 200px;
height: 300px;
border: 1px solid #ccc;
background-color: #fafafa;
margin-right: 30px;
}
#leak {
width: 400px;
height: 300px;
border: 1px solid #ccc;
background-color: #fafafa;
}
</style>
</head>
<body>
2021-05-17 06:02:19 +00:00
<div class="container" id="container"></div>
2021-05-17 06:02:19 +00:00
<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>
2021-05-17 06:02:19 +00:00
<div class="down">
<div id="freed"></div>
<div id="leak"></div>
</div>
<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-05-17 06:02:19 +00:00
2021-04-20 11:12:41 +00:00
<script src="./dataStruct/LinkList.js"></script>
2021-05-17 06:02:19 +00:00
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>
2021-04-24 12:48:54 +00:00
<script src="./dataStruct/RingArray.js"></script>
2021-05-17 06:02:19 +00:00
<script src="./dataStruct/GeneralizedList.js"></script>
<script>
2021-05-17 06:02:19 +00:00
const engines = {
0: BTree,
1: LList,
2: A,
3: CHT,
4: St,
5: LStack,
6: LQueue,
7: G,
8: DG,
9: RA,
10: GL
};
let dataCounter = 0;
let cur = engines[3](document.getElementById('container'), {
freedContainer: document.getElementById('freed'),
leakContainer: document.getElementById('leak')
});
2021-04-16 07:38:52 +00:00
2021-05-17 06:02:19 +00:00
cur.engine.render(cur.data[dataCounter]);
2021-04-16 07:38:52 +00:00
document.getElementById('btn').addEventListener('click', e => {
2021-05-17 06:02:19 +00:00
cur.engine.render(cur.data[++dataCounter]);
2021-04-16 07:38:52 +00:00
});
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}`;
});
2021-05-17 06:02:19 +00:00
</script>
</body>
</html>