Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rndmc
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jake Read
rndmc
Commits
4a7a7120
Commit
4a7a7120
authored
Aug 19, 2018
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
big mess on ui
parent
fc97954c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/client.js
+102
-17
102 additions, 17 deletions
client/client.js
client/style.css
+14
-7
14 additions, 7 deletions
client/style.css
with
116 additions
and
24 deletions
client/client.js
+
102
−
17
View file @
4a7a7120
...
@@ -8,6 +8,9 @@ var reps = new Array()
...
@@ -8,6 +8,9 @@ var reps = new Array()
var
sckt
=
{}
var
sckt
=
{}
var
lastPos
=
{}
var
lastPos
=
{}
// drawing / div-ing
var
wrapper
=
{}
// client fns
// client fns
function
socketSend
(
type
,
data
)
{
function
socketSend
(
type
,
data
)
{
...
@@ -75,18 +78,18 @@ function buildMenu(tree) {
...
@@ -75,18 +78,18 @@ function buildMenu(tree) {
li
.
addEventListener
(
'
click
'
,
function
(
evt
)
{
li
.
addEventListener
(
'
click
'
,
function
(
evt
)
{
var
data
=
this
.
id
var
data
=
this
.
id
socketSend
(
'
add module
'
,
data
)
socketSend
(
'
add module
'
,
data
)
document
.
body
.
removeChild
(
document
.
getElementById
(
'
menu
'
))
wrapper
.
removeChild
(
document
.
getElementById
(
'
menu
'
))
})
})
ul
.
appendChild
(
li
)
ul
.
appendChild
(
li
)
}
}
menuDom
.
appendChild
(
ul
)
menuDom
.
appendChild
(
ul
)
}
}
document
.
body
.
append
(
menuDom
)
wrapper
.
append
(
menuDom
)
function
rmListener
(
evt
)
{
function
rmListener
(
evt
)
{
var
findMenu
=
document
.
getElementById
(
'
menu
'
)
var
findMenu
=
document
.
getElementById
(
'
menu
'
)
if
(
findMenu
!==
null
&&
findMenu
.
id
==
'
menu
'
)
{
if
(
findMenu
!==
null
&&
findMenu
.
id
==
'
menu
'
)
{
document
.
body
.
removeChild
(
findMenu
)
wrapper
.
removeChild
(
findMenu
)
}
}
}
}
...
@@ -98,6 +101,86 @@ function get(data) {
...
@@ -98,6 +101,86 @@ function get(data) {
}
}
function
writeEventRep
(
rep
,
type
,
key
)
{
var
li
=
document
.
createElement
(
'
li
'
)
li
.
innerHTML
=
key
.
toString
()
li
.
id
=
rep
.
id
+
'
'
+
type
+
'
'
+
key
li
.
addEventListener
(
'
click
'
,
(
evt
)
=>
{
var
ipclk
=
{
rep
:
rep
,
type
:
type
,
name
:
key
,
evt
:
evt
}
evtConnectHandler
(
ipclk
)
})
return
li
}
var
inClkState
=
false
var
clkOne
=
{}
// ok, nearly ... but want better everything. so messy!
// need different x, y for outputs, overall better way to get position
// and consider when moving div, wtf?
function
evtConnectHandler
(
clk
){
if
(
!
inClkState
){
oClk
=
clk
inClkState
=
true
var
parent
=
clk
.
evt
.
target
.
offsetParent
var
offset
=
clk
.
evt
.
target
.
offsetTop
var
x
=
parseInt
(
clk
.
evt
.
target
.
offsetParent
.
style
.
left
,
10
)
var
y
=
parseInt
(
clk
.
evt
.
target
.
offsetParent
.
style
.
top
,
10
)
+
clk
.
evt
.
target
.
offsetTop
+
clk
.
evt
.
target
.
clientHeight
/
2
startBezier
(
x
,
y
,
clk
)
}
else
{
inClkState
=
false
}
}
function
startBezier
(
x
,
y
,
clk
){
if
(
clk
.
type
==
'
output
'
){
var
bezier
=
newBezier
(
x
,
y
,
clk
.
evt
.
clientX
,
clk
.
evt
.
clientY
)
console
.
log
(
bezier
)
function
bzMoveMod
(
evt
){
modifyBezier
(
bezier
,
x
,
y
,
evt
.
clientX
,
evt
.
clientY
)
}
document
.
addEventListener
(
'
mousemove
'
,
bzMoveMod
)
}
}
var
svgns
=
"
http://www.w3.org/2000/svg
"
;
var
svg
=
{}
function
newBezier
(
x1
,
y1
,
x2
,
y2
)
{
var
bz
=
document
.
createElementNS
(
svgns
,
'
path
'
)
bz
.
style
.
stroke
=
'
#000
'
bz
.
style
.
fill
=
'
none
'
bz
.
style
.
strokeWidth
=
'
2px
'
var
bl
=
Math
.
sqrt
(
Math
.
pow
((
x1
-
x2
),
2
)
+
Math
.
pow
((
y1
-
y2
),
2
))
*
0.4
var
ps
=
'
M
'
+
x1
+
'
'
+
y1
+
'
C
'
+
(
x1
+
bl
)
+
'
'
+
y1
var
pe
=
'
'
+
(
x2
-
bl
)
+
'
'
+
y2
+
'
'
+
x2
+
'
'
+
y2
bz
.
setAttribute
(
'
d
'
,
ps
+
pe
)
svg
.
appendChild
(
bz
)
return
bz
}
function
modifyBezier
(
bz
,
x1
,
y1
,
x2
,
y2
)
{
var
bl
=
Math
.
sqrt
(
Math
.
pow
((
x1
-
x2
),
2
)
+
Math
.
pow
((
y1
-
y2
),
2
))
*
0.4
var
ps
=
'
M
'
+
x1
+
'
'
+
y1
+
'
C
'
+
(
x1
+
bl
)
+
'
'
+
y1
var
pe
=
'
'
+
(
x2
-
bl
)
+
'
'
+
y2
+
'
'
+
x2
+
'
'
+
y2
bz
.
setAttribute
(
'
d
'
,
ps
+
pe
)
}
/*
var crv = {}
document.addEventListener('mousemove', function(evt) {
modifyBezier(crv, 0, 0, evt.pageX, evt.pageY)
})
*/
// write html from json representation
// write html from json representation
function
addRep
(
rep
)
{
function
addRep
(
rep
)
{
// a div to locate it
// a div to locate it
...
@@ -147,28 +230,17 @@ function addRep(rep) {
...
@@ -147,28 +230,17 @@ function addRep(rep) {
var
inElem
=
document
.
createElement
(
'
div
'
)
var
inElem
=
document
.
createElement
(
'
div
'
)
inElem
.
className
=
'
inputs
'
inElem
.
className
=
'
inputs
'
for
(
ip
in
rep
.
inputs
)
{
for
(
ip
in
rep
.
inputs
)
{
var
li
=
document
.
createElement
(
'
li
'
)
var
li
=
writeEventRep
(
rep
,
'
input
'
,
ip
)
li
.
innerHTML
=
ip
.
toString
()
li
.
id
=
ip
.
toString
()
li
.
addEventListener
(
'
click
'
,
function
(
evt
)
{
console
.
log
(
'
in clk
'
)
})
inElem
.
appendChild
(
li
)
inElem
.
appendChild
(
li
)
}
}
var
outElem
=
document
.
createElement
(
'
div
'
)
var
outElem
=
document
.
createElement
(
'
div
'
)
outElem
.
className
=
'
outputs
'
outElem
.
className
=
'
outputs
'
for
(
op
in
rep
.
outputs
)
{
for
(
op
in
rep
.
outputs
)
{
var
li
=
document
.
createElement
(
'
li
'
)
var
li
=
writeEventRep
(
rep
,
'
output
'
,
op
)
li
.
innerHTML
=
op
.
toString
()
li
.
id
=
op
.
toString
()
li
.
addEventListener
(
'
click
'
,
function
(
evt
)
{
console
.
log
(
'
out clk
'
)
})
outElem
.
appendChild
(
li
)
outElem
.
appendChild
(
li
)
}
}
// now we'll append our objects to the top level container
// now we'll append our objects to the top level container
domElem
.
appendChild
(
inElem
)
domElem
.
appendChild
(
inElem
)
domElem
.
appendChild
(
outElem
)
domElem
.
appendChild
(
outElem
)
...
@@ -201,7 +273,7 @@ function addRep(rep) {
...
@@ -201,7 +273,7 @@ function addRep(rep) {
rep
.
ui
.
domElem
=
domElem
rep
.
ui
.
domElem
=
domElem
reps
.
push
(
rep
)
reps
.
push
(
rep
)
document
.
body
.
append
(
rep
.
ui
.
domElem
)
wrapper
.
append
Child
(
rep
.
ui
.
domElem
)
}
}
function
newState
(
rep
)
{
function
newState
(
rep
)
{
...
@@ -216,6 +288,19 @@ function newState(rep) {
...
@@ -216,6 +288,19 @@ function newState(rep) {
// init & hookup
// init & hookup
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
svg
=
document
.
createElementNS
(
svgns
,
'
svg
'
)
svg
.
setAttribute
(
'
width
'
,
'
100%
'
)
svg
.
setAttribute
(
'
height
'
,
'
100%
'
)
document
.
body
.
appendChild
(
svg
)
wrapper
=
document
.
createElement
(
'
div
'
)
wrapper
.
id
=
'
wrapper
'
document
.
body
.
append
(
wrapper
)
crv
=
newBezier
(
10
,
10
,
100
,
100
)
const
socket
=
new
WebSocket
(
'
ws://localhost:8081
'
)
const
socket
=
new
WebSocket
(
'
ws://localhost:8081
'
)
socket
.
onopen
=
function
(
evt
)
{
socket
.
onopen
=
function
(
evt
)
{
...
...
This diff is collapsed.
Click to expand it.
client/style.css
+
14
−
7
View file @
4a7a7120
...
@@ -7,7 +7,7 @@ body {
...
@@ -7,7 +7,7 @@ body {
.block
{
.block
{
width
:
auto
;
width
:
auto
;
position
:
absolute
;
position
:
absolute
;
padding
:
3
px
;
padding
:
0
px
;
padding-bottom
:
23px
;
padding-bottom
:
23px
;
background-color
:
#303030
;
background-color
:
#303030
;
}
}
...
@@ -21,9 +21,9 @@ body {
...
@@ -21,9 +21,9 @@ body {
}
}
.inputs
{
.inputs
{
width
:
5
5
px
;
width
:
5
8
px
;
float
:
left
;
float
:
left
;
padd
in
g
-left
:
5
px
;
marg
in-left
:
2
px
;
font-size
:
11px
;
font-size
:
11px
;
background-color
:
#1a1a1a
;
background-color
:
#1a1a1a
;
color
:
#eee
;
color
:
#eee
;
...
@@ -38,9 +38,9 @@ body {
...
@@ -38,9 +38,9 @@ body {
}
}
.outputs
{
.outputs
{
width
:
5
5
px
;
width
:
5
8
px
;
float
:
right
;
float
:
right
;
padd
in
g
-right
:
5
px
;
marg
in-right
:
2
px
;
text-align
:
right
;
text-align
:
right
;
font-size
:
11px
;
font-size
:
11px
;
background-color
:
#1a1a1a
;
background-color
:
#1a1a1a
;
...
@@ -54,13 +54,20 @@ body {
...
@@ -54,13 +54,20 @@ body {
ul
{
ul
{
list-style-type
:
none
;
list-style-type
:
none
;
color
:
#eee
;
color
:
#eee
;
padding
:
7px
0
7px
;
padding
:
7px
0
7px
0
;
}
}
li
{
li
{
list-style-type
:
none
;
list-style-type
:
none
;
color
:
#eee
;
color
:
#eee
;
padding
:
7px
0
7px
;
padding
:
7px
5px
6px
5px
;
border-bottom
:
1px
;
border-bottom-style
:
solid
;
border-color
:
#303030
;
}
li
:hover
{
background-color
:
#000
;
}
}
#menu
{
#menu
{
...
...
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