-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·51 lines (46 loc) · 1.95 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<title>Query Builder</title>
</head>
<body>
<div class="container">
<p id="result" style="margin-top:2%"></p>
<div class="col-md-4 form-group">
<label for="mandatory">Mandatory</label>
<textarea class="form-control" name="mandatory" id="mandatory" rows="10"></textarea>
</div>
<div class="col-md-4 form-group">
<label for="regular">Regular</label>
<textarea class="form-control col-md-4" name="regular" id="regular" rows="10"></textarea>
</div>
<div class="col-md-4 form-group">
<label for="optional">Optional</label>
<textarea class="form-control col-md-4" name="optional" id="optional" rows="10"></textarea>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
const mandatory = $('#mandatory');
const regular = $('#regular');
const optional = $('#optional');
const htmlRes = $('#result');
const updateResult = () => {
const mandatoryJoined = mandatory.val().split(',').map(e => e.trim()).join(' ');
const results = regular.val().split(',').map((regEl) => {
const partial = optional.val().split(',').map(optEl => `${mandatoryJoined.trim()} ${regEl.trim()} ${optEl.trim()}`);
return partial.join(' or ');
});
if (results.length > 1) htmlRes.html('<b>Result:</b> ' + results.join(' or '));
}
mandatory.keyup(() => updateResult());
regular.keyup(() => updateResult());
optional.keyup(() => updateResult());
</script>
</body>
</html>