CoolFace
Apppublic

eg-art/up_fail2

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
settings.html191 linesDownload Raw Back to root
1<!DOCTYPE html>2<html lang="en">3<head>4    <meta charset="UTF-8">5    <title>Settings</title>6    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">7    <style>8        body {9            font-family: Arial, sans-serif;10            background-color: #f0f0f0;11            margin: 0;12            padding: 0;13        }14        h1 {15            background-color: #4CAF50;16            color: white;17            padding: 20px;18            margin: 0;19            border-bottom: 2px solid #388E3C;20            text-align: left;21        }22        form {23            padding: 20px;24        }25        label {26            display: block;27            margin-top: 10px;28            color: #4CAF50;29            text-align: left;30        }31        input[type="text"] {32            width: 100%;33            padding: 10px;34            margin-top: 5px;35            border: 1px solid #ccc;36            border-radius: 4px;37        }38        button {39            padding: 10px 20px;40            border: none;41            border-radius: 4px;42            cursor: pointer;43            margin-top: 20px;44        }45        button.save {46            background-color: #4CAF50;47            color: white;48        }49        button.refresh {50            background-color: #FFA500;51            color: white;52            margin-left: 10px;53        }54        button:hover {55            opacity: 0.8;56        }57        .orange-text {58        color: #FFA500;59        }60    </style>61</head>62<body>63 64    <form id="settingsForm">65        <label for="api_key_sys"><span class="orange-text">api_key_sys (Выдаётся администрацией сервиса):</span></label>66        <input type="text" id="api_key_sys" name="api_key_sys" onblur="saveApiKeySys()"><br><br>67 68        <label for="api_key_auth">api_key_auth (Ключ проверки подлинности запросов):</label>69        <input type="text" id="api_key_auth" name="api_key_auth"><br><br>70 71        <label for="api_key_apps_vk">apps_key (Объект, где ключ — это id приложения vk-mini-apps, а значение — защищённый ключ приложения vk-mini-apps.):</label>72        <input type="text" id="api_key_apps_vk" name="api_key_apps_vk"><br><br>73 74        <label for="vk_api_key">vk_api_key (Ключ ВК сообщества):</label>75        <input type="text" id="vk_api_key" name="vk_api_key"><br><br>76 77        <label for="vk_st_alone">vk_st_alone (Ключ ВК vk_st_alone):</label>78        <input type="text" id="vk_st_alone" name="vk_st_alone"><br><br>79 80        <label for="key_callback_vk">key_callback_vk (Ключ ВК key_callback_vk):</label>81        <input type="text" id="key_callback_vk" name="key_callback_vk"><br><br>      82 83        <label for="senler_token">senler_token (Ключ проверки подлинности запросов к API Сенлер):</label>84        <input type="text" id="senler_token" name="senler_token"><br><br>85 86        <label for="wa_ak">wa_ak (id инстанса WhatsApp):</label>87        <input type="text" id="wa_ak" name="wa_ak"><br><br>88 89        <label for="wa_api_key">wa_api_key (Ключ проверки подлинности запросов к API WhatsApp):</label>90        <input type="text" id="wa_api_key" name="wa_api_key"><br><br>91 92        <label for="curators">curators (Список email кураторов):</label>93        <input type="text" id="curators" name="curators"><br><br>94 95        <label for="call_api_key">call_api_key (Ключ проверки подлинности запросов к API Звонобот):</label>96        <input type="text" id="call_api_key" name="call_api_key"><br><br>97 98        <button type="button" class="save" onclick="saveSettings()">Сохранить данные</button>99        <button type="button" class="refresh" onclick="refreshSettings()">Обновить данные</button>100    </form>101 102    <script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>103    <script>104        function loadSettings() {105            // Загружаем ключ из локального хранилища106            const apiKeySys = localStorage.getItem('api_key_sys');107            if (apiKeySys) {108                document.getElementById('api_key_sys').value = apiKeySys;109            }110            fetch('/load_settings', {111                method: 'POST',112                headers: {113                    'Content-Type': 'application/json'114                },115                body: JSON.stringify({ action: 'load', api_key_sys: apiKeySys })116            })117            .then(response => response.json())118            .then(data => {119                document.getElementById('api_key_auth').value = data.api_key_auth;120                document.getElementById('api_key_apps_vk').value = data.api_key_apps_vk; 121                document.getElementById('vk_api_key').value = data.vk_api_key;  122                document.getElementById('vk_st_alone').value = data.vk_st_alone; 123                document.getElementById('key_callback_vk').value = data.key_callback_vk;              124                document.getElementById('senler_token').value = data.senler_token;125                document.getElementById('wa_ak').value = data.wa_ak;126                document.getElementById('wa_api_key').value = data.wa_api_key;127                document.getElementById('curators').value = data.curators; 128                document.getElementById('call_api_key').value = data.call_api_key;                129            })130            .catch(error => console.error('Error:', error));131        }132 133        function saveSettings() {134            const form = document.getElementById('settingsForm');135            const formData = new FormData(form);136            const data = {};137            formData.forEach((value, key) => {138                if (value !== '') {139                    data[key] = value;140                }141            });142            fetch('/save_settings', {143                method: 'POST',144                headers: {145                    'Content-Type': 'application/json'146                },147                body: JSON.stringify({ action: 'save', data: data, api_key_sys: data.api_key_sys })148            })149            .then(response => response.json())150            .then(data => {151                console.log('Success:', data);152                Toastify({153                    text: "Данные сохранены",154                    duration: 3000,155                    gravity: "top",156                    position: "right",157                    backgroundColor: "#4CAF50",158                }).showToast();159            })160            .catch(error => {161                console.error('Error:', error);162                Toastify({163                    text: "Ошибка при сохранении данных",164                    duration: 3000,165                    gravity: "top",166                    position: "right",167                    backgroundColor: "#FF0000",168                }).showToast();169            });170        }171 172        function refreshSettings() {173            loadSettings();174            Toastify({175                text: "Данные обновлены",176                duration: 3000,177                gravity: "top",178                position: "right",179                backgroundColor: "#FFA500",180            }).showToast();181        }182 183        function saveApiKeySys() {184            const apiKeySys = document.getElementById('api_key_sys').value;185            localStorage.setItem('api_key_sys', apiKeySys);186        }187 188        window.onload = loadSettings;189    </script>190</body>191</html>