-
Notifications
You must be signed in to change notification settings - Fork 211
Dzien_6 rozw. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
herbowicz
wants to merge
11
commits into
CodersLab:master
Choose a base branch
from
herbowicz:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fefd214
Update index.html
herbowicz a37f7f1
Update zadanie01.js
herbowicz 8e3a3d6
Update zadanie02.js
herbowicz e2d8e36
Update index.html
herbowicz d7776b9
Create add.html
herbowicz acf2550
Delete index.html
herbowicz 3bf7676
Update zadanieDnia.js
herbowicz 17115f6
const
herbowicz bd4eab3
const
herbowicz 6644e27
const
herbowicz c1c077c
no styles
herbowicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,18 @@ | ||
| <!-- Twój kod --> | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" | ||
| content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>Coders Lab</title> | ||
| </head> | ||
| <body> | ||
| <h1>Czy B jest dzielnikiem A?</h1> | ||
| <form action="/result" method="post"> | ||
| Liczba A: <input type="text" name="a"><br> | ||
| Liczba B: <input type="text" name="b"><br> | ||
| <button type="submit">Sprawdź!</button> | ||
| </form> | ||
| </body> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,18 @@ | ||
| <!-- Twój kod --> | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" | ||
| content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>Coders Lab</title> | ||
| </head> | ||
| <body> | ||
| <form action="/cookie/set" method="post"> | ||
| Imię: <input type="text" name="name"><br> | ||
| <button type="submit">Zapisz</button> | ||
| </form> | ||
| <a href="/cookie/show">Pokaż imię</a> | ||
| <a href="/cookie/check">Sprawdź imię</a> | ||
| </body> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" | ||
| content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>Add comment</title> | ||
| </head> | ||
| <body> | ||
| <form action="/save" method="post"> | ||
| <textarea name="comment"></textarea><br> | ||
| <button type="submit">Dodaj komentarz</button> | ||
| </form> | ||
| </body> | ||
| </html> |
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,17 @@ | ||
| //Twój kod | ||
| const express = require('express'); | ||
| const bodyParser = require('body-parser'); | ||
| const app = express(); | ||
| app.use(bodyParser.urlencoded({ | ||
| extended: true //body-parser deprecated undefined extended: provide extended option | ||
| })); | ||
| app.use(express.static('./public/zadanie01/')); | ||
|
|
||
| app.post('/result', (req, res) => { | ||
| const {a, b} = req.body; | ||
| const is = parseInt(a) % parseInt(b) === 0 ? '' : ' nie'; | ||
| res.send('Liczba ' + b + is + ' jest dzielnikiem liczby ' + a); | ||
| }); | ||
|
|
||
| app.listen(3000, () => { | ||
| console.log('Serwer uruchomiony na porcie 3000'); | ||
| }); | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,29 @@ | ||
| //Twój kod | ||
| const express = require('express'); | ||
| const cookieParser = require('cookie-parser'); | ||
| const bodyParser = require('body-parser'); | ||
| const app = express(); | ||
| app.use(cookieParser()); | ||
| app.use(bodyParser.urlencoded({ | ||
| extended: true | ||
| })); | ||
| app.use(express.static('./public/zadanie02/')); | ||
|
|
||
| app.post('/cookie/set', (req, res) => { | ||
| res.cookie('cookieName', req.body.name, { | ||
| maxAge : 2628000000, | ||
| }); | ||
| res.send('Zapisano imię: ' + req.body.name); | ||
| }); | ||
|
|
||
| app.get('/cookie/show', (req, res) => { | ||
| res.send('Zapisane imię: ' + req.cookies.cookieName); | ||
| }); | ||
|
|
||
| app.get('/cookie/check', (req, res) => { | ||
| const is = req.cookies.cookieName === undefined ? 'nie' : ''; | ||
| res.send('Imię '+ is + ' zostało zapisane w ciastku.'); | ||
| }); | ||
|
|
||
| app.listen(3000, () => { | ||
| console.log('Serwer uruchomiony na porcie 3000'); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,54 @@ | ||
| //Twój kod | ||
| const express = require('express'); | ||
| const cookieParser = require('cookie-parser'); | ||
| const bodyParser = require('body-parser'); | ||
| const app = express(); | ||
| app.use(cookieParser()); | ||
| app.use(bodyParser.urlencoded({ | ||
| extended: true | ||
| })); | ||
| app.use(express.static('./public/zadanieDnia/')); | ||
|
|
||
| app.get('/remove', (req, res) => { | ||
| res.clearCookie('comments'); | ||
| res.send('Komentarze usunięte!'); | ||
| }); | ||
|
|
||
| app.get('/', (req, res) => { | ||
| const comments = readComments(req.cookies.comments); | ||
| res.send(comments + '<hr><a href="/add.html">Dodaj nowy komentarz</a>'); | ||
| }); | ||
|
|
||
| app.post('/save', (req, res) => { | ||
| const comments = addComment(req.cookies.comments, req.body.comment); | ||
| res.cookie('comments', comments, { | ||
| maxAge: 2628000000, | ||
| }); | ||
| res.send('Zapisano nowy komentarz. <a href="/">Zobacz komentarze</a>'); | ||
| }); | ||
|
|
||
| app.listen(3000, () => { | ||
| console.log('Serwer uruchomiony na porcie 3000'); | ||
| }); | ||
|
|
||
| // Funkcje pomocnicze | ||
|
|
||
| /** | ||
| * Ta funkcja pobiera string dotychczasowego ciastka, dodaje nowy komentarz i zwraca nowy string - taki z jakim należy nadpisać to ciasto. | ||
| * @param {string} commentsCookieValue Wartość dotychczasowego ciastka przechowującego komentarze | ||
| * @param {string} newComment Nowy komentarz | ||
| * @return {string} Nowy string z komentarzami do zapisania w ciastku | ||
| */ | ||
| function addComment(commentsCookieValue, newComment) { | ||
| const comments = readComments(commentsCookieValue); | ||
| comments.push(newComment); | ||
| return JSON.stringify(comments); | ||
| } | ||
|
|
||
| /** | ||
| * Ta funkcja odczytuje już dodane komentarze i zwraca je w postaci tablicy. | ||
| * @param {string} commentsCookieValue Wartość dotychczasowego ciastka przechowującego komentarze | ||
| * @return {Array} Tablica z komentarzami | ||
| */ | ||
| function readComments(commentsCookieValue) { | ||
| return commentsCookieValue ? JSON.parse(commentsCookieValue) : []; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Świetnie :)