JavaScript Code Construction for recording Node Tree Changes [on hold]











up vote
-3
down vote

favorite












I have a node tree structure that renders database information in the browser using vis.js - see this. I won't use the actual table entities, but suppose it's something like:



building
floor
office
room


In particular, I am wanting to write an object that holds an array of all the node details. Each node contains the following data:



id
description
short_description
date_inserted
date_updated
db_primary_key(only upon initialisation)


Each edge holds a relation linking the id of two nodes like this:



 {from:'foo',to:'bar'}


The node tree clearly represents the underlying foreign key relations in a database. A building (root node) has 1 or more floors (children of the top node), a floor has 1 or more offices (grandchildren of the top node), an office has 1 or more rooms (great-grandchildren of the top node).



Vis.js graph has an edit function that allows the user to create nodes, update their position and I've extended this to store custom attributes (like the short_description). I'm wanting to keep track of the changes made to the data in an object like this:



var NodeTree = {
collection:{};//all node objects
toCreate:{b:,f:,o:,r:},//newly created nodes - use ids or the object itself?
toEdit:{b:,f:,o:,r:},//edited attribute of node - use ids or the object itself?
toDelete:{b:,f:,o:,r:},//deleted node from tree - use ids or the object itself?
create: function(type,node){
this.toCreate[type].push(node);
}//function to add created node?
}

var NodeEdges = {
collection:;
toCreate:{b:,f:,o:,r:},
toEdit:{b:,f:,o:,r:},
toDelete:{b:,f:,o:,r:},
create: function(type,node){
this.toCreate[type].push(node);
}
}


The idea is that the user can make changes to the Node Tree and then post these to a server that will update the database.



To put it succinctly, I have a hashmap of nodes and an array of edges written in JavaScript. I want to be able to keep a track of these changes so I can post them to the server. How do I best go about writing this in an OO way using JavaScript? I'm hoping to not have to post the entire NodeTree and NodeEdge objects.










share|improve this question















put on hold as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, IEatBagels, rolfl 9 hours ago


This question appears to be off-topic. The users who voted to close gave these specific reasons:



  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – rolfl

  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Sᴀᴍ Onᴇᴌᴀ, IEatBagels


If this question can be reworded to fit the rules in the help center, please edit the question.













  • Why the downvote?
    – LeDoc
    13 hours ago










  • The code you posted is incomplete. We can't review it.
    – 200_success
    12 hours ago










  • Ok, I'll look into it. Quite a lot of lines... I'll see if I can pull out the key parts of my code that work with the object.
    – LeDoc
    12 hours ago















up vote
-3
down vote

favorite












I have a node tree structure that renders database information in the browser using vis.js - see this. I won't use the actual table entities, but suppose it's something like:



building
floor
office
room


In particular, I am wanting to write an object that holds an array of all the node details. Each node contains the following data:



id
description
short_description
date_inserted
date_updated
db_primary_key(only upon initialisation)


Each edge holds a relation linking the id of two nodes like this:



 {from:'foo',to:'bar'}


The node tree clearly represents the underlying foreign key relations in a database. A building (root node) has 1 or more floors (children of the top node), a floor has 1 or more offices (grandchildren of the top node), an office has 1 or more rooms (great-grandchildren of the top node).



Vis.js graph has an edit function that allows the user to create nodes, update their position and I've extended this to store custom attributes (like the short_description). I'm wanting to keep track of the changes made to the data in an object like this:



var NodeTree = {
collection:{};//all node objects
toCreate:{b:,f:,o:,r:},//newly created nodes - use ids or the object itself?
toEdit:{b:,f:,o:,r:},//edited attribute of node - use ids or the object itself?
toDelete:{b:,f:,o:,r:},//deleted node from tree - use ids or the object itself?
create: function(type,node){
this.toCreate[type].push(node);
}//function to add created node?
}

var NodeEdges = {
collection:;
toCreate:{b:,f:,o:,r:},
toEdit:{b:,f:,o:,r:},
toDelete:{b:,f:,o:,r:},
create: function(type,node){
this.toCreate[type].push(node);
}
}


The idea is that the user can make changes to the Node Tree and then post these to a server that will update the database.



To put it succinctly, I have a hashmap of nodes and an array of edges written in JavaScript. I want to be able to keep a track of these changes so I can post them to the server. How do I best go about writing this in an OO way using JavaScript? I'm hoping to not have to post the entire NodeTree and NodeEdge objects.










share|improve this question















put on hold as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, IEatBagels, rolfl 9 hours ago


This question appears to be off-topic. The users who voted to close gave these specific reasons:



  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – rolfl

  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Sᴀᴍ Onᴇᴌᴀ, IEatBagels


If this question can be reworded to fit the rules in the help center, please edit the question.













  • Why the downvote?
    – LeDoc
    13 hours ago










  • The code you posted is incomplete. We can't review it.
    – 200_success
    12 hours ago










  • Ok, I'll look into it. Quite a lot of lines... I'll see if I can pull out the key parts of my code that work with the object.
    – LeDoc
    12 hours ago













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











I have a node tree structure that renders database information in the browser using vis.js - see this. I won't use the actual table entities, but suppose it's something like:



building
floor
office
room


In particular, I am wanting to write an object that holds an array of all the node details. Each node contains the following data:



id
description
short_description
date_inserted
date_updated
db_primary_key(only upon initialisation)


