Skip to content

Commit

Permalink
create new app using js6 b00tc4mp#40
Browse files Browse the repository at this point in the history
  • Loading branch information
JOSE-QUERO committed Nov 13, 2024
1 parent 864e775 commit ab4934b
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 0 deletions.
37 changes: 37 additions & 0 deletions staff/jose-quero/app 1/App.js
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)
}
}
24 changes: 24 additions & 0 deletions staff/jose-quero/app 1/data/logic/createPost.js
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'.
})()
19 changes: 19 additions & 0 deletions staff/jose-quero/app 1/data/post.js
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)
22 changes: 22 additions & 0 deletions staff/jose-quero/app 1/data/users.js
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
3 changes: 3 additions & 0 deletions staff/jose-quero/app 1/data/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function uuid() {
return (Date.now() + Math.random()).toString(36).replace('.', '')
}
43 changes: 43 additions & 0 deletions staff/jose-quero/app 1/index.html
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>
5 changes: 5 additions & 0 deletions staff/jose-quero/app 1/main.js
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.

0 comments on commit ab4934b

Please sign in to comment.