Update up_gr.html
Browse files- up_gr.html +40 -30
    	
        up_gr.html
    CHANGED
    
    | @@ -34,7 +34,7 @@ | |
| 34 | 
             
                    #fileInput {
         | 
| 35 | 
             
                        margin-top: 20px;
         | 
| 36 | 
             
                    }
         | 
| 37 | 
            -
                     | 
| 38 | 
             
                        color: white;
         | 
| 39 | 
             
                        background-color: #4CAF50;
         | 
| 40 | 
             
                        border: none;
         | 
| @@ -44,21 +44,22 @@ | |
| 44 | 
             
                        border-radius: 5px;
         | 
| 45 | 
             
                        margin-top: 20px;
         | 
| 46 | 
             
                    }
         | 
| 47 | 
            -
                     | 
| 48 | 
             
                        background-color: #388E3C;
         | 
| 49 | 
             
                    }
         | 
| 50 | 
             
                    .group-id-container {
         | 
| 51 | 
             
                        margin-top: 20px;
         | 
| 52 | 
             
                    }
         | 
| 53 | 
             
                    .group-id {
         | 
| 54 | 
            -
                         | 
| 55 | 
            -
                        padding: 10px;
         | 
| 56 | 
            -
                        background-color: #fff;
         | 
| 57 | 
            -
                        border: 1px solid #ccc;
         | 
| 58 | 
            -
                        border-radius: 5px;
         | 
| 59 | 
             
                        cursor: pointer;
         | 
|  | |
|  | |
|  | |
|  | |
| 60 | 
             
                    }
         | 
| 61 | 
             
                </style>
         | 
|  | |
| 62 | 
             
            </head>
         | 
| 63 | 
             
            <body>
         | 
| 64 | 
             
                <h1>Create Group with Members</h1>
         | 
| @@ -67,7 +68,7 @@ | |
| 67 | 
             
                    <input type="text" id="groupNameInput" placeholder="Enter group name">
         | 
| 68 | 
             
                </div>
         | 
| 69 | 
             
                <input type="file" id="fileInput" accept=".txt">
         | 
| 70 | 
            -
                <button id="createGroupButton">Create Group</button>
         | 
| 71 | 
             
                <div class="group-id-container">
         | 
| 72 | 
             
                    <span class="group-id" id="groupIdToCopy" onclick="copyToClipboard(this)">Click here to copy the group ID</span>
         | 
| 73 | 
             
                </div>
         | 
| @@ -80,30 +81,26 @@ | |
| 80 | 
             
                        const file = fileInput.files[0];
         | 
| 81 |  | 
| 82 | 
             
                        if (!apiKey || !groupName || !file) {
         | 
| 83 | 
            -
                             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 84 | 
             
                            return;
         | 
| 85 | 
             
                        }
         | 
| 86 |  | 
| 87 | 
             
                        const reader = new FileReader();
         | 
| 88 | 
             
                        reader.onload = async function(event) {
         | 
| 89 | 
             
                            const text = event.target.result;
         | 
| 90 | 
            -
                            const chatIds = text.split('\n')
         | 
| 91 | 
            -
                                                .map(line => line.trim())
         | 
| 92 | 
            -
                                                .filter(line => line && /^\d+$/.test(line))
         | 
| 93 | 
            -
                                                .map(line => line + '@c.us');
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                            if (chatIds.length === 0) {
         | 
| 96 | 
            -
                                alert('The file must contain valid phone numbers.');
         | 
| 97 | 
            -
                                return;
         | 
| 98 | 
            -
                            }
         | 
| 99 |  | 
| 100 | 
             
                            const payload = {
         | 
| 101 | 
             
                                groupName: groupName,
         | 
| 102 | 
             
                                chatIds: chatIds
         | 
| 103 | 
             
                            };
         | 
| 104 |  | 
| 105 | 
            -
                            console.log('Payload:', payload);
         | 
| 106 | 
            -
             | 
| 107 | 
             
                            try {
         | 
| 108 | 
             
                                const url = `https://api.green-api.com/waInstance1101952913/createGroup/${apiKey}`;
         | 
| 109 | 
             
                                const response = await fetch(url, {
         | 
| @@ -114,21 +111,27 @@ | |
| 114 | 
             
                                    body: JSON.stringify(payload)
         | 
| 115 | 
             
                                });
         | 
| 116 |  | 
| 117 | 
            -
                                console.log('Response status:', response.status);
         | 
| 118 | 
            -
             | 
| 119 | 
             
                                if (!response.ok) {
         | 
| 120 | 
            -
                                     | 
| 121 | 
            -
                                    console.error('Error response:', errorText);
         | 
| 122 | 
            -
                                    throw new Error(`HTTP error! status: ${response.status} - ${errorText}`);
         | 
| 123 | 
             
                                }
         | 
| 124 |  | 
| 125 | 
             
                                const data = await response.json();
         | 
| 126 | 
             
                                document.getElementById('groupIdToCopy').innerText = data.chatId;
         | 
| 127 | 
            -
                                 | 
| 128 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 129 | 
             
                            } catch (error) {
         | 
| 130 | 
            -
                                 | 
| 131 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 132 | 
             
                            }
         | 
| 133 | 
             
                        };
         | 
