Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hlgr
drawing-app
Commits
64b7d66c
Commit
64b7d66c
authored
5 years ago
by
Nayeem Rahman
Browse files
Options
Downloads
Patches
Plain Diff
Navigate search params on room change
Redirect when room isn't given.
parent
3954983f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app.js
+12
-18
12 additions, 18 deletions
src/app.js
src/server.js
+11
-0
11 additions, 0 deletions
src/server.js
with
23 additions
and
18 deletions
src/app.js
+
12
−
18
View file @
64b7d66c
...
...
@@ -14,8 +14,17 @@ import * as humanhash from "humanhash"
import
jdenticon
from
"
jdenticon
"
const
DEFAULT_ROOM
=
"
imperial
"
const
initialRoom
=
new
URLSearchParams
(
location
.
search
).
get
(
"
room
"
)
||
DEFAULT_ROOM
const
navigateToRoom
=
(
roomID
)
=>
{
const
url
=
new
URL
(
location
.
href
)
url
.
searchParams
.
set
(
"
room
"
,
roomID
)
location
.
href
=
url
}
const
initialRoom
=
new
URLSearchParams
(
location
.
search
).
get
(
"
room
"
)
if
(
initialRoom
==
null
)
{
navigateToRoom
(
DEFAULT_ROOM
)
}
const
MIN_PRESSURE_FACTOR
=
0.1
const
MAX_PRESSURE_FACTOR
=
1.5
...
...
@@ -362,22 +371,7 @@ HTML.peerButton.addEventListener("click", () => {
})
const
onRoomJoinEnter
=
()
=>
{
const
selectedRoomID
=
HTML
.
roomIDElem
.
value
if
(
!
selectedRoomID
||
selectedRoomID
==
room
.
name
)
{
return
}
if
(
room
!=
null
)
{
room
.
disconnect
()
room
=
null
}
canvas
.
clear
()
HTML
.
connectedPeers
.
innerHTML
=
"
No peers are connected
"
HTML
.
fastUndoButton
.
classList
.
add
(
"
disabled
"
)
HTML
.
undoButton
.
classList
.
add
(
"
disabled
"
)
tryRoomConnect
(
selectedRoomID
)
navigateToRoom
(
HTML
.
roomIDElem
.
value
)
}
HTML
.
roomConnectButton
.
addEventListener
(
"
click
"
,
onRoomJoinEnter
)
...
...
This diff is collapsed.
Click to expand it.
src/server.js
+
11
−
0
View file @
64b7d66c
...
...
@@ -45,6 +45,17 @@ app.use((request, response, next) => {
next
()
})
app
.
get
(
"
/
"
,
(
request
,
response
,
next
)
=>
{
if
(
request
.
query
.
room
==
null
)
{
const
url
=
new
URL
(
`
${
request
.
protocol
}
://
${
request
.
get
(
"
host
"
)}${
request
.
originalUrl
}
`
,
)
url
.
searchParams
.
set
(
"
room
"
,
"
imperial
"
)
return
response
.
redirect
(
url
)
}
next
()
})
app
.
use
(
"
/
"
,
express
.
static
(
"
public
"
))
server
.
listen
(
port
,
host
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment