Almost done, finish line!
Took 45 minutes
This commit is contained in:
31
vendor/js/faq.js
vendored
31
vendor/js/faq.js
vendored
@ -4,9 +4,9 @@ askQuestionModal = $( '#askQuestionModal' );
|
||||
readMoreModal = $( '#readMoreModal' );
|
||||
answerModal = $( '#answerModal' );
|
||||
answerText = $('#answer' );
|
||||
answerModalTitle = $('#answerModalTitle');
|
||||
answerModalTitle = $('#answerModalLabel');
|
||||
readMoreModalText = $('#readMoreModalText' );
|
||||
readMoreModalTitle = $('#readMoreModalTitle' );
|
||||
readMoreModalTitle = $('#readMoreModalLabel' );
|
||||
errorMsg = $( '#errorMsg' );
|
||||
askErrorMsg = $('#askErrorMsg')
|
||||
answerErrorMsg = $('#answerErrorMsg' );
|
||||
@ -68,6 +68,7 @@ function askQuestion()
|
||||
function( result ){
|
||||
askErrorMsg.html( '' );
|
||||
askButton.prop( 'disabled', false );
|
||||
question.val('');
|
||||
askQuestionModal.modal( 'hide' );
|
||||
}, function( result ) {
|
||||
askButton.prop( 'disabled', false );
|
||||
@ -97,10 +98,12 @@ function openReadMoreModal( id )
|
||||
readMoreModal.modal( 'show' );
|
||||
readMoreModalText.html( 'Loading...' );
|
||||
readMoreModalTitle.html( 'Question from: Anonymous' );
|
||||
request( 'getQuestion', {"id":id}, function( result )
|
||||
request( 'getQuestion', {"question_id":id}, function( result )
|
||||
{
|
||||
readMoreModalTitle.html( 'Question from: ' + result.data.created_by );
|
||||
readMoreModalText.html( result.data.question );
|
||||
readMoreModalText.html( '<strong>Question</strong><br>' + result.data.question +
|
||||
'<hr><strong>Answer</strong><br>' + result.data.answer
|
||||
);
|
||||
}, function() {
|
||||
readMoreModalText.html( 'An error occurred, please try again later!' );
|
||||
});
|
||||
@ -114,7 +117,7 @@ function openAnswerModal( id )
|
||||
answerErrorMsg.html( '' );
|
||||
answerModal.modal( 'show' );
|
||||
|
||||
request( 'getQuestion', {"id":id}, function( result )
|
||||
request( 'getQuestion', {"question_id":id}, function( result )
|
||||
{
|
||||
readMoreModalTitle.html( 'Answer ' + result.data.created_by + " question" );
|
||||
answer_id = result.data.id;
|
||||
@ -160,15 +163,20 @@ function getQuestions()
|
||||
{
|
||||
questions.append( '<div class="col-sm-6 col-lg-4 col-md-5"><div class="card" id="q_' + result.data.questions[i].id + '" style=" margin-bottom: 10px;">' +
|
||||
' <div class="card-body">' +
|
||||
' <h5 class="card-title">Subject</h5>' +
|
||||
' <h6 class="card-subtitle mb-2 text-muted">Creator</h6>' +
|
||||
' <p class="card-text">Text up to 100 characters</p>' +
|
||||
' <a onclick="openReadMoreModal(\''+ result.data.questions[i].id + '\');" class="card-link">Read more</a>' +
|
||||
' <a onclick="openAnswerModal(\'' + result.data.questions[i].id + '\');" class="card-link">Answer</a>' +
|
||||
' <h5 class="card-title">Question</h5>' +
|
||||
' <h6 class="card-subtitle mb-2 text-muted">From ' + result.data.questions[i].created_by + '</h6>' +
|
||||
' <p class="card-text">'+ result.data.questions[i].question + '</p>' +
|
||||
' <a href="#" onclick="openReadMoreModal(\''+ result.data.questions[i].id + '\');" class="card-link">Read more</a>' +
|
||||
' <a href="#" onclick="openAnswerModal(\'' + result.data.questions[i].id + '\');" class="card-link">Answer</a>' +
|
||||
' </div>' +
|
||||
' </div>' +
|
||||
'</div> ' )
|
||||
}
|
||||
else if ( $( '#qa_' + result.data.questions[i].id ).length < 1 && result.data.questions[i].answer.length !== null )
|
||||
{
|
||||
$('#q_' + result.data.questions[i].id + ' p' ).html( result.data.questions[i].question + '<hr><span id="qa_' + result.data.questions[i].id + '">' + result.data.questions[i].answer + '</span>' );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -188,4 +196,5 @@ function getQuestions()
|
||||
);
|
||||
}
|
||||
|
||||
getQuestions();
|
||||
getQuestions();
|
||||
setInterval( function() { getQuestions(); }, 1500 );
|
Reference in New Issue
Block a user