'use strict';

const template = require('../../views/pages/Search.hbs');

class SearchPage {

	constructor() {
		this.container = document.createElement('div');
		this.container.className = 'search-container';
		this.render();
	}

	render() {
		this.container.innerHTML = template();

		let searchValue = this.container.querySelector('.search-value');
		let button = this.container.querySelector('.btn');

		searchValue.addEventListener('input', () => {

			if(searchValue.value.length > 0) {
				button.classList.remove('disabled');
			}
			else {
				button.classList.add('disabled');
			}

		});

		button.addEventListener('click', () => {
			if(searchValue.value.length !== 0) {
				search();
			}
		});

	}



}

module.exports = SearchPage;

@@ -220,16 +220,17 @@
 nder();%0A
+%0A
 %09%7D%0A%0A%09ren
@@ -278,16 +278,48 @@
 late();%0A
+%09%09this.search();%0A%09%7D%0A%0A%09search() %7B
 %0A%09%09let s
@@ -676,56 +676,378 @@
 %0A%09%09%09
-if(searchValue.value.length !== 0)
+const data = fetch(%60http://api.apixu.com/v1/current.json?key=37a2650f4cb24c0a87091627171511&q=$%7BsearchValue.value%7D%60);%0A%0A%09%09%09if(searchValue.value.length) %7B%0A%09%09%09%09data.then(res =%3E res.json())%0A%09%09%09%09%09.then(data =%3E
  %7B%0A
+%0A%09
 %09%09%09%09
-search(
+%09console.log(data);%0A%0A%09%09%09%09%09%09alert(data.location.name + %22 %22 + data.location.country + %22 %22 + data.current.temp_c + %22 %C2%B0C%22)%0A%0A%09%09%09%09%09%7D).catch(err =%3E console.log(err)
 );%0A%09
@@ -1061,18 +1061,16 @@
 );%0A%0A%09%7D%0A%0A
-%0A%0A
 %7D%0A%0Amodul

Create search method