diff --git a/vendor/js/faq.js b/vendor/js/faq.js
index 9090f05..c62b3fb 100644
--- a/vendor/js/faq.js
+++ b/vendor/js/faq.js
@@ -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( '
Question' + result.data.question +
+ '
Answer' + 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( '
' +
'
' +
- '
Subject
' +
- '
Creator
' +
- '
Text up to 100 characters
' +
- '
Read more' +
- '
Answer' +
+ '
Question
' +
+ '
From ' + result.data.questions[i].created_by + '
' +
+ '
'+ result.data.questions[i].question + '
' +
+ '
Read more' +
+ '
Answer' +
'
' +
'
' +
'
' )
}
+ 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 + '
' + result.data.questions[i].answer + '' );
+ }
+
}
@@ -188,4 +196,5 @@ function getQuestions()
);
}
-getQuestions();
\ No newline at end of file
+getQuestions();
+setInterval( function() { getQuestions(); }, 1500 );
\ No newline at end of file
diff --git a/views/Apitemplate.class.inc.php b/views/Apitemplate.class.inc.php
index 1668f63..c48b5b9 100644
--- a/views/Apitemplate.class.inc.php
+++ b/views/Apitemplate.class.inc.php
@@ -36,6 +36,7 @@ class Apitemplate
902 => 'Answer-cannot-be-set',
903 => 'wrong-parameters-given',
905 => 'User-is-not-owner',
+ 906 => 'Question-does-not-exist',
);
$text = isset( $codes[$a_code] ) ? $codes[$a_code] : "Error";
header("HTTP/1.1 $a_code $text" );