This file contains hidden or 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
| function openMine () { | |
| let diamonds = 21 | |
| function dig (getDug: (remaining: number) => number) { | |
| const dug = getDug(diamonds) | |
| diamonds -= dug | |
| console.log('diamonds', diamonds) | |
| return dug | |
| } |
This file contains hidden or 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
| let diamonds: number = 10 | |
| function dig (getDug: (remaining: number) => number) { | |
| let dug = getDug(diamonds) | |
| diamonds -= dug | |
| return dug | |
| } | |
| function getOne () { | |
| return 1 | |
| } |
This file contains hidden or 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
| const form = document.getElementById('productForm') | |
| form.addEventListener('submit', async (event) => { | |
| event.preventDefault() | |
| const name = document.getElementById('pname') | |
| const price = document.getElementById('price') | |
| const units = document.getElementById('units') | |
| const description = document.getElementById('desc') | |
| const isAvailable = document.getElementById('instock') | |
| const category = document.getElementById('category') |
This file contains hidden or 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
| const form = document.getElementById('categoryForm') | |
| form.addEventListener('submit', async (event) => { | |
| event.preventDefault() | |
| const name = document.getElementById('category') | |
| const description = document.getElementById('desc') | |
| const isActive = document.getElementById('is_available') | |
| const data = { | |
| name: name.value, | |
| description: description.value, |
This file contains hidden or 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
| async function getProducts () { | |
| const tbody = document.querySelector('tbody') | |
| const response = await fetch('http://localhost:3000/products') | |
| const data = await response.json() | |
| console.log('data', data) | |
| /* | |
| category: "Bags" | |
| description: "Everyday bag with padded sleeved for Laptop" | |
| id: "1c66" | |
| image: "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg" |
This file contains hidden or 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
| async function getCategories () { | |
| const tbody = document.querySelector('tbody') | |
| const response = await fetch('http://localhost:3000/categories') | |
| const data = await response.json() | |
| console.log('data', data) | |
| /* | |
| description: "All Clothing for men" | |
| id: "19d4" | |
| isActive: true | |
| name: "Men's Clothing" |
This file contains hidden or 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
| async function getOrders () { | |
| const tbody = document.querySelector('tbody') | |
| const response = await fetch('http://localhost:3000/orders') | |
| const data = await response.json() | |
| console.log('data', data) | |
| /* | |
| date: "Dec 21, 2022 12:04 (ET)" | |
| id: "6789" | |
| name: "Alina Thomas" |
This file contains hidden or 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
| // Observer the body tag of all html files. use validateLogIn function to verfy the login activity | |
| function validateLogIn () { | |
| const uName = document.getElementById('uName') | |
| const signOut = document.getElementById('signout') | |
| signOut.addEventListener('click', () => { | |
| sessionStorage.clear('login') | |
| window.location.href = '../sign-in.html' | |
| }) |
This file contains hidden or 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
| const message = document.getElementById('message') | |
| const form = document.getElementById('sign-in') | |
| const username = document.getElementById('userName') | |
| const password = document.getElementById('password') | |
| form.addEventListener('submit', (event) => { | |
| event.preventDefault() | |
| const localUser = localStorage.getItem('user') | |
| console.log('localUser', localUser) |
This file contains hidden or 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
| console.log('user registration') | |
| const form = document.getElementById('registerForm') | |
| console.log('form', form) | |
| form.addEventListener('submit', (event) => { | |
| event.preventDefault() | |
| const fullname = document.getElementById('fullname') | |
| const username = document.getElementById('username') |
NewerOlder