Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions js-core/homeworks/homework-19/fileSistem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const fs = require('fs');

fs.readdir('./', (err, date) => {
console.log(date);
const src = fs.readdirSync('./src');
console.log(src);
})

//console.log(fs.readFileSync('./index.html').toString());
5 changes: 5 additions & 0 deletions js-core/homeworks/homework-19/helloUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const helloUserName = (username) => {
console.log('hello', username);
};

module.exports = helloUserName;
32 changes: 32 additions & 0 deletions js-core/homeworks/homework-19/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>js</title>
<meta charset="utf-8" />
<link href='style.css' rel='stylesheet' type='text/css'>

</head>
<body>
<style>
.box {
width: 200px;
height: 200px;
background-color: blue;
position: absolute;
}
a, div {
font-size: 35px;
display: flex;
justify-content: center;
}
</style>

<a href="a">Free javascript skill </a>
<a href="b">get salary 5000$ </a>
<div class="content">Loading...</div>
<!-- <div class ="box"></div>
<input id="www"/> -->
<img src="./src/cat.jpg" alt="Kitty">
<script src="main.js"></script>
</body>
</html>
53 changes: 53 additions & 0 deletions js-core/homeworks/homework-19/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//Task 0

function solution(str) {
let regExp = /[A-Z]/g;
let arrFromString = str.split('');
let convertedArr = arrFromString.reduce((done, elem, index) => {
if(regExp.test(elem) && index !== 0) {
done.push('_');
}
done.push(elem);
return done;
}, []);
let convertedStr = convertedArr.join('');
let newConvertedStr = convertedStr.replace(/::_/g, "/").replace(/-/g, "");
return newConvertedStr.toLowerCase();
};

console.log(solution("ActiveModel::Errors"));
console.log(solution("HelloHowAreYou"));
console.log(solution("MyNAMEIsBOND-JamesBond"));
console.log(solution("MAINCompany::BEST-MAINUser"));



alert('ddddd');

const box = document.querySelector('.box');

box.addEventListener('mousedown', (event) => {
console.log('mouse down');
box.style.backgroundColor = 'red';

const mousemove = (event) => {
console.log(event.pageX);
const widthOfBox = box.offsetWidth / 2;
const heightOfBox = box.offsetHeight / 2;
box.style.left = event.pageX - widthOfBox + 'px';
box.style.top = event.pageY - heightOfBox + 'px';
}

const mouseup = (event) => {
console.log('mouse up');
box.style.backgroundColor = 'blue';
box.removeEventListener('mousemove', mousemove);
box.removeEventListener('mouseup', mouseup);
};

box.addEventListener('mousemove', mousemove);

box.addEventListener('mouseup', mouseup);
box.ondragstart = (event) => false;
});

7 changes: 7 additions & 0 deletions js-core/homeworks/homework-19/math.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function add (num) {
return num * 2;
};

module.exports = {
add
}
4 changes: 4 additions & 0 deletions js-core/homeworks/homework-19/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const {add} = require('./math.js');
console.log(add);

console.log(add('3'));
19 changes: 19 additions & 0 deletions js-core/homeworks/homework-19/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const http = require('http');
const fs = require('fs');

http.createServer((request, respons) => {
if(request.url === '/') {
const index = fs.readFileSync('./index.html');
respons.end(index);
} else {
if(fs.existsSync(`.${request.url}`)) {
console.log('request.url', request.url);
const file = fs.readFileSync(`.${request.url}`);
respons.end(file);
}
}
respons.end('404 not found', 404);

}).listen(3000, (err) => {
console.log('server started http://localhost:3000');
});
Binary file added js-core/homeworks/homework-19/src/cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.