-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
Vls 33
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
#!/bin/bash | ||
handlebars -m public/src/pages/main-page/main-page.hbs -f public/build/main-page.js | ||
mkdir -p public/build | ||
handlebars -m public/src/pages/main/main.hbs -f public/build/main.js | ||
handlebars -m public/src/pages/login/login.hbs -f public/build/login.js | ||
handlebars -m public/src/pages/register/register.hbs -f public/build/register.js | ||
handlebars -m public/src/pages/profile/profile.hbs -f public/build/profile.js | ||
handlebars -m public/src/pages/notFound/not-found.hbs -f public/build/not-found.js | ||
handlebars -m public/src/components/image/image.hbs -f public/build/image.js | ||
handlebars -m public/src/components/header/header.hbs -f public/build/header.js | ||
handlebars -m public/src/components/notes/notes.hbs -f public/build/notes.js | ||
handlebars -m public/src/components/note/note.hbs -f public/build/note.js | ||
handlebars -m public/src/components/note-editor/note-editor.hbs -f public/build/note-editor.js | ||
handlebars -m public/src/components/avatar/avatar.hbs -f public/build/avatar.js | ||
handlebars -m public/src/components/link/link.hbs -f public/build/link.js | ||
handlebars -m public/src/components/home/home.hbs -f public/build/home.js | ||
handlebars -m public/src/components/input/input.hbs -f public/build/input.js | ||
handlebars -m public/src/components/wrapper/wrapper.hbs -f public/build/wrapper.js | ||
handlebars -m public/src/components/footer/footer.hbs -f public/build/footer.js | ||
handlebars -m public/src/components/button/button.hbs -f public/build/button.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,23 @@ | ||
import {config} from '/config.js'; | ||
import MainPage from './src/pages/main-page/main-page.js'; | ||
import {Header} from "./src/components/header/header.js"; | ||
import LoginPage from "./src/pages/login/login.js"; | ||
import RegisterPage from "./src/pages/register/register.js"; | ||
import {Wrapper} from "./src/components/wrapper/wrapper.js"; | ||
import {Footer} from "./src/components/footer/footer.js"; | ||
import {AppUserStore} from "./src/stores/user/userStore.js"; | ||
import {router} from "./src/modules/router.js"; | ||
|
||
const root = document.getElementById('root'); | ||
console.log('root'); | ||
|
||
const wrapper = document.createElement("div") | ||
wrapper.id = "wrapper" | ||
root.appendChild(wrapper) | ||
AppUserStore.registerEvents(); | ||
|
||
export const userInfo = { | ||
login: '', | ||
username: '', | ||
isAuthorized: true, | ||
}; | ||
|
||
let page = 'main'; | ||
const wrapper = new Wrapper(root, config.wrapper); | ||
wrapper.render(); | ||
|
||
function renderHeader() { | ||
const header = new Header(root, config, userInfo.isAuthorized); | ||
header.render(); | ||
} | ||
router.init(wrapper.self, config); | ||
|
||
const renderMainPage = () => { | ||
const main = new MainPage(wrapper, config, userInfo); | ||
main.render(); | ||
}; | ||
const header = new Header(root, config.header); | ||
header.render(); | ||
|
||
const renderLoginPage = () => { | ||
const login = new LoginPage(wrapper, config); | ||
login.render(); | ||
}; | ||
|
||
const renderRegisterPage = () => { | ||
const register = new RegisterPage(wrapper, config); | ||
register.render() | ||
} | ||
|
||
const changePage = (href) => { | ||
switch (href) { | ||
case '': | ||
if (page !== 'main') { | ||
renderMainPage(); | ||
page = 'main'; | ||
history.pushState(null, null, '/') | ||
} | ||
break; | ||
case 'main': | ||
if (page !== 'main') { | ||
renderMainPage(); | ||
page = 'main'; | ||
history.pushState(null, null, '/' + page) | ||
} | ||
break; | ||
case 'login': | ||
if (page !== 'login') { | ||
renderLoginPage(); | ||
page = 'login'; | ||
history.pushState(null, null, '/' + page) | ||
} | ||
break; | ||
case 'register': | ||
if (page !== 'register') { | ||
renderRegisterPage(); | ||
page = 'register'; | ||
history.pushState(null, null, '/' + page) | ||
} | ||
break; | ||
default: | ||
console.log('undefined click'); | ||
} | ||
}; | ||
|
||
const listenClick = (e) => { | ||
e.preventDefault(); | ||
const anchor = e.target.closest('a'); | ||
if (!anchor) return; | ||
const href = anchor.getAttribute('href').replace('/', ''); | ||
changePage(href); | ||
}; | ||
|
||
window.addEventListener('click', listenClick); | ||
|
||
|
||
renderHeader(); | ||
renderMainPage(); | ||
const footer = new Footer(root, config.footer); | ||
footer.render() | ||
|