Update biz_v.html
Browse files- biz_v.html +36 -16
biz_v.html
CHANGED
|
@@ -111,11 +111,19 @@
|
|
| 111 |
},
|
| 112 |
});
|
| 113 |
|
|
|
|
|
|
|
|
|
|
| 114 |
document.getElementById('sendRequestButton').addEventListener('click', function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
const token = document.getElementById('tokenInput').value;
|
| 116 |
const minDate = document.getElementById('dateSelect').value;
|
| 117 |
const type = document.getElementById('typeSelect').value;
|
| 118 |
const url = '/send_request';
|
|
|
|
| 119 |
fetch(url, {
|
| 120 |
method: 'POST',
|
| 121 |
headers: {
|
|
@@ -131,12 +139,16 @@
|
|
| 131 |
.catch(error => {
|
| 132 |
console.error('Error:', error);
|
| 133 |
notyf.error('Error: ' + error.message);
|
|
|
|
|
|
|
|
|
|
| 134 |
});
|
| 135 |
});
|
| 136 |
|
| 137 |
function createDropdown(data) {
|
| 138 |
const container = document.getElementById('dropdown-container');
|
| 139 |
container.innerHTML = ''; // Очистить контейнер перед добавлением нового списка
|
|
|
|
| 140 |
const select = document.createElement('select');
|
| 141 |
select.id = 'dropdown';
|
| 142 |
select.classList.add('form-group');
|
|
@@ -147,24 +159,32 @@
|
|
| 147 |
select.appendChild(option);
|
| 148 |
});
|
| 149 |
container.appendChild(select);
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
});
|
| 167 |
}
|
| 168 |
</script>
|
| 169 |
</body>
|
| 170 |
</html>
|
|
|
|
|
|
| 111 |
},
|
| 112 |
});
|
| 113 |
|
| 114 |
+
let requestButtonClicked = false;
|
| 115 |
+
|
| 116 |
+
// Привязываем обработчики событий только один раз
|
| 117 |
document.getElementById('sendRequestButton').addEventListener('click', function() {
|
| 118 |
+
if (requestButtonClicked) return; // Если уже нажимали, выходим
|
| 119 |
+
|
| 120 |
+
requestButtonClicked = true; // Устанавливаем флаг, что кнопка уже была нажата
|
| 121 |
+
|
| 122 |
const token = document.getElementById('tokenInput').value;
|
| 123 |
const minDate = document.getElementById('dateSelect').value;
|
| 124 |
const type = document.getElementById('typeSelect').value;
|
| 125 |
const url = '/send_request';
|
| 126 |
+
|
| 127 |
fetch(url, {
|
| 128 |
method: 'POST',
|
| 129 |
headers: {
|
|
|
|
| 139 |
.catch(error => {
|
| 140 |
console.error('Error:', error);
|
| 141 |
notyf.error('Error: ' + error.message);
|
| 142 |
+
})
|
| 143 |
+
.finally(() => {
|
| 144 |
+
requestButtonClicked = false; // Сбрасываем флаг после завершения запроса
|
| 145 |
});
|
| 146 |
});
|
| 147 |
|
| 148 |
function createDropdown(data) {
|
| 149 |
const container = document.getElementById('dropdown-container');
|
| 150 |
container.innerHTML = ''; // Очистить контейнер перед добавлением нового списка
|
| 151 |
+
|
| 152 |
const select = document.createElement('select');
|
| 153 |
select.id = 'dropdown';
|
| 154 |
select.classList.add('form-group');
|
|
|
|
| 159 |
select.appendChild(option);
|
| 160 |
});
|
| 161 |
container.appendChild(select);
|
| 162 |
+
|
| 163 |
+
// Привязываем обработчик событий только один раз
|
| 164 |
+
const sendGetRequestButton = document.getElementById('sendGetRequestButton');
|
| 165 |
+
sendGetRequestButton.removeEventListener('click', handleGetRequest); // Удаляем старый обработчик, если есть
|
| 166 |
+
sendGetRequestButton.addEventListener('click', handleGetRequest);
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
function handleGetRequest() {
|
| 170 |
+
const selectedValue = document.getElementById('dropdown').value;
|
| 171 |
+
const token = document.getElementById('tokenInput').value;
|
| 172 |
+
const getUrl = '/send_get_request?token=' + encodeURIComponent(token) + '&webinarId=' + encodeURIComponent(selectedValue);
|
| 173 |
+
|
| 174 |
+
fetch(getUrl, {
|
| 175 |
+
method: 'GET'
|
| 176 |
+
})
|
| 177 |
+
.then(response => response.json())
|
| 178 |
+
.then(data => {
|
| 179 |
+
console.log('GET Response:', data);
|
| 180 |
+
notyf.success('User data saved successfully');
|
| 181 |
+
})
|
| 182 |
+
.catch(error => {
|
| 183 |
+
console.error('Error:', error);
|
| 184 |
+
notyf.error('Error: ' + error.message);
|
| 185 |
});
|
| 186 |
}
|
| 187 |
</script>
|
| 188 |
</body>
|
| 189 |
</html>
|
| 190 |
+
|