Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pado
Behira Younes
Commits
5f481634
Commit
5f481634
authored
Oct 29, 2020
by
Ratnadeep Rajendra Kharade
Browse files
added formulas to calculate time based on combination
parent
d9101a16
Pipeline
#1116
passed with stages
in 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
public/index.js
View file @
5f481634
// Object which stores all the user selected/entered values
let
inputObj
=
{
textChoice
:
'
manual
'
,
// choice of text entry initially set as manual. Can have values manual, calculated
text
:
''
,
// User entered text in case of manual
textChoice
:
'
manual
'
,
// choice of text entry initially set as manual. Can have values manual, calculated
text
:
''
,
// User entered text in case of manual
numberOfCharacters
:
''
,
// number of characters in text. Either from user entered text or user entered number
schoolLevel
:
''
,
// Value of school level selected from dropdown
category
:
''
// Value of category selected from dropdown
schoolLevel
:
''
,
// Value of school level selected from dropdown
category
:
''
// Value of category selected from dropdown
};
...
...
@@ -110,13 +110,13 @@ function showFeedbackForm() {
// function schoolLevelChangeEvent: listens for change in school level dropdown
// and sets selected value to property schoolLevel on inputObj
function
schoolLevelChangeEvent
(
event
)
{
inputObj
.
schoolLevel
=
parseInt
(
event
.
target
.
value
)
;
inputObj
.
schoolLevel
=
event
.
target
.
value
;
}
// function categoryChangeEvent: listens for change in category dropdown
// and sets selected value to property category on inputObj
function
categoryChangeEvent
(
event
)
{
inputObj
.
category
=
parseInt
(
event
.
target
.
value
)
;
inputObj
.
category
=
event
.
target
.
value
;
}
...
...
@@ -129,18 +129,85 @@ function calculateReadingTime() {
//variable x which holds final reading time in minutes
let
x
=
0
;
console
.
log
(
inputObj
);
// TODO: logic or algorithm for calculating reading time goes here
// logic or algorithm for calculating reading time goes here
// inputObj.numberOfCharacters has number of characters (number data type)
// inputObj.schoolLevel has level of school (
number
data type)
// inputObj.category has category of reader (
number
data type)
// inputObj.schoolLevel has level of school (
string
data type)
// inputObj.category has category of reader (
string
data type)
// example calculation
x
=
(
inputObj
.
numberOfCharacters
*
inputObj
.
schoolLevel
*
inputObj
.
category
);
//x = (inputObj.numberOfCharacters * inputObj.schoolLevel * inputObj.category);
let
combination
=
inputObj
.
schoolLevel
+
''
+
inputObj
.
category
;
console
.
log
(
combination
);
let
C
=
inputObj
.
numberOfCharacters
;
switch
(
combination
)
{
case
'
11
'
:
x
=
(
0.7165
*
C
)
+
(
172.8332
*
0.690
)
-
125.9143
;
break
;
case
'
12
'
:
x
=
(
0.3463
*
C
)
+
(
185.4177
*
0.249
)
-
62.0577
;
break
;
case
'
13
'
:
x
=
(
0.4967
*
C
)
+
(
223.3422
*
0.386
)
-
101.3559
;
break
;
case
'
14
'
:
x
=
(
0.6489
*
C
)
+
(
195.7637
*
0.528
)
-
120.8358
;
break
;
case
'
15
'
:
x
=
(
0.7165
*
C
)
+
(
172.8332
*
0.690
)
-
125.9143
;
break
;
case
'
21
'
:
x
=
(
0.5007
*
C
)
+
(
703.686
*
0.505
)
-
358.5641
;
break
;
case
'
22
'
:
x
=
(
0.3135
*
C
)
+
(
902.8845
*
0.30
)
-
285.855
;
break
;
case
'
23
'
:
x
=
(
0.3396
*
C
)
+
(
956.5228
*
0.329
)
-
326.4739
;
break
;
case
'
24
'
:
x
=
(
0.3797
*
C
)
+
(
857.5144
*
0.378
)
-
328.6899
;
break
;
case
'
25
'
:
x
=
(
0.5007
*
C
)
+
(
703.686
*
0.505
)
-
358.5641
;
break
;
case
'
31
'
:
x
=
(
0.3524
*
C
)
+
(
563.8412
*
0.42
)
-
196.8003
;
break
;
case
'
32
'
:
x
=
(
0.1941
*
C
)
+
(
671.9616
*
0.204
)
-
131.0749
;
break
;
case
'
33
'
:
x
=
(
0.2432
*
C
)
+
(
712.2978
*
0.263
)
-
177.29
;
break
;
case
'
34
'
:
x
=
(
0.2965
*
C
)
+
(
628.5916
*
0.34
)
-
189.2485
;
break
;
case
'
35
'
:
x
=
(
0.3524
*
C
)
+
(
563.8412
*
0.42
)
-
196.8003
;
break
;
case
'
41
'
:
x
=
(
0.3445
*
C
)
+
(
1315.1448
*
0.357
)
-
459.0464
;
break
;
case
'
42
'
:
x
=
(
0.2003
*
C
)
+
(
51421.0975
*
0.206
)
-
290.0477
;
break
;
case
'
43
'
:
x
=
(
0.2289
*
C
)
+
(
1389.9964
*
0.24
)
-
325.0492
;
break
;
case
'
44
'
:
x
=
(
0.2842
*
C
)
+
(
1471.1005
*
0.298
)
-
431.9652
;
break
;
case
'
45
'
:
x
=
(
0.3445
*
C
)
+
(
1315.1448
*
0.357
)
-
459.0464
;
break
;
default
:
x
=
'
error
'
;
break
;
}
// set value to html element
var
s
=
document
.
getElementById
(
'
reading-time-element
'
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment