function loginPopup() {
/* $.ajax({
url: videobaseurl + "/ajax/ajaxLoginPopup.php",
method: "POST",
}).done(function (returnData) {
$('#popupDivContent').html(returnData);
$('#popupDiv').show();
}); */
window.location.href = videobaseurl + '/login.php';
}
$(document).ready(function () {
//enroll
$('#btnEnroll').click(function(){
if (var_auth != '') {
var vc = $(this).data('vc');
$.ajax({
url: videobaseurl + "/ajax/ajaxEnrollCourse.php",
method: "POST",
dataType: 'json',
data : {'vc':vc},
success: function (data) {
if(data.flag == 1){
alert(data.msg);
window.location.reload(true);
} else {
alert(data.msg);
}
}
});
} else {
loginPopup();
}
});
//left
$.ajax({
url: videobaseurl + "/ajax/ajaxGetLeftUserMenu.php",
method: "POST",
success: function (data) {
$('#divUserLeftMenu').html(data);
}
});
//header
$('input[name="q"]').keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
$(".vMenuDesc").hide();
$('.vMenu').click(function(event){
event.stopPropagation();
$.ajax({
url: profile_baseurl + "/ajax/ajaxGetVideosCategories.php",
method: "GET",
success: function (data) {
$('.video_cont').html(data);
}
});
$(".vMenuDesc").slideToggle("fast");
$(".library_cont").hide();
$(".search_cont").hide();
$(".profile_cont").hide();
});
$(".vMenuDesc").on("click", function (event) {
event.stopPropagation();
});
$(".library_cont").hide();
$('.vMenuL').click(function(event){
event.stopPropagation();
$.ajax({
url: profile_baseurl + "/ajax/ajaxGetTutorialsLibrary.php",
method: "GET",
success: function (data) {
$('.library_cont').html(data);
}
});
$(".library_cont").slideToggle("fast");
$(".search_cont").hide();
$(".video_cont").hide();
$(".profile_cont").hide();
});
$(".library_cont").on("click", function (event) {
event.stopPropagation();
});
$(".search_cont").hide();
$('.vMenuS').click(function(event){
event.stopPropagation();
$(".search_cont").slideToggle("fast");
$(".library_cont").hide();
$(".video_cont").hide();
$(".profile_cont").hide();
});
$(".search_cont").on("click", function (event) {
event.stopPropagation();
});
$(".profile_cont").hide();
$('.vMenuP').click(function(event){
event.stopPropagation();
$(".profile_cont").slideToggle("fast");
$(".library_cont").hide();
$(".video_cont").hide();
$(".search_cont").hide();
});
$(".profile_cont,#txtSearchKey").on("click", function (event) {
event.stopPropagation();
});
$(document).on("click", function () {
$(".library_cont").html('
');
$(".video_cont").html('');
$(".vMenuDesc").hide();
$(".library_cont").hide();
$(".search_cont").hide();
$("#txtSearchKey").hide();
$("#txtSearchKey").val('');
$("#divSearchVideos").html('');
});
$('#divMask').on("click", function () {
$(".vMenuDesc").hide();
$(this).hide();
$('.profile_cont').hide();
$(".library_cont").hide();
$(".qa-search-box").hide();
$(".qa-search-icon").hide();
$("#txtQuestion").val('');
$("#divHeaderQuestions").html('');
});
$('.clsCategories').mouseover(function(){
$(".clsCategories").removeClass("vmenuactive");
});
$('.vMenuDesc').mouseleave(function(){
$(this).removeClass('vmenuactive');
$(".clsCategories").first().addClass("vmenuactive");
});
$("#ancSearch").click(function(a){
a.stopPropagation();
$(".library_cont").hide();
$(".video_cont").hide();
$(".profile_cont").hide();
});
$(".magnifying-glass").click(function(a){
$(".vMenuDesc").hide();
$("#divMask").show();
$(".video-search-box, .qa-search-icon").is(":hidden")?(a.stopPropagation(),$(".video-search-box, .qa-search-icon").show().focus(),$(".video-search-box, .qa-search-icon").animate({
width:100==$(".video-search-box, .qa-search-icon").width()?"0px":"700px",opacity:1
},"slow",function(){
0==$(".video-search-box, .qa-search-icon").width()&&$(".video-search-box, .qa-search-icon").hide()
})):$el.animate({
width:435==$el.width()?"435px":"0px",opacity:.3
},"slow",function(){
0==$el.width()&&$el.hide()
});
});
$.ajax({
url: videobaseurl + "/ajax/ajaxGetHeaderProfile.php",
dataType: 'json',
method: "POST",
success: function (data) {
$('#liPMenu').html(data.content1);
$('#liPMobile').html(data.content1);
if(data.content2 == ''){
document.getElementById("mySidenav-b").style.width = "0px";
$('.up-arrow').css('margin-left','129px!important');
$('.up-arrowL').css('margin-left','247px!important');
$('.up-arrowS').css('right','110px');
}
$('#mySidenav-b').html(data.content2);
var_auth = data.var_auth;
}
});
//search
$('#txtSearchKey').keyup(function(){
var searchKey = $('#txtSearchKey').val();
searchKey = $.trim(searchKey);
if(searchKey != ''){
$.ajax({
url: videobaseurl + "/ajax/ajaxSearchVideos.php",
method: "POST",
data: {"search_key": searchKey},
success: function (data) {
$('#divSearchVideos').html(data);
}
});
} else {
$('#divSearchVideos').html('');
}
});
$('#ancSearch').click(function(){
var searchKey = $('#txtSearchKey').val();
searchKey = $.trim(searchKey);
if(searchKey == ''){
//$('#txtSearchKey').css('border-color', '#f00');
//return false;
}
$('#txtSearchKey').css('border-color', '#5ab155');
window.location.href = videobaseurl + "/search.php?key="+searchKey;
});
//Hide elements
$('#forgotOTPMail').hide();
$('#divforgotOTPForm').hide();
// user registration
$('#divSignup').bind('keydown', function (e) {
if (e.keyCode == 13) {
userSingup();
}
});
$('#submitRegister').on('click', function () {
userSingup();
});
$('#popupDiv').on('click', '#submitRegister', function () {
userSingup();
});
$("#divSignup input,textarea,select").keydown(function () {
$(this).css('border-color', '#ccc');
$(this).next().html('');
});
function userSingup() {
var full_name = $('#textRegName').val();
var email_id = $('#textSRegEmail').val();
var pwd = $('#textSRegPwd').val();
var repwd = $('#textRegRePwd').val();
var capchaReponse1 = $("#g-recaptcha-response-1").val();
var error_msg = '';
$("#divSignup input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (full_name == '')
{
$('.txtClass').next().html('');
$('#textRegName').next().html('Please enter a full name');
$('#textRegName').focus();
$('#textRegName').css('border-color', 'red');
return false;
} else if (!emailPattern.test(email_id))
{
$('#textRegName').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#textSRegEmail').next().html('Please enter a valid email id');
$('#textSRegEmail').focus();
$('#textSRegEmail').css('border-color', 'red');
return false;
} else if (pwd == '')
{
$('#textSRegEmail').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#textSRegPwd').next().html('Please enter password');
$('#textSRegPwd').focus();
$('#textSRegPwd').css('border-color', 'red');
return false;
} else if (repwd == '')
{
$('#textSRegPwd').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#textRegRePwd').next().html('Please re enter password');
$('#textRegRePwd').focus();
$('#textRegRePwd').css('border-color', 'red');
return false;
} else if (repwd != pwd)
{
$('#textSRegPwd').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#textRegRePwd').next().html('Passwords are not matching!');
$('#textRegRePwd').focus();
$('#textRegRePwd').css('border-color', 'red');
return false;
} else if (capchaReponse1 == '')
{
$('#textRegRePwd').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#errDivRegister').html('Please select captcha');
;
$('#recaptcha-anchor').focus();
$('#recaptcha-anchor').css('border-color', 'red');
return false;
}
full_name = $.trim(full_name);
email_id = $.trim(email_id);
pwd = $.trim(pwd);
$("#divSignup input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('.txtClass').next().html('');
$('#errDivRegister').html('');
$(".wrapLoader").show();
$.ajax({
url: videobaseurl + "/ajax/ajaxUserSignUp.php",
dataType: 'json',
method: "POST",
data: {"email_id": email_id, 'pwd': pwd, "full_name": full_name, 'g-recaptcha-response': capchaReponse1},
success: function (data) {
if (data.flag == 1) {
$(".wrapLoader").show();
window.location.href = data.rurl;
} else {
$(".wrapLoader").hide();
$('#errDivRegister').html(data.msg);
grecaptcha.reset(recaptcha2);
setTimeout(function () {
$('#errDivRegister').html('');
}, 3000);
}
}
});
} // end userSingup function
// user singin
// $('#divLogin').bind('keydown', function (e) {
// if (e.keyCode == 13) {
// userLogin();
// }
// });
// $('#popupDiv').on('click', '#submitLogin', function () {
// userLogin();
// });
$("#divLogin input,textarea,select").keydown(function () {
$(this).css('border-color', '#ccc');
$(this).next().html('');
});
// $('#textRegEmail,#textRegPwd').bind('keydown', function (e) {
// if (e.keyCode == 13) {
// userLogin();
// }
// });
$('#submitLogin').on('click', function () {
userLogin();
});
function userLogin()
{
$(".wrapLoader").show();
var email = $('#textRegEmail').val();
var pwd = $('#textRegPwd').val();
var capchaReponse = $("#g-recaptcha-response").val();
$("#divLogin input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (email == '')
{
$('.txtClass').next().html('');
$('#textRegEmail').next().html('Please enter a email id');
$('#textRegEmail').focus();
$('#textRegEmail').css('border-color', 'red');
$(".wrapLoader").hide();
return false;
} else if (!emailPattern.test(email))
{
$('#textRegEmail').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#textRegEmail').next().html('Please enter a valid email id');
$('#textRegEmail').focus();
$('#textRegEmail').css('border-color', 'red');
$(".wrapLoader").hide();
return false;
} else if (pwd == '')
{
$('#textRegEmail').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#textRegPwd').next().html('Please enter a password');
$('#textRegPwd').focus();
$('#textRegPwd').css('border-color', 'red');
$(".wrapLoader").hide();
return false;
} else if (capchaReponse == '')
{
$('#textRegPwd').css('border-color', '#ccc');
$('.txtClass').next().html('');
$('#errDivLogin').html('Please select captcha');
$('#recaptcha-anchor').focus();
$('#recaptcha-anchor').css('border-color', 'red');
$(".wrapLoader").hide();
return false;
}
$("#divLogin input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('.txtClass').next().html('');
$('#errDivLogin').html('');
$.ajax({
url: videobaseurl + "/ajax/ajaxUserSignIn.php",
method: "POST",
async: true,
cache: false,
dataType: 'json',
data: {"email": email, 'pwd': pwd, 'g-recaptcha-response': capchaReponse},
success: function (data) {
if (data.flag == 1)
{
$(".wrapLoader").show();
//window.location.href = data.rurl;
//window.location.href = videobaseurl+'/admin_view_courses.php';
window.location.href = data.rurl;
} else
{
$(".wrapLoader").hide();
$('#errDivLogin').html(data.msg);
grecaptcha.reset(recaptcha1);
setTimeout(function () {
$('#errDivLogin').html('');
}, 3000);
}
}
});
} // end userSingin function
if (localStorage.chkbx && localStorage.chkbx != '') {
$('#remember_me').attr('checked', 'checked');
$('#textRegEmail').val(localStorage.useremail);
$('#textRegPwd').val(localStorage.pwd);
} else {
$('#remember_me').removeAttr('checked');
$('#textRegEmail').val('');
$('#textRegPwd').val('');
}
$('#remember_me').click(function () {
if ($('#remember_me').is(':checked')) {
localStorage.useremail = $('#textRegEmail').val();
localStorage.pwd = $('#textRegPwd').val();
localStorage.chkbx = $('#remember_me').val();
} else {
localStorage.useremail = '';
localStorage.pwd = '';
localStorage.chkbx = '';
}
});
// forgot password
$('#popupDiv').on('click', '#btnForgotOTP', function () {
var email_id = $('#txtForgotEmailId').val();
var otp = $('#txtForgotOTP').val();
var error_msg = '';
$("#forgotOTPForm input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (otp == '')
{
error_msg = 'Please enter OTP which is sent to your email id';
$('#txtForgotOTP').focus();
$('#txtForgotOTP').css('border-color', 'red');
}
if (error_msg != '') {
$('#forgotOTPAlert').html(error_msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPAlert").hide();
$('#txtForgotOTP').css('border-color', '#ccc');
$('#txtForgotOTP').css('border-color', '#ccc');
}, 3000);
return false;
}
email_id = $.trim(email_id);
otp = $.trim(otp);
$("#forgotOTPForm input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('#forgotOTPAlert').html('');
$('#forgotOTPAlert').hide();
$.ajax({
url: videobaseurl + "/ajax/ajaxCheckForgotOTP.php",
dataType: 'json',
method: "POST",
data: {"email_id": email_id, "otp": otp},
success: function (data) {
if (data.flag == 1) {
$('#forgotOTPMail').hide();
$('#forgotOTPForm').hide();
$('#forgotOTPSubmit').show();
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPAlert").hide();
$('#txtForgotOTP').focus();
}, 5000);
}
if (data.flag == -2) {
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPAlert").hide();
}, 3000);
} else {
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPAlert").hide();
}, 3000);
}
}
});
});
$('#popupDiv').on('click', '#btnForgotOTPSubmit', function () {
var email_id = $('#txtForgotEmailId').val();
var otp = $('#txtForgotOTP').val();
var new_password = $('#txtNewPassword').val();
var confirm_password = $('#txtConfirmPassword').val();
var error_msg = '';
$("#forgotOTPSubmit input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (new_password == '')
{
error_msg = 'Please enter new password';
$('#txtNewPassword').focus();
$('#txtNewPassword').css('border-color', 'red');
} else if (confirm_password == '')
{
error_msg = 'Please re enter new password';
$('#txtConfirmPassword').focus();
$('#txtConfirmPassword').css('border-color', 'red');
} else if (confirm_password != new_password)
{
error_msg = 'Please re enter new password';
$('#txtConfirmPassword').focus();
$('#txtConfirmPassword').css('border-color', 'red');
}
if (error_msg != '') {
$('#forgotOTPSubmitAlert').html(error_msg);
$('#forgotOTPSubmitAlert').show();
setTimeout(function () {
$("#forgotOTPSubmitAlert").hide();
$('#txtNewPassword').css('border-color', '#ccc');
$('#txtConfirmPassword').css('border-color', '#ccc');
}, 3000);
return false;
}
email_id = $.trim(email_id);
otp = $.trim(otp);
new_password = $.trim(new_password);
$("#forgotOTPSubmit input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('#forgotOTPSubmitAlert').html('');
$('#forgotOTPSubmitAlert').hide();
$.ajax({
url: videobaseurl + "/ajax/ajaxChangePasswordOTP.php",
dataType: 'json',
method: "POST",
data: {"email_id": email_id, "otp": otp, "new_password": new_password},
success: function (data) {
if (data.flag == 1) {
$('#forgotOTPSubmitAlert').html(data.msg);
$('#forgotOTPSubmitAlert').show();
setTimeout(function () {
$("#forgotOTPSubmitAlert").hide();
$("#spanSignIn").addClass('signup_active');
$('#spanSignUp').removeClass('signup_active');
$('#signinForm').show();
$('#registerForm').hide();
$('#forgotOTPMail').hide();
$('#txtForgotEmailId').val('');
$('#forgotOTPMail').hide();
$('#forgotOTPForm').hide();
$('#forgotOTPSubmit').hide();
}, 5000);
} else {
$('#forgotOTPSubmitAlert').html(data.msg);
$('#forgotOTPSubmitAlert').show();
setTimeout(function () {
$("#forgotOTPSubmitAlert").hide();
}, 3000);
}
}
});
});
// change password
$('#btnUpdatePwd').click(function () {
var old_password = $('#txtOldPwd').val();
var new_password = $('#txtNewPwd').val();
var confirm_password = $('#txtConfirmPwd').val();
var error_msg = '';
$("#profileForm input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (old_password == '')
{
error_msg = 'Please enter old password';
$('#txtOldPwd').focus();
$('#txtOldPwd').css('border-color', 'red');
} else if (new_password == '')
{
error_msg = 'Please enter new password';
$('#txtNewPwd').focus();
$('#txtNewPwd').css('border-color', 'red');
} else if (confirm_password == '')
{
error_msg = 'Please re enter new password';
$('#txtConfirmPwd').focus();
$('#txtConfirmPwd').css('border-color', 'red');
} else if (confirm_password != new_password)
{
error_msg = 'Please enter same new password';
$('#txtConfirmPwd').focus();
$('#txtConfirmPwd').css('border-color', 'red');
}
if (error_msg != '') {
$('#profileAlert').html(error_msg);
$('#profileAlert').show();
setTimeout(function () {
$("#profileAlert").hide();
}, 3000);
return false;
}
old_password = $.trim(old_password);
new_password = $.trim(new_password);
$("#profileForm input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('#profileAlert').html('');
$('#profileAlert').hide();
$.ajax({
url: videobaseurl + "/ajax/ajaxChangeUserPassword.php",
dataType: 'json',
method: "POST",
data: {"old_password": old_password, "new_password": new_password},
beforeSend: function () {
$('.wrap_loader').show();
},
success: function (data) {
if (data.flag == 0) {
window.location.href = videobaseurl + '/index.php';
} else if (data.flag == 1) {
$('.wrap_loader').hide();
$('#profileAlert').html(data.msg);
$('#profileAlert').show();
setTimeout(function () {
$("#profileAlert").hide();
window.location.href = videobaseurl + '/login.php';
}, 2000);
} else {
$('.wrap_loader').hide();
$('#profileAlert').html(data.msg);
$('#profileAlert').show();
setTimeout(function () {
$("#profileAlert").hide();
}, 3000);
}
}
});
});
// Report a videos
$('#ancReportFlag').on('click', function () {
if (var_auth != '') {
var vc = $(this).data('vc');
var vl = $(this).data('vl');
$.ajax({
url: videobaseurl + "/ajax/ajaxReportEditor.php",
method: "POST",
data: {
"vc": vc,
"vl": vl
}
}).done(function (returnData) {
if ($.trim(returnData) != '') {
$('#divReport').html(returnData);
$('#divReport').slideDown();
} else {
$('.search_bg_mask').show();
$('#divReport').html('You have already report this course lecture !');
$('#divReport').slideDown();
setTimeout(function () {
$('#divReport').slideUp();
$('#divReport').html(returnData);
}, 3000);
}
});
} else {
loginPopup();
}
});
$.getScript('//connect.facebook.net/en_US/all.js', function () {
FB.init({
appId: '216851252183948',
version: 'v2.10'
});
});
// Share a vidoes on facebook
$(".btnFBShare").on("click", function () {
if (var_auth != '') {
// var shareId = $(this).data('shareid');
var link = $(this).data('link');
var course = $(this).data('course');
FB.ui({
method: 'feed',
display: 'popup',
link: link,
name: course,
description: 'content',
redirect_uri: videobaseurl + '/index.php'
}, function (response) {
if (response.length == 0) {
$('#divDisplay').html("Shared to Facebook ");
$('#divDisplay').show();
setTimeout(function () {
$('#divDisplay').hide();
}, 4000);
}
});
} else {
guestFlag = false;
loginPopup();
}
});
// Remove a report
$(".clsRemoveReport").on('click', function () {
var rid = $(this).data('rid');
if (confirm("Are sure you want to remove the report")) {
$.ajax({
url: videobaseurl + "/ajax/ajaxRemoveVideoReport.php",
method: "POST",
data: {
"rid": rid
},
dataType: 'json',
success: function (returnData) {
if (returnData.flag == 1) {
// window.location.reload(true);
$("div").remove("#divReported_" + rid);
alert('Report Removed');
}
},
error: function (returnData) {
}
});
}
})
// cover photo
var originalPostion;
var imageFlag = $('.profile_upload').data('flag');
$(".clsCoverImage").click(function () {
var imgnum = $(this).data('num');
var vu = $('#varData5').val();
var user_title = $('#varData2').val();
// Ajax Call to upload the file and store the name in DB
$.ajax({
url: profile_baseurl + "/ajax/ajaxCoverPhotoUpload.php",
method: "POST",
cache: false,
data: {'vu': vu, 'user_title': user_title, "imgnum": imgnum},
}).done(function (returnData) {
var respObj = jQuery.parseJSON(returnData);
if (respObj.flag == 1) {
$("#cover-img").css("display", "block");
getCoverImage();
}
});
});
$("#ancUploadCover").click(function () {
$("#fileUserCoverPhoto").click();
});
$('.profile_upload').click(function () {
//imageFlag = $('.profile_upload').data('flag' );
if (imageFlag) {
$('.cover-resize-wrapper').show().find('img').css('top', originalPostion);
repositionCoverImage();
}
$('.cover_holder').show();
$(this).hide();
});
$('#btnCancelCover').click(function () {
$('.cover_holder').hide();
$('.profile_upload').show();
cancelRepositionCoverImage();
});
$('#btnCancelRepositionCover').click(function () {
cancelRepositionCoverImage();
});
$("#fileUserCoverPhoto").change(function (e) {
var names = [];
var exts = ['jpg', 'jpeg', 'png'];
var vu = $('#varData5').val();
var user_title = $('#varData2').val();
// Check if the uploaded photo is of JPG/PNG format
for (var i = 0; i < $(this).get(0).files.length; ++i) {
names.push($(this).get(0).files[i].name);
var ext = $(this).get(0).files[i].name.split('.');
ext = ext.reverse();
var size = ($(this).get(0).files[i].size / (1024 * 1024)).toFixed(2);
if ($.inArray(ext[0].toLowerCase(), exts) < 0) {
alert("Please select jpeg/png format files only.");
$('#fileUserCoverPhoto').focus();
$("#fileUserCoverPhoto").val('');
return false;
} else if (size > 5) {
alert("Please select file less than 5 MB files only.");
$('#fileUserCoverPhoto').focus();
$("#fileUserCoverPhoto").val('');
return false;
}
}
//If no photo name return false
if ($('#fileUserCoverPhoto')[0].files[0] == '') {
return false;
}
//Creating an object for the form
var formdata = new FormData();
var fileDetails = $('#fileUserCoverPhoto')[0].files[0];
formdata.append("file", fileDetails);
formdata.append("vu", vu);
formdata.append("user_title", user_title);
// Ajax Call to upload the file and store the name in DB
$.ajax({
url: profile_baseurl + "/ajax/ajaxCoverPhotoUpload.php",
method: "POST",
cache: false,
data: formdata,
mimeType: "multipart/form-data",
processData: false,
contentType: false
}).done(function (returnData) {
var respObj = jQuery.parseJSON(returnData);
if (respObj.flag == 1) {
$("#cover-img").css("display", "block");
getCoverImage();
}
});
});
$("#ancRemoveCover").click(function () {
removeCoverImage();
});
$("#ancRepositonCover").click(function () {
repositionCoverImage();
});
function saveRepositionCoverImage() {
if ($('input.cover-position').length == 1) {
posY = $('input.cover-position').val();
var vu = $('#varData1').val();
var user_title = $('#varData2').val();
var finalPosition = posY + "px";
var coverPosition = {"positionY": posY, "vu": vu, "user_title": user_title};
$.post(videobaseurl + "/ajax/ajaxUpdateCoverPosition.php", coverPosition, function (returnData) {
// console.log(returnData);
});
originalPostion = finalPosition;
$("#cover-img").css('margin-top', finalPosition);
// $('form.cover-position-form').submit();
$('.cover-progress').html('Repositioning...').fadeIn('fast').removeClass('hidden');
$('.cover-progress').fadeOut('fast').addClass('hidden').html('');
// $('.cover-wrapper').show();
$('.cover-resize-wrapper').show().find('img').css('top', finalPosition);
$('.cover-resize-buttons').show();
$('.default-buttons').show();
$('input.cover-position').val(0);
// $('.cover-resize-wrapper img').draggable('destroy').css('cursor','default');
// $("#ancRepositonCover").show();
$("#ancRemoveCover").show();
$('#divCoverReposition').hide();
}
}
function getCoverImage() {
var vu = $('#varData5').val();
var user_title = $('#varData2').val();
var param = {'vu': vu, 'user_title': user_title};
$.ajax({
url: profile_baseurl + "/ajax/ajaxGetCoverImage.php",
method: "POST",
cache: false,
data: param,
}).done(function (returnData) {
var jsonObj = jQuery.parseJSON(returnData);
if (jsonObj.flag == 1) {
var timeRand = Math.floor(Math.random() * 20);
$("#cover-img").attr("src", jsonObj.coverPhoto + "?time=" + timeRand);
$("#org-photo").attr("src", jsonObj.coverPhoto + "?time=" + timeRand);
imageFlag = true;
$("span.cover_holder_tag ").removeClass('cover_tagsb').addClass('cover_tags');
if (jsonObj.coverPosition != null) {
originalPostion = jsonObj.coverPosition + "px";
$("#cover-img").css('margin-top', originalPostion);
}
repositionCoverImage();
$("#ancUploadCover").show();
} else if (jsonObj.flag == -1) {
setDefaultCoverImage();
}
});
}
function repositionCoverImage() {
$("#ancUploadCover").show();
//$('#divCoverReposition').show();
$('.cover-wrapper').hide();
$("#ancRepositonCover").hide();
$("#ancRemoveCover").show();
$('.cover-resize-wrapper').show();
$('.cover-resize-buttons').show();
$('.default-buttons').hide();
$('.screen-width').val($('.cover-resize-wrapper').width());
$('.cover-resize-wrapper img')
.css({'cursor': 's-resize'})
.draggable({
scroll: false,
axis: "y",
cursor: "s-resize",
drag: function (event, ui) {
y1 = $('.timeline-header-wrapper').height();
y2 = $('.cover-resize-wrapper').find('img').height();
if (ui.position.top >= 0) {
ui.position.top = 0;
} else
if (ui.position.top <= (y1 - y2)) {
ui.position.top = y1 - y2;
}
},
stop: function (event, ui) {
$('input.cover-position').val(ui.position.top);
saveRepositionCoverImage();
}
});
}
function removeCoverImage() {
// $("#ancUploadCover").show();
// $("#ancRepositonCover").hide();
$("#ancRemoveCover").hide();
var vu = $('#varData5').val();
var user_title = $('#varData2').val();
var data = {'vu': vu, 'user_title': user_title};
$.ajax({
url: profile_baseurl + "/ajax/ajaxRemoveCoverImage.php",
data: data,
method: "POST",
success: function (returnData) {
setDefaultCoverImage();
$(".cover-wrapper").show();
$(".cover-resize-wrapper").hide();
originalPostion = "0px";
imageFlag = false;
$("#org-photo").css("margin-top", "0px");
$("#cover-img").css("margin-top", "0px");
$("span.cover_holder_tag ").removeClass('cover_tags').addClass('cover_tagsb');
}
});
}
function cancelRepositionCoverImage() {
$('.cover-wrapper').show();
// $("#ancRepositonCover").css('display','block');
if (imageFlag) {
$("#ancRemoveCover").show();
}
$('.cover-resize-wrapper').hide();
$('.cover-resize-buttons').hide();
$('.default-buttons').show();
$('input.cover-position').val(0);
//$('.cover-resize-wrapper img').draggable('destroy').css('cursor','default');
$('#divCoverReposition').hide();
}
function setDefaultCoverImage() {
$("#cover-img").css("display", "none");
$(".cover-wrapper").css("background-color", "#2f2f2f");
}
$('#cropImg').click(function () {
var vu = $('#varData1').val();
$.ajax({
url: videobaseurl + "/ajax/ajaxProfileImageCrop.php",
method: "POST",
data: {'vu': vu}
}).done(function (returnData) {
$('#popupDivContent').html(returnData);
$('#popupDiv').show();
});
});
$('#popupDivClose').click(function () {
$('#popupDivContent').html('');
$('#popupDiv').hide();
});
// follow user event
$('.clsFollowUserTab').click(function () {
var thisObj = $(this);
var vu = $(this).data('vu');
fnFollowUser(thisObj, vu);
});
$('#divUserProfile').on('click', '.clsFollowUser', function () {
var thisObj = $(this);
var vu = $(this).data('vu');
fnFollowUser(thisObj, vu);
});
function fnFollowUser(thisObj, vu) {
if (var_auth != '') {
$.ajax({
url: videobaseurl + "/ajax/ajaxUpdateUserFollower.php",
dataType: 'json',
method: "POST",
data: {"vu": vu},
success: function (data) {
if (data.flag == 0) {
window.location.href = videobaseurl + '/login.php';
} else if (data.flag == 1) {
var objTitle = thisObj.attr('title');
if (typeof objTitle != 'undefined') {
objTitle = objTitle.replace("Follow", "Unfollow");
thisObj.attr('title',objTitle);
}
thisObj.find('b').html('Unfollow');
thisObj.find('strong').html(data.followcount);
$('.profileFollowBtn').find('b').html('Unfollow');
$('.profileFollowBtn').find('strong').html(data.followcount);
} else if (data.flag == 2) {
var objTitle = thisObj.attr('title');
if (typeof objTitle != 'undefined') {
objTitle = objTitle.replace("Unfollow", "Follow");
thisObj.attr('title',objTitle);
}
thisObj.find('b').html('Follow');
$('.profileFollowBtn').find('b').html('Follow');
$('.profileFollowBtn').find('strong').html(data.followcount);
thisObj.find('strong').html(data.followcount);
} else {
}
}
});
} else {
loginPopup();
}
}
// Delete Course
$('#divUserProfile').on('click', '.clsDeleteCourse', function () {
var r = confirm("Are you sure to delete this course and all sections,lectures of this course!");
if (r == true) {
var vc = $(this).data('vc');
var formdata = new FormData();
formdata.append("course_id", course_id);
$.ajax({
url: videobaseurl+"/deleteCourse.php",
method: "POST",
cache: false,
dataType: "json",
data: formdata,
processData: false,
contentType: false,
}).done(function (data) {
if (data.flag == -99)
{
window.location.href = videobaseurl + '/login.php';
}
if (data.flag === 1)
{
$('#divCourse' + course_id).remove();
alert(data.msg);
} else
{
alert(data.msg);
return false;
}
});
}
});
// Delete Feedback
$('#divUserProfile').on('click', '.clsDeleteFeedback', function () {
var r = confirm("Are you sure to delete this course feedback");
if (r == true) {
var feedback_id = $(this).data('feedback');
var formdata = new FormData();
formdata.append("feedback_id", feedback_id);
$.ajax({
url: videobaseurl + "/ajax/ajaxAdminDeleteFeedback.php",
method: "POST",
cache: false,
dataType: "json",
data: formdata,
processData: false,
contentType: false,
}).done(function (data) {
if (data.flag == -99)
{
window.location.href = videobaseurl + '/login.php';
}
if (data.flag === 1)
{
$('#trFeed' + feedback_id).remove();
alert(data.msg);
} else
{
alert(data.msg);
return false;
}
});
}
});
// Get Index courses
$('#btnAddFilter').click(function () {
var myCheckboxes = '';
$("input:checkbox[name=chkCategory]:checked").each(function () {
myCheckboxes = myCheckboxes + $(this).val() + ',';
});
$.ajax({
url: videobaseurl + "/ajax/ajaxGetIndexCourses.php",
method: "POST",
data: {"categories": myCheckboxes},
}).done(function (data) {
$('#divIndexCourses').html(data);
$('#spanCategoryName').html('Courses');
$('#divFilter').hide();
$('#divFilter').find('input[type=checkbox]:checked').removeAttr('checked');
});
});
$('#divFilter').click(function (e) {
// e.preventDefault();
e.stopPropagation();
});
$('#ancAddFilter').click(function (e) {
e.stopPropagation();
var $el = $("#divFilter");
if ($el.is(":visible")) {
$('#divFilter').hide();
} else {
$('#divFilter').show();
}
});
$(document).on('click', function (e) {
var $el = $("#divFilter");
if ($el.is(":visible")) {
$el.hide();
}
});
//feedback
$('.feedshow').hide();
$('.feedshide').click(function () {
if (var_auth != '') {
$('.feedshow').toggle();
$('.feedshide').hide();
} else {
loginPopup();
}
});
$('.courseRating').click(function () {
if (var_auth == '') {
loginPopup();
}
});
$('.tog_open').click(function () {
$('.toggle-desc').toggle();
$(this).removeClass('fa-caret-right').addClass('fa-caret-down');
$('fa-caret-right').hide();
});
$('#btnCancelFeedback').click(function () {
$('.feedshow').toggle();
$('.feedshide').show();
});
$('#btnSubmitFeedback').click(function () {
if (var_auth != '') {
var vc = $(this).data('vc');
var courseRating = 0;
var feedbackContent = $('#txtCourseFeedback').val();
if ($("input[name=courseRating]").is(':checked')) {
courseRating = $("input[name=courseRating]:checked").val();
}
$('#feedbackErrmsg').html('');
if (courseRating == 0)
{
$('.txtClass').next().html('');
$('#feedbackErrmsg').html('Please select rating');
$('#starRating').focus();
$('#starRating').css('border-color', 'red');
return false;
} else if (feedbackContent == '') {
$('.txtClass').next().html('');
$('#feedbackErrmsg').html('Please enter course feedback message');
$('#txtCourseFeedback').focus();
$('#txtCourseFeedback').css('border-color', 'red');
return false;
}
$.ajax({
url: videobaseurl + "/ajax/ajaxAddCourseFeedback.php",
method: "POST",
dataType: "json",
cache: false,
data: {'vc': vc, 'courseRating': courseRating, 'feedbackContent': feedbackContent}
}).done(function (data) {
if (data.flag == -99) {
window.location = videobaseurl + "/login.php";
} else if (data.flag == 1)
{
$('#feedbackErrmsg').html(data.msg);
setTimeout(function () {
$('#divFeedback').hide('slow');
}, 3000);
} else
{
$('#feedbackErrmsg').html(data.msg);
}
});
} else {
loginPopup();
}
});
});
function entityView(entity_var, entity_type) {
if (entity_var != '') {
$.ajax({
url: videobaseurl + "/ajax/ajaxUpdateViews.php",
method: "POST",
data: {'entity_var':entity_var,'entity_type':entity_type}
}).done(function (returnData) {
});
}
}
function forgotMail() {
var email_id = $('#txtForgotEmailId').val();
var error_msg = '';
var capchaReponse = $("#g-recaptcha-response-2").val();
$("#forgotOTPMail input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (!emailPattern.test(email_id))
{
error_msg = 'Please enter a valid email id';
$('#txtForgotEmailId').focus();
$('#txtForgotEmailId').css('border-color', 'red');
}
if (error_msg != '') {
$('#forgotMailAlert').html(error_msg);
$('#forgotMailAlert').show();
grecaptcha.reset(recaptcha3);
setTimeout(function () {
$("#forgotMailAlert").hide();
$('#txtForgotEmailId').css('border-color', '#ccc');
$('#txtForgotEmailId').css('border-color', '#ccc');
}, 3000);
return false;
}
email_id = $.trim(email_id);
$("#forgotOTPMail input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('#forgotMailAlert').html('');
$('#forgotMailAlert').hide();
$.ajax({
url: videobaseurl + "/ajax/ajaxSendForgotOTP.php",
dataType: 'json',
method: "POST",
data: {
"email_id": email_id,
'g-recaptcha-response': capchaReponse,
},
success: function (data) {
if (data.flag == 1) {
$('#divForgot').hide();
$('#forgotOTPForm').show();
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
$('#txtForgotOTP').focus();
setTimeout(function () {
$("#forgotOTPAlert").hide();
}, 5000);
} else {
$('#forgotMailAlert').html(data.msg);
$('#forgotMailAlert').show();
grecaptcha.reset(recaptcha3);
setTimeout(function () {
$("#forgotMailAlert").hide();
}, 3000);
}
}
});
}
function sendOTP() {
var email_id = $('#txtForgotEmailId').val();
var otp = $('#txtForgotOTP').val();
var capchaReponse = $("#g-recaptcha-response-3").val();
var error_msg = '';
$("#forgotOTPForm input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (otp == '') {
error_msg = 'Please enter OTP which is sent to your email id';
$('#txtForgotOTP').focus();
$('#txtForgotOTP').css('border-color', 'red');
}
if (error_msg != '') {
$('#forgotOTPAlert').html(error_msg);
$('#forgotOTPAlert').show();
grecaptcha.reset(recaptcha4);
setTimeout(function () {
$("#forgotOTPAlert").hide();
$('#txtForgotOTP').css('border-color', '#ccc');
$('#txtForgotOTP').css('border-color', '#ccc');
}, 3000);
return false;
}
email_id = $.trim(email_id);
otp = $.trim(otp);
$("#forgotOTPForm input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('#forgotOTPAlert').html('');
$('#forgotOTPAlert').hide();
$.ajax({
url: videobaseurl + "/ajax/ajaxCheckForgotOTP.php",
dataType: 'json',
method: "POST",
data: {
"email_id": email_id,
"otp": otp,
'g-recaptcha-response': capchaReponse,
},
success: function (data) {
if (data.flag == 1) {
$('#forgotOTPMail').hide();
$('#forgotOTPForm').hide();
$('#forgotOTPSubmit').show();
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPAlert").hide();
$('#txtForgotOTP').focus();
}, 5000);
}
if (data.flag == 2) {
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
grecaptcha.reset(recaptcha4);
setTimeout(function () {
$("#forgotOTPAlert").hide();
}, 3000);
} else {
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
grecaptcha.reset(recaptcha4);
setTimeout(function () {
$("#forgotOTPAlert").hide();
}, 3000);
}
}
});
}
function checkOTP() {
var email_id = $('#txtForgotEmailId').val();
var otp = $('#txtForgotOTP').val();
var new_password = $('#txtNewPassword').val();
var confirm_password = $('#txtConfirmPassword').val();
var error_msg = '';
$("#forgotOTPSubmit input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
if (new_password == '') {
error_msg = 'Please enter new password';
$('#txtNewPassword').focus();
$('#txtNewPassword').css('border-color', 'red');
} else if (confirm_password == '') {
error_msg = 'Please re enter new password';
$('#txtConfirmPassword').focus();
$('#txtConfirmPassword').css('border-color', 'red');
} else if (confirm_password != new_password) {
error_msg = 'Please re enter new password';
$('#txtConfirmPassword').focus();
$('#txtConfirmPassword').css('border-color', 'red');
}
if (error_msg != '') {
$('#forgotOTPSubmitAlert').html(error_msg);
$('#forgotOTPSubmitAlert').show();
setTimeout(function () {
$("#forgotOTPSubmitAlert").hide();
$('#txtNewPassword').css('border-color', '#ccc');
$('#txtConfirmPassword').css('border-color', '#ccc');
}, 3000);
return false;
}
email_id = $.trim(email_id);
otp = $.trim(otp);
new_password = $.trim(new_password);
$("#forgotOTPSubmit input,textarea,select").each(function () {
$(this).css('border-color', '#ccc');
});
$('#forgotOTPAlert').html('');
$('#forgotOTPAlert').hide();
$.ajax({
url: videobaseurl + "/ajax/ajaxChangePasswordOTP.php",
dataType: 'json',
method: "POST",
data: {
"email_id": email_id,
"otp": otp,
"new_password": new_password
},
success: function (data) {
if (data.flag == 1) {
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPSubmitAlert").hide();
$("#spanSignIn").addClass('signup_active');
$('#spanSignUp').removeClass('signup_active');
$('#divLogin').show();
$('#registerForm').hide();
$('#forgotOTPMail').hide();
$('#txtForgotEmailId').val('');
$('#forgotOTPMail').hide();
$('#forgotOTPForm').hide();
$('#forgotOTPSubmit').hide();
}, 5000);
} else {
$('#forgotOTPAlert').html(data.msg);
$('#forgotOTPAlert').show();
setTimeout(function () {
$("#forgotOTPAlert").hide();
}, 3000);
}
}
});
}
// added by prashanth
function show_menu() {
var menu = document.getElementById('dropdown_menu');
if (menu.style.display == 'block') {
menu.style.display = 'none';
} else {
menu.style.display = 'block';
}
}
/* toggle full screen*/
function toggleFullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}
/*
function toggleMenu(){
var menu = document.getElementById('left-bar');
if(menu.style.display == 'block'){
menu.style.display = 'none';
}else {
menu.style.display = 'block';
}
}
function toggleProfile(){
var menu = document.getElementById('dpdwnRmenu');
if(menu.style.display == 'block'){
menu.style.display = 'none';
}else {
menu.style.display = 'block';
}
}
function toggleSearch(){
var menu = document.getElementById('searchMenu');
if(menu.style.display == 'block'){
menu.style.display = 'none';
}else {
menu.style.display = 'block';
}
}
*/
function toggleRmenu() {
var menu = document.getElementById('dpdwnRmenu');
if (menu.style.display == 'block') {
menu.style.display = 'none';
} else {
menu.style.display = 'block';
}
}
function expandRight() {
var menu = document.getElementById('left-bar');
if (menu.style.display == 'block') {
document.getElementById('center').style.marginLeft = '0px';
menu.style.display = 'none';
} else {
document.getElementById('center').style.marginLeft = '270px';
menu.style.display = 'block';
}
}
$(document).ready(function () {
$('#topSearch').click(function () {
$('#dpdwnRmenu').toggle();
});
$('#topMenu').click(function () {
$('#left-bar').toggle();
});
$('.nav_search').click(function () {
$('.librarybox').hide();
$('.searchbox').toggle();
});
$('.dropdown-library').click(function () {
$('.librarybox').toggle();
$('.searchbox').hide();
});
});
$(document).on("click", ".cclose", function (b) {
$(".librarybox").hide();
});