forked from v01pe/Text2Braille3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
140 lines (114 loc) · 3.82 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html><head>
<script type="text/javascript" src="lightgl.js"></script>
<script type="text/javascript" src="csg.js"></script>
<script type="text/javascript" src="openjscad.js"></script>
<script type="text/javascript" src="braille.jscad" charset="utf-8"></script>
<script type="text/javascript" src="jquery-1.10.1.min.js"></script>
<style>
body {
font: 14px/20px 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif;
max-width: 820px;
margin: 0 auto;
padding: 10px;
}
canvas {
border: 1px solid black;
margin: 0px 8px;
}
pre, code {
font: 12px/20px Monaco, monospace;
border: 1px solid #CCC;
border-radius: 3px;
background: #F9F9F9;
padding: 0 3px;
color: #555;
}
pre {
padding: 10px;
width: 100%;
}
textarea {
font: 12px/20px Monaco, monospace;
padding: 5px 8px;
width: 300px;
height: 100px;
}
td {
vertical-align: top;
}
canvas { cursor: move; }
</style>
<link rel="stylesheet" href="openjscad.css" type="text/css" />
<script>
var gProcessor=null;
var detailsOffset = 4;
var detailsAmount = 7;
// Show all exceptions to the user:
OpenJsCad.AlertUserOfUncaughtExceptions();
function onload()
{
gProcessor = new OpenJsCad.Processor(document.getElementById("viewer"));
jQuery.get('braille.jscad', function(data)
{
gProcessor.setJsCad(data, "braille.jscad");
showDetails(false);
});
adaptControls();
}
function adaptControls()
{
if (gProcessor.viewer != null)
gProcessor.viewer.gl.clearColor(1, 1, 0.97, 1);
$("#viewer .viewer")[0].style.backgroundColor = "white";
$("#viewer .parametersdiv button")[0].onclick = parseParameters;
var moreElement = "<hr/><p><a id='more'></a></p>";
$("#viewer .parametersdiv .parameterstable").after(moreElement);
setLanguage("german");
}
function setLanguage(lang)
{
if (lang == "german")
{
// var $statusBar = $("#viewer .statusdiv");
// $statusBar.children("span")[0].innerHTML = "Fertig."
$("#viewer .parametersdiv button")[0].innerHTML = "3D Modell generieren";
}
}
function showDetails(show)
{
var tableRows = $("#viewer .parametersdiv .parameterstable tr");
for (var i=detailsOffset; i < tableRows.length && i < detailsOffset+detailsAmount; i++)
{
tableRows[i].style.display = (show) ? "table-row" : "none";
}
var moreLink = $("#more")[0];
moreLink.innerHTML = (show) ? "simple Einstellungen" : "Details einstellen";
moreLink.href = "javascript:showDetails(" + !show + ");";
}
function parseParameters()
{
var param_form_size = $("#viewer .parametersdiv .parameterstable tr:eq(4) td:eq(1) input")[0];
param_form_size.value = Math.min(Math.max(param_form_size.value, 0.0), 10.0);
var param_dot_height = $("#viewer .parametersdiv .parameterstable tr:eq(5) td:eq(1) input")[0];
param_dot_height.value = Math.min(Math.max(param_dot_height.value, 0.5), 0.8);
var param_dot_diameter = $("#viewer .parametersdiv .parameterstable tr:eq(6) td:eq(1) input")[0];
param_dot_diameter.value = Math.min(Math.max(param_dot_diameter.value, 1.4), 1.6);
var param_plate_thickness = $("#viewer .parametersdiv .parameterstable tr:eq(7) td:eq(1) input")[0];
param_plate_thickness.value = Math.max(param_plate_thickness.value, 0.0);
var param_resolution = $("#viewer .parametersdiv .parameterstable tr:eq(10) td:eq(1) input")[0];
var isnumber = !isNaN(parseInt(param_resolution.value)) && isFinite(param_resolution.value);
var resolution = (isnumber) ? parseInt(param_resolution.value) : 0;
resolution = Math.min(Math.max(param_resolution.value, 10), 30);
resolution += (resolution % 2);
param_resolution.value = resolution;
gProcessor.rebuildSolid();
}
</script>
<title>Text to 3d printable Braille</title>
</head>
<body onload="onload()">
<h1>Text to 3d printable Braille</h1>
<div id="viewer"></div>
</body>
</html>