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
09104bad
Commit
09104bad
authored
Oct 29, 2020
by
Ratnadeep Rajendra Kharade
Browse files
changed variable textLngth to numberOfCharacters
parent
08addb6a
Pipeline
#1114
passed with stages
in 11 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
public/index.js
View file @
09104bad
...
...
@@ -2,7 +2,7 @@
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
textLength
:
''
,
// number of characters in text. Either from user entered text or user entered number
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
};
...
...
@@ -30,7 +30,7 @@ function toggleElement(id) {
// function handleTextAreaChange: captures the changes as user enters the text and gets the length
// and sets number of characters to property
textLength
on inputObj
// and sets number of characters to property
numberOfCharacters
on inputObj
function
handleTextAreaChange
()
{
let
value
=
document
.
getElementById
(
"
manual-text-entry
"
).
value
;
inputObj
.
text
=
value
;
...
...
@@ -49,15 +49,15 @@ function removeSpecialCharacters(str) {
// function handleCharacterInputChange: captures changes in number of characters input field
// and sets number of characters to property
textLength
on inputObj
// and sets number of characters to property
numberOfCharacters
on inputObj
function
handleCharacterInputChange
()
{
let
value
=
document
.
getElementById
(
"
inputTextCharacters
"
).
value
;
setCharacterLength
(
value
);
}
// function setCharacterLength: sets number of characters to property
textLength
on inputObj
// function setCharacterLength: sets number of characters to property
numberOfCharacters
on inputObj
function
setCharacterLength
(
characters
)
{
inputObj
.
textLength
=
parseInt
(
characters
);
inputObj
.
numberOfCharacters
=
parseInt
(
characters
);
}
...
...
@@ -73,7 +73,9 @@ function isFormValid() {
document
.
getElementById
(
'
textarea-validation
'
).
style
.
display
=
'
none
'
;
}
if
(
inputObj
.
textChoice
===
'
calculated
'
&&
(
inputObj
.
textLength
===
''
||
inputObj
.
textLength
===
0
))
{
if
(
inputObj
.
textChoice
===
'
calculated
'
&&
(
inputObj
.
textLenumberOfCharactersngth
===
''
||
inputObj
.
numberOfCharacters
===
0
))
{
invalidFields
++
;
document
.
getElementById
(
'
textCharacters-validation
'
).
style
.
display
=
'
block
'
;
}
else
{
...
...
@@ -130,13 +132,13 @@ function calculateReadingTime() {
console
.
log
(
inputObj
);
// TODO: logic or algorithm for calculating reading time goes here
// inputObj.
textLength
has number of characters (number data type)
// 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)
// example calculation
x
=
(
inputObj
.
textLength
*
inputObj
.
schoolLevel
*
inputObj
.
category
);
x
=
(
inputObj
.
numberOfCharacters
*
inputObj
.
schoolLevel
*
inputObj
.
category
);
...
...
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