forked from wasbringeich/wasbringeich.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
77 lines (70 loc) · 1.91 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
<html>
<head>
<title>Was bringe ich mit?</title>
</head>
<style>
form {
display: grid;
grid-template-columns: 200px 300px;
column-gap: 10px;
}
form label, input {
width: 200px;
display: block;
margin: 10px;
}
label {
text-align: right;
}
button {
margin: 10px;
}
</style>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
const mitbringenNet = 'https://mitbringen.net/'
let result = '';
const createList = function() {
id = $('input[name="id"]')[0].value;
name = $('input[name="name"]')[0].value;
$.ajax( {
url: mitbringenNet + id,
type: 'GET',
headers: {
'Accept-Language': 'de'
},
success: function(result) {
test = $('<template></template>').append($.parseHTML(result));
rows = test.find('#itemList .row');
items = []
rows.each( function(i, el) {
item = $(this).find('.item div').text();
bringer = $(this).find('.bringer ul li');
amount = undefined;
bringer.each( function(index, element) {
text = $(this).text();
if(text.includes(name)) {
amount = text.slice(name.length);
}
});
if(amount !== undefined) {
$('#list').append('<li>' + item + amount+ '</li>');
}
});
},
error: function(error) {console.log(error) }
})
}
</script>
<form onsubmit="createList();return false;">
<label for="name">Name</label>
<input type="text" name="name" />
<label for="id">Mitbringen.net Pin</label>
<input type="text" name="id" />
<button type="reset" value="Reset">Zurücksetzen</button>
<button type="submit" value="Submit">Erstelle meine Mitbringliste</button>
</form>
<ul id="list"></ul>
</body>
</html>