+
+
+
+
+
+ In the following page you can ask unlimited questions.
Your question should be contain 10 up to 500 characters.
The owner of this room then can answer your question.
+
+ You are an XXX of this room.
This means you can XXX
+
+
+
+
+
+
diff --git a/vendor/js/faq.js b/vendor/js/faq.js
index 8326bc4..bac8429 100644
--- a/vendor/js/faq.js
+++ b/vendor/js/faq.js
@@ -1,19 +1,23 @@
-errorModal = $( '#errorModal' );
-askQuestionModal = $( '#askQuestionModal' );
-readMoreModal = $( '#readMoreModal' );
-answerModal = $( '#answerModal' );
-answerText = $('#answer' );
-answerModalTitle = $('#answerModalLabel');
+const errorModal = $( '#errorModal' );
+const askQuestionModal = $( '#askQuestionModal' );
+const readMoreModal = $( '#readMoreModal' );
+const answerModal = $( '#answerModal' );
+const welcomeModal = $('#welcomeModal' );
+const welcomeModalText = $('#welcomeModalText');
+const welcomeModalClose = $('#welcomeModalClose' );
+const answerText = $('#answer' );
+const answerModalTitle = $('#answerModalLabel');
readMoreModalText = $('#readMoreModalText' );
-readMoreModalTitle = $('#readMoreModalLabel' );
-errorMsg = $( '#errorMsg' );
-askErrorMsg = $('#askErrorMsg')
-answerErrorMsg = $('#answerErrorMsg' );
-questions = $( '#questions' )
-question = $('#question' );
-askButton = $('#askBtn' );
-nickname = $('#nickname' );
+const readMoreModalTitle = $('#readMoreModalLabel' );
+const errorMsg = $( '#errorMsg' );
+const askErrorMsg = $('#askErrorMsg')
+const answerErrorMsg = $('#answerErrorMsg' );
+const questions = $( '#questions' )
+const question = $('#question' );
+const askButton = $('#askBtn' );
+const nickname = $('#nickname' );
+let is_owner = false;
function request( a_uri, a_data, a_successhandler, a_errorhandler )
{
@@ -138,6 +142,14 @@ function openAnswerModal( id )
{
answerModalTitle.html( 'Answer ' + 'XXX' + " question" );
answerErrorMsg.html( '' );
+
+ if( !is_owner )
+ {
+ errorModal.modal( 'show' );
+ errorMsg.html( 'You are not allowed to answer questions!
Ask the room-owner for permissions.' );
+ return;
+ }
+
answerModal.modal( 'show' );
request( 'getQuestion', {"question_id":id}, function( result )
@@ -236,5 +248,40 @@ function getQuestions()
);
}
-getQuestions();
-setInterval( function() { getQuestions(); }, 1500 );
\ No newline at end of file
+function welcomeMessage()
+{
+ // Starting welcome modal
+ welcomeModal.modal( 'show' );
+ welcomeModalClose.prop( 'disabled', true );
+ request( 'getWelcomeInfo', {}, function( result ) {
+ if ( result.data.is_owner === true )
+ {
+ welcomeModalText.html( 'You are the owner of this room.
This means you are allowed to ask and
answer questions!
To share your room code, use the share-url or the room-code.' );
+ is_owner = true;
+ }
+ else
+ {
+ welcomeModalText.html( 'You are an guest of this room.
This means you are allowed to ask questions.
To ask a question, click on "Ask a question", then enter your name and your question.' );
+ is_owner = false;
+ }
+ setTimeout( function() { welcomeModalClose.prop( 'disabled', false ); }, 1500 );
+ }, function()
+ {
+ is_owner = false;
+ setTimeout( function() {
+ welcomeModal.modal('hide');
+ }, 500 );
+ setTimeout( function(){
+ errorMsg.html( "Oopsie! Your user information cannot be loaded.
Try reloading the page!" );
+
+ errorModal.modal( 'show' );
+
+ }, 800 );
+ });
+
+}
+
+
+
+setInterval( function() { getQuestions(); }, 1500 );
+welcomeMessage();
\ No newline at end of file