File size: 5,181 Bytes
7bf3754 1b02027 ca0590b 1b02027 ca0590b 1b02027 7bf3754 ca0590b 7bf3754 3faf523 7bf3754 09aff32 7bf3754 1b02027 09aff32 aaaf846 7a65e40 aaaf846 1b02027 aaaf846 1b02027 aaaf846 9a6fd85 aaaf846 541e943 aaaf846 541e943 aaaf846 1b02027 7bf3754 |
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 140 141 142 143 144 145 |
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Получение информации о группе</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
h1 {
background-color: #4CAF50;
color: white;
padding: 20px;
margin: 0;
border-bottom: 2px solid #388E3C;
}
.input-row {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 20px;
}
.input-row input, .input-row select {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
button[type="submit"] {
color: white;
background-color: #4CAF50;
border: none;
cursor: pointer;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
margin-top: 20px;
}
button[type="submit"]:hover {
background-color: #388E3C;
}
.result-table {
width: 50%;
margin: 20px auto;
border-collapse: collapse;
}
.result-table th, .result-table td {
border: 1px solid #ddd;
padding: 8px;
}
.result-table th {
background-color: #4CAF50;
color: white;
}
</style>
</head>
<body>
<h1>Получение списка параметров группы</h1>
<form id="groupForm">
<div class="input-row">
<label for="groupId">Идентификатор группы:</label>
<input type="text" id="groupId" name="groupId" required>
</div>
<div class="input-row">
<label for="apiToken">API Токен:</label>
<input type="text" id="apiToken" name="apiToken" required>
</div>
<button type="submit">Получить список параметров группы</button>
</form>
<div id="result"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const groupForm = document.getElementById('groupForm');
const resultDiv = document.getElementById('result');
groupForm.addEventListener('submit', function(event) {
event.preventDefault();
const groupId = document.getElementById('groupId').value;
const apiToken = document.getElementById('apiToken').value;
const url = `https://diamonik7777-up-fail.hf.space/api/group/${groupId}/parameters?apiToken=${apiToken}`;
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
return response.json();
})
.then(data => {
if (data.error) {
resultDiv.innerHTML = `<p style="color: red;">Ошибка: ${data.error}</p>`;
} else {
displayResult(data.collection);
}
})
.catch(error => {
resultDiv.innerHTML = `<p style="color: red;">Ошибка: ${error.message}</p>`;
});
});
function displayResult(collection) {
let list_id = collection[0].list_id;
let phone_id = collection.find(item => item.title === "phone")?.id || "Не найдено";
let name_id = collection.find(item => item.title === "name")?.id || "Не найдено";
let tableHTML = `
<table class="result-table">
<thead>
<tr>
<th>Ключ</th>
<th>Параметр</th>
</tr>
</thead>
<tbody>
<tr>
<td>list_id</td>
<td>${list_id}</td>
</tr>
<tr>
<td>phone_id</td>
<td>${phone_id}</td>
</tr>
<tr>
<td>name_id</td>
<td>${name_id}</td>
</tr>
</tbody>
</table>
`;
resultDiv.innerHTML = tableHTML;
}
});
</script>
</body>
</html> |