forked from b00tc4mp/isdi-bootcamp-202402
-
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.
Implement Register & Login in JS6 b00tc4mp#391
- Loading branch information
Showing
56 changed files
with
2,404 additions
and
203 deletions.
There are no files selected for viewing
File renamed without changes.
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,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 |
Binary file added
BIN
+6.53 KB
staff/pere-hernandez/isdigram copy 2/add-circle-fill-system.256x256.png
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.
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
132
staff/pere-hernandez/isdigram copy 2/data/Collection.mjs
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,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
17
staff/pere-hernandez/isdigram copy 2/data/Collection.spec.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,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> |
Oops, something went wrong.