Done issue #5 and #3

Took 9 minutes
This commit is contained in:
2020-10-04 13:24:24 +02:00
parent f3cc31e9b6
commit ab03d3a263
2 changed files with 29 additions and 9 deletions

15
vendor/js/faq.js vendored
View File

@ -100,9 +100,18 @@ function openReadMoreModal( id )
readMoreModalTitle.html( 'Question from: Anonymous' );
request( 'getQuestion', {"question_id":id}, function( result )
{
let _answer = '';
if( result.data.answer === null || result.data.answer.length < 5 )
{
_answer = 'So far there is no answer to this question.';
}
else
{
_answer = result.data.answer;
}
readMoreModalTitle.html( 'Question from: ' + result.data.created_by );
readMoreModalText.html( '<strong>Question</strong><br>' + result.data.question +
'<hr><strong>Answer</strong><br>' + result.data.answer
'<hr><strong>Answer</strong><br>' + _answer
);
}, function() {
readMoreModalText.html( 'An error occurred, please try again later!' );
@ -120,6 +129,10 @@ function openAnswerModal( id )
request( 'getQuestion', {"question_id":id}, function( result )
{
readMoreModalTitle.html( 'Answer ' + result.data.created_by + " question" );
if( result.data.answer !== null && result.data.answer.length > 5 )
{
answerText.val( result.data.answer );
}
answer_id = result.data.id;
}, function() {
answerErrorMsg.html( 'An error occurred, please try again!' );