-
Notifications
You must be signed in to change notification settings - Fork 10
/
altium_sch.html
50 lines (46 loc) · 1.44 KB
/
altium_sch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<head>
<script type="text/javascript" src="base64_binary.js"></script>
<script type="text/javascript" src="helper_extensions.js"></script>
<script type="text/javascript" src="u8stream.js"></script>
<script type="text/javascript" src="ole.js"></script>
<script type="text/javascript" src="altium_sch_document.js"></script>
<script type="text/javascript" src="altium_sch_renderer.js"></script>
<script type="text/javascript" src="test_schdoc.js"></script>
</head>
<body>
<div><input type="file" id="altium-file"></input></div>
<div><canvas id="canvas" width="1024" height="768"></canvas></div>
<div><pre id="results"></pre></div>
<script type="text/javascript">
renderSchematic(getTestFile());
function readSchematicFile(e)
{
let file = e.target.files[0];
if (!file)
{
return;
}
let reader = new FileReader();
reader.onload = function(e)
{
let contents = e.target.result;
renderSchematic(contents);
};
reader.readAsArrayBuffer(file);
}
document.getElementById('altium-file').addEventListener('change', readSchematicFile, false);
function renderSchematic(data)
{
let canvas = document.getElementById("canvas");
let ole = new OLE(data);
let fhEntry = ole.directory_entries.find((de) => de.name == "FileHeader");
let fhData = fhEntry.read_all();
let altiumDocument = new AltiumDocument(fhData);
window.altiumDocument = altiumDocument;
let renderer = new AltiumSchematicRenderer(canvas, altiumDocument);
renderer.render();
}
</script>
</body>
</html>