From 53ab025a179f05eff412233c62b143af12900723 Mon Sep 17 00:00:00 2001 From: sergeyzharko Date: Tue, 9 Jan 2018 20:19:29 +0300 Subject: [PATCH 1/2] new branch --- 1-ES6/index.html | 11 ------- 1-ES6/key.txt | 1 - 1-ES6/script.js | 82 ------------------------------------------------ 1-ES6/style.css | 27 ---------------- 4 files changed, 121 deletions(-) delete mode 100644 1-ES6/index.html delete mode 100644 1-ES6/key.txt delete mode 100644 1-ES6/script.js delete mode 100644 1-ES6/style.css diff --git a/1-ES6/index.html b/1-ES6/index.html deleted file mode 100644 index e034fc1e..00000000 --- a/1-ES6/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - News API - - - - -
-
- - \ No newline at end of file diff --git a/1-ES6/key.txt b/1-ES6/key.txt deleted file mode 100644 index b140d141..00000000 --- a/1-ES6/key.txt +++ /dev/null @@ -1 +0,0 @@ -f53b56a81c57478689c3058487c41269 \ No newline at end of file diff --git a/1-ES6/script.js b/1-ES6/script.js deleted file mode 100644 index 202101bc..00000000 --- a/1-ES6/script.js +++ /dev/null @@ -1,82 +0,0 @@ -const sources = [ - { - name: 'Google News', - logo: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Google_News_Logo.svg/1200px-Google_News_Logo.svg.png', - link: 'google-news-ru' - }, - { - name: 'BBC News', - logo: 'http://m.files.bbci.co.uk/modules/bbc-morph-news-waf-page-meta/1.2.0/bbc_news_logo.png', - link: 'bbc-news' - }, - { - name: 'РБК', - logo: 'http://www.raketa.com/wp-content/uploads/RBC.jpg', - link: 'rbc' - } -]; - - -var url = 'https://newsapi.org/v2/sources?' + -'apiKey=f53b56a81c57478689c3058487c41269'; - -var req = new Request(url); - -fetch(req) -.then(function(response) { - console.log(response.json()); -}) - - - -function loadSources() { - let buttons = document.querySelector('.buttons'); - - for (let source of sources) { - let button = document.createElement('div'); - button.classList.add('source'); - button.classList.add(source.link); - button.innerHTML = ` - ${source.name} -
`; - button.addEventListener('click', function(){ loadNews(source.link) }); - buttons.appendChild(button); - } -} - -document.addEventListener("DOMContentLoaded", loadSources); - - -function loadNews(link) { - document.querySelectorAll('.source').forEach(function(element, index){ - element.classList.remove('selected'); - }); - - document.querySelector(`.${link}`).classList.add('selected'); - - var url = `https://newsapi.org/v2/top-headlines?sourceS=${link}&apiKey=f53b56a81c57478689c3058487c41269`; - - var req = new Request(url); - - fetch(req) - .then( response => response.json() ) - .then( response => renderNews(response.articles) ) -} - -function renderNews(articles) { - let items = document.querySelector('.news'); - items.innerHTML = ''; - for (let article of articles) { - let dateTime = new Date(article.publishedAt); - let dateTimeRow = `${dateTime.getFullYear()}.${dateTime.getMonth()}.${dateTime.getDay()} ${dateTime.getHours()}:${dateTime.getMinutes()}`; - let item = document.createElement('div'); - - item.setAttribute('class', 'article'); - item.innerHTML = ` -

${article.title}

- -

${article.description}

-

Published: ${dateTimeRow}

`; - items.appendChild(item); - } -} \ No newline at end of file diff --git a/1-ES6/style.css b/1-ES6/style.css deleted file mode 100644 index d14b6774..00000000 --- a/1-ES6/style.css +++ /dev/null @@ -1,27 +0,0 @@ -.source { - cursor: pointer; - width: 150px; - display: inline-block; - margin: 10px; - padding: 10px; -} - -.source-image { - height: 140px; - width: 150px; -} - -.news-image { - height: 200px; -} - -.article { - width: 50%; - margin-top: 20px; - padding: 5px; - border: solid gray 3px; -} - -.selected { - border: solid green 3px; -} \ No newline at end of file From 86a483f4a6104a28efcc74d09b07e418fba896ad Mon Sep 17 00:00:00 2001 From: sergeyzharko Date: Tue, 9 Jan 2018 20:22:18 +0300 Subject: [PATCH 2/2] babel --- 2-Babel/.babelrc => .babelrc | 0 2-Babel/.gitignore | 42 ------------------- 2-Babel/ReadMe.txt => ReadMe.txt | 0 2-Babel/index.html => index.html | 0 2-Babel/key.txt => key.txt | 0 .../nodeListForEach.js => nodeListForEach.js | 0 2-Babel/package.json => package.json | 0 2-Babel/plugin.js => plugin.js | 0 .../script-compiled.js => script-compiled.js | 0 2-Babel/script.js => script.js | 0 2-Babel/style.css => style.css | 0 11 files changed, 42 deletions(-) rename 2-Babel/.babelrc => .babelrc (100%) delete mode 100644 2-Babel/.gitignore rename 2-Babel/ReadMe.txt => ReadMe.txt (100%) rename 2-Babel/index.html => index.html (100%) rename 2-Babel/key.txt => key.txt (100%) rename 2-Babel/nodeListForEach.js => nodeListForEach.js (100%) rename 2-Babel/package.json => package.json (100%) rename 2-Babel/plugin.js => plugin.js (100%) rename 2-Babel/script-compiled.js => script-compiled.js (100%) rename 2-Babel/script.js => script.js (100%) rename 2-Babel/style.css => style.css (100%) diff --git a/2-Babel/.babelrc b/.babelrc similarity index 100% rename from 2-Babel/.babelrc rename to .babelrc diff --git a/2-Babel/.gitignore b/2-Babel/.gitignore deleted file mode 100644 index 54bfd200..00000000 --- a/2-Babel/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# compiled output -/dist -/tmp -/out-tsc - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# misc -/.sass-cache -/connect.lock -/coverage -/libpeerconnection.log -npm-debug.log -testem.log -/typings - -# e2e -/e2e/*.js -/e2e/*.map - -# System Files -.DS_Store -Thumbs.db diff --git a/2-Babel/ReadMe.txt b/ReadMe.txt similarity index 100% rename from 2-Babel/ReadMe.txt rename to ReadMe.txt diff --git a/2-Babel/index.html b/index.html similarity index 100% rename from 2-Babel/index.html rename to index.html diff --git a/2-Babel/key.txt b/key.txt similarity index 100% rename from 2-Babel/key.txt rename to key.txt diff --git a/2-Babel/nodeListForEach.js b/nodeListForEach.js similarity index 100% rename from 2-Babel/nodeListForEach.js rename to nodeListForEach.js diff --git a/2-Babel/package.json b/package.json similarity index 100% rename from 2-Babel/package.json rename to package.json diff --git a/2-Babel/plugin.js b/plugin.js similarity index 100% rename from 2-Babel/plugin.js rename to plugin.js diff --git a/2-Babel/script-compiled.js b/script-compiled.js similarity index 100% rename from 2-Babel/script-compiled.js rename to script-compiled.js diff --git a/2-Babel/script.js b/script.js similarity index 100% rename from 2-Babel/script.js rename to script.js diff --git a/2-Babel/style.css b/style.css similarity index 100% rename from 2-Babel/style.css rename to style.css