-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
139 lines (128 loc) · 4.42 KB
/
index.php
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
136
137
138
139
<?php
$documents = json_decode(file_get_contents('documents.json'));
?>
<!DOCTYPE html>
<html lang="cs">
<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>Google Tabulky</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%22256%22 height=%22256%22 viewBox=%220 0 100 100%22><text x=%2250%%22 y=%2250%%22 dominant-baseline=%22central%22 text-anchor=%22middle%22 font-size=%2290%22>📜</text></svg>" />
<style>
body {
background-color: #f7f7f7;
color: #333;
font-family: 'Segoe Ui', sans-serif;
font-size: 18px;
padding: 64px;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid #333;
text-align: center;
padding: 8px;
}
button {
background: none;
border: none;
color: #4222db;
cursor: pointer;
font: inherit;
font-weight: 600;
padding: 0;
}
a {
text-decoration: none;
}
v-cloak {
display: none;
}
</style>
<script src="assets/petite-vue.js" defer init></script>
</head>
<body>
<table>
<tbody>
<?php foreach ($documents as $doc) : ?>
<?php if ($doc->active) : ?>
<tr>
<td>
<strong>
<?= $doc->title ?>
</strong>
<a href="https://docs.google.com/spreadsheets/d/<?= $doc->id ?>" target="_blank">
📝
</a>
</td>
<td>
[<?= $doc->shortcode ?>]
</td>
<td>
<button type="button" name="<?= $doc->id ?>">
Vygenerovat
</button>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<div v-scope="{ show: false }">
<button @click="show = !show" type="button" style="margin: 1.2em 0;">
Starší
</button>
<table v-if="show" v-cloak>
<tbody>
<?php foreach ($documents as $doc) : ?>
<?php if (!$doc->active) : ?>
<tr>
<td>
<strong>
<?= $doc->title ?>
</strong>
<a href="https://docs.google.com/spreadsheets/d/<?= $doc->id ?>" target="_blank">
📝
</a>
</td>
<td>
[<?= $doc->shortcode ?>]
</td>
<td>
<button @click="generateData($el)" type="button" name="<?= $doc->id ?>">
Vygenerovat
</button>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script>
window.generateData = (element) => {
fetch('generate.php?id=' + element.getAttribute('name'))
.then((response) => {
if (response.ok) {
return response.text();
}
throw new Error('Něco se pokazilo');
})
.then(() => {
alert('Vygenerováno!');
})
.catch((error) => {
alert(error)
console.error('There has been a problem with your fetch operation:', error);
});
}
document.querySelectorAll('button[name]').forEach(button => {
button.addEventListener('click', event => {
generateData(event.target);
})
})
</script>
</body>
</html>