Skip to content

Commit

Permalink
Implement Register & Login in JS6 b00tc4mp#391
Browse files Browse the repository at this point in the history
  • Loading branch information
PereHDZ committed Mar 15, 2024
1 parent cc66911 commit 2f987cc
Show file tree
Hide file tree
Showing 56 changed files with 2,404 additions and 203 deletions.
File renamed without changes.
28 changes: 28 additions & 0 deletions staff/pere-hernandez/isdigram copy 2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ISDIGram

## Functional Description

### Functionalities

- Crate a post
- take picture with camera
- upload picture from phone
- apply filter to picture
- Tag a user
- View other people's posts
- Send messages
- Follow user
- Search user
- Search post (by hashtag)
- Toggle like a post
- Toggle save a post
- Comment a post
- Video-call user
- Live video streaming
- Publsh a story

### UI Design

#### Layout

#### Prototype
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions staff/pere-hernandez/isdigram copy 2/chat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions staff/pere-hernandez/isdigram copy 2/data/Collection.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
class Collection {
constructor (name){
this.name = name
}

//helpers

_generateId() {
return (+((parseInt(Math.random() * 10 ** 17)).toString())).toString(36)
}

_loadDocuments () {
var documentsJSON = localStorage[this.name]

var documents = JSON.parse(documentsJSON || '[]')

return documents
}

_saveDocuments (documents) {
//validation

if (!(documents instanceof Array))
throw new TypeError ('documents is not an Array')

documents.forEach(function (document){
if(!(document instanceof Object))
throw new TypeError('some elements in documents are not a document')
})

//logic
var documentsJSON = JSON.stringify(documents)

localStorage[this.name] = documentsJSON
}

_backup (){
localStorage[this.name + '_backup'] = localStorage[this.name]
}

_restore (){
localStorage[this.name] = localStorage[this.name + '_backup']
}



// CRUD

findOne (callback) {
//validation

if (!(callback instanceof Function))
throw new TypeError ('callback is not a Function')

//logic
var documents = this._loadDocuments()

var document = documents.find(callback)

return document
}

insertOne (document) {
//validation

if (!(document instanceof Object))
throw new TypeError ('document is not an Object')

//logic
var documents = this._loadDocuments()

document.id = this._generateId()

documents.push(document)

this._saveDocuments(documents)
}

updateOne (document) {
//validation

if (!(document instanceof Object))
throw new TypeError('document is not an Object')
if (typeof document.id !== 'string')
throw new TypeError('id must be a string')

//logic
var documents = this._loadDocuments()

var index = documents.findIndex(function (document2) {
return document2.id === document.id
})

if (index > -1){
documents.splice(index, 1, document)

this._saveDocuments(documents)
}
}

deleteOne (callback){
//validation

if (!(callback instanceof Function))
throw new TypeError ('callback is not a Function')

//logic
var documents = this._loadDocuments()

var index = documents.findIndex(callback)

if (index > -1){
documents.splice(index, 1)

this._saveDocuments(documents)
}
}

getAll (){
var documents = this._loadDocuments()

return documents
}

printAll () {
var documents = this._loadDocuments()

console.table(documents)
}
}

export default Collection
17 changes: 17 additions & 0 deletions staff/pere-hernandez/isdigram copy 2/data/Collection.spec.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Collection spec</title>
</head>

<body>
<h1>Collection spec</h1>

<script src="../vendor/matcha.js"></script>

<script src="Collection.js"></script>
<script src="Collection.spec.js"></script>
</body>
</html>
Loading

0 comments on commit 2f987cc

Please sign in to comment.