/**
* This is an object to store some of the values after offender's dashboard is loaded
*/
var session_info = {
video_start:0,
video_started:0,
offender_staff_session_id: 0,
current_staff_id : null,
current_staff_role: null,
current_staff_title: null,
staff_changed : false,
jitsi_offender_staff_sessions_id : null,
jitsi_registration_info : null,
jitsi_staff_id : {},
}
var jisti_api = null;
var toastrOptions = {
timeOut: 15000,
closeButton: false,
positionClass: "toast-bottom-right",
}
/**
* This function shows the success (green) popup message on the screen
* @param {string} message - Success Message
*/
var successToastr = function(message) {
return;
toastr.remove()
toastr.success(message, '', toastrOptions)
}
/**
* This function shows the information (blue) popup message on the screen
* @param {string} message - Information Message
*/
var infoToastr = function(message) {
toastr.remove()
toastr.info(message, '', toastrOptions)
}
/**
* This function shows the error (red) popup message on the screen
* @param {string} message - Error Message
*/
var errorToastr = function(message) {
toastr.remove()
toastr.error(message, '', toastrOptions)
}
$(document).ready(function(){
initAb();
/**
* refresh the current page
*/
$('.js-refresh').on('click', function(){
location.reload();
})
// When the user scrolls the page, execute myFunction
// window.onscroll = function() {
// var windowWidth = $(window).width();
// if(windowWidth < 992) {
// roadMapSticky()
// }
// };
// Get the header
var header = document.getElementById("stickyHeader");
// Get the offset position of the navbar
var sticky = header.offsetTop;
/**
* Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
*/
function roadMapSticky() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
/**
* This function sets height of video and main body
*/
var setVideoHt = function() {
// var windowWidth = $(window).width();
// var infoHt = ('.nd-session-time-staff').outerHeight()
var windowHt = $(window).height();
var headerHt = $('.navbar.navbar-expand-lg').height()
var footerHt = $('.mbl-foot').outerHeight()
var headHt = headerHt + footerHt + 38
if(windowWidth < 575) {
if(!$('#navbarSupportedContent').hasClass('show')) {
$('#test').css('height', windowHt - headHt)
$('.nd-video-wrap').css('height', windowHt - headHt)
// $('#mbl_link').trigger('click')
}
}
}
// Add smooth scrolling to all links
$("a#mbl_link").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
// window.location.hash = hash;
});
} // End if
});
window.onresize = function () {
var windowWidth = $(window).width()
if (windowWidth > 576) {
setVideoHt();
}
};
setVideoHt()
});
/**
* Current is the main function of this project,
* when dashboard is loaded this function is called,
* this function loads the roadmap, gets current queue position and renders it in offender's dashboard, loads Plea form and get registration details of the offender
*
*/
var current = function(){
$('body').find('.modal-backdrop').remove()
getHistory(); /// sagun added
findCurrentStaff();
//getStaffSession();
//getStaffSessionActivities();
loadPDSuggestionForm();
getRegistrationDetails();
// getStaffSessionActivitiesUpdate();
}
/**
* to be deleted
* This function takes message as parameter and returns the html template with current time
*/
var newInfoBox = function(message){
var date = new Date();
var Hrs = date.getHours();
var Min = date.getMinutes();
var ampm = Hrs >= 12 ? 'PM' : 'AM';
Hrs = Hrs % 12;
Hrs = Hrs ? Hrs : 12; // the hour '0' should be '12'
Hrs = Hrs < 10 ? '0'+Hrs : Hrs;
Min = Min < 10 ? '0'+Min : Min;
var time = Hrs + ':' + Min + ' '+ ampm;
var template = `<div class="staff-response-box-wrap">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${time}
</p>
</div>
<div class="card new-card w-100 ml-2">
<h6 class="text-capitalize">
${message}
</h6>
</div>
</div>`;
return template;
}
// 12/20/2020
/**
* This function handles offender's session with current staff and unsubscribe session with the previous staff
*/
var findCurrentStaff = function(){
$.get(base_url+ "offender/current", function(data){
if(data.status=="failed"){
getCaseStatus();
var mess = 'The case has been closed. You will receive a confirmation email with copies of all signed documents';
// $('#first-queue-position').html("<div class='nd-queue-msg'><h5>"+mess+"</h5></div>");
var date = new Date();
var Hrs = date.getHours();
var Min = date.getMinutes();
var time = Hrs + ':' + Min;
var template = `<div class="staff-response-box-wrap">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${time}
</p>
</div>
<div class="card new-card w-100 ml-2">
<h6>
${mess}
</h6>
</div>
</div>`;
// $('#offender_content').html(template);
// $('#offender_content').html("<div class='card new-card w-auto'><h5>"+mess+"</h5></div>");
// $('#offender_content').html('');
// Todo redirect to status check screen;
return;
}
console.log(data);
if(session_info.current_staff_id == data.staff_id){
session_info.staff_changed = false;
}else{ /// if staff attending the offender changes then only we will unsubscribe or subscribe
//console.log('New session being started with a different staff '+ data.staff_slug);
infoToastr('You are now on a queue to the '+ data.staff_slug);
session_info.staff_changed = true;
if(session_info.current_staff_id!=null){
try{
unsubscribe(session_info.current_staff_id);
if(session_info.judges_clerk_id!= null){
unsubscribe(judges_clerk_id); /// need to unsubscribe
}
}catch(err){
console.log(err);
}
}
session_info.current_staff_id = data.staff_id;
session_info.judges_clerk_id = data.judges_clerk_id;
var current_video_session = 'Session with ' +data.staff_title;
session_info.current_staff_role = data.staff_slug;
session_info.current_staff_title = data.staff_title;
//alert(data.staff_slug);
subscribeStaff(data.staff_id); /// need to unsubscribe
if(data.judges_clerk_id!= null){
subscribe(data.judges_clerk_id); /// need to unsubscribe
}
$('#current-video-session').html("<div class='js-video-icon-toggle'><i class='fa fa-video-camera mr-2'></i> "+data.staff_title+"</div>")
$('#first-queue-position').html("");
}
//wait will be called
//alert("session_info.staff_changed inside find current Staff"+session_info.staff_changed);
wait(data.staff_slug);
},"json");
}
/**
* This function display's the plea form in the offender's dashboard
*/
var loadPDSuggestionForm = function(){
//alert('');
$.get(base_url+ "offender/pd-choice", function(data){
// $("#pd_choice_opinion").html(atob(data.message));
// //alert(atob(data.message));
// $("#negotiate_a_plea").bind("click", function() {
// pd_choice_opinion("negotiate_a_plea");
// });
// $("#reset_for_compliance" ).bind("click", function() {
// pd_choice_opinion("reset_for_compliance");
// });
// $("#reset_for_trial").bind("click", function() {
// pd_choice_opinion("reset_for_trial");
// });
$('#offender_plea_choose').html(atob(data.message));
},"json");
}
/**
* This function hides the plea form form the offender's dashboard
*/
var hidePDSuggestionForm = function(){
$("#pd_choice_opinion").html("");
}
/**
*
* This function handles the session with currently subscribed staff, auto starts the offender's video if the video session was previously started when the page is reloaded, and updates the offender's queue information
*/
var wait = function(slug){
$.get(base_url+ "offender/queue-position", function(data){
console.log("************************ wait function");
console.log(data.staff_id);
var notify_music = document.getElementById('queue_position_music');
// notify_music.play();
if(data.position === 1) {
//$('#first-queue-position').html("<div class='mb-4'><div class='p-3 alert alert-info'><h4>You are now in first position in the queue.</h4></div></div>")
}
session_info.offender_staff_session_id = data.offender_staff_session_id;
//alert(data.helps_plea);
if((data.helps_plea == true) ){
// loadPDSuggestionForm();
// alert('---');
}else{
hidePDSuggestionForm();
}
$('.js-centered-img-wrap').hide();
$("#first-queue-position").html(render_queue_counter(data));
//console.log(data);
//alert('');
$.get(base_url+ 'offender/get-session-id', function(data){
switch(data.status){
case "success":
console.log("this is wait after getting session id");
var offender_staff_sessions_id = data.code;
unsubscribeSession(session_info.jitsi_offender_staff_sessions_id );
if(session_info.jitsi_offender_staff_sessions_id == null ){
wasVideoStarted(offender_staff_sessions_id);
}
session_info.jitsi_offender_staff_sessions_id = offender_staff_sessions_id;
subscribeSession(offender_staff_sessions_id);
//unsubscribeSession(session_info.jitsi_offender_staff_sessions_id );
localStorage.setItem('LS_offender_staff_sessions_id', offender_staff_sessions_id);
localStorage.setItem('LS_registration_info', JSON.stringify(registration_info));
// localStorage.setItem('LS_staff_id', data.staff_id);
break;
case "error":
break;
}
},"json");
//session_info.offender_staff_session_id = data.offender_staff_session_id;
if(data.position === 1 ){ // waiting in the queue
// $('.js-centered-img-wrap').show();
console.log("communicating with staff: ");
console.log (data.staff_id);
$.get(base_url+ 'offender/natural/getStaffDetail/'+data.staff_id, function(re){
console.log(re.staff_type_title);
var resp = 'It is your turn to have a session with the '+re.staff_type_title;
$.get(base_url + "offender/was-session-started/"+ session_info.offender_staff_session_id, function (data) {
if(data.sessionStarted == null) {
$('#first-queue-position').append("<div class='nd-queue-msg'><h5>"+resp+"</h5></div>");
}
},"json");
//infoToastr("session_info.staff_changed");
},"json");
/**
* sagun
*/
// offender_staff_sessions_id
// TODO : SAGUN FIX
// var mess = 'Session started with '+session_info.current_staff_title;
// $('#offender_content').html(newInfoBox(mess));
// getStaffResonse(data.staff_id);
//getStaffSession();
//getStaffSessionActivities();
// getStaffSessionActivitiesUpdate();
//alert(registration_info.user_name);
//jist_stop();
/**
*
* Sagun need to fix
*
* getStaffResonse(data.staff_id);
if(session_info.video_start==1){
jist_stop();
jist_start(session_info.offender_staff_session_id,registration_info,data.staff_id);
}
*/
// if(session_info.video_start==2){
// jist_start(session_info.offender_staff_session_id,registration_info);
// }
// response aucha form
// user le form submit garcha form submit garcha staff lai alert janu pacha alert ayepachi staff ko corresponding form refresh huncha
// user wait garcha
// staff ko kaam bhaye pachi dashboard.php->subscribe ko call back trigger huncha
//
}
},"json");
}
/**
* This function displays the queue information such as queue position and current staff type with whome offfender is waiting
* @param {string} data - Queue data such as staff's id, staff's type, and queue position
*/
var render_queue_counter = function(data){
console.log('data queue', data)
localStorage.setItem('LS_staff_id', data.staff_id)
var output = '<div class="nd-first-queue" id="waiting-info"> <p class="mb-2 new-sm-font">You are now waiting for the '+data.staff_role+'</p><hr><p class="mb-2">Here is your position in the waiting queue:</p><div class="queue-position-box"><h1 class="mb-0"># '+data.position+'</h1></div></div>';
return output;
}
/**
* This function starts the video session and hides the content of queue information
*/
//"1"+"0002"
var jist_start = function(offender_staff_sessions_id, registration_info, staff_id){
stopVideoPreview();
console.log('jisti start');
console.log('registration_info',registration_info)
if(offender_staff_sessions_id == null){
return;
}
// $('.nd-queue-msg').hide('')
$('.nd-queue-msg').remove()
$('#loading-icon').show();
// $('.js-centered-img-wrap').show();
$('#video-preview').hide();
var video_music = document.getElementById('video_start_music');
// video_music.play();
// infoToastr('Starting video session ...');
// console.log('jisti session being started with '+registration_info.user_id);
//infoToastr('Jisti session being started with '+registration_info.user_id);
//$('#test').empty();
$('#test').find('iframe').remove()
var container = document.querySelector('#test');
//var caseno = caseno
//alert(caseno);
//var domain = "jitsi1.outlines-rnd.com/";
//var domain ="3.235.252.250:8443";
//if(caseno ==""){alert("invalid case no"); return;}
console.log(registration_info.jwt + "----jwt");
console.log("******************************************************");
console.log("******************************************************");
console.log("******************************************************");
console.log("******************************************************");
console.log("******************************************************");
console.log(registration_info.jitsi_url);
console.log("******************************************************");
var jisti_room = "ROOM"+offender_staff_sessions_id;
console.log(jisti_room);
var options = {
"roomName":jisti_room,
"parentNode": container,
"jwt": registration_info.jwt,
userInfo: {
canmute : false,
canmutevideo :false,
displayName: registration_info.user_name
},
"width": "100%",
"height": "100%",
interfaceConfigOverwrite: {
filmStripOnly: false,
DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
},
configOverwrite: {
disableRemoteMute: true,
remoteVideoMenu: {
disableKick: true
},
},
onload: function(){
console.log('jitsi load')
session_info.video_started = true;
$.get(base_url+ 'offender/natural/getStaffDetail/'+staff_id, function(re){
var mess = 'You are now having a video session with the '+re.staff_type_title;
// $('#first-queue-position').html("<div class='mb-4'><div class='p-3 alert alert-info'><h4>"+mess+"</h4></div></div>");
infoToastr(mess)
/**
* @ashesh please make video icon orange here and make it green when video has been loaded
*/
$('.js-video-icon-toggle').addClass('active')
$('#join_stop_video').show().attr('title', 'Stop My Video').html('Stop').addClass('active')
$('#loading-icon').hide();
$('.js-centered-img-wrap').hide();
$('#first-queue-position').hide()
},"json");
},
};
jisti_api = new JitsiMeetExternalAPI(registration_info.jitsi_url, options);
//jisti_api.executeCommand('toggleTileView');
if(typeof localStorage.videoSourceText != "undefined"){
jisti_api.setVideoInputDevice(localStorage.videoSourceText, localStorage.videoSourceValue)
}
if(typeof localStorage.inputSourceText != "undefined"){
jisti_api.setAudioInputDevice(localStorage.inputSourceText, localStorage.inputSourceValue)
}
if(typeof localStorage.outputSourceText != "undefined"){
jisti_api.setAudioOutputDevice(localStorage.outputSourceText, localStorage.outputSourceValue)
}
jisti_api.executeCommand('subject', ' ');
session_info.video_start = 1;
//$("#start").hide();
// jitsi_offender_staff_sessions_id = offender_staff_sessions_id
// jitsi_registration_info = registration_info
// jitsi_staff_id = staff_id
localStorage.setItem('LS_offender_staff_sessions_id', offender_staff_sessions_id);
localStorage.setItem('LS_registration_info', JSON.stringify(registration_info));
localStorage.setItem('LS_staff_id', staff_id);
};
/**
* This function stops the video session and shows the content of queue information
*/
var jist_stop = function(){
startVideoPreview();
console.log('jitsi stop');
//alert('');
if(jisti_api!=null){
jisti_api.executeCommand("hangup");
// infoToastr('Closing video session ...');
$('#test').html('')
$('#test').html('<div class="js-centered-img-wrap">'+
'<img src="'+video_icon_url+'" alt="iCourt loading" class="centered-video-img">'+
'</div>');
// $('.js-centered-img-wrap').show();
session_info.video_started = false;
}
$('.js-video-icon-toggle').removeClass('active')
$('#loading-icon').hide();
$('.js-centered-img-wrap').hide()
// $('.nd-queue-msg').show()
$('#video-preview').show()
$('#first-queue-position').show()
}
/**
* This function stops the video session whenever staff ends the session with the offender
*/
jist_close = function(){
if(jisti_api!=null){
jisti_api.executeCommand("hangup");
// infoToastr('Closing video session ...');
$('#test').html('')
// $('#test').html('<div class="js-centered-img-wrap">'+
// '<img src="'+video_icon_url+'" alt="iCourt loading" class="centered-video-img">'+
// '</div>');
$('#test').html('<div class="js-centered-img-wrap"></div>');
$('.js-centered-img-wrap').show();
$('#first-queue-position').hide();
// $('.js-centered-img-wrap').show();
session_info.video_started = false;
}
}
/**
* This function gets new/latest staff's response and calls the StaffAction.updateDOM() function to render it's corresponding UI.
* This function also shows the unread form counter number in mobile device
*/
//staff-response-update
var getStaffSessionActivitiesUpdate = function(){
//alert(atob(data.message));
$.get(base_url+ "offender/staff-session-activities-update/"+ registration_info.login_hash, function(data){
//alert(atob(data.status));
console.log("data.status="+data.status);
//infoToastr('Getting response from staff')
switch(data.status){
case "success":
StaffAction.updateDOM(data.activities,"new");
break;
case "invalid_login_hash":
window.location.replace(base_url+'active_session');
break;
case "invalid_session":
window.location.replace(base_url+'active_session')
break;
}
// $("#offender_content").html(atob(data.message));
var old_count = 0;
if(typeof $('#ax_count').html() != "undefined"){
old_count = parseInt($('#ax_count').html());
}
var count = 0;
for (var key in data.activities) {
var elem = data.activities[key];
switch (elem.type) {
case 'videoStart':
break;
case 'videoStop':
break;
case 'sessionStart':
break;
case 'transfer':
break;
case 'joinSession':
break;
case 'leftSession':
break;
case 'conferenceCall':
break;
case 'pickup':
break;
case 'closeCase':
break;
default:
count = Object.keys(data.activities).length + old_count;
}
}
var _this = $(this)
if(!$('.js-foot-documents').hasClass('active') && count !== 0) {
$('.activity_counter').html('<span class="badge badge-danger badge-pill position-absolute" style="top: -7px; font-size: 60% !important;"> <span id="ax_count" class="">'+ count +'</span></span>');
var roadMapHt = $('#my-roadmap').height()
}
var roadMapAvailableHt = roadMapHt - 170
$('.new-scrolling-table-wrap').css('max-height', roadMapAvailableHt+'px')
},"json");
}
/**
* to be deleted
* This function loads UI for currently subscribed staff's response
* @param {string} staff_id - ID of staff
*/
var getStaffResonse = function(staff_id){
//alert(atob(data.message));
$.get(base_url+ "offender/staff-response/"+staff_id, function(data){
//alert(atob(data.status));
console.log("data.status="+data.status);
//infoToastr('Getting response from staff')
switch(data.status){
case "success":
// $("#offender_content").html(atob(data.message));
$('.js-offender_content').html(atob(data.message))
break;
case "fail":
break;
}
// $("#offender_content").html(atob(data.message));
var roadMapHt = $('#my-roadmap').height()
var roadMapAvailableHt = roadMapHt - 170
$('.new-scrolling-table-wrap').css('max-height', roadMapAvailableHt+'px')
},"json");
}
/**
* This function loads the forms or activities when staff sends it
*/
var getStaffSessionActivities = function(){
//alert(atob(data.message));
$.get(base_url+ "offender/staff-session-activities", function(data){
console.log("data.status="+data.status);
//showToastr('Getting response from staff')
switch(data.status){
case "success":
$('#offender_content').html('<div class="js-staff-res-block"></div>')
//$(".js-staff-res-block").html();
StaffAction.updateDOM(data.activities, "all");
//var te = atob(data.message);
//console.log(te);
//$(".js-staff-res-block").html(te);
//$(te).prependTo('.js-list-view-block').fadeIn(2000,'swing');
break;
case "fail":
break;
}
// $("#offender_content").html(atob(data.message));
var roadMapHt = $('#my-roadmap').height()
var roadMapAvailableHt = roadMapHt - 170
$('.new-scrolling-table-wrap').css('max-height', roadMapAvailableHt+'px')
},"json");
}
/**
* This function gets all the legal documents associated with offender
*/
var getLegalDocuments = function(){
return;
$.get(base_url+ "offender/legal-documents", function(data){
if(data.message != '') {
// $('.legal-docs-wrap').show();
$("#legal-docs").html(atob(data.message));
}
else {
$("#legal-docs").html('Currently you have not received any documents');
// $('.legal-docs-wrap').hide();
}
return
},"json");
}
/**
* This function loads the road map on the sidebar
* @param {string} staff_id - ID of staff
*/
var getHistory = function($staff_id){
console.log('roadmap being reloaded...');
$.get(base_url+ "offender/history", function(data){
//alert(atob(data.status));
// alert("data.status="+data.status);
switch(data.status){
case "success":
break;
case "fail":
break;
default:
break;
}
$("#offender_road_map").html(atob(data.message));
},"json");
}
var public_defender = function(){
$.get(base_url+ "offender/public-defender", function(data){
//alert(atob(data.status));
//alert("data.status="+data.status);
switch(data.status){
case "incomplete":
//pd_choice_opinion();
// loadPDSuggestionForm();
//jist_start('case 1','Sagun Dhakhwa');
break;
case "response_complete":
$("#offender_content").html(atob(data.message));
jist_stop();
break;
//jist_start('case 1','Sagun Dhakhwa');
case "response_pending":
break;
default:
$("#offender_content").html(atob(data.message));
break;
}
},"json");
}
// @author Sagun Dhakhwa
/**
* This function sends opinion chosen of Plea form by offender to the staff
* @param {string} val - Value of Plea form's chosen option
*/
var pd_choice_opinion = function(val){
$.post(base_url+"offender/pd-choice-opinion", { 'choice': val }
, function(data) {
switch(data.status){
case "success":
$('.ch').css("border", "0px");
$('#'+val).css("border", "2px red solid");
$('#pd_choice_opinion').html(atob(data.message));
console.log(data);
break;
case "validation_failed":
console.log('error');
break;
}
}, 'json');
}
var clerk = function(){
console.log("this is clerk");
$.get(base_url+ "offender/clerk", function(data){
if(data.status=="response_complete"){
clearInterval(intId);
jist_stop();
current();
}else{
$("#offender_content").html(data.message);
}
},"json");
}
/**
* function to submit the plea form
*/
$(document).on('click', '#request_plea_submit', function() {
$.post($("#request_plea").attr('action'), $("#request_plea").serialize(), function(data) {
switch(data.status){
case "success":
$("#offender_plea_choose").html('');
$("#offender_plea_choose").html(data.message);
break;
}
}, 'json');
return false;
});
// var submitPromation = function(){
// var _this = $(this)
// var form = $('#offender_probation_sign')[0];
// // Create an FormData object
// var formData = new FormData(form);
// $.ajax({
// type: 'POST',
// url:$("#offender_probation_sign").attr('action'),
// data: formData,
// dataType: 'json',
// contentType: false,
// cache: false,
// processData:false,
// beforeSend: function(){
// },
// success: function(response){
// switch(response.status){
// case "success":
// getLegalDocuments();
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
// //$("#offender_content").html(atob(response.message));
// infoToastr(atob(response.message));
// break;
// case "validation_failed":
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
// //infoToastr('Validation error occured');
// break;
// case "error":
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
// //infoToastr(atob(response.message));
// break;
// }
// $('#clerk_compliance_form').css("opacity","");
// $('.modal').remove();
// }
// });
// }
/**
* to be deleted
* This function updates the offender's queue position's message
* @param {string} mess - Queue position's message
*/
var changeFirstQueuePosition= function(mess){
$('#first-queue-position').html("<div class='nd-queue-msg'><h5>"+mess+"</h5></div>");
}
// var getCaseStatus = function(){
// get case implementation.
// this functi
// }
/**
* view details from road map
*/
$(document).on('click', '.js-get-roadmap-details', function() {
var _this = $('.nd-toggle-view')
var staffTitle = $(this).data('title')
var id = $(this).data('id')
if(_this.find('.active').hasClass('js-view-list')) {
document.querySelector('.'+staffTitle).scrollIntoView({ behavior: 'smooth' });
}
else {
$('#staff_data').empty();
if(id === 0) {
$('#staff_data').append('<div class="js-registration-info"></div>');
getRegistrationDetails();
}
else {
$('#staff_data').append('<div class="js-offender_content"></div>');
getStaffResonse(id)
}
}
})
/**
* function to handle the list view of staff's response
*/
$(document).on('click', '.js-view-list', function() {
$('.nd-toggle-view').find('.active').removeClass('active')
$('.nd-toggle-view .nd-hearing-date-title').addClass('active')
$('.js-view-legal-doc-block').hide()
$('.js-list-view-block').show()
})
/**
* function to handle the staff view
*/
$(document).on('click', '.js-view-staff', function() {
$('.nd-toggle-view').find('.active').removeClass('active')
$('.nd-toggle-view .nd-hearing-date').addClass('active')
$('.js-staff-view-block').show()
$('.js-list-view-block').hide()
getStaffResonse(session_info.current_staff_id)
})
/**
* function to handle the legal document's view
*/
$(document).on('click', '.js-view-legal-doc', function() {
$('.nd-toggle-view').find('.active').removeClass('active')
$('.nd-toggle-view .nd-hearing-date').addClass('active')
$('.js-view-legal-doc-block').show()
$('.js-list-view-block').hide()
getLegalDocuments()
// getStaffResonse(session_info.current_staff_id)
})
/**
* This function gets the offender's registration details
*/
var getRegistrationDetails = function(){
$.get(base_url+ "offender/getRegistrationDetails", function(data){
console.log(data)
$('.js-registration-info').html(atob(data.message))
},"json");
}
/**
* open new window for case summary
*/
$(document).on('click', '.js-case-summary', function(e) {
e.preventDefault();
var caseId = $(this).data('id')
var myWindow = window.open(base_url+"welcome/case_summary/"+caseId+"/yes", "", "width='auto',height='auto',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
})
// open new window for support
// $(document).on('click', '.call-help-wrap', function(e) {
// e.preventDefault();
// var caseId = $(this).data('id')
// var pageURL = base_url+"offender/support" ;
// var pageTitle = "iCourtApp::Support";
// // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, '800', '400');
// if($('#navbarSupportedContent').hasClass('show')) {
// $('#navbarSupportedContent').removeClass('show')
// }
// popUpHandler.open(pageURL, pageTitle)
// })
/**
* open new window for invite my lawyer
*/
$(document).on('click', '.js-invite-lawyer', function(e) {
e.preventDefault()
// $('#inviteLawyerModal').modal('show');
var pageURL = base_url+"offender/invite-lawyer" ;
var pageTitle = "iCourtApp::Invite My Lawyer";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 800, 525);
})
/**
* form submission from new window for invite my lawyer
*/
$(document).on('click', '#offender_invite_my_lawyer', function() {
//function to be implemented
})
/**
* This function opens the new window for payment url
* @param {string} fineUrl - Url of payment acknowledgement
*/
var openFineUrl = function(fineUrl) {
var pageTitle = "iCourtApp::Fine";
var newmyWindow = newWindow.createPopupWin(fineUrl, pageTitle, 'auto', 'auto');
// Object.assign(document.createElement('a'), { target: '_blank', href: fineUrl}).click();
// $('#fine_url').attr('href', fineUrl)
// $('#fine_url').trigger('click')
// let a= document.createElement('a');
// a.target= '_blank';
// a.href= fineUrl;
// a.click();
}
/**
* This function opens payment acknowledgment in iframe
* @param {string} id - ID of payment acknowledgement
*/
var newOpenFineUrl = function(id) {
var pageURL = base_url+"offender/get-fine/"+id ;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle)
// var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
}
/**
* function to start video session
*/
$(document).on('click', '.js-start-my-video', function() {
jist_start(jitsi_offender_staff_sessions_id, jitsi_registration_info, jitsi_staff_id);
})
/**
* function to handle video session
*/
$(document).on('click', '#join_stop_video', function() {
if($(this).hasClass('active')) {
jist_stop();
$('#join_stop_video').attr('title', 'Join Video Session').html('Join').removeClass('active')
}
else {
if(localStorage.LS_offender_staff_sessions_id != ''){
jist_start(localStorage.LS_offender_staff_sessions_id, JSON.parse(localStorage.LS_registration_info), localStorage.LS_staff_id);
$('#join_stop_video').attr('title', 'Stop My Video').html('Stop').addClass('active')
}
}
})
/**
* This function checks whether video session was started or not
* @param {string} offender_staff_session_id - ID of offender staff session
*/
var wasVideoStarted = function(offender_staff_session_id){
$.get(base_url + "offender/was-video-started/"+ offender_staff_session_id, function (data) {
console.log(data);
if(data.videoStated > 0){
jist_start(offender_staff_session_id,registration_info,session_info.current_staff_id);
$('#join_stop_video').attr('title', 'Stop My Video').html('Stop').addClass('active');
}
},"json");
}
// $(document).on('click', '.js-foot-documents', function() {
/**
* handle click event to show form view in mobile device
*/
$('.js-foot-documents').on('click touchstart', function(e) {
var _this = $(this)
if(!_this.hasClass('active')) {
if(!$(e.target).hasClass('js-refresh-staff-action')) {
$('#offender-action-message').empty();
$('#offender-activity-msg').empty();
$('.activity_counter').html('');
getStaffSessionActivities();
_this.parent('.mbl-foot').find('.active').removeClass('active')
_this.addClass('active')
$('#offender-action-message').addClass('js-mbl-doc-wrap')
$('#offender-activity-msg').addClass('js-mbl-doc-wrap')
// var windowHt = $(window).height();
var headerHt = $('.navbar.navbar-expand-lg').height()
var footerHt = $('.mbl-foot').outerHeight()
var topHt = headerHt + footerHt
var windowWidth = $(window).width()
if(windowWidth < 992) {
$('#offender-action-message.js-mbl-doc-wrap').css('top', topHt).css('min-height', VideoHt);
$('#offender-activity-msg.js-mbl-doc-wrap').css('top', topHt).css('min-height', VideoHt); // $('#mbl_link').trigger('click')
}
// $('#mbl_link').trigger('click')
$('.js-dark-img').hide()
$('.js-white-img').show()
$('#no-form').show()
$('#no-activity').css('top', topHt)
$('#no-form').css('top', topHt);
}
}
})
// $(document).on('click', '.js-foot-video', function() {
/**
* handle click event to show video view in mobile device
*/
$('.js-foot-video').on('click touchstart', function() {
var _this = $(this)
if(!_this.hasClass('active')) {
_this.parent('.mbl-foot').find('.active').removeClass('active')
_this.addClass('active')
$('#offender-action-message').empty();
$('#offender-activity-msg').empty();
$('#offender-action-message').removeClass('js-mbl-doc-wrap')
$('#offender-activity-msg').removeClass('js-mbl-doc-wrap')
popUpHandler.closeIframe()
$('.js-white-img').hide()
$('.js-dark-img').show()
$('#no-activity').hide()
$('#no-form').hide()
}
})
// $(document).on('click', '.js-foot-participants', function() {
// var _this = $(this)
// if(_this.hasClass('active')) {
// }
// else {
// _this.parent('.mbl-foot').find('.active').removeClass('active')
// _this.addClass('active')
// $('#offender-action-message').removeClass('js-mbl-doc-wrap')
// popUpHandler.closeIframe()
// }
// })
/**
* refresh the form view
*/
$('.js-refresh-staff-action').on('click touchstart', function () {
// getStaffSessionActivities();
$.get(base_url + "offender/staff-session-activities", function (data) {
console.log("data.status=" + data.status);
switch (data.status) {
case "success":
$('#offender_content').html('<div class="js-staff-res-block"></div>');
$('#offender-action-message').empty();
$('#offender-activity-msg').empty();
StaffAction.updateDOM(data.activities, "all");
break;
case "fail":
break;
}
}, "json");
});