-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
132 lines (117 loc) · 4.63 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.column {
float: left;
width: 50%;
padding: 10px;
box-sizing: border-box;
}
.row::after {
content: "";
clear: both;
display: table;
}
</style>
</head>
<body>
<div class="row" id="login">
</div>
</div>
<div class="row">
<div class="column">
<section>
<h2>Arithmetic</h2>
<input id="operand1">
<br></br>
<button onclick="add()">+</button>
<button onclick="subtract()">-</button>
<button onclick="multiply()">*</button>
<button onclick="divide()">/</button>
<br></br>
<input id="operand2">
<label>=</label>
<label id="sum"></label>
</section>
</div>
<div class="column">
<section>
<h2>Prime check</h2>
<label>Number to test:</label>
<input id="numberToTest" />
<button onclick="isPrime()">Check</button>
<label id="primeCheckResult"></label>
</section>
</div>
<div class="column">
<section>
<h2>Caesar cipher</h2>
<label>Text:</label>
<input id="plain_text" />
<button onclick="cipher()">Cipher</button>
<label id="Cipher"></label>
</section>
</div>
</div>
<script src="configuration.js"></script>
<script>
let hosts = configuration.hosts;
displayLogin();
async function add() {
const operand1Input = document.getElementById("operand1");
const operand2Input = document.getElementById("operand2");
let n = operand1Input.value;
let m = operand2Input.value;
const response = await fetch("https://arithmetic-service-abankhele.onrender.com/add/" + n + "/" + m);
const result = await response.json();
document.getElementById("result").innerText = result;
}
async function subtract() {
const operand1Input = document.getElementById("operand1");
const operand2Input = document.getElementById("operand2");
let n = operand1Input.value;
let m = operand2Input.value;
const response = await fetch("https://arithmetic-service-abankhele.onrender.com/subtract/" + n + "/" + m);
const result = await response.json();
document.getElementById("result").innerText = result;
}
async function multiply() {
const operand1Input = document.getElementById("operand1");
const operand2Input = document.getElementById("operand2");
let n = operand1Input.value;
let m = operand2Input.value;
const response = await fetch("https://arithmetic-service-abankhele.onrender.com/multiply/" + n + "/" + m);
const result = await response.json();
document.getElementById("result").innerText = result;
}
async function divide() {
const operand1Input = document.getElementById("operand1");
const operand2Input = document.getElementById("operand2");
let n = operand1Input.value;
let m = operand2Input.value;
const response = await fetch("https://arithmetic-service-abankhele.onrender.com/divide/" + n + "/" + m);
const result = await response.json();
document.getElementById("result").innerText = result;
}
async function cipher() {
const numberToTest = document.getElementById("plain_text");
let n = numberToTest.value;
const response = await fetch("https://ciphers-service-abankhele.onrender.com/caesar" + "/" + 2);
const result = await response.json();
document.getElementById("cipher").innerText = result;
}
async function isPrime() {
const umberToTest = document.getElementById("numberToTest");
let n = numberToTest.value;
const headers = { 'Authorization': 'Bearer ${configuration.token}' };
const response = await fetch('${hosts.primes_service}/primes/${n}', { headers });
const result = await response.json();
document.getElementById("primeCheckResult").innerText = result;
}
</script>
</body>
</html>