Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
doodle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Arnaud
doodle
Commits
8cb2f1a8
Commit
8cb2f1a8
authored
Feb 21, 2018
by
Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pas mal
parent
e40fdfff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
45 deletions
+74
-45
doodle.js
assets/lib/doodle/js/doodle.js
+74
-45
No files found.
assets/lib/doodle/js/doodle.js
View file @
8cb2f1a8
...
@@ -16,6 +16,10 @@
...
@@ -16,6 +16,10 @@
const
EDITMODE
=
this
.
config
.
editMode
;
const
EDITMODE
=
this
.
config
.
editMode
;
this
.
initLoad
=
()
=>
{
this
.
initLoad
=
()
=>
{
console
.
log
(
'INIT'
);
//Vide le localStorage au chargement de la page
localStorage
.
clear
();
this
.
getJsonData
();
this
.
getJsonData
();
if
(
!
this
.
json
)
{
if
(
!
this
.
json
)
{
console
.
warn
(
'Invalid Json data'
);
console
.
warn
(
'Invalid Json data'
);
...
@@ -89,13 +93,6 @@
...
@@ -89,13 +93,6 @@
return
tbodyFinal
.
html
();
return
tbodyFinal
.
html
();
};
};
function
createInputBox
(
hour
,
day
)
{
let
dayFormat
=
moment
(
day
,
'DD/MM/YYYY'
).
format
(
'DDMMYYYY'
);
console
.
log
(
dayFormat
);
return
"<input type='checkbox' data-check="
+
dayFormat
+
'_'
+
hour
+
" />"
}
/**
/**
* Create body content
* Create body content
* @param index
* @param index
...
@@ -107,12 +104,11 @@
...
@@ -107,12 +104,11 @@
for
(
let
key
in
this
.
hours
)
{
for
(
let
key
in
this
.
hours
)
{
if
(
this
.
json
[
index
].
includes
(
this
.
hours
[
key
]))
{
if
(
this
.
json
[
index
].
includes
(
this
.
hours
[
key
]))
html
=
'<td>'
+
createInputBox
(
this
.
hours
[
key
],
index
)
+
'</td>'
;
html
=
'<td>'
+
createInputBox
(
this
.
hours
[
key
],
index
)
+
'</td>'
;
}
else
{
else
html
=
'<td></td>'
;
html
=
'<td></td>'
;
}
plop
=
$td
.
append
(
html
);
plop
=
$td
.
append
(
html
);
}
}
...
@@ -120,6 +116,18 @@
...
@@ -120,6 +116,18 @@
};
};
/**
/**
* Creer l'input
* @param hour
* @param day
* @returns {string}
*/
function
createInputBox
(
hour
,
day
)
{
let
dayFormat
=
moment
(
day
,
'DD/MM/YYYY'
).
format
(
'DDMMYYYY'
);
return
"<input type='checkbox' data-check="
+
dayFormat
+
'_'
+
hour
+
" />"
}
/**
* Create table header for hours
* Create table header for hours
* @returns {string}
* @returns {string}
*/
*/
...
@@ -127,8 +135,25 @@
...
@@ -127,8 +135,25 @@
let
$thead
=
$
(
'<thead>'
);
let
$thead
=
$
(
'<thead>'
);
let
$tr
=
$
(
'<tr>'
);
let
$tr
=
$
(
'<tr>'
);
let
html
,
theadFinal
;
let
html
,
theadFinal
;
let
finalSortedTab
=
[];
// Permet de mettre un 'h' pour les heures/minutes
this
.
hours
.
forEach
(
(
el
,
index
)
=>
{
if
(
el
.
split
(
':'
).
length
===
2
)
{
console
.
log
(
el
.
split
(
':'
));
let
test
=
el
.
split
(
':'
);
let
final
=
test
[
0
]
+
'h'
+
test
[
1
];
finalSortedTab
.
push
(
final
);
}
else
{
finalSortedTab
.
push
(
el
)
}
/*console.log(finalSortedTab.sort());*/
});
let
hoursSorted
=
this
.
hours
.
sort
();
let
hoursSorted
=
finalSortedTab
.
sort
();
for
(
let
index
in
hoursSorted
)
{
for
(
let
index
in
hoursSorted
)
{
...
@@ -164,6 +189,7 @@
...
@@ -164,6 +189,7 @@
for
(
let
index
in
this
.
json
[
key
])
{
for
(
let
index
in
this
.
json
[
key
])
{
if
(
!
this
.
hours
.
includes
(
this
.
json
[
key
][
index
]))
{
if
(
!
this
.
hours
.
includes
(
this
.
json
[
key
][
index
]))
{
this
.
hours
.
push
(
this
.
json
[
key
][
index
]);
this
.
hours
.
push
(
this
.
json
[
key
][
index
]);
this
.
hours
.
sort
();
}
}
}
}
}
}
...
@@ -215,44 +241,17 @@
...
@@ -215,44 +241,17 @@
}
}
};
};
/**
* Generate JSON
* @param date
* @param heure
* @param isChecked
*/
this
.
createJSON
=
(
date
,
heure
,
isChecked
)
=>
{
this
.
createJSON
=
(
date
,
heure
,
isChecked
)
=>
{
/*let json = {};
console.log(isChecked);
if (localStorage.getItem('test')) {
console.log('YEnA');
json = JSON.parse(localStorage.getItem('test'));
} else {
console.log('Empty');
json = {
date : '',
hour: []
};
}
console.log(json.date);
/!**
* Check si je suis lo
*!/
if ($.inArray(heure, json.hour) === -1) {
console.log('Jsuis pas encore lo');
json.date = date;
json.hour.push(heure);
}
localStorage.setItem('test', JSON.stringify(json));
console.log(json);*/
let
json
=
{};
let
json
=
{};
if
(
localStorage
.
getItem
(
'test'
))
{
if
(
localStorage
.
getItem
(
'test'
))
{
console
.
log
(
'YEnA'
);
json
=
JSON
.
parse
(
localStorage
.
getItem
(
'test'
));
json
=
JSON
.
parse
(
localStorage
.
getItem
(
'test'
));
}
}
...
@@ -262,13 +261,43 @@
...
@@ -262,13 +261,43 @@
if
(
json
[
date
]
===
undefined
)
{
if
(
json
[
date
]
===
undefined
)
{
json
[
date
]
=
[
heure
];
json
[
date
]
=
[
heure
];
}
else
{
}
else
{
json
[
date
].
push
(
heure
);
if
(
isChecked
)
{
json
[
date
].
push
(
heure
);
json
[
date
].
sort
();
}
}
}
else
{
if
(
!
isChecked
)
{
console
.
log
(
'Je suis lo et pa check, alor jdegoge'
);
//Supprime l'entrée dans le JSON
let
index
=
json
[
date
].
indexOf
(
heure
);
if
(
index
>
-
1
)
{
json
[
date
].
splice
(
index
,
1
);
}
//Supprime la clé dans le JSON si le tableau est vide
if
(
json
[
date
].
length
===
0
)
{
console
.
log
(
'Jsui vide lo'
);
delete
json
[
date
];
}
}
}
}
}
localStorage
.
setItem
(
'test'
,
JSON
.
stringify
(
json
));
localStorage
.
setItem
(
'test'
,
JSON
.
stringify
(
json
));
console
.
log
(
json
);
console
.
log
(
json
);
let
$input
=
$
(
'<input type="hidden">'
);
//Check si l'input est créé
if
(
$
(
'#jsonGenerate'
).
length
!==
0
)
{
$input
.
val
(
JSON
.
stringify
(
json
));
}
else
{
$input
.
val
(
JSON
.
stringify
(
json
)).
attr
(
'id'
,
'jsonGenerate'
);
$
(
'#myTables'
).
after
(
$input
);
}
};
};
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment