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
| export const Router = createRouter({ | |
| history: createWebHistory(), | |
| routes, | |
| scrollBehavior: (to, from, savedPosition) => { | |
| if (to && to.hash) { | |
| return { el: to.hash, behavior: 'smooth' }; | |
| } else { | |
| return { x: 0, y: 0 }; | |
| } | |
| }, |
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
| <template> | |
| <div class="row mtp-3"> | |
| <div class="block-27"> | |
| <ul class="pagination-ul"> | |
| <li @click="prev" class="cursor"> | |
| <a> | |
| <img | |
| class="chevron_right_pag" | |
| src="/assets/img/chevron_big_right.png" | |
| alt="right" |
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 router = new Router({ | |
| mode: "history", | |
| routes, | |
| scrollBehavior: (to, from, savedPosition) => { | |
| if (to && to.hash) { | |
| return { selector: to.hash }; | |
| } else { | |
| return { x: 0, y: 0 }; | |
| } | |
| }, |
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
| shuf -i 1-10 -n 1 | |
| // -i the range (here from 1 to 10) | |
| // -n number of results (here one number between the given range will be printed |
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
| autocomplete="chrome-off" |
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 MIN_PASSWORD_LENGTH = 6; | |
| const [data, setData] = React.useState({ | |
| name: '', | |
| email: '', | |
| password: '', | |
| confirmPassword:'' | |
| }) | |
| const errors = { | |
| name: '', | |
| email: '', |
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
| <Switch> | |
| {!user && <Redirect exact from='/' to='/auth' />} | |
| // you can only place the Redirect component inside the Switch Component if you are using the from to sytax | |
| {user && <Redirect exact from='/' to='/dashboard'/>} | |
| {user && <Redirect from='/auth' to='/dashboard'/>} | |
| <Route path='/auth' component={AuthPage}/> | |
| <Route path='/landing' component={LandingPage} /> | |
| <Route path='/' component={ProjectPage}/> | |
| </Switch> |
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
| // sign up route | |
| Router.post('/signUp',cors(), async (req, res) => { | |
| const {email, password, name, imgUrl} = req.body | |
| if(!email || !password || !name) return res.status(400).json({msg: 'all fields are required'}) | |
| try { | |
| const user = await User.findOne({email}) | |
| if(user) return res.status(400).json({msg: 'email already exists'}) |
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
| //One could (or should) use it as a protoype from Array: | |
| //From ChristopheD: | |
| Array.prototype.shuffle = function() { | |
| var i = this.length, j, temp; | |
| if ( i == 0 ) return this; | |
| while ( --i ) { | |
| j = Math.floor( Math.random() * ( i + 1 ) ); | |
| temp = this[i]; |
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
| // sending to sender-client only | |
| socket.emit('message', "this is a test"); | |
| // sending to all clients, include sender | |
| io.emit('message', "this is a test"); | |
| // sending to all clients except sender | |
| socket.broadcast.emit('message', "this is a test"); | |
| // sending to all clients in 'game' room(channel) except sender |