diff --git a/.gitignore b/.gitignore index d618f07..115dd1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.iml .DS_Store/ .idea/ +.node_modules/ out/ \ No newline at end of file diff --git a/taskNodeJs/app.js b/taskNodeJs/app.js new file mode 100644 index 0000000..138b6e3 --- /dev/null +++ b/taskNodeJs/app.js @@ -0,0 +1,7 @@ +const express = require('express'); + +const app = express(); +app.use(express.static('public')); +app.listen(3000, () => { +console.log('Server is running...'); +}); diff --git a/taskNodeJs/package-lock.json b/taskNodeJs/package-lock.json new file mode 100644 index 0000000..195882a --- /dev/null +++ b/taskNodeJs/package-lock.json @@ -0,0 +1,373 @@ +{ + "name": "tasknodejs", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "2.1.18", + "negotiator": "0.6.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.3", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.16" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "requires": { + "accepts": "1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.2", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.3", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "1.4.0", + "type-is": "1.6.16", + "utils-merge": "1.0.1", + "vary": "1.1.2" + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.4.0", + "unpipe": "1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": "1.4.0" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", + "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + }, + "mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "requires": { + "mime-db": "1.33.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", + "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.6.0" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.4.0" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.2", + "destroy": "1.0.4", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.3", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.4.0" + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.18" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + } + } +} diff --git a/taskNodeJs/package.json b/taskNodeJs/package.json new file mode 100644 index 0000000..48fdd9c --- /dev/null +++ b/taskNodeJs/package.json @@ -0,0 +1,25 @@ +{ + "name": "tasknodejs", + "version": "1.0.0", + "description": "Project1", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Seal98/stud-practice.git" + }, + "keywords": [ + "Project1" + ], + "author": "A-Legan", + "license": "UNLICENSED", + "bugs": { + "url": "https://github.com/Seal98/stud-practice/issues" + }, + "homepage": "https://github.com/Seal98/stud-practice#readme", + "dependencies": { + "express": "^4.16.3" + } +} diff --git a/taskNodeJs/public/css/style.css b/taskNodeJs/public/css/style.css new file mode 100644 index 0000000..129abc1 --- /dev/null +++ b/taskNodeJs/public/css/style.css @@ -0,0 +1,426 @@ +html{ + overflow-x: hidden; + overflow-y: hidden; +} +body{ + width: 100vw; + height: 100vh; + margin: 0; +} + +.main{ + width: 100vw; + height: 100vh; +} + +.main-header{ + width: 100vw; + height: 8vh; + border: none; + background: url("../img/header.jpg") no-repeat; + background-size: 100% 100%; +} + +.ver-button{ + width: 10%; + height: 50%; + margin: 1% 0 0 87%; + background-color: rgb(0, 163, 232); + border-radius: 10px; + text-align: center; + font-size: 1.1vw; +} + +.filter-page-part{ + width: 100vw; + height: 85vh; + border: none; + background: url("../img/bl.jpg") no-repeat; + background-size: 100% 100%; +} + +.question-user{ + width: 20%; + height: 10.5%; + background-color: rgb(200, 191, 231); + float:left; + margin-top: 1.6%; + margin-left: 4%; + border-radius: 10px; + border: 3px solid #000; + text-align: center; + display: flex; + align-items: center; + font-weight: bold; + font-size: 1.3vw; +} + +.filters-block{ + width: 30%; + height: 16.5%; + border: 3px solid #000; + float:left; + margin-top: 0.6%; + margin-left: 6%; + border-radius: 10px; + background-color: rgb(200, 191, 231); + padding: 0.2%; + padding-top: 0.7%; +} +.filter-single{ + width:100%; + height:30%; +} +#cb-author{ + width:3vw; + height: 3vh; + margin-top:4.4%; +} +.cb{ + float:left; + width:15%; + height:50%; + margin-left: 0%; +} +.label-filter{ + padding:1.2%; + width:35%; + height:50%; + float:left; +} +.filter-text-input{ + margin-top:1%; + font-size: 0.8vw; +} + +.text-of-filters{ + font-size:1.1vw; +} + +.filter-input-part{ + height:95%; + width:80%; + + float: left; +} +#cb-date{ + width:3vw; + height: 3vh; +} +#cb-hashtag{ + width:3vw; + height: 3vh; +} +.block-filter-button{ + height: 95%; + width:17%; + float:right; +} +.filter-button{ + width: 85%; + height: 50.5%; + background-color: rgb(200, 191, 231); + margin-top: 31.4%; + margin-left: 6%; + border-radius: 0.6vw; + font-size: 1.0vw; + outline: none; +} +.add-post-button{ + width: 17%; + height: 10.5%; + background-color: rgb(200, 191, 231); + float: right; + margin-top: 1.6%; + margin-right: 4%; + border-radius: 1.6vw; + font-size: 1.7vw; + outline: none; + visibility: hidden; +} +.cards { + + width: 35vw; + height: 100vw; + position: absolute; + top: -44%; + left: 32.5%; + overflow-x: hidden; + overflow-y: scroll; + transform: rotate(270deg); +} +.cards::-webkit-scrollbar { + display: none; +} +.cards-content { + background-color: rgb(200, 191, 231); + width: 23vw; + height: 30vw; + margin: 3px auto; + transform: rotate(90deg); + border-radius: 10px; + border: 3px solid #000; + +} + +.post-header{ + + width: 95%; + height: 10%; + margin:auto; + +} + +.edit-button{ + outline: none; + width: 15%; + height: 90%; + float:right; + margin-top:1%; + visibility: hidden; +} +.post-hashtags{ + margin-left: 6%; + width: 55%; + height: 90%; + display:inline-block; + font-size: 1vw; + font-style:italic; + overflow:hidden; + margin-top: 2%; +} +.delete-button{ + outline: none; + width: 15%; + height: 90%; + margin-left: 1%; + margin-top:2%; + float: left; + visibility: hidden; +} +.del-add-post-image{ + width: 95%; + height: 95%; + +} +.like-post-image{ + width: 95%; + height: 95%; +} +.like-button{ + outline: none; + width: 23%; + margin-left: 2%; + margin-top: 2%; + float:left; + visibility: hidden; +} +.like-and-comment{ + width: 98%; + height: 16.5%; +} +.image-post{ + margin-top: 1%; + margin-left: 14%; + width: 70%; +} +.post-body{ + height: 66%; + width: 100%; +} +.comments{ + width: 67%; + height: 72.6%; + margin-left: 4%; + margin-top: 2%; + border: 0.2vw solid black; + border-radius: 1vw; + padding: 1%; + background-color: rgb(200, 191, 231); + font-size: 1vw; + overflow:hidden; + float: left; +} +.logged-user{ + + height: 80%; + width: 15%; + margin-left: 83% +} +.user-avatar{ + height:88%; + width:22%; + margin-top: 3%; + background: url("../img/av1.png") no-repeat; + background-size: 100% 100%; + float: left +} +.user-name{ + margin-top: 5%; + float:left; + height:88%; + width:76%; + text-align: center; + font-size: 2vw; + font-weight:bold + +} +.post-data{ + + margin-top: 1%; + margin-left: 2%; + width: 70%; + float: left; + height: 6%; + background-color: rgb(200, 191, 231); + text-align: left; + font-size: 1.3vw; + font-style:italic +} +.post-name{ + margin-top: 1%; + margin-left: 1%; + width: 25%; + height: 6%; + float: left; + background-color: rgb(200, 191, 231); + text-align: right; + font-size: 1.3vw; + font-weight:bold +} +.main-footer{ + width: 100vw; + height: 7vh; + border: none; + background: url("../img/footer.jpg") no-repeat; + background-size: 100% 100%; + alignment: bottom; + padding-top: 1%; + padding-left: 0.5%; +} +.text-footer-date{ + opacity: 0.7; + font-size: 1.0vw; + float: left; +} + +.text-footer-creator{ + opacity: 0.9; + font-size: 1.0vw; + margin-left: 79%; +} +.auth-button{ + width: 57%; + height: 60.5%; + background-color: rgb(200, 191, 231); + float: right; + margin-top: 5%; + margin-right: 1%; + border-radius: 0.6vw; + font-size: 0.9vw; + outline: none; +} +.submit-auth-button{ + width: 25%; + height: 15%; + background-color: rgb(73, 113, 231); + margin-top: 5%; + margin-left: 37.5%; + border-radius: 0.6vw; + font-size: 0.9vw; + outline: none; +} +.cancel-auth-button{ + width: 25%; + height: 15%; + background-color: rgb(73, 113, 231); + margin-top: 5%; + float: right; + border-radius: 0.6vw; + font-size: 0.9vw; + outline: none; +} +.auth-window{ + position: absolute; + top: 20%; + left: 39%; + width: 22%; + height: 30.5%; + border-radius: 0.6vw; + padding: 0.5%; + border: 3px solid yellow; + background-color: rgb(200, 191, 231); + z-index: 100; +} +.ed-window{ + position: absolute; + top: 20%; + left: 39%; + width: 22%; + height: 30.5%; + border-radius: 0.6vw; + padding: 0.5%; + border: 3px solid yellow; + background-color: rgb(200, 191, 231); + z-index: 100; +} +.back-button-edit{ + width: 30%; + height: 51%; + border: solid #090400; + float: right; + alignment: right; + background-color: rgb(91, 164, 231); + cursor: pointer; + outline: none; +} +.user-name-edit{ + float: left; + font-size: 1.6vw; + font-weight: bold; + margin-top: 0; + color: #429eff; +} +.edit-header{ + width: 100%; + height: 25%; +} +.edit-main{ + width: 100%; + height:30%; +} + +.edit-footer{ + width: 100%; + height: 25%; +} +.description-edit{ + height: 100%; + width: 65%; + float: left; + margin-top: 0px; +} +.submit-button-edit{ + height: 112%; + width: 30%; + border: 2px solid #090400; + float: right; + background-color: rgb(91, 164, 231); + cursor: pointer; + outline: none; +} +.input-text-image-edit{ + width: 55%; + height: 16%; + alignment: left; +} +.font-image-edit{ + float: left; + font-size: 0.8vw; + font-weight: bold; + margin-top: 0; + color: #429eff; +} +.login-password-font-style{ + padding: 0 15px; +} diff --git a/taskNodeJs/public/img/.gitignore b/taskNodeJs/public/img/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/taskNodeJs/public/img/av1.png b/taskNodeJs/public/img/av1.png new file mode 100644 index 0000000..e337615 Binary files /dev/null and b/taskNodeJs/public/img/av1.png differ diff --git a/taskNodeJs/public/img/av2.png b/taskNodeJs/public/img/av2.png new file mode 100644 index 0000000..5b3b82e Binary files /dev/null and b/taskNodeJs/public/img/av2.png differ diff --git a/taskNodeJs/public/img/avatar.png b/taskNodeJs/public/img/avatar.png new file mode 100644 index 0000000..f2e96bc Binary files /dev/null and b/taskNodeJs/public/img/avatar.png differ diff --git a/taskNodeJs/public/img/bl.jpg b/taskNodeJs/public/img/bl.jpg new file mode 100644 index 0000000..938babc Binary files /dev/null and b/taskNodeJs/public/img/bl.jpg differ diff --git a/taskNodeJs/public/img/brush.png b/taskNodeJs/public/img/brush.png new file mode 100644 index 0000000..0f1ea10 Binary files /dev/null and b/taskNodeJs/public/img/brush.png differ diff --git a/taskNodeJs/public/img/cross.png b/taskNodeJs/public/img/cross.png new file mode 100644 index 0000000..beb1a48 Binary files /dev/null and b/taskNodeJs/public/img/cross.png differ diff --git a/taskNodeJs/public/img/footer.jpg b/taskNodeJs/public/img/footer.jpg new file mode 100644 index 0000000..0565037 Binary files /dev/null and b/taskNodeJs/public/img/footer.jpg differ diff --git a/taskNodeJs/public/img/header.jpg b/taskNodeJs/public/img/header.jpg new file mode 100644 index 0000000..c6224e6 Binary files /dev/null and b/taskNodeJs/public/img/header.jpg differ diff --git a/taskNodeJs/public/img/like.svg b/taskNodeJs/public/img/like.svg new file mode 100644 index 0000000..a1d32f5 --- /dev/null +++ b/taskNodeJs/public/img/like.svg @@ -0,0 +1,17 @@ + + + + + background + + + + + + + Layer 1 + + + + + \ No newline at end of file diff --git a/taskNodeJs/public/img/liked.svg b/taskNodeJs/public/img/liked.svg new file mode 100644 index 0000000..d47dd0e --- /dev/null +++ b/taskNodeJs/public/img/liked.svg @@ -0,0 +1,17 @@ + + + + + background + + + + + + + Layer 1 + + + + + \ No newline at end of file diff --git a/taskNodeJs/public/img/naruto.png b/taskNodeJs/public/img/naruto.png new file mode 100644 index 0000000..2029821 Binary files /dev/null and b/taskNodeJs/public/img/naruto.png differ diff --git a/taskNodeJs/public/img/sham.png b/taskNodeJs/public/img/sham.png new file mode 100644 index 0000000..3920c9d Binary files /dev/null and b/taskNodeJs/public/img/sham.png differ diff --git a/taskNodeJs/public/index.html b/taskNodeJs/public/index.html new file mode 100644 index 0000000..d6baa6f --- /dev/null +++ b/taskNodeJs/public/index.html @@ -0,0 +1,86 @@ + + + + + + Title + + + +
+
+
+ +
+
+
+ +
+
+ +
+ + + + + + + diff --git a/taskNodeJs/public/js/Data.js b/taskNodeJs/public/js/Data.js new file mode 100644 index 0000000..ac5f4ac --- /dev/null +++ b/taskNodeJs/public/js/Data.js @@ -0,0 +1,112 @@ +var basicPosts = [ + { + id: '1', + description: 'NARUTO best anime', + createdAt: new Date('2014-12-12'), + author: 'Misha', + photoLink: 'img/naruto.png', + postVisibility: true, + hashTags: ['#NARUTOBESTANIME'], + likes: ['Alex'] + }, + + { + id: '2', + description: 'AVATAR best anime', + createdAt: new Date('2015-12-12'), + author: 'Misha', + photoLink: 'img/avatar.png', + postVisibility: true, + hashTags: ['#AVATARBESTANIME'], + likes: ['Egor'] + }, { + id: '3', + description: 'SHAMAN-KING best anime', + createdAt: new Date('2012-12-12'), + author: 'Misha2019', + photoLink: 'img/sham.png', + postVisibility: true, + hashTags: ['#SHAMANKINGBESTANIME'], + likes: ['Pomeedorka'] + }, + { + id: '4', + description: 'NARURO best anime', + createdAt: new Date('2013-12-12'), + author: 'Misha20', + photoLink: 'img/naruto.png', + postVisibility: true, + hashTags: ['#NARUTOBESTANIME'], + likes: ['Jora'] + }, + { + id: '5', + description: 'AVATAR best anime', + createdAt: new Date('2018-12-12'), + author: 'Misha', + photoLink: 'img/avatar.png', + postVisibility: true, + hashTags: ['#AVATARBESTANIME'], + likes: ['Jaga'] + }, + { + id: '6', + description: 'SHAMAN-KING best anime', + createdAt: new Date('2017-12-12'), + author: 'Misha22', + photoLink: 'img/sham.png', + postVisibility: true, + hashTags: ['#SHAMANKINGBESTANIME'], + likes: ['Jaguar'] + }, + { + id: '7', + description: 'NARUTO best anime', + createdAt: new Date('2016-12-12'), + author: 'Misha23', + photoLink: 'img/naruto.png', + postVisibility: true, + hashTags: ['#NARUTOBESTANIME'], + likes: ['Jagorka'] + }, + { + id: '8', + description: 'AVATAR best anime', + createdAt: new Date('2091-12-12'), + author: 'Misha', + photoLink: 'img/avatar.png', + postVisibility: true, + hashTags: ['#AVATARBESTANIME'], + likes: ['Igor'] + }, + { + id: '9', + description: 'SHAMAN-KING best anime', + createdAt: new Date('2020-12-12'), + author: 'Misha', + photoLink: 'img/sham.png', + postVisibility: true, + hashTags: ['#SHAMANKINGBESTANIME'], + likes: ['Egr'] + }, +]; + +for (var i = 0; i < basicPosts.length; i++) { + addPostToLocalStorage(basicPosts[i]); +} + +function addCurrentUserToLocalStorage(userName){ + localStorage.setItem("user", userName); +} + +function addPostToLocalStorage(post) { + localStorage.setItem(post.id, JSON.stringify(post)); +} + +function getPostFromLocalStorage(keyOfPost){ + return localStorage.getItem(keyOfPost); +} + +function removePostFromLocalStorage(keyOfPost){ + localStorage.removeItem(keyOfPost); +} diff --git a/taskNodeJs/public/js/dom.js b/taskNodeJs/public/js/dom.js new file mode 100644 index 0000000..d2d49b3 --- /dev/null +++ b/taskNodeJs/public/js/dom.js @@ -0,0 +1,277 @@ +var domBlockOfFunc = (function () { + + function createAuthWindow() { + let windowForAuth = document.createElement('div'); + let authButton = document.getElementById('a-button'); + authButton.style.pointerEvents = 'none'; + authButton.style.cursor = 'default'; + let posts = document.getElementById('anime-header'); + windowForAuth.className = 'auth-window'; + windowForAuth.id = 'auth-window' + windowForAuth.innerHTML = `

Авторизация

+

Логин :   

+
+

Пароль :

+ + `; + posts.appendChild(windowForAuth); + } + + function cancelEditing() { + let edWindow = document.getElementById('ed-window'); + let posts = document.getElementById('anime-header'); + posts.removeChild(edWindow); + } + + function cancelAdding() { + let adWindow = document.getElementById('add-window'); + let posts = document.getElementById('anime-header'); + posts.removeChild(adWindow); + } + + function createEditPostDomWindow(edButtonId) { + let windowForEditing = document.createElement('div'); + let posts = document.getElementById('anime-header'); + windowForEditing.className = 'ed-window'; + windowForEditing.id = 'ed-window'; + var submitButtonId = edButtonId.replace('e', ''); + submitButtonId = 's' + submitButtonId; + windowForEditing.innerHTML = `

${userName}

+
+
+

Путь к изображению:

+

Описание:

+
+ `; + + posts.appendChild(windowForEditing); + } + + function createAddPostWindow() { + let windowForEditing = document.createElement('div'); + let posts = document.getElementById('anime-header'); + windowForEditing.className = 'ed-window'; + windowForEditing.id = 'add-window' + + windowForEditing.innerHTML = `

${userName}

+
+
+

Путь к изображению:

+

Описание:

+
+ `; + + posts.appendChild(windowForEditing); + } + + function finishAdding() { + let descriptionEd = document.getElementById('description-for-adding').value; + let imageEd = document.getElementById('image-for-adding').value; + var idOfPost = '' + (photoPosts.length + 1); + var newPhotoPost = { + id: idOfPost, + description: descriptionEd, + createdAt: new Date(), + author: userName, + photoLink: imageEd, + postVisibility: true, + hashTags: [''], + likes: [''] + }; + mainBlockOfFunc.addPhotoPost(newPhotoPost); + var addWindow = document.getElementById('add-window'); + let posts = document.getElementById('anime-header'); + posts.removeChild(addWindow); + } + + function finishEditing(idOfPost) { + let descriptionEd = document.getElementById('description-for-editing').value; + let imageEd = document.getElementById('image-for-editing').value; + var post = {description: descriptionEd, photoLink: imageEd}; + mainBlockOfFunc.editPhotoPost(idOfPost.replace('s', ''), post); + var edWindow = document.getElementById('ed-window'); + let posts = document.getElementById('anime-header'); + posts.removeChild(edWindow); + } + + function finishAuth() { + let authWindow = document.getElementById('auth-window'); + let posts = document.getElementById('anime-header'); + let authBlock = document.getElementById('auth-block'); + let loginValue = document.getElementById('login-field').value; + posts.removeChild(authWindow); + posts.removeChild(authBlock); + let loggedUser = document.createElement('div'); + loggedUser.className = 'logged-user'; + loggedUser.innerHTML = `
${loginValue}
`; + posts.appendChild(loggedUser); + var allPhotoPosts = mainBlockOfFunc.getPhotoPosts(0, photoPosts.length); + userName = loginValue; + //addCurrentUserToLocalStorage(userName); + if(userName){ + let addPostButton = document.getElementById('add-post-button'); + addPostButton.style.visibility = 'visible'; + } + for (var i = 0; i < photoPosts.length; i++) { + activateButtons(allPhotoPosts[i].id); + } + + } + + function activateButtons(idOfPost) { + if(userName){ + let likeButton = document.getElementById('l' + idOfPost); + likeButton.style.visibility = 'visible'; + } + if (document.getElementById(idOfPost) && mainBlockOfFunc.getPhotoPost(idOfPost).author===userName) { + let deleteButton = document.getElementById('del' + idOfPost); + let editButton = document.getElementById('e' + idOfPost); + + deleteButton.style.visibility = 'visible'; + editButton.style.visibility = 'visible'; + } + } + + function cancelAuth() { + let authWindow = document.getElementById('auth-window'); + let posts = document.getElementById('anime-header'); + posts.removeChild(authWindow); + let authButton = document.getElementById('a-button'); + authButton.style.pointerEvents = ''; + authButton.style.cursor = ''; + } + + function deletePostDom(idOfButton) { + var idOfPost = idOfButton.replace('del', ''); + mainBlockOfFunc.removePhotoPost(idOfPost); + removePostFromLocalStorage(idOfPost); + + } + + function addPhotoPostDom(post) { + if (post.postVisibility) { + let cards = document.getElementById('posts'); + let photoPost = document.createElement('div'); + photoPost.className = 'cards-content'; + photoPost.id = post.id; + photoPost.innerHTML = createDomHTML(post); + + cards.appendChild(photoPost); + localStorage.setItem(post.id, JSON.stringify(post)); + } + } + + function addNewPhotoPostDom(post) { + addPhotoPostDom(post) + activateButtons(post.id); + } + + function removePhotoPostDom(idOfPost) { + let photoPost = document.getElementById(idOfPost); + let cards = document.getElementById('posts'); + cards.removeChild(photoPost); + } + + function createDomHTML(post) { + + var idOfDeleteButton = 'del'; + var idOfLikeButton = 'l'; + var idOfEditButton = 'e'; + var imageId = 'im'; + idOfDeleteButton += post.id; + idOfLikeButton += post.id; + idOfEditButton += post.id; + imageId += post.id; + var dateOfCreation = new Date(post.createdAt); + return `
+ Delete +
${post.hashTags}
+ Edit +
+
+ +
+
+
${post.description}
+
+
+
${dateOfCreation.getDate()}.${dateOfCreation.getMonth()}.${dateOfCreation.getFullYear()}
+
${post.author}
+ `; + } + + function likePostDom(idOfPost){ + var imageLike = document.getElementById('im'+idOfPost.replace('l','')); + if(imageLike.src === 'img/like.svg'){ + imageLike.src = 'img/liked.svg'; + } + else{ + imageLike.src = 'img/like.svg'; + } + } + + function editPhotoPostDom(idOfPost, editedPost) { + let photoPost = document.getElementById(idOfPost); + let cards = document.getElementById('posts'); + photoPost.innerHTML = createDomHTML(editedPost); + localStorage.setItem(editedPost.id, JSON.stringify(editedPost)); + activateButtons(idOfPost); + } + + function filterWindow() { + var filterParam = {createdAt: '', author: '', hashTags: ['']}; + var checkBoxAuthor = document.getElementById('cb-author').checked; + if (checkBoxAuthor) { + var valueOfAuthorFilter = document.getElementById('text-field-filter-author').value; + filterParam.author = valueOfAuthorFilter; + } + var checkBoxDate = document.getElementById('cb-date').checked; + if (checkBoxDate) { + var valueOfDateFilter = document.getElementById('text-field-filter-date').value; + filterParam.createdAt = new Date(valueOfDateFilter); + } + var checkBoxHashTags = document.getElementById('cb-hashtag').checked; + if (checkBoxHashTags) { + var valueOfHashTagsFilter = document.getElementById('text-field-filter-hashtags').value; + filterParam.hashTags[0] = valueOfHashTagsFilter; + } + var sortedArrOfPosts = mainBlockOfFunc.getPhotoPosts(0,photoPosts.length,filterParam); + var posts = document.getElementById('posts'); + while(posts.firstChild){ + posts.removeChild(posts.firstChild); + } + for(var i=0;i0) { + photoPosts[i-counter] = JSON.parse(localStorage.getItem(keys[i-counter])); + counter--; + } + for(var k=0;k photoPosts.length || postStart < 0) { + console.log('Нельзя вывести столько постов. Промежуток вывода не совпадает с количеством постов'); + return null; + } + else { + var sortedArrOfPosts = photoPosts; + if(typeof filterConfig !== 'undefined'){ + if (filterConfig.author) { + sortedArrOfPosts = sortedArrOfPosts.filter(function (post) { + return post.author === filterConfig.author; + }); + } + if (filterConfig.createdAt) { + sortedArrOfPosts = sortedArrOfPosts.filter(function (post) { + return post.createdAt === filterConfig.createdAt; + }); + } + if (filterConfig.hashTags) { + sortedArrOfPosts = sortedArrOfPosts.filter(function (post) { + for (let hashTagsOfPost of post.hashTags) { + for (let hashTagsOfFilter of [].concat(filterConfig.hashTags)) { + if (hashTagsOfPost.search(hashTagsOfFilter) !== -1) { + return true; + } + } + } + }); + } + } + sortedArrOfPosts = sortedArrOfPosts.sort(dateComparator).slice(postStart, number + postStart); + + return sortedArrOfPosts; + } + } + + function dateComparator(post1, post2) { + return post1.createdAt - post2.createdAt; + } + + function getPhotoPost(idOfPost) { + return photoPosts.find(function findPost(post) { + return post.id === idOfPost; + }); + } + + function validatePhotoPost(postForCheck) { + if (typeof postForCheck.id !== 'string' || postForCheck.id === '') { + console.log('Пустое поле id'); + return false; + } + + if (photoPosts.some(function checkUniqueness(post) { + return postForCheck.id === post.id; + })) { + console.log('id не уникальный'); + return false; + } + + if (typeof postForCheck.description !== 'string' || postForCheck.description.length > 200 || postForCheck.description === '') { + console.log('Неверный description'); + return false; + } + if (typeof postForCheck.author !== 'string' || postForCheck.author === '') { + console.log('Поле author пустое'); + return false; + } + if (!(postForCheck.createdAt instanceof Date) || ((postForCheck.createdAt).toString() === 'Invalid Date')) { + console.log('Поле даты создания не введено, либо имеет неправильную структуру'); + return false; + } + if (typeof postForCheck.photoLink !== 'string' || postForCheck.photoLink === '') { + console.log('Поле photoLink пустое'); + return false; + } + if (!(postForCheck.hashTags instanceof Array)) { + console.log('Структура поля hashTags не верна'); + return false; + } + return true; + } + + function validateForEditing(postForCheck) { + if (typeof postForCheck.description !== 'string' || postForCheck.description.length > 200 || postForCheck.description === '') { + console.log('Неверный description'); + + return false; + } + if (typeof postForCheck.author !== 'string' || postForCheck.author === '') { + console.log('Поле author пустое'); + return false; + } + if (!(postForCheck.createdAt instanceof Date) || ((postForCheck.createdAt).toString() === 'Invalid Date')) { + console.log('Поле даты создания не введено, либо имеет неправильную структуру'); + alert(postForCheck.createdAt); + return false; + } + if (typeof postForCheck.photoLink !== 'string' || postForCheck.photoLink === '') { + console.log('Поле photoLink пустое'); + return false; + } + if (!(postForCheck.hashTags instanceof Array)) { + console.log('Структура поля hashTags не верна'); + return false; + } + return true; + } + + function addPhotoPost(newPost) { + if (!validatePhotoPost(newPost)) { + return false; + } + else { + photoPosts.push(newPost); + domBlockOfFunc.addNewPhotoPostDom(newPost); + return true; + } + } + + function editPhotoPost(idForEd, postForEd) { + var postOfId = getPhotoPost(idForEd); + if (!postOfId) { + return false; + } + var postCopy = JSON.parse(JSON.stringify(postOfId)); + if (postForEd.description) { + postCopy.description = postForEd.description; + } + if (postForEd.author) { + postCopy.author = postForEd.author; + } + if (postForEd.photoLink) { + postCopy.photoLink = postForEd.photoLink; + } + if (postForEd.hashTags) { + postCopy.hashTags = postForEd.hashTags; + } + postCopy.createdAt = new Date(); + if (validateForEditing(postCopy)) { + changePostData(postOfId, postCopy); + domBlockOfFunc.editPhotoPostDom(idForEd, postCopy); + return true; + } + return false; + } + + function changePostData(post1, post2) { + post1.description = post2.description; + + post1.author = post2.author; + + post1.createdAt = post2.createdAt; + + post1.photoLink = post2.photoLink; + + post1.hashTags = post2.hashTags; + } + + function removePhotoPost(idForRem) { + var postOfId = getPhotoPost(idForRem); + if (postOfId == null) { + console.log('Пост для удаления не найден'); + return false; + } + else { + postOfId.postVisibility = false; + domBlockOfFunc.removePhotoPostDom(idForRem); + return true; + } + } + + return { + addPhotoPost, + removePhotoPost, + getPhotoPosts, + editPhotoPost, + getPhotoPost + } +}()); +