You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/extension/background.js
+47-33Lines changed: 47 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -22,48 +22,60 @@ function createTabObj(title) {
22
22
},
23
23
};
24
24
}
25
-
// once state is modified (when user does something with app), a step appears in actionContainer.jsx column. That current state snapshot is added to our hierarchy object. That is what the buildHierarchy function is for. It takes in the entire tabObj, which has a hierarcy object as a property within it. Then we build this hierarchy object so that d3 can render graphs in our extension
26
-
functionbuildHierarchy(obj,newNode){
27
-
// whenever we receive a snapshot from contentScript.js via message, we execute this function
28
-
//* if empty on extension UI is clicked hierarchy needs to be reset to an object
29
-
letnum=1;
30
-
classd3Node{
31
-
constructor(num,obj){
32
-
this.name=num++;
25
+
26
+
constmakeNewNode=()=>{
27
+
letnum=0;
28
+
29
+
returnclassNode{
30
+
constructor(obj){
31
+
this.index=num+=1;
33
32
this.stateSnapshot=obj;
34
33
this.children=[];
35
34
}
35
+
};
36
+
}
37
+
constNode=makeNewNode();
38
+
39
+
functionbuildHierachy(tabObj,newNode){
40
+
if(!tabObj.currLocation){
41
+
tabObj.currLocation=newNode;
42
+
tabObj.hierachy=newNode;
43
+
}else{
44
+
tabObj.currLocation.children.push(newNode);
45
+
tabObj.currLocation=newNode;
36
46
}
37
-
38
-
obj.hierarchy
39
-
/* properties inside this object absolutely requires:
40
-
name: string (the first state snapshot has to be a root)
//! once state is modified (when user does something with app), a step appears in actionContainer.jsx column. That current state snapshot is added to our hierarchy object. That is what the buildHierarchy function is for. It takes in the entire tabObj, which has a hierarcy object as a property within it. Then we build this hierarchy object so that d3 can render graphs in our extension
67
+
// whenever we receive a snapshot from contentScript.js via message, we execute this function
68
+
//* if empty on extension UI is clicked hierarchy needs to be reset to an object
44
69
45
70
// each time a statesnapshot is added, this gets incremented otherwise it will be decremented
46
71
// we need to find a way to traverse through the object to know which node the user is on so we can add a new state snapshot in the right location
47
72
// could we potentially have a variable in timejump function (timeJump.js in the package) that our function can work with --> contentScript.js has access to it --> we can access that variable message;
48
-
stateCount=1;
49
-
50
-
classstateNode{
51
-
52
-
constructor(){
53
-
this.name=`state${stateCount}`;
54
-
this.stateSnapshot={};
55
-
this.children=[];
56
-
}
57
-
}
58
-
59
73
60
74
// create a helper function that groups all the snapshots underneath each other
61
75
// current state snapshot
62
76
// needs to be supplied by the UI
63
77
// also need to figure out how we would traverse through the big ass object to find the current state
0 commit comments