\n"},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/link.js b/public/build/link.js
new file mode 100644
index 00000000..732bc4cd
--- /dev/null
+++ b/public/build/link.js
@@ -0,0 +1 @@
+!function(){var n=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["link.hbs"]=n({1:function(n,l,t,e,a){var o,r=null!=l?l:n.nullContext||{},u=n.hooks.helperMissing,i="function",c=n.escapeExpression,n=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return'\t\n\t\t\n\t\n"},3:function(n,l,t,e,a){var o,r=null!=l?l:n.nullContext||{},u=n.hooks.helperMissing,i="function",c=n.escapeExpression,n=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return'\t\n\t\t'+c(typeof(o=null!=(o=n(t,"text")||(null!=l?n(l,"text"):l))?o:u)==i?o.call(r,{name:"text",hash:{},data:a,loc:{start:{line:9,column:2},end:{line:9,column:10}}}):o)+"\n\t\n"},compiler:[8,">= 4.3.0"],main:function(n,l,t,e,a){var o=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return null!=(t=o(t,"if").call(null!=l?l:n.nullContext||{},null!=l?o(l,"isBtn"):l,{name:"if",hash:{},fn:n.program(1,a,0),inverse:n.program(3,a,0),data:a,loc:{start:{line:1,column:0},end:{line:11,column:7}}}))?t:""},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/login.js b/public/build/login.js
new file mode 100644
index 00000000..a0c80769
--- /dev/null
+++ b/public/build/login.js
@@ -0,0 +1 @@
+!function(){var n=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["login.hbs"]=n({compiler:[8,">= 4.3.0"],main:function(n,l,e,t,a){var o=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return'
\n\t\n
\n'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/main.js b/public/build/main.js
new file mode 100644
index 00000000..e9589cad
--- /dev/null
+++ b/public/build/main.js
@@ -0,0 +1 @@
+!function(){var a=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["main.hbs"]=a({compiler:[8,">= 4.3.0"],main:function(a,n,e,t,i){return'
\n\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/not-found.js b/public/build/not-found.js
new file mode 100644
index 00000000..c00870d6
--- /dev/null
+++ b/public/build/not-found.js
@@ -0,0 +1 @@
+!function(){var n=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["not-found.hbs"]=n({compiler:[8,">= 4.3.0"],main:function(n,e,l,t,a){var o=n.lookupProperty||function(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]};return'
\r\n\t
Страница 404
\r\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/note-editor.js b/public/build/note-editor.js
new file mode 100644
index 00000000..310f9109
--- /dev/null
+++ b/public/build/note-editor.js
@@ -0,0 +1 @@
+!function(){var e=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["note-editor.hbs"]=e({compiler:[8,">= 4.3.0"],main:function(e,t,a,n,i){return'
\n\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/note.js b/public/build/note.js
new file mode 100644
index 00000000..d7d6330d
--- /dev/null
+++ b/public/build/note.js
@@ -0,0 +1 @@
+!function(){var n=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["note.hbs"]=n({compiler:[8,">= 4.3.0"],main:function(n,a,e,t,s){return'
\n\t
Заголовок
\n\t
Первая строчка заметки
\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/notes.js b/public/build/notes.js
new file mode 100644
index 00000000..ab20e30b
--- /dev/null
+++ b/public/build/notes.js
@@ -0,0 +1 @@
+!function(){var e=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["notes.hbs"]=e({compiler:[8,">= 4.3.0"],main:function(e,n,a,t,s){return'
\n\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/profile.js b/public/build/profile.js
new file mode 100644
index 00000000..59ad08ec
--- /dev/null
+++ b/public/build/profile.js
@@ -0,0 +1 @@
+!function(){var e=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["profile.hbs"]=e({compiler:[8,">= 4.3.0"],main:function(e,n,l,a,t){var o=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return'
\n\t
Страница профиля
\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/register.js b/public/build/register.js
new file mode 100644
index 00000000..7beefc4b
--- /dev/null
+++ b/public/build/register.js
@@ -0,0 +1 @@
+!function(){var e=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["register.hbs"]=e({compiler:[8,">= 4.3.0"],main:function(e,t,n,r,l){var a=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'
\n\t\n
\n'},useData:!0})}();
\ No newline at end of file
diff --git a/public/build/wrapper.js b/public/build/wrapper.js
new file mode 100644
index 00000000..f8b2b18c
--- /dev/null
+++ b/public/build/wrapper.js
@@ -0,0 +1 @@
+!function(){var e=Handlebars.template;(Handlebars.templates=Handlebars.templates||{})["wrapper.hbs"]=e({compiler:[8,">= 4.3.0"],main:function(e,n,l,a,t){var r=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return'
\n\n
'},useData:!0})}();
\ No newline at end of file
diff --git a/public/config.js b/public/config.js
index 5bea6757..bb91152b 100644
--- a/public/config.js
+++ b/public/config.js
@@ -5,9 +5,7 @@ const mainPage = {
home: {
id: "home",
linkToLogin: {
- href: "/login",
- text: "Попробовать",
- type: "submit"
+ text: "Попробовать"
}
}
}
diff --git a/public/index.css b/public/index.css
index efcc90e8..d161b6e8 100644
--- a/public/index.css
+++ b/public/index.css
@@ -14,7 +14,6 @@
@import "src/components/button/button.css";
@import "src/components/wrapper/wrapper.css";
@import "src/components/footer/footer.css";
-@import "src/components/link-button/link-button.css";
*, *::before, *::after {
box-sizing: border-box;
diff --git a/public/src/components/button/button.css b/public/src/components/button/button.css
index 57f17d5d..d4d30c8c 100644
--- a/public/src/components/button/button.css
+++ b/public/src/components/button/button.css
@@ -1,16 +1,14 @@
.submit-btn{
- width: 100%;
- min-width: 80px;
display: flex;
align-items: center;
justify-content: center;
background-color: #56A6F0;
border-radius: 20px;
+ padding: 8px 16px;
border: none;
outline: none;
color: #ffffff;
text-align: center;
- padding: 8px;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
cursor: pointer;
transition: 0.3s;
@@ -22,4 +20,8 @@
.submit-btn:active{
transform: scale(0.98)
+}
+
+.submit-btn.hidden {
+ display: none;
}
\ No newline at end of file
diff --git a/public/src/components/button/button.js b/public/src/components/button/button.js
index b59539b9..f951cd11 100644
--- a/public/src/components/button/button.js
+++ b/public/src/components/button/button.js
@@ -21,11 +21,12 @@ export class Button {
}
#addEventListeners(){
- this.self.addEventListener('click', (e) => {
- console.log(e)
- e.preventDefault()
- this.#onSubmit()
- });
+ if (this.#onSubmit !== undefined) {
+ this.self.addEventListener('click', (e) => {
+ e.preventDefault()
+ this.#onSubmit()
+ });
+ }
}
#removeEventListeners(){
@@ -33,7 +34,9 @@ export class Button {
}
remove(){
- this.#removeEventListeners();
+ if (this.#onSubmit !== undefined) {
+ this.#removeEventListeners();
+ }
}
render(){
diff --git a/public/src/components/header/header.js b/public/src/components/header/header.js
index 28794e3c..9b60d0fa 100644
--- a/public/src/components/header/header.js
+++ b/public/src/components/header/header.js
@@ -4,7 +4,8 @@ import '../../../build/header.js';
import {AppEventMaker} from "../../modules/eventMaker.js";
import {UserStoreEvents} from "../../stores/user/events.js";
import {AppUserStore} from "../../stores/user/userStore.js";
-import {LinkButton} from "../link-button/link-button.js";
+import {router} from "../../modules/router.js";
+import {Button} from "../button/button.js";
export class Header {
#parent;
@@ -37,8 +38,6 @@ export class Header {
AppEventMaker.subscribe(UserStoreEvents.SUCCSSESFUL_LOGIN, () => {
- console.log("log hueg")
-
if (this.#avatarLink === undefined) {
this.#avatarLink = new Link(document.querySelector(".right-container"), this.#config.avatarLink)
this.#avatarLink.render()
@@ -57,14 +56,16 @@ export class Header {
})
AppEventMaker.subscribe(UserStoreEvents.LOGOUT, () => {
- console.log(this.#avatar.self)
-
this.#avatarLink.self.hidden = true;
this.#authPageLink.self.classList.remove("hidden");
});
}
+ handleButtonClick = () => {
+ router.redirect("/login")
+ }
+
render() {
console.log("header render")
@@ -84,7 +85,7 @@ export class Header {
rightContainer.appendChild(this.#menu)
if (this.#authPageLink === undefined) {
- this.#authPageLink = new LinkButton(this.#menu, this.#config.menu.auth)
+ this.#authPageLink = new Button(this.#menu, this.#config.menu.auth, this.handleButtonClick)
this.#authPageLink.render()
}
diff --git a/public/src/components/home/home.js b/public/src/components/home/home.js
index ff4ac44b..971d4bd9 100644
--- a/public/src/components/home/home.js
+++ b/public/src/components/home/home.js
@@ -1,5 +1,6 @@
import "../../../build/home.js"
-import {LinkButton} from "../link-button/link-button.js";
+import {router} from "../../modules/router.js";
+import {Button} from "../button/button.js";
export class Home {
#parent;
@@ -14,13 +15,17 @@ export class Home {
return document.getElementById('home');
}
+ handleButtonClick = () => {
+ router.redirect("/login")
+ }
+
render() {
this.#parent.insertAdjacentHTML(
'afterbegin',
window.Handlebars.templates['home.hbs'](this.#config)
);
- const link = new LinkButton(document.querySelector(".first"), this.#config.linkToLogin)
+ const link = new Button(document.querySelector(".first"), this.#config.linkToLogin, this.handleButtonClick)
link.render()
}
diff --git a/public/src/components/link-button/link-button.css b/public/src/components/link-button/link-button.css
deleted file mode 100644
index d750b7ac..00000000
--- a/public/src/components/link-button/link-button.css
+++ /dev/null
@@ -1,27 +0,0 @@
-.link-button{
- padding: 8px 16px;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #56A6F0;
- border-radius: 20px;
- border: none;
- outline: none;
- color: #ffffff;
- text-align: center;
- box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
- cursor: pointer;
- transition: 0.3s;
-}
-
-.link-button:hover{
- transform: scale(1.05)
-}
-
-.link-button:active{
- transform: scale(0.98)
-}
-
-.link-button.hidden {
- display: none;
-}
\ No newline at end of file
diff --git a/public/src/components/link-button/link-button.hbs b/public/src/components/link-button/link-button.hbs
deleted file mode 100644
index e72b0ff1..00000000
--- a/public/src/components/link-button/link-button.hbs
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/public/src/components/link-button/link-button.js b/public/src/components/link-button/link-button.js
deleted file mode 100644
index 0eb2efa5..00000000
--- a/public/src/components/link-button/link-button.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import {router} from "../../modules/router.js";
-import "../../../build/link-button.js"
-
-export class LinkButton {
- #parent;
-
- #props = {};
-
- id;
-
- constructor(parent, config) {
- this.id = crypto.randomUUID();
-
- this.#parent = parent;
-
- this.#props.id = this.id ;
- this.#props.text = config.text;
- this.#props.href = config.href;
- }
-
- get self(){
- return document.getElementById(this.id);
- }
-
- handleClick = (e) => {
- e.preventDefault()
- router.redirect(this.#props.href)
- }
-
- #addListeners () {
- this.self.addEventListener("click", this.handleClick)
- }
-
- render() {
-
- this.#parent.insertAdjacentHTML(
- 'beforeend',
- window.Handlebars.templates['link-button.hbs'](this.#props)
- );
-
- this.#addListeners()
- }
-}
diff --git a/public/src/pages/notFound/not-found.js b/public/src/pages/notFound/not-found.js
index c15ab040..668898c1 100644
--- a/public/src/pages/notFound/not-found.js
+++ b/public/src/pages/notFound/not-found.js
@@ -1,5 +1,6 @@
import "../../../build/not-found.js"
-import {LinkButton} from "../../components/link-button/link-button.js";
+import {router} from "../../modules/router.js";
+import {Button} from "../../components/button/button.js";
export default class NotFoundPage {
#parent;
@@ -19,9 +20,12 @@ export default class NotFoundPage {
}
remove() {
-
+ this.#parent.innerHTML = '';
}
+ handleButtonClick = () => {
+ router.redirect("/")
+ }
render() {
console.log("404 page render")
@@ -31,7 +35,7 @@ export default class NotFoundPage {
window.Handlebars.templates['not-found.hbs'](this.#config)
);
- const link = new LinkButton(this.self, this.#config.link)
+ const link = new Button(this.self, this.#config.link, this.handleButtonClick)
link.render()
}
}
diff --git a/public/src/pages/register/register.js b/public/src/pages/register/register.js
index a24335ef..aaeb6241 100644
--- a/public/src/pages/register/register.js
+++ b/public/src/pages/register/register.js
@@ -5,6 +5,9 @@ import {Button} from "../../components/button/button.js";
import {ValidateLogin, ValidatePassword} from "../../shared/validation.js";
import {AppEventMaker} from "../../modules/eventMaker.js";
import {inputEvents} from "../../components/input/events.js";
+import {AppDispatcher} from "../../modules/dispathcer.js";
+import {UserActions} from "../../stores/user/userStore.js";
+import {router} from "../../modules/router.js";
export default class RegisterPage {
#parent;
@@ -29,6 +32,20 @@ export default class RegisterPage {
return document.getElementById(this.#config.form.id)
}
+ validateData = () => {
+ const validateLogin = this.#validateLogin()
+ const validatePassword = this.#validatePassword()
+ if (validateLogin && validatePassword) {
+
+ AppDispatcher.dispatch({
+ type: UserActions.LOGIN,
+ payload: this.#loginInput.value
+ })
+
+ router.redirect("/")
+ }
+ }
+
#validateLogin(){
delete this.#loginInput.self.dataset.error;
@@ -52,6 +69,12 @@ export default class RegisterPage {
if (!validationResult.result){
this.#passwordInput.throwError(validationResult.message);
+ this.#repeatPasswordInput.throwError(validationResult.message);
+ }
+
+ if (this.#passwordInput.value !== this.#repeatPasswordInput.value) {
+ this.#passwordInput.throwError("Пароли не совпадают");
+ this.#repeatPasswordInput.throwError("Пароли не совпадают");
}
return validationResult.result;
@@ -115,7 +138,7 @@ export default class RegisterPage {
this.#link = new Link(this.form, this.#config.form.links.loginPage);
this.#link.render();
- this.#submitBtn = new Button(this.form, this.#config.form.buttons.submitBtn);
+ this.#submitBtn = new Button(this.form, this.#config.form.buttons.submitBtn, this.validateData);
this.#submitBtn.render();
this.#subscribeToEvents();
diff --git a/public/src/shared/validation.js b/public/src/shared/validation.js
new file mode 100644
index 00000000..91ebe2b7
--- /dev/null
+++ b/public/src/shared/validation.js
@@ -0,0 +1,54 @@
+export const ValidatePassword = (value) => {
+ for (let index = 0; index < value.length; ++index){
+ if (!(value.charCodeAt(index) >= 97 && value.charCodeAt(index) <= 122 ||
+ value.charCodeAt(index) >= 64 && value.charCodeAt(index) <= 90 ||
+ value.charCodeAt(index) >= 48 && value.charCodeAt(index) <= 57 ||
+ value.charCodeAt(index) >= 35 && value.charCodeAt(index) <= 38)){
+ return ValidationResult(false, "Пароль должен содержать только латинские символы, цифры или символы #$%&");
+ }
+ }
+
+ if (value === "")
+ {
+ return ValidationResult(false, "Пароль не может быть пустым!")
+ }
+
+ if (value.length < 8){
+ return ValidationResult(false, "Пароль должен быть не менее 8 символов!")
+ }
+
+ if (value.length > 20){
+ return ValidationResult(false, "Пароль должен быть короче 20 символов!")
+ }
+
+ return ValidationResult(true)
+}
+
+export const ValidateLogin = (value) => {
+ for (let index = 0; index < value.length; ++index){
+ if (!(value.charCodeAt(index) >= 97 && value.charCodeAt(index) <= 122 ||
+ value.charCodeAt(index) >= 64 && value.charCodeAt(index) <= 90 ||
+ value.charCodeAt(index) >= 48 && value.charCodeAt(index) <= 57 )){
+ return ValidationResult(false, "Логин должен содержать только латинские символы или цифры")
+ }
+ }
+
+ if (value === "")
+ {
+ return ValidationResult(false, "Логин не может быть пустым!")
+ }
+
+ if (value.length < 4){
+ return ValidationResult(false, "Логин должен быть не менее 4 символов!")
+ }
+
+ if (value.length > 12){
+ return ValidationResult(false, "Логин должен быть короче 12 символов!")
+ }
+
+ return ValidationResult(true)
+}
+
+const ValidationResult = (result, message = null) => {
+ return {result, message}
+}
\ No newline at end of file