| 134 | 
             
                        reader.readAsText(file);
         | 
| @@ -141,8 +144,15 @@ | |
| 141 | 
             
                        tempInput.select();
         | 
| 142 | 
             
                        document.execCommand('copy');
         | 
| 143 | 
             
                        document.body.removeChild(tempInput);
         | 
| 144 | 
            -
                         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 145 | 
             
                    }
         | 
| 146 | 
             
                </script>
         | 
| 147 | 
             
            </body>
         | 
| 148 | 
             
            </html>
         | 
|  | 
|  | |
| 34 | 
             
                    #fileInput {
         | 
| 35 | 
             
                        margin-top: 20px;
         | 
| 36 | 
             
                    }
         | 
| 37 | 
            +
                    .create-button {
         | 
| 38 | 
             
                        color: white;
         | 
| 39 | 
             
                        background-color: #4CAF50;
         | 
| 40 | 
             
                        border: none;
         | 
|  | |
| 44 | 
             
                        border-radius: 5px;
         | 
| 45 | 
             
                        margin-top: 20px;
         | 
| 46 | 
             
                    }
         | 
| 47 | 
            +
                    .create-button:hover {
         | 
| 48 | 
             
                        background-color: #388E3C;
         | 
| 49 | 
             
                    }
         | 
| 50 | 
             
                    .group-id-container {
         | 
| 51 | 
             
                        margin-top: 20px;
         | 
| 52 | 
             
                    }
         | 
| 53 | 
             
                    .group-id {
         | 
| 54 | 
            +
                        color: #4CAF50;
         | 
|  | |
|  | |
|  | |
|  | |
| 55 | 
             
                        cursor: pointer;
         | 
| 56 | 
            +
                        font-size: 16px;
         | 
| 57 | 
            +
                    }
         | 
| 58 | 
            +
                    .group-id:hover {
         | 
| 59 | 
            +
                        text-decoration: underline;
         | 
| 60 | 
             
                    }
         | 
| 61 | 
             
                </style>
         | 
| 62 | 
            +
                <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
         | 
| 63 | 
             
            </head>
         | 
| 64 | 
             
            <body>
         | 
| 65 | 
             
                <h1>Create Group with Members</h1>
         | 
|  | |
| 68 | 
             
                    <input type="text" id="groupNameInput" placeholder="Enter group name">
         | 
| 69 | 
             
                </div>
         | 
| 70 | 
             
                <input type="file" id="fileInput" accept=".txt">
         | 
| 71 | 
            +
                <button class="create-button" id="createGroupButton">Create Group</button>
         | 
| 72 | 
             
                <div class="group-id-container">
         | 
| 73 | 
             
                    <span class="group-id" id="groupIdToCopy" onclick="copyToClipboard(this)">Click here to copy the group ID</span>
         | 
| 74 | 
             
                </div>
         | 
|  | |
| 81 | 
             
                        const file = fileInput.files[0];
         | 
