Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DP_projet
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VILLAUME Lucas
DP_projet
Commits
7e1be5a3
Commit
7e1be5a3
authored
1 year ago
by
VILLAUME Lucas
Browse files
Options
Downloads
Patches
Plain Diff
fct pour lire JSON
parent
e90439c3
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
modele/Cellule.js
+6
-0
6 additions, 0 deletions
modele/Cellule.js
modele/Component.js
+4
-0
4 additions, 0 deletions
modele/Component.js
modele/Document.js
+15
-0
15 additions, 0 deletions
modele/Document.js
modele/Feuille.js
+17
-0
17 additions, 0 deletions
modele/Feuille.js
with
42 additions
and
0 deletions
modele/Cellule.js
+
6
−
0
View file @
7e1be5a3
const
Component
=
require
(
"
./Component
"
);
const
Component
=
require
(
"
./Component
"
);
const
Nombre
=
require
(
"
./Nombre
"
);
class
Cellule
extends
Component
{
class
Cellule
extends
Component
{
...
@@ -21,6 +22,11 @@ class Cellule extends Component{
...
@@ -21,6 +22,11 @@ class Cellule extends Component{
expression
:
this
.
#expression
.
toJSON
()
//voir si on garde expression ou si on met le type d'expression (ex nombre: 12)
expression
:
this
.
#expression
.
toJSON
()
//voir si on garde expression ou si on met le type d'expression (ex nombre: 12)
}
}
}
}
readJSON
(
json
){
//TODO: gerer les autres expressions par la suite
this
.
#expression
=
new
Nombre
(
json
.
expression
);
}
}
}
module
.
exports
=
Cellule
;
module
.
exports
=
Cellule
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modele/Component.js
+
4
−
0
View file @
7e1be5a3
...
@@ -8,6 +8,10 @@ class Component{
...
@@ -8,6 +8,10 @@ class Component{
getNom
(){
getNom
(){
return
this
.
#nom
;
return
this
.
#nom
;
}
}
setNom
(
name
){
this
.
#nom
=
name
;
}
}
}
module
.
exports
=
Component
;
module
.
exports
=
Component
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modele/Document.js
+
15
−
0
View file @
7e1be5a3
...
@@ -67,6 +67,21 @@ class Document extends Component{
...
@@ -67,6 +67,21 @@ class Document extends Component{
}
}
}
}
readJSON
(
json
){
super
.
setNom
(
json
.
nom
);
this
.
#auteur
=
json
.
auteur
;
this
.
#id
=
json
.
id
;
this
.
#dateCreation
=
json
.
dateCreation
;
this
.
#dateModification
=
json
.
dateModification
;
this
.
clearFeuilles
();
json
.
feuilles
.
forEach
(
feuille
=>
{
let
f
=
new
Feuille
(
this
);
f
.
readJSON
(
feuille
);
this
.
addFeuille
(
f
);
});
}
}
}
module
.
exports
=
Document
;
module
.
exports
=
Document
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modele/Feuille.js
+
17
−
0
View file @
7e1be5a3
const
Component
=
require
(
"
./Component
"
);
const
Component
=
require
(
"
./Component
"
);
const
Cellule
=
require
(
"
./Cellule
"
);
class
Feuille
extends
Component
{
class
Feuille
extends
Component
{
...
@@ -37,6 +38,22 @@ class Feuille extends Component{
...
@@ -37,6 +38,22 @@ class Feuille extends Component{
cells
:
cellsJSON
cells
:
cellsJSON
}
}
}
}
readJSON
(
json
){
super
.
setNom
(
json
.
nom
);
let
tmp
=
[];
this
.
#cells
=
[];
//reset du tableau
for
(
let
i
=
0
;
i
<
json
.
cells
.
length
;
i
++
){
json
.
cells
[
i
].
forEach
(
cell
=>
{
let
cellule
=
new
Cellule
(
cell
.
numero
);
cellule
.
readJSON
(
cell
);
tmp
.
push
(
cellule
);
});
this
.
#cells
.
push
(
tmp
);
tmp
=
[];
}
}
}
}
module
.
exports
=
Feuille
;
module
.
exports
=
Feuille
;
\ No newline at end of file
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