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
sweng-group-15
drawing-app
Commits
3af54c4e
Commit
3af54c4e
authored
5 years ago
by
Moritz Langenstein
Browse files
Options
Downloads
Patches
Plain Diff
(ml5717) Fixed global pathElems map (now per room connection)
parent
52f2594e
No related branches found
No related tags found
1 merge request
!28
Rooms and frontend
Pipeline
#101755
passed
5 years ago
Stage: fetch
Stage: deps
Stage: check
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app.js
+12
-7
12 additions, 7 deletions
src/app.js
with
12 additions
and
7 deletions
src/app.js
+
12
−
7
View file @
3af54c4e
...
@@ -20,9 +20,7 @@ const STROKECOLOUR = "blue"
...
@@ -20,9 +20,7 @@ const STROKECOLOUR = "blue"
const
STROKERADIUS
=
2
const
STROKERADIUS
=
2
const
ERASERRADIUS
=
STROKERADIUS
*
2
const
ERASERRADIUS
=
STROKERADIUS
*
2
const
pathElems
=
new
Map
()
const
addOrUpdatePathElem
=
(
pathElems
,
id
,
points
)
=>
{
const
addOrUpdatePathElem
=
(
id
,
points
)
=>
{
let
pathElem
=
pathElems
.
get
(
id
)
let
pathElem
=
pathElems
.
get
(
id
)
if
(
pathElem
==
null
)
{
if
(
pathElem
==
null
)
{
...
@@ -129,6 +127,8 @@ function handleRoomConnectionEstablished(room) {
...
@@ -129,6 +127,8 @@ function handleRoomConnectionEstablished(room) {
let
userInput
=
false
let
userInput
=
false
let
currentTool
=
tools
.
PEN
let
currentTool
=
tools
.
PEN
let
pathElems
=
new
Map
()
let
currentPathID
=
null
let
currentPathID
=
null
HTML
.
userIDElem
.
value
=
room
.
ownID
||
""
HTML
.
userIDElem
.
value
=
room
.
ownID
||
""
...
@@ -159,7 +159,7 @@ function handleRoomConnectionEstablished(room) {
...
@@ -159,7 +159,7 @@ function handleRoomConnectionEstablished(room) {
})
})
room
.
addEventListener
(
"
addOrUpdatePath
"
,
({
detail
:
{
id
,
points
}
})
=>
{
room
.
addEventListener
(
"
addOrUpdatePath
"
,
({
detail
:
{
id
,
points
}
})
=>
{
addOrUpdatePathElem
(
id
,
points
)
addOrUpdatePathElem
(
pathElems
,
id
,
points
)
})
})
const
canvasOnMouseDown
=
(
e
)
=>
{
const
canvasOnMouseDown
=
(
e
)
=>
{
...
@@ -265,6 +265,9 @@ function handleRoomConnectionEstablished(room) {
...
@@ -265,6 +265,9 @@ function handleRoomConnectionEstablished(room) {
HTML
.
roomConnectButton
.
removeEventListener
(
"
click
"
,
handleRoomConnectClick
)
HTML
.
roomConnectButton
.
removeEventListener
(
"
click
"
,
handleRoomConnectClick
)
const
roomConnectButtonOnClick
=
()
=>
{
const
roomConnectButtonOnClick
=
()
=>
{
const
selectedRoomID
=
HTML
.
roomIDElem
.
value
if
(
!
selectedRoomID
||
selectedRoomID
===
room
.
name
)
return
HTML
.
canvas
.
removeEventListener
(
"
mousedown
"
,
canvasOnMouseDown
)
HTML
.
canvas
.
removeEventListener
(
"
mousedown
"
,
canvasOnMouseDown
)
HTML
.
canvas
.
removeEventListener
(
"
mouseleave
"
,
canvasOnMouseLeave
)
HTML
.
canvas
.
removeEventListener
(
"
mouseleave
"
,
canvasOnMouseLeave
)
HTML
.
canvas
.
removeEventListener
(
"
mouseenter
"
,
canvasOnMouseEnter
)
HTML
.
canvas
.
removeEventListener
(
"
mouseenter
"
,
canvasOnMouseEnter
)
...
@@ -273,15 +276,17 @@ function handleRoomConnectionEstablished(room) {
...
@@ -273,15 +276,17 @@ function handleRoomConnectionEstablished(room) {
HTML
.
peerButton
.
removeEventListener
(
"
click
"
,
peerButtonOnClick
)
HTML
.
peerButton
.
removeEventListener
(
"
click
"
,
peerButtonOnClick
)
HTML
.
penButton
.
removeEventListener
(
"
click
"
,
penButtonOnClick
)
HTML
.
penButton
.
removeEventListener
(
"
click
"
,
penButtonOnClick
)
HTML
.
eraserButton
.
removeEventListener
(
"
click
"
,
eraserButtonOnClick
)
HTML
.
eraserButton
.
removeEventListener
(
"
click
"
,
eraserButtonOnClick
)
HTML
.
roomConnectButton
.
removeEventListener
(
"
click
"
,
roomConnectButtonOnClick
,
)
room
.
disconnect
()
room
.
disconnect
()
room
=
undefined
room
=
undefined
handleRoomConnectClick
()
handleRoomConnectClick
()
}
}
HTML
.
roomConnectButton
.
addEventListener
(
"
click
"
,
roomConnectButtonOnClick
,
{
HTML
.
roomConnectButton
.
addEventListener
(
"
click
"
,
roomConnectButtonOnClick
)
once
:
true
,
})
}
}
function
handleRoomConnectionError
(
err
)
{
function
handleRoomConnectionError
(
err
)
{
...
...
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