Each edge holds a relation linking the id of two nodes like this:



 {from:'foo',to:'bar'}


The node tree clearly represents the underlying foreign key relations in a database. A building (root node) has 1 or more floors (children of the top node), a floor has 1 or more offices (grandchildren of the top node), an office has 1 or more rooms (great-grandchildren of the top node).



Vis.js graph has an edit function that allows the user to create nodes, update their position and I've extended this to store custom attributes (like the short_description). I'm wanting to keep track of the changes made to the data in an object like this:



var NodeTree = {
collection:{};//all node objects
toCreate:{b:,f:,o:,r:},//newly created nodes - use ids or the object itself?
toEdit:{b:,f:,o:,r:},//edited attribute of node - use ids or the object itself?
toDelete:{b:,f:,o:,r:},//deleted node from tree - use ids or the object itself?
create: function(type,node){
this.toCreate[type].push(node);
}//function to add created node?
}

var NodeEdges = {
collection:;
toCreate:{b:,f:,o:,r:},
toEdit:{b:,f:,o:,r:},
toDelete:{b:,f:,o:,r:},
create: function(type,node){
this.toCreate[type].push(node);
}
}


The idea is that the user can make changes to the Node Tree and then post these to a server that will update the database.



To put it succinctly, I have a hashmap of nodes and an array of edges written in JavaScript. I want to be able to keep a track of these changes so I can post them to the server. How do I best go about writing this in an OO way using JavaScript? I'm hoping to not have to post the entire NodeTree and NodeEdge objects.










share|improve this question















I have a node tree structure that renders database information in the browser using vis.js - see this. I won't use the actual table entities, but suppose it's something like:



building
floor
office
room


In particular, I am wanting to write an object that holds an array of all the node details. Each node contains the following data:



id
description
short_description
date_inserted
date_updated
db_primary_key(only upon initialisation)


Each edge holds a relation linking the id of two nodes like this:



 {from:'foo',to:'bar'}


The node tree clearly represents the underlying foreign key relations in a database. A building (root node) has 1 or more floors (children of the top node), a floor has 1 or more offices (grandchildren of the top node), an office has 1 or more rooms (great-grandchildren of the top node).



Vis.js graph has an edit function that allows the user to create nodes, update their position and I've extended this to store custom attributes (like the short_description). I'm wanting to keep track of the changes made to the data in an object like this:



var NodeTree = {
collection:{};//all node objects
toCreate:{b:,f:,o:,r:},//newly created nodes - use ids or the object itself?
toEdit:{b:,f:,o:,r:},//edited attribute of node - use ids or the object itself?
toDelete:{b:,f:,o:,r:},//deleted node from tree - use ids or the object itself?
create: function(type,node){
this.toCreate[type].push(node);
}//function to add created node?
}

var NodeEdges = {
collection:;
toCreate:{b:,f:,o:,r:},
toEdit:{b:,f:,o:,r:},
toDelete:{b:,f:,o:,r:},
create: function(type,node){
this.toCreate[type].push(node);
}
}


The idea is that the user can make changes to the Node Tree and then post these to a server that will update the database.



To put it succinctly, I have a hashmap of nodes and an array of edges written in JavaScript. I want to be able to keep a track of these changes so I can post them to the server. How do I best go about writing this in an OO way using JavaScript? I'm hoping to not have to post the entire NodeTree and NodeEdge objects.







javascript object-oriented






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 13 hours ago

























asked 13 hours ago









LeDoc

1104




1104




put on hold as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, IEatBagels, rolfl 9 hours ago


This question appears to be off-topic. The users who voted to close gave these specific reasons:



  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – rolfl

  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Sᴀᴍ Onᴇᴌᴀ, IEatBagels


If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by 200_success, Sᴀᴍ Onᴇᴌᴀ, IEatBagels, rolfl 9 hours ago


This question appears to be off-topic. The users who voted to close gave these specific reasons:



  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – rolfl

  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Sᴀᴍ Onᴇᴌᴀ, IEatBagels


If this question can be reworded to fit the rules in the help center, please edit the question.












  • Why the downvote?
    – LeDoc
    13 hours ago










  • The code you posted is incomplete. We can't review it.
    – 200_success
    12 hours ago










  • Ok, I'll look into it. Quite a lot of lines... I'll see if I can pull out the key parts of my code that work with the object.
    – LeDoc
    12 hours ago


















  • Why the downvote?
    – LeDoc
    13 hours ago










  • The code you posted is incomplete. We can't review it.
    – 200_success
    12 hours ago










  • Ok, I'll look into it. Quite a lot of lines... I'll see if I can pull out the key parts of my code that work with the object.
    – LeDoc
    12 hours ago
















Why the downvote?
– LeDoc
13 hours ago




Why the downvote?
– LeDoc
13 hours ago












The code you posted is incomplete. We can't review it.
– 200_success
12 hours ago




The code you posted is incomplete. We can't review it.
– 200_success
12 hours ago












Ok, I'll look into it. Quite a lot of lines... I'll see if I can pull out the key parts of my code that work with the object.
– LeDoc
12 hours ago




Ok, I'll look into it. Quite a lot of lines... I'll see if I can pull out the key parts of my code that work with the object.
– LeDoc
12 hours ago















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Ellipse (mathématiques)

Quarter-circle Tiles

Mont Emei