This commit is contained in:
2025-12-21 15:12:09 +03:00
parent e149d7380d
commit 865224ba5a
10 changed files with 145 additions and 156 deletions
+18 -30
View File
@@ -20,9 +20,8 @@ function saveOriginalSettings() {
selected_users: getSelectedUsers(),
static_text: document.getElementById('static_text').value,
full_name: document.getElementById('full_name').checked,
start_hour: parseInt(document.getElementById('start_hour').value),
end_hour: parseInt(document.getElementById('end_hour').value),
interval_minutes: parseInt(document.getElementById('interval_minutes').value),
hour: parseInt(document.getElementById('hour').value),
minute: parseInt(document.getElementById('minute').value),
enabled: document.getElementById('scheduler_enabled').checked
};
}
@@ -38,7 +37,7 @@ function setupChangeListeners() {
});
// Поля формы
const formFields = ['static_text', 'start_hour', 'end_hour', 'interval_minutes'];
const formFields = ['static_text', 'hour', 'minute'];
formFields.forEach(field => {
const element = document.getElementById(field);
if (element) {
@@ -58,9 +57,8 @@ function checkForChanges() {
selected_users: getSelectedUsers(),
static_text: document.getElementById('static_text').value,
full_name: document.getElementById('full_name').checked,
start_hour: parseInt(document.getElementById('start_hour').value),
end_hour: parseInt(document.getElementById('end_hour').value),
interval_minutes: parseInt(document.getElementById('interval_minutes').value),
hour: parseInt(document.getElementById('hour').value),
minute: parseInt(document.getElementById('minute').value),
enabled: document.getElementById('scheduler_enabled').checked
};
@@ -194,9 +192,8 @@ async function saveSettings() {
const selectedUsers = getSelectedUsers();
const staticText = document.getElementById('static_text').value.trim();
const fullName = document.getElementById('full_name').checked;
const startHour = parseInt(document.getElementById('start_hour').value);
const endHour = parseInt(document.getElementById('end_hour').value);
const intervalMinutes = parseInt(document.getElementById('interval_minutes').value);
const hour = parseInt(document.getElementById('hour').value);
const minute = parseInt(document.getElementById('minute').value);
const schedulerEnabled = document.getElementById('scheduler_enabled').checked;
// Валидация
@@ -210,23 +207,13 @@ async function saveSettings() {
return;
}
if (startHour < 0 || startHour > 23) {
showAlert('warning', 'Время начала должно быть от 0 до 23 часов');
if (hour < 0 || hour > 23) {
showAlert('warning', 'Час должен быть от 0 до 23 часов');
return;
}
if (endHour < 0 || endHour > 23) {
showAlert('warning', 'Время окончания должно быть от 0 до 23 часов');
return;
}
if (startHour >= endHour) {
showAlert('warning', 'Время начала должно быть раньше времени окончания');
return;
}
if (intervalMinutes < 1 || intervalMinutes > 1440) {
showAlert('warning', 'Интервал должен быть от 1 до 1440 минут');
if (minute < 0 || minute > 59) {
showAlert('warning', 'Минута должна быть от 0 до 59 минут');
return;
}
@@ -248,14 +235,12 @@ async function saveSettings() {
}
// Только измененные данные для schedulerData
if (startHour !== originalSettings.start_hour ||
endHour !== originalSettings.end_hour ||
intervalMinutes !== originalSettings.interval_minutes ||
if (hour !== originalSettings.hour ||
minute !== originalSettings.minute ||
schedulerEnabled !== originalSettings.enabled) {
postData.schedulerData = {
startTime: startHour.toString(),
endTime: endHour.toString(),
interval_minutes: intervalMinutes.toString(),
hour: hour,
minute: minute,
enabled: schedulerEnabled
};
}
@@ -288,6 +273,9 @@ async function saveSettings() {
if (Object.keys(postData.schedulerData).length > 0) {
setTimeout(updateSchedulerStatus, 1000);
}
if (data.next_run_time) {
document.getElementById('nextRunTime').textContent = data.next_run_time;
}
} else {
const error = data.message || 'Ошибка сохранения';
showAlert('danger', error);
+39 -1
View File
@@ -151,4 +151,42 @@ document.getElementById('base_photo_url').addEventListener('focus', function ()
if (!this.value) {
showAlert('info', 'Формат ID фото: photo_id (например: 7236456789)');
}
});
});
function handleLink() {
const link = prompt('Введите ссылку на фотографию:');
if (!link) return;
try {
const url = new URL(link);
const zParam = url.searchParams.get('z');
if (!zParam || !zParam.startsWith('photo')) {
alert('Некорректная ссылка на фото ВК');
return;
}
const decoded = decodeURIComponent(zParam);
const match = decoded.match(/photo(-?\d+)_(\d+)/);
if (!match) {
alert('Не удалось разобрать ссылку');
return;
}
const groupId = Math.abs(Number(match[1]));
const photoId = Number(match[2]);
const isConfirmed = window.confirm(
`Применить новые данные?\nГруппа: ${groupId}\nID фото: ${photoId}`
);
if (isConfirmed) {
document.getElementById('group_id').value = groupId;
document.getElementById('base_photo_url').value = photoId;
}
} catch (e) {
alert('Ошибка обработки ссылки');
}
}