Added room_owner and welcome message thingy(client-side)
Took 36 minutes
This commit is contained in:
79
vendor/js/faq.js
vendored
79
vendor/js/faq.js
vendored
@ -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!<br>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 );
|
||||
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.<br>This means you are allowed to ask and <strong>answer</strong> questions!<br><br>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.<br>This means you are allowed to ask questions.<br>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.<br>Try reloading the page!" );
|
||||
|
||||
errorModal.modal( 'show' );
|
||||
|
||||
}, 800 );
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setInterval( function() { getQuestions(); }, 1500 );
|
||||
welcomeMessage();
|
Reference in New Issue
Block a user