Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OSE
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
OSE
Commits
c8812dc2
Commit
c8812dc2
authored
Mar 5, 2019
by
Laurent Lecluse
Browse files
Options
Downloads
Patches
Plain Diff
Finalisation de l'interface de test de la formule de calcul : gestion des fractions
parent
e9e27d03
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!35
B8.1
,
!26
Motif modification service
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
code/test1.php
+42
-3
42 additions, 3 deletions
code/test1.php
module/Application/view/application/formule/test-saisir.phtml
+26
-6
26 additions, 6 deletions
...le/Application/view/application/formule/test-saisir.phtml
public/js/app.js
+37
-12
37 additions, 12 deletions
public/js/app.js
with
105 additions
and
21 deletions
code/test1.php
+
42
−
3
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
This diff is collapsed.
Click to expand it.
module/Application/view/application/formule/test-saisir.phtml
+
26
−
6
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
'
:
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
'
:
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
));
}
});
...
...
This diff is collapsed.
Click to expand it.
public/js/app.js
+
37
−
12
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
;
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
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