-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
168 lines (137 loc) · 3.65 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
var chkZ;
function calc()
{
// Eingaben
var imgw = parseFloat(document.getElementById('inp_width').value.replace(/\,/g, "."));
var imgh = parseFloat(document.getElementById('inp_height').value.replace(/\,/g, "."));
var sdpi = parseFloat(document.getElementById('inp_dpi').value.replace(/\,/g, "."));
var type = document.getElementById('convert_type').value;
// Eingabencheck
checkZahl(imgw,imgh,sdpi);
var width = 0;
var height = 0;
var px_w = 0;
var px_h = 0;
// Berechnung
if (type == "a" && chkZ == 1) // Umwandlung Pixel in cm
{
width = imgw/sdpi*2.54;
height = imgh/sdpi*2.54;
var cm_w = Math.round(width*100) / 100;
var cm_h = Math.round(height*100) / 100;
var result = cm_w + " x " + cm_h + " cm";
printErr("");
print1(result);
}
if (type == "b" && chkZ == 1) // Umwandlung cm in Pixel
{
width = imgw/2.54*sdpi;
height = imgh/2.54*sdpi;
var px_w = Math.ceil(width);
var px_h = Math.ceil(height);
var result = px_w + " x " + px_h + " px"
printErr("");
print1(result);
}
}
function checkZahl(imgw,imgh,sdpi)
{
chkZ = 1;
if (isNaN(imgw) && isNaN(imgh) && isNaN(sdpi))
{
print1("");
printErr("Breite, Höhe und DPI-Wert eingeben!");
chkZ = 0;
return chkZ;
}
if (isNaN(imgw) && isNaN(imgh))
{
printErr("Breite und Höhe eingeben!");
print1("");
chkZ = 0;
return chkZ;
}
if (isNaN(imgw) && isNaN(sdpi))
{
print1("");
printErr("Breite und DPI-Wert eingeben!");
chkZ = 0;
return chkZ;
}
if (isNaN(imgh) && isNaN(sdpi))
{
print1("");
printErr("Höhe und DPI-Wert eingeben!");
chkZ = 0;
return chkZ;
}
if (isNaN(imgw))
{
print1("");
printErr("Breite des Bildes eingeben!");
chkZ = 0;
return chkZ;
}
if (isNaN(imgh))
{
print1("");
printErr("Höhe des Bildes eingeben!");
chkZ = 0;
return chkZ;
}
if (isNaN(sdpi))
{
print1("");
printErr("DPI-Wert des Bildes eingeben!");
chkZ = 0;
return chkZ;
}
}
function loesch() // Löschen
{
window.location.reload();
}
function print1(x) // Ausgabe Ergebnis
{
var ausgabefeld = document.getElementById("output");
ausgabefeld.removeChild(ausgabefeld.lastChild);
ausgabefeld.appendChild(document.createTextNode(x));
}
function printErr(x) // Ausgabe Fehlermeldung
{
var ausgabefeld = document.getElementById("ausgabe_fehler");
ausgabefeld.removeChild(ausgabefeld.lastChild);
ausgabefeld.appendChild(document.createTextNode(x));
}
</script>
<link href="cm2px.css" rel="stylesheet" type="text/css">
<link href="animate.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="actionbar"></div>
<div id="ausgabefeld">
<div id="ausgabefeldtext">
<div id="ausgabe_fehler"> </div>
<div id="output"> </div>
</div>
</div>
<div id="content">
<span class="description">Bildbreite</span>
<input type="number" id="inp_width" size="6" maxlength="10" onChange="calc()" onKeyUp="calc()" />
<span class="description">Bildhöhe</span>
<input type="number" id="inp_height" size="6" maxlength="10" onChange="calc()" onKeyUp="calc()" />
<span class="description">Maßeinheit</span>
<select name="convert_type" id="convert_type" onChange="calc()">
<option selected="" value="b">cm</option>
<option value="a">Pixel</option>
</select>
<span class="description">Bildauflösung</span>
<input style="width:85%;float:left;" type="number" id="inp_dpi" value="300" size="6" onChange="calc()" />
<div class="dpi" style="width:15%;float:left;">dpi</div>
</div>
</body></html>