-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
135 lines (115 loc) · 6.57 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>screen-to-body calculator</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700,300,400' rel='stylesheet' type='text/css'>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container" style="margin-top: 100px">
<div class="panel panel-default">
<div class="panel-heading">screen-to-body ratio online calculator <span class="pull-right">v.1.0.0</span></div>
<div class="panel-body">
<form action="" class="form-horizontal">
<div class='row'>
<div class="form-group">
<label class="col-sm-2 control-label" for="device_height">Device properties:</label>
<div class="col-sm-2">
<div class="input-group">
<input id="device_height" placeholder="w or h" class="form-control" type="text" value="" />
<div class="input-group-addon">mm.</div>
</div>
</div>
<p class="help-block pull-left">x</p>
<div class="col-sm-2">
<div class="input-group">
<input id="device_width" placeholder="w or h" class="form-control" type="text" value="" />
<div class="input-group-addon">mm.</div>
</div>
</div>
<p class="help-block">порядок ввода высоты/ширины не важен</p>
</div>
</div>
<div class='row'>
<div class="form-group">
<label class="col-sm-2 control-label" for="device_diagonal_inch">Device diagonal:</label>
<div class="col-sm-2">
<div class="input-group">
<input placeholder="diag. inch." id="device_diagonal_inch" class="form-control" type="text" value="" />
<div class="input-group-addon">inch.</div>
</div>
</div>
<p class="help-block pull-left">=</p>
<div class="col-sm-2">
<div class="input-group">
<input placeholder="diag. mm." id="device_diagonal_mm" class="form-control" type="text" value="" disabled="disabled" />
<div class="input-group-addon">mm.</div>
</div>
</div>
<p class="help-block">1 inch. = 25.4 mm.</p>
</div>
</div>
<div class='row'>
<div class="form-group">
<label class="col-sm-2 control-label" for="screen_height">Screen resolution:</label>
<div class="col-sm-2">
<div class="input-group">
<input id="screen_height" placeholder="w or h" class="form-control" type="text" value="" />
<div class="input-group-addon">px.</div>
</div>
</div>
<p class="help-block pull-left">x</p>
<div class="col-sm-2">
<div class="input-group">
<input id="screen_width" placeholder="w or h" class="form-control" type="text" value="" />
<div class="input-group-addon">px.</div>
</div>
</div>
<p class="help-block">порядок ввода высоты/ширины не важен</p>
</div>
</div>
<div class='row'>
<div class="form-group">
<label class="col-sm-2 control-label" for="result">RESULT (ratio):</label>
<div class="col-sm-2">
<div class="input-group">
<input id="result" placeholder="ratio" class="form-control" type="text" value="" />
<div class="input-group-addon">%</div>
</div>
</div>
<p class="help-block pull-left"> </p>
<div class="col-sm-2">
<button type="button" class="btn btn-primary form-control" onclick="calculate()">Calculate</button>
</div>
<p class="help-block">для тестов: <a target="_blank" href="http://08-08-08.com/2014/02/04/ultimate-screen-to-body-ratio-comparison/">таблица сравнения</a></p>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$('#device_height, #device_width, #device_diagonal_inch, #screen_height, #screen_width').on('keyup paste', function(){
$('#result').val('');
});
function calculate(){
var dev_height = parseFloat($('#device_height').val());
var dev_width = parseFloat($('#device_width').val());
var dev_diagonal = parseFloat($('#device_diagonal_inch').val())*25.4;
$('#device_diagonal_mm').val(dev_diagonal.toFixed(2));
var screen_height = parseFloat($('#screen_height').val());
var screen_width = parseFloat($('#screen_width').val());
var ratio = screen_width/screen_height;
var dev_area = dev_height*dev_width;
var screen_area = dev_diagonal*dev_diagonal*ratio / (1+ratio*ratio);
var result = screen_area/dev_area*100;
$('#result').val(result.toFixed(2));
}
</script>
</body>
</html>