Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open-source
OSE
Commits
c8812dc2
Commit
c8812dc2
authored
Mar 05, 2019
by
Laurent Lécluse
Browse files
Finalisation de l'interface de test de la formule de calcul : gestion des fractions
parent
e9e27d03
Changes
3
Hide whitespace changes
Inline
Side-by-side
code/test1.php
View file @
c8812dc2
...
...
@@ -7,8 +7,47 @@
* @var $sl \Zend\ServiceManager\ServiceLocatorInterface
*/
$
d
=
"2015-04-30 15:11:48"
;
$
max
=
10
;
$r
=
\
DateTime
::
createFromFormat
(
'Y-m-d H:i:s'
,
$d
)
;
$r
ess
=
[]
;
var_dump
(
$r
);
\ No newline at end of file
for
(
$i
=
1
;
$i
<
$max
;
$i
++
){
for
(
$j
=
1
;
$j
<
$max
;
$j
++
){
$res
=
round
(
$i
/
$j
,
6
);
if
(
!
in_array
(
$res
,
$ress
))
{
if
(
$res
!=
round
(
$res
,
5
))
{
echo
"
$res
: '
$i
/
$j
',<br />"
;
}
$ress
[]
=
$res
;
}
}
}
$t
=
[
'1/3'
=>
0.333333
,
'1/6'
=>
0.166667
,
'1/7'
=>
0.142857
,
'1/9'
=>
0.111111
,
'2/3'
=>
0.666667
,
'2/7'
=>
0.285714
,
'2/9'
=>
0.222222
,
'3/7'
=>
0.428571
,
'4/3'
=>
1.333333
,
'4/7'
=>
0.571429
,
'4/9'
=>
0.444444
,
'5/3'
=>
1.666667
,
'5/6'
=>
0.833333
,
'5/7'
=>
0.714286
,
'5/9'
=>
0.555556
,
'6/7'
=>
0.857143
,
'7/3'
=>
2.333333
,
'7/6'
=>
1.166667
,
'7/9'
=>
0.777778
,
'8/3'
=>
2.666667
,
'8/7'
=>
1.142857
,
'8/9'
=>
0.888889
,
'9/7'
=>
1.285714
,
];
\ No newline at end of file
module/Application/view/application/formule/test-saisir.phtml
View file @
c8812dc2
...
...
@@ -370,6 +370,10 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
background-color
:
#fff8dc
;
}
.doutput
{
text-align
:
right
;
}
.debug
{
display
:
none
;
}
...
...
@@ -396,7 +400,7 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
max-width
:
20px
;
}
.debug-table
td
.zero
{
td
.zero
{
color
:
gray
;
}
...
...
@@ -426,7 +430,11 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
case
'
float
'
:
return
Util
.
stringToFloat
(
value
);
case
'
float-pourc
'
:
return
Util
.
stringToFloat
(
value
)
/
100
;
if
(
value
.
indexOf
(
'
/
'
)
!==
-
1
){
return
Util
.
stringToFloat
(
value
);
}
else
{
return
Util
.
stringToFloat
(
value
)
/
100
;
}
case
'
int
'
:
return
parseInt
(
value
);
}
...
...
@@ -445,7 +453,12 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
case
'
float
'
:
return
Util
.
floatToString
(
variable
);
case
'
float-pourc
'
:
return
Util
.
floatToString
(
variable
*
100
);
var
res
=
Util
.
floatToString
(
variable
);
if
(
res
.
indexOf
(
'
/
'
)
!==
-
1
){
return
res
;
}
else
{
return
Util
.
floatToString
(
variable
*
100
);
}
case
'
int
'
:
return
variable
.
toString
();
}
...
...
@@ -553,6 +566,11 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
}
}
var
value
=
that
.
variableToValue
(
variable
,
type
);
if
(
value
===
'
0
'
){
value
=
'
<span class="zero">0</span>
'
;
}
$
(
this
).
html
(
value
);
});
...
...
@@ -566,7 +584,6 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
affDebugInfo
:
function
(
data
)
{
var
h
=
''
;
console
.
log
(
data
);
h
+=
'
<table class="table table-bordered table-condensed table-extra-condensed debug-table">
'
;
h
+=
'
<tr><th></th>
'
;
...
...
@@ -634,8 +651,11 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
});
this
.
element
.
find
(
"
input.dinput
"
).
change
(
function
()
{
if
(
$
(
this
).
data
(
'
type
'
)
!==
'
string
'
)
{
$
(
this
).
val
(
Util
.
floatToString
(
Util
.
stringToFloat
(
$
(
this
).
val
())));
var
type
=
$
(
this
).
data
(
'
type
'
);
if
(
type
!==
'
string
'
)
{
var
variable
=
that
.
valueToVariable
(
$
(
this
).
val
(),
type
);
console
.
log
(
variable
);
$
(
this
).
val
(
that
.
variableToValue
(
variable
,
type
));
}
});
...
...
public/js/app.js
View file @
c8812dc2
...
...
@@ -225,6 +225,32 @@ Util = {
return
false
;
},
fractions
:
{
0.333333
:
'
1/3
'
,
0.166667
:
'
1/6
'
,
0.142857
:
'
1/7
'
,
0.111111
:
'
1/9
'
,
0.666667
:
'
2/3
'
,
0.285714
:
'
2/7
'
,
0.222222
:
'
2/9
'
,
0.428571
:
'
3/7
'
,
1.333333
:
'
4/3
'
,
0.571429
:
'
4/7
'
,
0.444444
:
'
4/9
'
,
1.666667
:
'
5/3
'
,
0.833333
:
'
5/6
'
,
0.714286
:
'
5/7
'
,
0.555556
:
'
5/9
'
,
0.857143
:
'
6/7
'
,
2.333333
:
'
7/3
'
,
1.166667
:
'
7/6
'
,
0.777778
:
'
7/9
'
,
2.666667
:
'
8/3
'
,
1.142857
:
'
8/7
'
,
0.888889
:
'
8/9
'
,
1.285714
:
'
9/7
'
,
},
/**
*
* @param float value
...
...
@@ -233,6 +259,11 @@ Util = {
*/
floatToString
:
function
(
value
)
{
var
test
=
Math
.
round
(
value
*
1000000
)
/
1000000
;
console
.
log
(
this
.
fractions
[
test
]);
if
(
undefined
!==
this
.
fractions
[
test
]){
return
this
.
fractions
[
test
];
}
var
locale
=
'
fr
'
;
var
options
=
{
minimumFractionDigits
:
0
,
maximumFractionDigits
:
2
,
useGrouping
:
false
};
var
formatter
=
new
Intl
.
NumberFormat
(
locale
,
options
);
...
...
@@ -244,20 +275,14 @@ Util = {
{
if
(
null
===
value
||
''
===
value
||
undefined
===
value
)
return
null
;
value
=
parseFloat
(
value
.
replace
(
'
,
'
,
'
.
'
));
if
(
value
.
indexOf
(
'
/
'
)
!==
-
1
){
value
=
value
.
split
(
'
/
'
);
value
=
Util
.
stringToFloat
(
value
[
0
])
/
Util
.
stringToFloat
(
value
[
1
]);
}
else
{
value
=
parseFloat
(
value
.
replace
(
'
,
'
,
'
.
'
));
}
return
value
;
},
/*
function stringToFloat($value)
{
if (null === $value || '' === $value) return null;
$value = str_replace([',', ' '], ['.', ''], $value);
return (float)$value;
}
*/
};
\ No newline at end of file
Write
Preview
Supports
Markdown
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