| 82 |  | 
| 83 | 
             
                        if (!apiKey || !groupName || !file) {
         | 
| 84 | 
            +
                            Toastify({
         | 
| 85 | 
            +
                                text: "Please enter an API key, group name, and select a file.",
         | 
| 86 | 
            +
                                duration: 3000,
         | 
| 87 | 
            +
                                gravity: "top",
         | 
| 88 | 
            +
                                position: "right",
         | 
| 89 | 
            +
                                backgroundColor: "red",
         | 
| 90 | 
            +
                            }).showToast();
         | 
| 91 | 
             
                            return;
         | 
| 92 | 
             
                        }
         | 
| 93 |  | 
| 94 | 
             
                        const reader = new FileReader();
         | 
| 95 | 
             
                        reader.onload = async function(event) {
         | 
| 96 | 
             
                            const text = event.target.result;
         | 
| 97 | 
            +
                            const chatIds = text.split('\n').map(line => line.trim() + '@c.us').filter(line => line);
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 98 |  | 
| 99 | 
             
                            const payload = {
         | 
| 100 | 
             
                                groupName: groupName,
         | 
| 101 | 
             
                                chatIds: chatIds
         | 
| 102 | 
             
                            };
         | 
| 103 |  | 
|  | |
|  | |
| 104 | 
             
                            try {
         | 
| 105 | 
             
                                const url = `https://api.green-api.com/waInstance1101952913/createGroup/${apiKey}`;
         | 
| 106 | 
             
                                const response = await fetch(url, {
         | 
|  | |
| 111 | 
             
                                    body: JSON.stringify(payload)
         | 
| 112 | 
             
                                });
         | 
| 113 |  | 
|  | |
|  | |
| 114 | 
             
                                if (!response.ok) {
         | 
| 115 | 
            +
                                    throw new Error(`HTTP error! status: ${response.status}`);
         | 
|  | |
|  | |
| 116 | 
             
                                }
         | 
| 117 |  | 
| 118 | 
             
                                const data = await response.json();
         | 
| 119 | 
             
                                document.getElementById('groupIdToCopy').innerText = data.chatId;
         | 
| 120 | 
            +
                                Toastify({
         | 
| 121 | 
            +
                                    text: "Group created successfully!",
         | 
| 122 | 
            +
                                    duration: 3000,
         | 
| 123 | 
            +
                                    gravity: "top",
         | 
| 124 | 
            +
                                    position: "right",
         | 
| 125 | 
            +
                                    backgroundColor: "green",
         | 
| 126 | 
            +
                                }).showToast();
         | 
| 127 | 
             
                            } catch (error) {
         | 
| 128 | 
            +
                                Toastify({
         | 
| 129 | 
            +
                                    text: "Error creating group.",
         | 
| 130 | 
            +
                                    duration: 3000,
         | 
| 131 | 
            +
                                    gravity: "top",
         | 
| 132 | 
            +
                                    position: "right",
         | 
| 133 | 
            +
                                    backgroundColor: "red",
         | 
| 134 | 
            +
                                }).showToast();
         | 
| 135 | 
             
                            }
         | 
| 136 | 
             
                        };
         | 
| 137 | 
             
                        reader.readAsText(file);
         | 
|  | |
| 144 | 
             
                        tempInput.select();
         | 
| 145 | 
             
                        document.execCommand('copy');
         | 
| 146 | 
             
                        document.body.removeChild(tempInput);
         | 
| 147 | 
            +
                        Toastify({
         | 
| 148 | 
            +
                            text: "Group ID copied to clipboard!",
         | 
| 149 | 
            +
                            duration: 3000,
         | 
| 150 | 
            +
                            gravity: "top",
         | 
| 151 | 
            +
                            position: "right",
         | 
| 152 | 
            +
                            backgroundColor: "green",
         | 
| 153 | 
            +
                        }).showToast();
         | 
| 154 | 
             
                    }
         | 
| 155 | 
             
                </script>
         | 
| 156 | 
             
            </body>
         | 
| 157 | 
             
            </html>
         | 
| 158 | 
            +
             |