diff --git a/telegram-poll-api/css/style.css b/telegram-poll-api/css/style.css deleted file mode 100644 index 2702860..0000000 --- a/telegram-poll-api/css/style.css +++ /dev/null @@ -1,34 +0,0 @@ -* { - margin: 0; - padding: 0; - outline: none; - box-sizing: border-box; -} -body { - font-family: Arial, sans-serif; - background-color: #0d496f; - color: #ffbf6b; - padding: 40px; - font-size: 20px; -} -.container { - max-width: 1000px; - margin: 0 auto; - display: flex; - gap: 24px; - flex-direction: column; -} -#result { - background-color: #647176; - border-radius: 4px; - padding: 24px; -} -.btn { - border: 2px solid #647176; - background-color: #ffbf6b; - color: #0d496f; - padding: 10px 20px; - border-radius: 4px; - font-size: 20px; - cursor: pointer; -} \ No newline at end of file diff --git a/telegram-poll-api/favicon.ico b/telegram-poll-api/favicon.ico deleted file mode 100644 index b6143eb..0000000 Binary files a/telegram-poll-api/favicon.ico and /dev/null differ diff --git a/telegram-poll-api/index.html b/telegram-poll-api/index.html deleted file mode 100644 index 8a5689c..0000000 --- a/telegram-poll-api/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - Telegram poll api - - - - - - - - - - - - - - - - - - - - -
-

Telegram votes API

- -
-
- - - diff --git a/telegram-poll-api/js/script.js b/telegram-poll-api/js/script.js deleted file mode 100644 index 5e32765..0000000 --- a/telegram-poll-api/js/script.js +++ /dev/null @@ -1,40 +0,0 @@ -const startBtn = document.querySelector('#start'); -const resultBox = document.querySelector('#result'); -startBtn.addEventListener('click', startApp); - -const token = '6984190497:AAFivyswRSE2zT8bK_AL7RYf_znndhov7tA'; -const firstPost = '800520411' // update_id of the first post -const postsQuantity = '1' - -function startApp(){ - // fetch(`https://api.telegram.org/bot${token}/getUpdates?offset=${firstPost}&limit=${postsQuantity}`) - fetch(`https://api.telegram.org/bot${token}/getUpdates`) - .then((response) => response.json()) - .then((data) => { - console.log('Fetch data:',data); - console.log('Fetch data:',data.result[0].message.poll); - renderPoll(data.result[0].message.poll); - }) - } - -async function renderPoll(pollData){ - const newPoll = document.createElement('div'); - newPoll.classList.add('poll'); - const pollTitle = createHtmlNode('h1', pollData.question); - newPoll.appendChild(pollTitle); - resultBox.appendChild(newPoll); - - - const pollOptions = document.createElement('ul'); - pollData.options.map((option) => { - const optionNode = createHtmlNode('li', `${option.text}: ${option.voter_count}`) - pollOptions.appendChild(optionNode); - }); - resultBox.appendChild(pollOptions); -} - -function createHtmlNode(tag, content){ - const node = document.createElement(tag); - node.innerText = content; - return node; -} \ No newline at end of file