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
047102bb
Commit
047102bb
authored
Sep 1, 2018
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
getters and setters werk
parent
92934cb7
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
client/client.js
+9
-28
9 additions, 28 deletions
client/client.js
client/divtools.js
+14
-0
14 additions, 0 deletions
client/divtools.js
client/index.html
+1
-0
1 addition, 0 deletions
client/index.html
server.js
+42
-18
42 additions, 18 deletions
server.js
src/ui/terminal.js
+1
-0
1 addition, 0 deletions
src/ui/terminal.js
with
67 additions
and
46 deletions
client/client.js
+
9
−
28
View file @
047102bb
...
@@ -10,6 +10,7 @@ var lastPos = {}
...
@@ -10,6 +10,7 @@ var lastPos = {}
// drawing / div-ing
// drawing / div-ing
var
wrapper
=
{}
var
wrapper
=
{}
var
dt
=
new
DT
()
// div tools
// client fns
// client fns
...
@@ -104,9 +105,9 @@ function buildMenu(tree) {
...
@@ -104,9 +105,9 @@ function buildMenu(tree) {
}
}
function
addReps
(
reps
){
function
addReps
(
reps
){
// when adding links, we'll have to add all and then draw links
for
(
rep
in
reps
){
for
(
rep
in
reps
){
addRep
(
reps
[
rep
])
addRep
(
reps
[
rep
])
console
.
log
(
reps
[
rep
])
}
}
}
}
...
@@ -137,36 +138,16 @@ function addRep(rep) {
...
@@ -137,36 +138,16 @@ function addRep(rep) {
rep
.
ui
.
domElem
=
domElem
rep
.
ui
.
domElem
=
domElem
// WRITE UI ELEMENTS
// WRITE UI ELEMENTS
var
dat
Elem
=
document
.
createElement
(
'
div
'
)
var
ui
Elem
=
document
.
createElement
(
'
div
'
)
dat
Elem
.
className
=
'
inside
'
ui
Elem
.
className
=
'
inside
'
var
datui
=
new
dat
.
GUI
({
autoplace
:
false
})
// rolling through the json object
// rolling through the json object
console
.
log
(
rep
)
for
(
key
in
rep
.
state
)
{
for
(
key
in
rep
.
state
)
{
// can handle up to one layer of nested objects
console
.
log
(
key
)
if
(
typeof
rep
.
state
[
key
]
==
'
object
'
&&
rep
.
state
[
key
]
!==
null
)
{
var
fold
=
datui
.
addFolder
(
key
)
for
(
twokey
in
rep
.
state
[
key
])
{
if
(
typeof
rep
.
state
[
key
][
twokey
]
==
'
object
'
&&
rep
.
state
[
key
][
twokey
]
!==
null
)
{
console
.
log
(
'
two layers of settings!
'
)
}
else
{
var
newi
=
fold
.
add
(
rep
.
state
[
key
],
twokey
)
newi
.
folder
=
key
.
toString
()
newi
.
onFinishChange
(
function
(
value
)
{
newState
(
rep
)
})
}
}
fold
.
open
()
}
else
{
var
newi
=
datui
.
add
(
rep
.
state
,
key
)
newi
.
onFinishChange
(
function
(
value
)
{
newState
(
rep
)
})
}
}
}
dat
Elem
.
appendChild
(
datui
.
dom
Elem
ent
)
rep
.
ui
.
dom
Elem
.
appendChild
(
ui
Elem
)
// add this as well to the representation obj
// add this as well to the representation obj
rep
.
ui
.
dat
=
datui
// WRITE INPUTS AND OUTPUTS
// WRITE INPUTS AND OUTPUTS
var
inElem
=
document
.
createElement
(
'
div
'
)
var
inElem
=
document
.
createElement
(
'
div
'
)
...
@@ -190,7 +171,7 @@ function addRep(rep) {
...
@@ -190,7 +171,7 @@ function addRep(rep) {
// 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
)
domElem
.
appendChild
(
dat
Elem
)
domElem
.
appendChild
(
ui
Elem
)
var
clearElem
=
document
.
createElement
(
'
div
'
)
var
clearElem
=
document
.
createElement
(
'
div
'
)
clearElem
.
className
=
'
clear
'
clearElem
.
className
=
'
clear
'
domElem
.
appendChild
(
clearElem
)
domElem
.
appendChild
(
clearElem
)
...
...
This diff is collapsed.
Click to expand it.
client/divtools.js
0 → 100644
+
14
−
0
View file @
047102bb
function
DT
()
{
this
.
makeLineInput
=
(
title
,
size
)
=>
{
var
div
=
document
.
createElement
(
'
div
'
)
div
.
className
=
'
uiText
'
div
.
innerHTML
=
title
return
{
domElem
:
div
}
}
return
this
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
client/index.html
+
1
−
0
View file @
047102bb
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<link
href=
"style.css"
rel=
"stylesheet"
>
<link
href=
"style.css"
rel=
"stylesheet"
>
<script
type=
"text/javascript"
src=
"dat.gui.js"
></script>
<script
type=
"text/javascript"
src=
"dat.gui.js"
></script>
<script
type=
"text/javascript"
src=
"dummies.js"
></script>
<script
type=
"text/javascript"
src=
"dummies.js"
></script>
<script
type=
"text/javascript"
src=
"divtools.js"
></script>
<script
type=
"text/javascript"
src=
"client.js"
></script>
<script
type=
"text/javascript"
src=
"client.js"
></script>
</body>
</body>
...
...
This diff is collapsed.
Click to expand it.
server.js
+
42
−
18
View file @
047102bb
...
@@ -39,7 +39,7 @@ wss.on('connection', (ws) => {
...
@@ -39,7 +39,7 @@ wss.on('connection', (ws) => {
// say hello
// say hello
socketSend
(
'
console
'
,
'
hello client
'
)
socketSend
(
'
console
'
,
'
hello client
'
)
// send current config
// send current config
s
ocketSend
(
'
put reps
'
,
m
odules
)
s
endM
odules
(
)
console
.
log
(
'
socket open on 8081
'
)
console
.
log
(
'
socket open on 8081
'
)
ws
.
on
(
'
message
'
,
(
evt
)
=>
{
ws
.
on
(
'
message
'
,
(
evt
)
=>
{
socketRecv
(
evt
)
socketRecv
(
evt
)
...
@@ -110,6 +110,14 @@ var modules = new Array()
...
@@ -110,6 +110,14 @@ var modules = new Array()
var
term
=
addModule
(
'
./src/ui/terminal.js
'
)
var
term
=
addModule
(
'
./src/ui/terminal.js
'
)
var
gcode
=
addModule
(
'
./src/parsing/gcode.js
'
)
var
gcode
=
addModule
(
'
./src/parsing/gcode.js
'
)
console
.
log
(
'
here setting term state txt to new txt
'
)
term
.
state
.
txt
=
"
new txt
"
console
.
log
(
'
here setting term state text to new txt
'
)
term
.
state
.
text
=
"
new text
"
gcode
.
state
.
g0speed
=
1255
term
.
outputs
.
lineOut
.
attach
(
gcode
.
inputs
.
lineIn
)
term
.
outputs
.
lineOut
.
attach
(
gcode
.
inputs
.
lineIn
)
// to add UI vars to prgmem / save them
// to add UI vars to prgmem / save them
...
@@ -125,6 +133,13 @@ gcode.ui.top = 200
...
@@ -125,6 +133,13 @@ gcode.ui.top = 200
console
.
log
(
'
modules at prgmem start
'
,
modules
)
console
.
log
(
'
modules at prgmem start
'
,
modules
)
function
sendModules
(){
for
(
md
in
modules
){
console
.
log
(
modules
[
md
].
state
)
}
socketSend
(
'
put reps
'
,
modules
)
}
/*
/*
PROGRAM EDITING
PROGRAM EDITING
...
@@ -145,30 +160,24 @@ function addModule(path) {
...
@@ -145,30 +160,24 @@ function addModule(path) {
console
.
log
(
'
adding module
'
,
mod
.
description
.
name
,
'
id
'
,
mod
.
id
)
console
.
log
(
'
adding module
'
,
mod
.
description
.
name
,
'
id
'
,
mod
.
id
)
// get and set skullduggery
// get and set skullduggery
for
(
item
in
mod
.
state
)
{
for
(
var
item
in
mod
.
state
)
{
// turn into 'don't f with' property
// turn into 'don't f with' property
mod
.
state
[
'
_
'
+
item
]
=
mod
.
state
[
item
]
mod
.
state
[
'
_
'
+
item
.
toString
()
]
=
mod
.
state
[
item
]
//
make oj ptr into object
//
add a setter to hit _ when this
mod
.
state
[
item
]
=
{}
addSetGet
(
mod
.
state
,
item
)
//
write getter and setter for object
//
Object.defineProperty(mod.state, item, {
Object
.
defineProperty
(
mod
.
state
,
item
,
{
// set: function(x)
{
set
:
function
(
x
)
{
// console.log(this['_' + item])
this
[
'
_
'
+
item
]
=
x
//
console.log(place)
console
.
log
(
'
setting
'
,
item
,
'
to
'
,
x
)
//
}
}
//
}
)
})
/*
Object.defineProperty(mod.state, item, {
Object.defineProperty(mod.state, item, {
get: function() {
get: function() {
console.log('getting', item)
console.log('getting', item)
return this['_' + item]
return this['_' + item]
}
}
})
})
// HERE:
/*
still: how do we use these setters in module? make .onChange type ?
- see terminal.js for hook example ?
now we re-write server side to look for _objects,
probably write our own setter? no more dat?
*/
*/
}
}
...
@@ -182,6 +191,21 @@ function addModule(path) {
...
@@ -182,6 +191,21 @@ function addModule(path) {
}
}
}
}
function
addSetGet
(
obj
,
item
){
Object
.
defineProperty
(
obj
,
item
,
{
set
:
function
(
x
)
{
this
[
'
_
'
+
item
]
=
x
console
.
log
(
'
SET
'
,
item
,
this
[
'
_
'
+
item
])
}
})
Object
.
defineProperty
(
obj
,
item
,
{
get
:
function
()
{
console
.
log
(
'
GET
'
,
item
,
this
[
'
_
'
+
item
])
return
this
[
'
_
'
+
item
]
}
})
}
function
newState
(
data
)
{
function
newState
(
data
)
{
// of one module
// of one module
// should just recv all state, walk tree for differences
// should just recv all state, walk tree for differences
...
...
This diff is collapsed.
Click to expand it.
src/ui/terminal.js
+
1
−
0
View file @
047102bb
...
@@ -12,6 +12,7 @@ function Terminal() {
...
@@ -12,6 +12,7 @@ function Terminal() {
// object state
// object state
this
.
state
=
{
this
.
state
=
{
txt
:
'
ln
'
,
text
:
'
line to out
'
text
:
'
line to out
'
}
}
...
...
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