forked from b00tc4mp/isdi-parttime-202410
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create new app using js6 b00tc4mp#40
- Loading branch information
1 parent
864e775
commit ab4934b
Showing
8 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class App extends Component { | ||
constructor() { | ||
super(document.body) | ||
|
||
const title = new Heading(1) | ||
tittle.setText("Hola, App!") | ||
this.add(title) | ||
|
||
const landing = new landing | ||
this.add(title) | ||
|
||
landing.onRegisterClick(() => { | ||
this.remove(landing) | ||
this.add(register) | ||
}) | ||
|
||
landing.onLoginClick(() => { | ||
this.remove(landing) | ||
this.add(login) | ||
}) | ||
|
||
const login = new login | ||
login.onRegisterClick(() => { | ||
this.remove(login) | ||
this.add(register) | ||
}) | ||
|
||
const register = new register | ||
register.onLoginClick(() => { | ||
this.remove(register) | ||
this.add(login) | ||
}) | ||
|
||
// const home = new Home | ||
// this.add(home) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(function () { | ||
function createPost(image, text) { | ||
if (typeof image !== "string") throw new Error("invalid image type") | ||
if (typeof text !== "string") throw new Error("invalid text type") | ||
|
||
var posts = JSON.parse(localStorage.posts) | ||
|
||
// Crea un nuevo objeto 'post' con las siguientes propiedades: | ||
|
||
var post = { | ||
id: uuid(), | ||
author: sessionStorage.userId, // el ID del usuario logueado, almacenado en 'sessionStorage'?? | ||
image: image, | ||
text: text, | ||
date: new Date().toISOString() // la fecha y hora actuales en formato ISO. | ||
} | ||
|
||
posts.push(post) // Añade el nuevo 'post' al array de 'posts' | ||
|
||
localStorage.posts = JSON.stringify(posts) // Convierte el array 'posts' nuevamente a una cadena JSON y lo guarda en 'localStorage' | ||
} | ||
|
||
logic.createPost = createPost // Asigna la función 'createPost' al objeto 'logic', de modo que esté disponible globalmente en 'logic'. | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var posts = [] | ||
|
||
posts.push({ | ||
id: 'uuid()', // Genera un ID único para el usuario usando la función uuid() | ||
author: 'uuid()', // Poner el username; | ||
image: 'https://spirit.scene7.com/is/image/Spirit/01642859-a?wid=400&qlt=85,1&resMode=bicub&fmt=jpeg&op_sharpen=1&hei=400', | ||
text: 'here me', | ||
date: new Date().toISOString() | ||
}) | ||
|
||
posts.push({ | ||
id: 'm2w92r8h44', | ||
author: 'm2w92r8h10', | ||
image: 'https://i.ytimg.com/vi/9oWEZSL_53U/maxresdefault.jpg', | ||
text: 'dream team', | ||
date: new Date().toISOString() | ||
}) | ||
|
||
localStorage.posts = JSON.stringify(posts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//users | ||
|
||
var users = [] | ||
|
||
users.push({ | ||
id: uuid(), //Genera un ID único para el usuario usando la función uuid() | ||
name: 'quero', | ||
email: '[email protected]', | ||
username: 'querito', | ||
password: '123123' | ||
}) | ||
|
||
users.push({ | ||
id: uuid(), | ||
name: 'sora', | ||
email: '[email protected]', | ||
username: 'Chosen One', | ||
password: 713 | ||
}) | ||
|
||
|
||
localStorage.users = JSON.stringify(users) // Almacena el array de usuarios en localStorage como una cadena de texto de JSON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function uuid() { | ||
return (Date.now() + Math.random()).toString(36).replace('.', '') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>App</title> | ||
</head> | ||
|
||
<body> | ||
<script src="data/uuid.js"></script> | ||
|
||
<script src="logic/helper/validate.js"></script> | ||
<script src="logic/index.js"></script> | ||
<script src="logic/loginUser.js"></script> | ||
<script src="logic/registerUser.js"></script> | ||
<script src="logic/getUserName.js"></script> | ||
<script src="logic/isUserLoggedIn.js"></script> | ||
<script src="logic/logoutUser.js"></script> | ||
<script src="logic/getPosts.js"></script> | ||
<script src="logic/createPost.js"></script> | ||
|
||
<script src="view/Component.js"></script> | ||
|
||
<script src="view/Button.js"></script> | ||
<script src="view/Form.js"></script> | ||
<script src="view/Heading.js"></script> | ||
<script src="view/Input.js"></script> | ||
<script src="view/Label.js"></script> | ||
<script src="view/Link.js"></script> | ||
<script src="view/Paragraph.js"></script> | ||
<script src="view/Text.js"></script> | ||
|
||
<script src="view/Landing.js"></script> | ||
<script src="view/Register.js"></script> | ||
<script src="view/Login.js"></script> | ||
<script src="view/Home.js"></script> | ||
|
||
<script src="App.js"></script> | ||
<script src="main.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var body = document.body | ||
|
||
var title = document.createElement('h1') | ||
title.innerText = 'Hola, App!' | ||
body.appendChild(title) |
Empty file.