DmitrMakeev commited on
Commit
42c7dd6
·
verified ·
1 Parent(s): a64fb39

Update pages_gen.html

Browse files
Files changed (1) hide show
  1. pages_gen.html +47 -125
pages_gen.html CHANGED
@@ -1,140 +1,62 @@
1
  <!DOCTYPE html>
2
- <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Form Viewer</title>
7
  </head>
8
  <body>
9
- <div id="form-container"></div>
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  <script>
12
- // Пример JSON-файла
13
- const formJson = {
14
- "components": [
15
- {
16
- "text": "# File an Invoice\n\nAdd your invoice details below.",
17
- "type": "text",
18
- "id": "Field_1na090z",
19
- "layout": {
20
- "row": "Row_0lmsy15"
21
- }
22
- },
23
- {
24
- "label": "Image view",
25
- "type": "image",
26
- "layout": {
27
- "row": "Row_1ju954r",
28
- "columns": null
29
- },
30
- "id": "Field_0kfhe9d",
31
- "source": "https://i.ibb.co/NrZMfsR/105.png"
32
- },
33
- {
34
- "key": "creditor",
35
- "label": "Creditor",
36
- "type": "textfield",
37
- "validate": {
38
- "required": true
39
- },
40
- "id": "Field_12chft0",
41
- "layout": {
42
- "row": "Row_1rvpcsw"
43
- }
44
- },
45
- {
46
- "description": "An invoice number in the format: C-123.",
47
- "key": "invoiceNumber",
48
- "label": "Invoice Number",
49
- "type": "textfield",
50
- "validate": {
51
- "pattern": "^C-[0-9]+$"
52
- },
53
- "id": "Field_0jcge34",
54
- "layout": {
55
- "row": "Row_0960rdj"
56
- }
57
- },
58
- {
59
- "values": [
60
- {
61
- "label": "Value",
62
- "value": "value"
63
- }
64
- ],
65
- "label": "Tag list",
66
- "type": "taglist",
67
- "layout": {
68
- "row": "Row_1szoxy7",
69
- "columns": null
70
- },
71
- "id": "Field_0mea1nt",
72
- "key": "taglist_30y47"
73
- },
74
- {
75
- "values": [
76
- {
77
- "label": "Value",
78
- "value": "value"
79
- }
80
- ],
81
- "label": "Checkbox group",
82
- "type": "checklist",
83
- "layout": {
84
- "row": "Row_1szoxy7",
85
- "columns": null
86
- },
87
- "id": "Field_0u7r33p",
88
- "key": "checklist_vyc3y"
89
- },
90
- {
91
- "action": "submit",
92
- "key": "submit",
93
- "label": "Submit",
94
- "type": "button",
95
- "id": "Field_0ie528a",
96
- "layout": {
97
- "row": "Row_1szoxy7"
98
- }
99
- }
100
- ],
101
- "schemaVersion": 16,
102
- "exporter": {
103
- "name": "form-js (https://demo.bpmn.io)",
104
- "version": "1.8.3"
105
- },
106
- "type": "default",
107
- "id": "Form_020yixm"
108
- };
109
 
110
- // Функция для генерации HTML-формы
111
- function generateForm(formData) {
112
- const container = document.getElementById('form-container');
113
- formData.components.forEach(component => {
114
- const element = document.createElement('div');
115
- element.id = component.id;
116
 
117
- if (component.type === 'text') {
118
- element.innerHTML = `<p>${component.text}</p>`;
119
- } else if (component.type === 'textfield') {
120
- element.innerHTML = `<label for="${component.key}">${component.label}</label>
121
- <input type="text" id="${component.key}" name="${component.key}" ${component.validate.required ? 'required' : ''}>`;
122
- } else if (component.type === 'checklist') {
123
- element.innerHTML = `<label>${component.label}</label>`;
124
- component.values.forEach(value => {
125
- element.innerHTML += `<input type="checkbox" id="${value.value}" name="${value.value}" value="${value.value}">
126
- <label for="${value.value}">${value.label}</label>`;
127
- });
128
- } else if (component.type === 'button') {
129
- element.innerHTML = `<button type="button" id="${component.key}">${component.label}</button>`;
130
- }
131
 
132
- container.appendChild(element);
133
- });
134
- }
135
 
136
- // Генерация формы
137
- generateForm(formJson);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  </script>
139
  </body>
140
  </html>
 
1
  <!DOCTYPE html>
2
+ <html lang="ru">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Получение информации о группе</title>
7
  </head>
8
  <body>
9
+ <h1>Получение информации о группе</h1>
10
+ <form id="groupForm">
11
+ <label for="groupId">Идентификатор группы:</label>
12
+ <input type="text" id="groupId" name="groupId" required>
13
+ <br>
14
+ <label for="groupName">Название группы (опционально):</label>
15
+ <input type="text" id="groupName" name="groupName">
16
+ <br>
17
+ <button type="submit">Получить информацию о группе</button>
18
+ </form>
19
+ <div id="result"></div>
20
+
21
 
22
  <script>
23
+ document.addEventListener('DOMContentLoaded', function() {
24
+ const groupForm = document.getElementById('groupForm');
25
+ const resultDiv = document.getElementById('result');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ groupForm.addEventListener('submit', function(event) {
28
+ event.preventDefault();
 
 
 
 
29
 
30
+ const groupId = document.getElementById('groupId').value;
31
+ const groupName = document.getElementById('groupName').value;
32
+ const apiToken = 'YOUR_API_TOKEN'; // Ваш API токен
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ const url = `https://api.notisend.ru/v1/email/lists/${groupId}`;
 
 
35
 
36
+ fetch(url, {
37
+ method: 'GET',
38
+ headers: {
39
+ 'Content-Type': 'application/json',
40
+ 'Authorization': `Bearer ${apiToken}`
41
+ }
42
+ })
43
+ .then(response => {
44
+ if (!response.ok) {
45
+ throw new Error('Network response was not ok ' + response.statusText);
46
+ }
47
+ return response.json();
48
+ })
49
+ .then(data => {
50
+ resultDiv.innerHTML = `
51
+ <p><strong>Идентификатор группы:</strong> ${data.id}</p>
52
+ <p><strong>Название группы:</strong> ${data.title}</p>
53
+ `;
54
+ })
55
+ .catch(error => {
56
+ resultDiv.innerHTML = `<p style="color: red;">Ошибка: ${error.message}</p>`;
57
+ });
58
+ });
59
+ });
60
  </script>
61
  </body>
62
  </html>