DmitrMakeev
commited on
Commit
•
e4aa7fc
1
Parent(s):
511f669
Update up_gr.html
Browse files- up_gr.html +3 -30
up_gr.html
CHANGED
@@ -44,18 +44,6 @@
|
|
44 |
.create-button:hover {
|
45 |
background-color: #388E3C;
|
46 |
}
|
47 |
-
.group-id-container {
|
48 |
-
margin-top: 20px;
|
49 |
-
}
|
50 |
-
.group-id {
|
51 |
-
color: #007BFF;
|
52 |
-
text-decoration: none;
|
53 |
-
font-size: 16px;
|
54 |
-
cursor: pointer;
|
55 |
-
}
|
56 |
-
.group-id:hover {
|
57 |
-
text-decoration: underline;
|
58 |
-
}
|
59 |
</style>
|
60 |
</head>
|
61 |
<body>
|
@@ -66,9 +54,6 @@
|
|
66 |
</div>
|
67 |
<input type="file" id="fileInput" accept=".txt">
|
68 |
<button class="create-button" id="createGroupButton">Create Group</button>
|
69 |
-
<div class="group-id-container">
|
70 |
-
<span class="group-id" id="groupIdToCopy" onclick="copyToClipboard(this)">Click here to copy the group ID</span>
|
71 |
-
</div>
|
72 |
|
73 |
<script>
|
74 |
document.getElementById('createGroupButton').addEventListener('click', async function() {
|
@@ -77,7 +62,7 @@
|
|
77 |
const fileInput = document.getElementById('fileInput');
|
78 |
const file = fileInput.files[0];
|
79 |
if (!apiKey || !groupName || !file) {
|
80 |
-
|
81 |
return;
|
82 |
}
|
83 |
const reader = new FileReader();
|
@@ -88,8 +73,6 @@
|
|
88 |
groupName: groupName,
|
89 |
chatIds: chatIds
|
90 |
};
|
91 |
-
console.log('JSON to be sent:', JSON.stringify(payload, null, 2));
|
92 |
-
|
93 |
try {
|
94 |
const response = await fetch('https://api.green-api.com/waInstance1101952913/createGroup/fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92', {
|
95 |
method: 'POST',
|
@@ -103,25 +86,15 @@
|
|
103 |
throw new Error(`HTTP error! status: ${response.status}`);
|
104 |
}
|
105 |
const data = await response.json();
|
106 |
-
|
107 |
-
console.log('Group created successfully!');
|
108 |
console.log('Response JSON:', data);
|
109 |
} catch (error) {
|
110 |
console.error('Error creating group:', error);
|
|
|
111 |
}
|
112 |
};
|
113 |
reader.readAsText(file);
|
114 |
});
|
115 |
-
|
116 |
-
function copyToClipboard(element) {
|
117 |
-
const tempInput = document.createElement('input');
|
118 |
-
document.body.appendChild(tempInput);
|
119 |
-
tempInput.value = element.innerText;
|
120 |
-
tempInput.select();
|
121 |
-
document.execCommand('copy');
|
122 |
-
document.body.removeChild(tempInput);
|
123 |
-
console.log('Group ID copied to clipboard!');
|
124 |
-
}
|
125 |
</script>
|
126 |
</body>
|
127 |
</html>
|
|
|
44 |
.create-button:hover {
|
45 |
background-color: #388E3C;
|
46 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
</style>
|
48 |
</head>
|
49 |
<body>
|
|
|
54 |
</div>
|
55 |
<input type="file" id="fileInput" accept=".txt">
|
56 |
<button class="create-button" id="createGroupButton">Create Group</button>
|
|
|
|
|
|
|
57 |
|
58 |
<script>
|
59 |
document.getElementById('createGroupButton').addEventListener('click', async function() {
|
|
|
62 |
const fileInput = document.getElementById('fileInput');
|
63 |
const file = fileInput.files[0];
|
64 |
if (!apiKey || !groupName || !file) {
|
65 |
+
alert('Please enter an API key, group name, and select a file.');
|
66 |
return;
|
67 |
}
|
68 |
const reader = new FileReader();
|
|
|
73 |
groupName: groupName,
|
74 |
chatIds: chatIds
|
75 |
};
|
|
|
|
|
76 |
try {
|
77 |
const response = await fetch('https://api.green-api.com/waInstance1101952913/createGroup/fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92', {
|
78 |
method: 'POST',
|
|
|
86 |
throw new Error(`HTTP error! status: ${response.status}`);
|
87 |
}
|
88 |
const data = await response.json();
|
89 |
+
alert('Group created successfully!');
|
|
|
90 |
console.log('Response JSON:', data);
|
91 |
} catch (error) {
|
92 |
console.error('Error creating group:', error);
|
93 |
+
alert('Error creating group.');
|
94 |
}
|
95 |
};
|
96 |
reader.readAsText(file);
|
97 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
</script>
|
99 |
</body>
|
100 |
</html>
|