-
Notifications
You must be signed in to change notification settings - Fork 0
/
upcoming.php
125 lines (104 loc) · 4.36 KB
/
upcoming.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
<?php
require_once('functions.php');
$current_page = htmlspecialchars("https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", ENT_QUOTES, 'UTF-8');
header('X-Frame-Options: DENY');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('Strict-Transport-Security: max-age=63072000');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#c7ecee">
<link rel="shortcut icon" type="image/x-icon" href="/media/favicon.ico" />
<link rel="icon" type="image/png" sizes="196x196" href="/media/192.png" />
<link rel="apple-touch-icon" href="/media/180.png" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="application-name" content="Cricket" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Cricket" />
<title>Upcoming Live Cricket Matches 🏏</title>
<meta name="description" content="Get Real-time Live Cricket Score Update without refreshing the page.">
<?php $current_page = htmlspecialchars("https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", ENT_QUOTES, 'UTF-8');
echo '<link rel="canonical" href="' . $current_page . '" />';
?>
<meta property="og:site_name" content="Upcoming Live Cricket Matches 🏏">
<meta property="og:type" content="website">
<meta property="og:title" content="Upcoming Live Cricket Matches 🏏">
<meta property="og:description" content="Get Real-time Live Cricket Score Update without refreshing the page.">
<meta property="og:url" content="<?php echo $current_page; ?>">
<meta property="og:image" content="<?php echo getFullUrl() . '/media/random-score.jpg'; ?>">
<meta property="og:image:alt" content="Live Cricket Score 🏏" />
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:title" content="Upcoming Live Cricket Matches 🏏">
<meta name="twitter:description" content="Get Real-time Live Cricket Score Update without refreshing the page.">
<meta name="twitter:url" content="<?php echo $current_page; ?>">
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="<?php echo getFullUrl() . '/media/random-score.jpg'; ?>">
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.4/css/bulma.min.css" integrity="sha512-HqxHUkJM0SYcbvxUw5P60SzdOTy/QVwA1JJrvaXJv4q7lmbDZCmZaqz01UPOaQveoxfYRv1tHozWGPMcuTBuvQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title is-size-5">Upcoming Matches</h1>
<div id="matches-table" class="table-container table-wrapper"></div>
</div>
</section>
<script>
const baseURL = '/api/data.php';
async function fetchMatches() {
try {
const response = await fetch(`${baseURL}`);
if (!response.ok) {
throw new Error('Failed to fetch data');
}
const data = await response.json();
return data;
} catch (error) {
console.error(error);
return [];
}
}
function displayMatches(matches) {
const tableContainer = document.getElementById('matches-table');
tableContainer.innerHTML = '';
const table = document.createElement('table');
table.classList.add('table', 'is-fullwidth');
table.classList.add('table', 'is-hoverable');
table.innerHTML = `
<thead>
<tr>
<th>ID</th>
<th>Match Name</th>
<th>Get Score</th>
</tr>
</thead>
`;
const tbody = document.createElement('tbody');
matches.forEach(match => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${match.id}</td>
<td>${match.title}</td>
<td><a href=/?id=${match.id}>View Score</a></td>
`;
tbody.appendChild(row);
});
table.appendChild(tbody);
tableContainer.appendChild(table);
}
async function fetchAndDisplayMatches() {
const matches = await fetchMatches();
displayMatches(matches);
}
fetchAndDisplayMatches();
</script>
</body>
</html>