-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
80 lines (74 loc) · 2.35 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="Roman to Decimal calculator">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Omar's Roman to Decimal Calculator</title>
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<style>
#container { width: 800px; margin: 50px auto 0; }
#output, #loading { display: none; }
</style>
<body>
<div id="container">
<div class="row">
<h1 class="text-center">Roman to Decimal calculator</h1>
<h5 class="text-center">Ever wanted to know what's the value of a Roman Numeral? This is the perfect place for you!</h5>
<div>
<form class="form-horizontal" id="romanForm">
<div class="form-group">
<label for="number" class="col-lg-4 control-label">Roman numeral</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="number" id="inputRoman" placeholder="MCCCXXXVII">
<br>
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
</div>
<div id="output" class="text-center">
<strong>Computed value is</strong> <span id="spanResult"></span>
</div>
<div id="loading" class="text-center">
Calculating...
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script>
$(function() {
var $output = $('#output'), $loading = $('#loading'), $result = $('#spanResult');
$('#romanForm').on('submit', function(e) {
e.preventDefault();
e.stopPropagation();
$loading.show();
$output.show();
var data = $(this).serialize();
$.ajax('/calculate', {
data: data,
success: function(returned_val) {
if(returned_val.status === 'OK') {
$loading.hide();
$output.show();
$result.html(returned_val.result);
}
else {
alert('Problems with calculation! Oh noes! :(');
$loading.hide();
}
},
type: 'GET',
error: function() {
$loading.hide();
alert('Something wrong happened :( Maybe you typed an incorrect value?');
}
});
return false;
})
});
</script>
</body>
</html>