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
bd11bc78
Commit
bd11bc78
authored
6 years ago
by
Jake Read
Browse files
Options
Downloads
Patches
Plain Diff
good statechange update
parent
f6917db4
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
+5
-15
5 additions, 15 deletions
client/client.js
server.js
+14
-8
14 additions, 8 deletions
server.js
with
19 additions
and
23 deletions
client/client.js
+
5
−
15
View file @
bd11bc78
...
@@ -125,7 +125,7 @@ function addRep(rep) {
...
@@ -125,7 +125,7 @@ function addRep(rep) {
var
newi
=
fold
.
add
(
rep
.
state
[
key
],
twokey
)
var
newi
=
fold
.
add
(
rep
.
state
[
key
],
twokey
)
newi
.
folder
=
key
.
toString
()
newi
.
folder
=
key
.
toString
()
newi
.
onFinishChange
(
function
(
value
)
{
newi
.
onFinishChange
(
function
(
value
)
{
newState
(
rep
,
this
.
folder
,
this
.
property
,
value
)
newState
(
rep
)
})
})
}
}
}
}
...
@@ -133,7 +133,7 @@ function addRep(rep) {
...
@@ -133,7 +133,7 @@ function addRep(rep) {
}
else
{
}
else
{
var
newi
=
datui
.
add
(
rep
.
state
,
key
)
var
newi
=
datui
.
add
(
rep
.
state
,
key
)
newi
.
onFinishChange
(
function
(
value
)
{
newi
.
onFinishChange
(
function
(
value
)
{
newState
(
rep
,
null
,
this
.
property
,
value
)
newState
(
rep
)
})
})
}
}
}
}
...
@@ -167,23 +167,13 @@ function addRep(rep) {
...
@@ -167,23 +167,13 @@ function addRep(rep) {
document
.
body
.
append
(
rep
.
ui
.
domElem
)
document
.
body
.
append
(
rep
.
ui
.
domElem
)
}
}
function
newState
(
rep
,
folder
,
property
,
value
){
function
newState
(
rep
){
// better if we do this with an update event? can add event watchers to each state, fired by change?
// write brief json for state change
// yep, fire all state and write tree scrubber on other side
var
newState
=
{}
if
(
folder
){
newState
[
folder
]
=
{}
newState
[
folder
][
property
]
=
value
}
else
{
newState
[
property
]
=
value
}
var
data
=
{
var
data
=
{
id
:
rep
.
id
,
id
:
rep
.
id
,
newS
tate
:
newS
tate
s
tate
:
rep
.
s
tate
}
}
socketSend
(
'
put state
'
,
data
)
socketSend
(
'
put state
'
,
data
)
console
.
log
(
'
pushing new state
for
'
,
folder
,
property
)
console
.
log
(
'
pushing new state
'
,
data
)
}
}
// init & hookup
// init & hookup
...
...
This diff is collapsed.
Click to expand it.
server.js
+
14
−
8
View file @
bd11bc78
...
@@ -100,19 +100,25 @@ function addModule(path) {
...
@@ -100,19 +100,25 @@ function addModule(path) {
function
newState
(
data
)
{
function
newState
(
data
)
{
// should just recv all state, walk tree for differences
// should just recv all state, walk tree for differences
console
.
log
(
modules
[
data
.
id
]
)
var
os
=
modules
[
data
.
id
]
.
state
var
n
ewState
=
data
.
newS
tate
var
n
s
=
data
.
s
tate
var
id
=
data
.
id
var
id
=
data
.
id
for
(
key
in
newState
)
{
if
(
typeof
newState
[
key
]
==
'
object
'
&&
newState
[
key
]
!==
null
)
{
for
(
key
in
os
)
{
for
(
subkey
in
newState
[
key
])
{
if
(
typeof
os
[
key
]
==
'
object
'
&&
os
[
key
]
!==
null
)
{
modules
[
id
].
state
[
key
][
subkey
]
=
newState
[
key
][
subkey
]
for
(
subkey
in
os
[
key
])
{
if
(
os
[
key
][
subkey
]
!=
ns
[
key
][
subkey
]){
os
[
key
][
subkey
]
=
ns
[
key
][
subkey
]
console
.
log
(
subkey
,
'
to
'
,
ns
[
key
][
subkey
],
'
in
'
,
data
.
id
)
}
}
}
}
else
{
}
else
{
modules
[
id
].
state
[
key
]
=
newState
[
key
]
if
(
os
[
key
]
!=
ns
[
key
]){
os
[
key
]
=
ns
[
key
]
console
.
log
(
key
,
'
to
'
,
ns
[
key
],
'
in
'
,
data
.
id
)
}
}
}
}
}
console
.
log
(
modules
[
id
])
}
}
function
put
(
data
)
{
function
put
(
data
)
{
...
...
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