$(function() {
LoginFancybox ();
services_animation();
mobile_menu();
init_menu();
// init_fancybox();
// init_tooltip();
// init_flickr();
// init_testimonials_slide();
loginTVT();
portfolio_filter();
FeaturesTVT_filter();
SignupTVT_Tabs();
pickvideoTVT_Tabs();
form_institute_signup();
form_trainer_signup();
form_sub_trainer_signup();
form_institute_course();
form_upload_file();
form_trainer_finance();
form_paypal();
form_otherpayment();
form_upload_trainee_CSV();
form_billinginfo();
form_trainer_page();
form_trainer_course();
form_trainer_course_deadline();
form_trainer_invemail();
form_trainer_rmdemail();
form_trainer_compemail();
form_receive_email_notifications();
form_course_certs();
form_course_access();
course_invemail_existingtrainees();
course_invemail_anyone();
form_trainer_create_course();
form_trainer_personalinfo();
form_trainer_personalinfo_changepassword();
forgot_PWD();
// forgotPWD2();
vlm();
goto_top();
contact_form();
tabs_ui();
accordion_ui();
custom_lists_ui();
Inst_Reg_form();
demo_request_form();
change_RecoverPWD_form() ;
course_file_uploading_page ();
Init_ManageQuizPage ();
applySubTrainerCourseFunctions ();
YoutubeFancyBox ();
addTrainerFancyBox ();
addTraineeFancyBox ();
RashidFrame ();
// init_tweets();
});
function services_animation() {
$(".services .service").hover(
function() {
var id = $(this).attr('id');
$('.services .service#' + id + ' .icon').addClass('animated bounce');
},
function() {
$('.icon').removeClass('animated bounce');
}
);
}
function mobile_menu() {
selectnav('nav', { label: 'Menu', nested: true, indent: '-' });
}
function init_menu() {
$('ul.sf-menu').superfish({
speed: 'normal',
disableHI: false,
delay: 150
});
}
function init_tweets() {
$(".latest_tweets #tweets, #footer #twitter_feed").tweet({
username: 'mojothemes',
modpath: 'js/twitter/',
join_text: "auto",
avatar_size: 25,
count: 2,
auto_join_text_default: "we said,",
auto_join_text_ed: "we",
auto_join_text_ing: "we were",
auto_join_text_reply: "we replied to",
auto_join_text_url: "we were checking out",
loading_text: "loading tweets..."
});
}
function init_fancybox() {
$('.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null
});
$(".fancybox.video").click(function() {
$.fancybox({
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'overlayColor' : '#fcfcfc',
'width' : 640,
'height' : 385,
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
});
return false;
});
$(".fancybox.iframe").click(function() {
$.fancybox({
'width' : 640,
'height' : 385
});
return false;
});
// alert ("init_fancybox");
}
function init_tooltip() {
$('.tooltip').tipsy({ 'gravity' : 's' });
}
function init_flickr() {
$('#flickr_feed').jflickrfeed({
limit: 9,
qstrings: {
id: '34903216@N04'
},
useTemplate: false,
itemCallback: function(item){
$(this).append("
");
}
});
}
function init_testimonials_slide() {
$('.testimonial_slides .testimonial').quovolver();
}
function portfolio_filter() {
$('.portfolio ul.sort li').eq(0).addClass('current');
$('.portfolio ul.sort a').click(function() {
$(this).css('outline','none');
$('ul.sort .current').removeClass('current');
$(this).parent().addClass('current');
var filterVal = $(this).text().toLowerCase().replace(' ','-');
if(filterVal == 'all') {
$('ul.portfolio_sort li.hidden').fadeIn('slow').removeClass('hidden');
} else {
$('ul.portfolio_sort li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeOut('normal').addClass('hidden');
} else {
$(this).fadeIn('slow').removeClass('hidden');
}
});
}
return false;
});
}
function FeaturesTVT_filter() {
var arr = new Array();
arr.push({item_key: "All", item_value: "All"});arr.push({item_key: "Course Management", item_value: "Course Management"});arr.push({item_key: "Video Management", item_value: "Video Management"});arr.push({item_key: "Video Conferencing", item_value: "Video Conferencing"});arr.push({item_key: "Video Chat", item_value: "Video Chat"});
$('.FeaturesTVT ul.sort li').eq(0).addClass('current');
$('.FeaturesTVT ul.sort a').click(function() {
$(this).css('outline','none');
$('ul.sort .current').removeClass('current');
$(this).parent().addClass('current');
var item = "";
for (x in arr) {
if (arr[x].item_value == $(this).text()) {
item = arr[x].item_key;
}
}
// var filterVal = $(this).text().toLowerCase().replace(' ','-');
var filterVal = item.toLowerCase().replace(' ','-');
if(filterVal == 'all') {
$('ul.FeaturesTVT_sort li.hidden').fadeIn('slow').removeClass('hidden');
} else {
$('ul.FeaturesTVT_sort li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeOut('normal').addClass('hidden');
} else {
$(this).fadeIn('slow').removeClass('hidden');
}
});
}
return false;
});
}
// ===============================
// Functions added by Khalil Mangi
// ===============================
// ===================== uploading/importing student .csv file ==========================================================
function form_upload_trainee_CSV () {
$('#Uploadcsv').click(function(){
if ($('select#gid').val() == 0 && $('input#new-group').val().trim() == '') {
$("#responce").html ('New group name can not be empty. ');
return;
}
$(this).hide();
$('progress').show();
$("#responce").html ("");
var formData = new FormData($('form')[0]);
$.ajax({
url: 'act_upload_student_csv.php', //Server script to process data
type: 'POST',
xhr: function() { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // Check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
//Ajax events
// beforeSend: beforeSendHandler,
success: function (data) {
if (data) {
$("#responce").html (data);
}
$('#Uploadcsv').show();
return false;
},
error: function() {
alert("Error Occurred...");
$('#Uploadcsv').show();
},
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
});
$('progress').hide();
}
// ==================== Other Payment Gateway Email Template ============================================================
function form_otherpayment()
{
$('#other_Payment').on('click', function() {
$("div#responce").html(" Processing data, please wait ...");
var invsubject = $('input#invsubject').val();
var invbody = $('textarea#invbody').val();
var post='invsubject=' + invsubject + '&invbody=' + invbody;
$.post('act_otherpaymentGateway.php', post, function(data) {
$("div#responce").html(data);
});
});
}
// ===================== Inserting TVT Paypal ID for course payments ================================================
function form_paypal()
{
$('#paypal').on('click', function() {
$("div#responce").html(" Processing data, please wait ...");
var paypal = $("#paypal").attr("checked") ? 1 : 0;
var post = 'paypal=' + paypal;
var act_file = "act_userPaypal.php";
$.post(act_file, post, function(data) {
$("div#responce").html(data);
});
});
}
// ===================== Trainer Finance insertion ===============================================================
function form_trainer_finance()
{
$('#trainer_finance').on('click', function() {
$("div#responce").html(" Processing data, please wait ...");
var p_name = $('input#p_name').val();
var p_email = $('input#p_email').val();
var post = 'p_email=' + p_email + '&p_name='+ p_name;
var act_file = "act_financialSettings.php";
$.post(act_file, post, function(data) {
$("div#responce").html(data);
});
});
}
// ===================== Forgot Password ===============================================================
function forgot_PWD()
{
$('#forgot').on('click', function() {
$("div#responce2").html(" Please wait..");
var email = $('input#email').val();
var username = $('input#uname').val();
if (email ==""){
if(username==""){
$("div#responce2").html("Please supply either Email address or Username ");
return;
} else {
var post = 'username=' + username;
}
} else {
var post = 'email=' + email;
}
var act_file = "act_forgotPassword.php";
$.post(act_file, post, function(data) {
$("div#responce2").html(data);
});
});
}
// Trainer course deadline form ===================================================================================
function form_trainer_course_deadline()
{
$('#trainer_deadline').on('click', function() {
$("div#responce_trainer_course_deadline").html(" Processing data, please wait ...");
//var deadline = $("#deadline").attr("checked") ? 1 : 0;
var CDeadline = $('input#CDeadline').val();
var DType = $("#DType option:selected").val();
var post='CDeadline=' + CDeadline + '&DType=' + DType;
$.post('act_course_trainer_deadline.php', post, function(data) {
$("div#responce_trainer_course_deadline").html(data);
});
});
}
// ==================== Course Invitation Email Template ============================================================
function form_trainer_invemail()
{
$('#trainer_invemail').on('click', function() {
var invsubject = $('input#invsubject').val();
var invbody = $('textarea#invbody').val();
var post='invsubject=' + invsubject + '&invbody=' + invbody;
$.post('act_course_invitationEmail.php', post, function(data) {
$("div#responce_trainer_invemail").html(data);
});
});
}
// ==================== Course Reminder Email Template ============================================================
function form_trainer_rmdemail()
{
$('#trainer_rmdemail').on('click', function() {
var rmdsubject = $('input#rmdsubject').val();
var rmdbody = $('textarea#rmdbody').val();
var post='rmdsubject=' + rmdsubject + '&rmdbody=' + rmdbody;
$.post('act_course_reminderEmail.php', post, function(data) {
$("div#responce_trainer_rmdemail").html(data);
});
});
}
// ==================== Course COMPLETED Email Template ============================================================
function form_trainer_compemail()
{
$('#trainer_compemail').on('click', function() {
var compsubject = $('input#compsubject').val();
var compbody = $('textarea#compbody').val();
var post='compsubject=' + compsubject + '&compbody=' + compbody;
$.post('act_course_completionEmail.php', post, function(data) {
$("div#responce_trainer_compemail").html(data);
});
});
}
// ==================== TRAINEE ACTIVITY EMAIL NOTIFICATIONS ============================================================
function form_receive_email_notifications()
{
$('#trainer_noti').on('click', function() {
var Cnotification = $("#Cnotification option:selected").val();
var post='Cnotification=' + Cnotification;
$.post('act_trainee_notification_emails.php', post, function(data) {
$("div#responce_receive_email_notifications").html(data);
});
});
}
// ==================== Certifications options ============================================================
function form_course_certs()
{
$('#cert_btn').on('click', function() {
var icerts = $("#issue_certs").attr("checked") ? 1 : 0;
var scerts = $("#score_certs").attr("checked") ? 1 : 0;
//document.write("i am here");
var post='icerts=' + icerts + '&scerts=' + scerts;
$.post('act_course_certs.php', post, function(data) {
$("div#responce_course_certs").html(data);
});
});
}
// ==================== Course access ============================================================
function form_course_access()
{
$('#course_access').on('click', function() {
var access = $("input[name='access']:checked").val()
var post='access=' + access;
$.post('act_course_access.php', post, function(data) {
$("div#responce_course_access").html(data);
});
});
}
// ==================== Course Invitation email to existing trainees =================================
function course_invemail_existingtrainees()
{
$('#invemail_trainees').on('click', function() {
var ids = "";
$('input[type=checkbox]').each (function (index) {
ids += (this.checked ? $(this).val() + "|" : "");
});
var arr = ids.split("|");
arr.splice(arr.length-1);
var str = arr.join("|");
// alert (str);
if (str == "") {
$('div#responce_invemail_existingtrainees').html ('You have not selected any trainee ... ');
} else {
$('div#responce_invemail_existingtrainees').html ('Preparing to send invitation ... ');
var post = 'ids=' + str;
$.post('act_invemail_existingTrainees.php', post, function(data) {
$("div#responce_invemail_existingtrainees").html(data);
});
}
});
}
// ==================== Course Invitation email to existing trainees =================================
function course_invemail_anyone()
{
$('#invemail_anyone').on('click', function() {
var ids = $('textarea#anyone_emails').val();
/*
alert (ids);
ids = ids.replace('\r\n', '|');
ids = ids.replace('\r', '|');
ids = ids.replace('\n', '|');
*/
// alert (ids);
/*
var arr = ids.split("|");
arr.splice(arr.length-1);
var str = arr.join("|");
*/
// alert (str);
if (ids == "") {
$('div#responce_invemail_anyone').html ('You have not placed any email ... ');
} else {
$('div#responce_invemail_anyone').html ('Preparing to send invitation ... ');
var post = 'ids=' + ids;
$.post('act_invemail_anyone.php', post, function(data) {
$("div#responce_invemail_anyone").html(data);
});
}
});
}
// ==================== Course Invitation email to existing trainees =================================
function form_trainer_create_course()
{
$('#trainer_Coursecreate').on('click', function() {
$("div#responce_trainer_create_course").html(" Saving data, please wait ...");
var CTitle = encodeURIComponent($('input#CTitle').val());
var CDesc = encodeURIComponent($('textarea#CDesc').val());
var CLevel = $('select#CLevel').val();
var CServer = $('select#CServer').val();
var post='CTitle='+CTitle+ '&CDesc=' + CDesc + '&CLevel=' + CLevel + '&CServer=' + CServer;
$.post('act_step02_trainer_createCourse.php', post, function(data) {
$("div#responce_trainer_create_course").html(data);
});
});
}
// ==================== Trainer Billing information form =================================
function form_billinginfo()
{
$('#trainer_billing').on('click', function() {
$("div#responce_trainer_personalinfo").html(" Saving data, please wait ...");
var amount = $('input#amount').val();
var pkg_id = $('input#pkg_id').val();
var pkg_name = $('input#pkg_name').val();
var FullName = $('input#FullName').val();
var email = $('input#email').val();
var bill_desc = $('input#bill_desc').val();
var tele_no = $('input#tele_no').val();
var country_code = $("#country option:selected").val();
var country_text = $("#country option:selected").text();
var post='FullName=' + FullName +'&tele_no=' + tele_no +'&amount=' + amount +'&bill_desc=' + bill_desc +'&country_code=' + country_code + '&country_text=' + country_text +'&email=' + email + '&pkg_id=' + pkg_id + '&pkg_name=' + pkg_name ;
$.post('act_billingInfo.php', post, function(data) {
$("div#responce_trainer_personalinfo").html(data);
});
});
}
// ==================== Trainer personal information form =================================
function form_trainer_personalinfo()
{
$('#trainer_personal').on('click', function() {
$("div#responce_trainer_personalinfo").html(" Saving data, please wait ...");
var inst_name = $('input#inst_name').val();
var FullName = $('input#FullName').val();
var email = $('input#email').val();
var WebsiteAdd = $('input#WebsiteAdd').val();
var tele_no = $('input#tele_no').val();
var st_add = encodeURIComponent($('input#st_add').val());
var zip_code = $('input#zip_code').val();
var city = $('input#city').val();
var state = $('input#state').val();
var country_code = $("#country option:selected").val();
var country_text = $("#country option:selected").text();
var post='U_name=' + U_name +'&inst_name=' + inst_name +'&FullName=' + FullName +'&tele_no=' + tele_no +'&st_add=' + st_add +'&zip_code=' + zip_code +'&city=' + city +'&state=' + state +'&country_code=' + country_code + '&country_text=' + country_text +'&WebsiteAdd=' + WebsiteAdd + '&email=' + email;
$.post('act_trainerPersonalinfoRashid.php', post, function(data) {
$("div#responce_trainer_personalinfo").html(data);
});
});
}
//=============== Trainer Change Password =====================================
function form_trainer_personalinfo_changepassword()
{
$('#trainer_personal_changepwd').on('click', function() {
$("div#responce_trainer_password").html(" Saving data, please wait ...");
var U_name = $('input#U_name').val();
var old_pwd = $('input#old_pwd').val();
var pwd_1 = $('input#pwd_1').val();
var pwd_2 = $('input#pwd_2').val();
var post='U_name=' + U_name + '&old_pwd=' + old_pwd + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 ;
$.post('act_trainerPersonalPwd.php', post, function(data) {
$("div#responce_trainer_password").html(data);
});
});
}
// ==================== Trainer course updating =================================
function form_trainer_course()
{
$('#trainer_Coursesend').on('click', function() {
var CTitle = encodeURIComponent($('input#CTitle').val());
var CDesc = encodeURIComponent($('textarea#CDesc').val());
var CDesc_arabic = encodeURIComponent($('textarea#CDesc-arabic').val());
// var CCreator = $('input#CCreator').val();
// var CEmail = $('input#CEmail').val();
// var CFree = $('input#CFree').val();
var Clevel = $("#Clevel option:selected").val();
// var CType = $("#CType option:selected").val();
// var cCurrency_code = $("#cCurrency option:selected").val();
// var cCurrency_text = $("#cCurrency option:selected").text();
// var cAssignedTo = $("#cAssignedTo option:selected").val();
// var CType = $("#CType option:selected").val();
// var Cduration = $('input#Cduration').val();
// var Dtype = $("#Dtype option:selected").val();
var CRequirement = $('textarea#CRequirement').val();
var LDesc = encodeURIComponent(CKEDITOR.instances['LDesc'].getData());
// var LDesc = CKEDITOR.instances['LDesc'].getData();
var LDesc_arabic = encodeURIComponent(CKEDITOR.instances['LDesc-arabic'].getData());
// var post='CTitle=' + CTitle + '&CDesc=' + CDesc + '&CDesc_arabic=' + CDesc_arabic + '&CFree=' + CFree +'&Clevel=' + Clevel +'&cCurrency_code=' + cCurrency_code +'&cCurrency_text='+ cCurrency_text +'&CType=' + CType +'&Cduration=' + Cduration +'&Dtype=' + Dtype +'&LDesc=' + LDesc + '&LDesc_arabic=' + LDesc_arabic +'&CRequirement=' + CRequirement +'&CCreator=' + CCreator + '&CEmail=' + CEmail + '&cAssignedTo=' + cAssignedTo + '&dt=' + (new Date()).getTime();
var post='CTitle=' + CTitle + '&CDesc=' + CDesc + '&CDesc_arabic=' + CDesc_arabic + '&Clevel=' + Clevel + '&LDesc=' + LDesc + '&LDesc_arabic=' + LDesc_arabic + '&dt=' + (new Date()).getTime();
// alert (LDesc);
// return false;
$.post('Post_course_trainer.php', post, function(data) {
$("div#responce_trainer_course").html(data);
});
});
$('a#btn-save-course-form').on('click', function() {
var cvForm = $('select#cv-form option:selected').val();
var post = 'cvForm=' + cvForm + '&dt=' + (new Date()).getTime();
// alert (LDesc);
// return false;
$.post('act_SaveCourseFormSelection.php', post, function(data) {
$("div#response-course-form").html(data);
});
});
$('a#btn-save-forum').on('click', function() {
var fid = $('select#selected-forum option:selected').val();
var post = 'fid=' + fid + '&dt=' + (new Date()).getTime();
$.post('act_SaveCourseForum.php', post, function(data) {
$("div#response-forum").html(data);
});
});
}
// ==================== Trainer Page =================================
function form_trainer_page()
{
$("#folder_name").change(function(){
$("#message").html(" Checking ...");
var d_folder=$("#folder_name").val();
$.ajax({
type:"post",
url:"check_domainFolder.php",
data:"d_folder="+d_folder,
success:function(data){
if(data==0){
$("#message").html(" Available");
}
else{
$("#message").html(" Not available");
}
}
});
});
}
// ==================== Trainer signup =================================
function form_trainer_signup()
{
$("#U_name").change(function(){
$("#message").html(" Checking ...");
var username = $("#U_name").val();
$.ajax({
type:"post",
url:"check_username.php",
data:"username="+username,
success:function(data){
if(data==0){
$("#message").html(" Available");
}
else{
$("#message").html(" Not available");
}
}
});
});
$('#trainer_send').on('click', function() {
$("div#responce").html(" Saving data, please wait ...");
var U_name = $('input#U_name').val();
var pwd_1 = $('input#pwd_1').val();
var pwd_2 = $('input#pwd_2').val();
var FullName = $('input#FullName').val();
var email = $('input#email').val();
var WebsiteAdd = $('input#WebsiteAdd').val();
var post='U_name=' + U_name + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&FullName=' + FullName + '&WebsiteAdd=' + WebsiteAdd + '&email=' + email;
$.post('act_trainer_signup.php', post, function(data) {
$("div#responce").html(data);
});
});
}
function form_sub_trainer_signup()
{
$("#T_name").change(function(){
$("#message").html(" Checking ...");
var username = $("#T_name").val();
$.ajax({
type:"post",
url:"check_username.php",
data:"username="+username,
success:function(data){
if(data==0){
$("#message").html(" Available");
}
else{
$("#message").html(" Not available");
}
}
});
});
$('#sub_trainer_signup').on('click', function() {
$("div#responce").html(" Saving data, please wait ...");
var U_name = $('input#T_name').val();
var pwd_1 = $('input#pwd_1').val();
var pwd_2 = $('input#pwd_2').val();
var FullName = $('input#FullName').val();
var email = $('input#email').val();
var post='U_name=' + U_name + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&FullName=' + FullName + '&email=' + email;
// alert (post);
$.post('act_sub_trainer_signup.php', post, function(data) {
$("div#responce").html(data);
});
});
}
function form_assistant_trainer_registration () {
$("#ST_name").change(function(){
$("#message").html(" Checking ...");
var username = $("#ST_name").val();
$.ajax({
type:"post",
url:"check_username.php",
data:"username="+username,
success:function(data){
if(data==0){
$("#message").html(" Available");
}
else{
$("#message").html(" Not available");
}
}
});
});
$('#assistant_trainer_signup').on('click', function() {
$("div#responce").html(" Saving data, please wait ...");
var U_name = $('input#ST_name').val();
var pwd_1 = $('input#pwd_1').val();
var pwd_2 = $('input#pwd_2').val();
var FullName = $('input#FullName').val();
var email = $('input#email').val();
var tel = $('input#tele_no').val();
var post='U_name=' + U_name + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&FullName=' + FullName + '&email=' + email + '&tel=' + tel;
// alert (post);
$.post('act_assistant_trainer_signup.php', post, function(data) {
$("div#responce").html(data);
});
});
}
// ==================== Trainer signup =================================
function form_institute_signup() {
$("#T_name").change(function(){
$("#message").html(" Checking ...");
var username = $("#T_name").val();
$.ajax({
type:"post",
url:"check_username.php",
data:"username="+username,
success:function(data){
if(data==0){
$("#message").html(" Available");
}
else{
$("#message").html(" Not available");
}
}
});
});
$('#institute_signup').on('click', function() {
$("div#responce").html(" Saving data, please wait ...");
var U_name = $('input#T_name').val();
var pwd_1 = $('input#pwd_1').val();
var pwd_2 = $('input#pwd_2').val();
var FullName = $('input#FullName').val();
var email = $('input#email').val();
var typ = $('select#institute-type').val();
var post='U_name=' + U_name + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&FullName=' + FullName + '&typ=' + typ + '&email=' + email;
$.post('act_institute_signup.php', post, function(data) {
$("div#responce").html(data);
});
});
}
// ==================== Institute signup =================================
function Inst_Reg_form()
{
$("#I_name").change(function(){
$("#message").html(" Checking ...");
var username=$("#I_name").val();
$.ajax({
type:"post",
url:"check_username.php",
data:"username="+username,
success:function(data){
if(data==0){
$("#message").html(" Available");
}
else{
$("#message").html(" Not available");
}
}
});
});
$("#URLD").change(function(){
$("#message1").html(" Checking ...");
var instname=$("#URLD").val();
$.ajax({
type:"post",
url:"check_instname.php",
data:"instname="+instname,
success:function(data){
if(data==0){
$("#message1").html(" Available");
}
else{
$("#message1").html(" Not available");
}
}
});
});
$('#Inst_info').on('click', function() {
$("div#responce").html(" Saving data, please wait ...");
var Ins_name = $('input#Ins_name').val();
var I_name = $('input#I_name').val();
var pwd_1 = $('input#pwd_1').val();
var pwd_2 = $('input#pwd_2').val();
var FullName = $('input#FullName').val();
var URLD = $('input#URLD').val();
var email = $('input#email').val();
var WebsiteAdd = $('input#WebsiteAdd').val();
var post = 'Ins_name=' + Ins_name + '&U_name=' + I_name + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&FullName=' + FullName + '&URLD=' + URLD + '&WebsiteAdd=' + WebsiteAdd + '&email=' + email;
$.post('Post_form_institute.php', post, function(data) {
$("div#responce").html(data);
});
});
}
// =================================================================================================================
function change_RecoverPWD_form()
{
$('#chngPwd').on('click', function() {
var pwd_1 = $('input#password').val();
var pwd_2 = $('input#cnfrm_password').val();
var User_ID = $('input#userID').val();
var stopHere="";
if(pwd_1 == "" ){
$("#e_password").toggleClass("Nshow_span show_span");
$("#e_password").html("Required");
stopHere=1;
}
if(pwd_2 == "" ){
$("#e_cnfrm_password").toggleClass("Nshow_span show_span");
$("#e_cnfrm_password").html("Required");
stopHere=1;
}
if(pwd_1 != pwd_2){
$("#e_cnfrm_password").html("Password Missmatched ");
stopHere=1;
}
if (stopHere!=""){
$("div#responce1").html(" Missing Information");
return false;
}
var post = 'pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&User_ID=' + User_ID;
// alert(post);
$("div#responce").html(" Changing Password, please wait ...");
$.post('act_chngPWD.php', post, function(data) {
// alert(data);
if(data==1){
var welcomeNote = "Password has been change. ";
welcomeNote += '
Login ';
welcomeNote += "
";
$("div#responce1").html(welcomeNote);
}
else {
$("div#responce").html("Please try later!");
}
});
});
}
//++++++++++++++++++++++++++++++
function demo_request_form()
{
$("#User_Name").change(function(){
$("#e_User_Name").removeClass("Nshow_span");
$("#e_User_Name").html(" checking...");
var username=$("#User_Name").val();
if (username!=""){
$.ajax({
type:"post",
url:"check_username.php",
data:"username="+username,
success:function(data){
if(data==0){
$("#e_User_Name").addClass("show_spanG");
$("#e_User_Name").html(" Available");
}
else{
$("#e_User_Name").removeClass("Nshow_span");
$("#e_User_Name").removeClass("show_spanG");
$("#e_User_Name").addClass("show_span");
$("#e_User_Name").html(" Not available");
}
}
});
} else {
$("#e_User_Name").removeClass("show_span");
$("#e_User_Name").removeClass("show_spanG");
$("#e_User_Name").addClass("Nshow_span");
}
});
$("#Email_Address").change(function(){
$("#e_Email_Address").removeClass("Nshow_span");
$("#e_Email_Address").html(" checking...");
var Email_Address=$("#Email_Address").val();
if (Email_Address!=""){
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(Email_Address)) {
$.ajax({
type:"post",
url:"check_email.php",
data:"Email_Address="+Email_Address,
success:function(data){
if(data==0){
$("#e_Email_Address").addClass("show_spanG");
$("#e_Email_Address").html(" Available");
}
else{
$("#e_Email_Address").removeClass("Nshow_span");
$("#e_Email_Address").removeClass("show_spanG");
$("#e_Email_Address").addClass("show_span");
$("#e_Email_Address").html(" Not available");
}
}
});
} else {
$("#e_Email_Address").removeClass("Nshow_span");
$("#e_Email_Address").removeClass("show_spanG");
$("#e_Email_Address").addClass("show_span");
$("#e_Email_Address").html("Invalid Format");
}
} else {
$("#e_Email_Address").removeClass("show_span");
$("#e_Email_Address").removeClass("show_spanG");
$("#e_Email_Address").addClass("Nshow_span");
}
});
$("#Phone_Number").change(function(){
$("#e_Phone_Number").removeClass("Nshow_span");
$("#e_Phone_Number").addClass("show_span");
$("#e_Phone_Number").html(" checking...");
var Phone_Number=$("#Phone_Number").val();
if (Phone_Number!=""){
var filter = /^[0-9-+s()]*$/;
if (filter.test(Phone_Number)) {
$("#e_Phone_Number").html("");
$("#e_Phone_Number").removeClass("show_span");
$("#e_Phone_Number").addClass("Nshow_span");
return true;
}
else {
$("#e_Phone_Number").html("Invlid Number Format!");
return false;
}
} else {
$("#e_Phone_Number").removeClass("show_span");
$("#e_Phone_Number").addClass("Nshow_span");
}
});
$("#password").keyup(function(){
$("#e_password").removeClass("Nshow_span");
$("#e_password").addClass("show_spanW");
$("#e_password").html(" checking...");
var password=$("#password").val();
if (password!=""){
//Regular Expressions.
var regex = new Array();
regex.push("[A-Z]"); //Uppercase Alphabet.
regex.push("[a-z]"); //Lowercase Alphabet.
regex.push("[0-9]"); //Digit.
regex.push("[$@$!%*#?&]"); //Special Character.
var passed = 0;
for (var i = 0; i < regex.length; i++) {
if (new RegExp(regex[i]).test(password)) {
passed++;
}
//Validate for length of Password.
if (passed > 3 && password.length > 5) {
passed++;
}
var color = "";
var strength = "";
switch (passed) {
case 0:
case 1:
strength = "Very Weak";
color = "red";
break;
case 2:
strength = "Weak";
color = "darkorange";
break;
case 3:
case 4:
strength = "Strong";
color = "green";
break;
case 5:
strength = "Very Strong";
color = "darkgreen";
break;
}
$("#e_password").html(strength);
$("#e_password").css("color", color);
}
} else {
$("#e_password").removeClass("show_spanW");
$("#e_password").addClass("Nshow_span");
}
});
$(".toggle-password").click(function() {
$(this).toggleClass("icon-eye-open icon-eye-close");
$("#password").toggleClass( "pw" );
$("#pwdOld").toggleClass( "pw" );
return false;
});
$("#cnfrm_password").keyup(function() {
$("#e_cnfrm_password").removeClass("Nshow_span");
$("#e_cnfrm_password").addClass("show_span");
var password1=$("#password").val();
var password2=$("#cnfrm_password").val();
if(password1 != password2){
$("#e_cnfrm_password").html("Password Missmatched ");
}else {
$("#e_cnfrm_password").html("");
$("#e_cnfrm_password").removeClass("show_span");
$("#e_cnfrm_password").addClass("Nshow_span");
}
});
$("#First_Name").change(function(){
$("#e_First_Name").toggleClass("Nshow_span show_span");
});
$("#Last_Name").change(function(){
$("#e_Last_Name").toggleClass("Nshow_span show_span");
});
$("#Service_Interested_In").change(function(){
$("#e_Service_Interested_In").toggleClass("Nshow_span show_span");
});
$("#CTitle").change(function(){
$("#e_CTitle").toggleClass("Nshow_span show_span");
});
$("#countryS").change(function(){
$("#e_country").toggleClass("Nshow_span show_span");
});
$('#RegFrom_info').on('click', function() {
var CTitle = $('#CTitle option:selected').val();
var First_Name = $('input#First_Name').val();
var Last_Name = $('input#Last_Name').val();
var pwd_1 = $('input#password').val();
var pwd_2 = $('input#cnfrm_password').val();
var User_Name = $('input#User_Name').val();
var email = $('input#Email_Address').val();
var Phone_Number = $('input#Phone_Number').val();
var Visitor_Occupation = $('input#Visitor_Occupation').val();
var Visitor_Age = $('input#Visitor_Age').val();
var Service_Interested_In = $('#Service_Interested_In option:selected').val();
var country = $('#countryS option:selected').val();
var stopHere="";
if(CTitle == "" ){
$("#e_CTitle").toggleClass("Nshow_span show_span");
$("#e_CTitle").html("Required");
stopHere=1;
}
if(First_Name == "" ){
$("#e_First_Name").toggleClass("Nshow_span show_span");
$("#e_First_Name").html("Required");
stopHere=1;
}
if(Last_Name == "" ){
$("#e_Last_Name").toggleClass("Nshow_span show_span");
$("#e_Last_Name").html("Required");
stopHere=1;
}
if(pwd_1 == "" ){
$("#e_password").toggleClass("Nshow_span show_span");
$("#e_password").html("Required");
stopHere=1;
}
if(pwd_2 == "" ){
$("#e_cnfrm_password").toggleClass("Nshow_span show_span");
$("#e_cnfrm_password").html("Required");
stopHere=1;
}
if(pwd_1 != pwd_2){
$("#e_cnfrm_password").html("Password Missmatched ");
stopHere=1;
}
if(User_Name == "" ){
$("#e_User_Name").removeClass("Nshow_span");
$("#e_User_Name").addClass("show_span");
$("#e_User_Name").html("Required");
stopHere=1;
}
if(Phone_Number == "" ){
$("#e_Phone_Number").toggleClass("Nshow_span show_span");
$("#e_Phone_Number").html("Required");
stopHere=1;
}
if(Service_Interested_In == "" ){
$("#e_Service_Interested_In").toggleClass("Nshow_span show_span");
$("#e_Service_Interested_In").html("Required");
stopHere=1;
}
if(country == "" ){
$("#e_country").toggleClass("Nshow_span show_span");
$("#e_country").html("Required");
stopHere=1;
}
if(email == "" ){
$("#e_Email_Address").toggleClass("Nshow_span show_span");
$("#e_Email_Address").html("Required");
stopHere=1;
}
if (stopHere!=""){
$("div#responce1").html(" Missing Information");
return false;
}
var post = 'CTitle=' + CTitle + '&First_Name=' + First_Name + '&Last_Name='
+ Last_Name + '&pwd_1=' + pwd_1 + '&pwd_2=' + pwd_2 + '&User_Name=' + User_Name + '&email=' + email +
'&Phone_Number=' + Phone_Number + '&Visitor_Occupation=' + Visitor_Occupation + '&Visitor_Age=' + Visitor_Age +
'&Service_Interested_In=' + Service_Interested_In + '&country=' + country;
// alert(post);
$("div#responce1").html(" Saving data, please wait ...");
$("div#responce").html(" Saving data, please wait ...");
$.post('act_Reg.php', post, function(data) {
var arr = data.split("|");
if(arr[0]==0) {
$("div#responce").html('Your Email is already registered with us. Use another email OR Click here for login');
$("div#responce1").html('Your Email is already registered with us. Use another email OR Click here for login');
}
else if(arr[0]==2){
$("div#responce").html("We are unable to create account at this time. Please try again later!");
$("div#responce1").html("We are unable to create account at this time. Please try again later!");
}
else if(arr[0]==1){
var welcomeNote = ""+ arr[3]+", ";
welcomeNote += '
Thank you for registering with us. We have send you an email with all the information required to login to your account. ';
welcomeNote += "
";
$("div#responce").html(welcomeNote);
$("div#responce1").html("");
$("div#formArea").hide();
$("div#menuUpdate").load();
}
else {
$("div#responce").html("Please try later!");
$("div#responce1").html("Please try later!");
}
//alert (data);
});
});
}
//*************************************
//+++++++++++++++++++++++++++++
function SignupTVT_Tabs() {
var arr_signup = new Array();
arr_signup.push({item_key: "Sign Up", item_value: "Sign Up"});arr_signup.push({item_key: "1 Create Course Videos", item_value: "1 Create Course Videos"});arr_signup.push({item_key: "2 Manage Course Information", item_value: "2 Manage Course Information"});arr_signup.push({item_key: "3 Manage Course Content", item_value: "3 Manage Course Content"});arr_signup.push({item_key: "4 Publish Course", item_value: "4 Publish Course"});arr_signup.push({item_key: "5 Market Course", item_value: "5 Market Course"});
$('.SignupTVT ul.sort li').eq(0).addClass('current');
changeContent ('sign-up');
$('.SignupTVT ul.sort a').click(function() {
$(this).css('outline','none');
$('ul.sort .current').removeClass('current');
$(this).parent().addClass('current');
var item = "";
for (x in arr_signup) {
if (arr_signup[x].item_value == $(this).text()) {
item = arr_signup[x].item_key;
}
}
// var filterVal = $(this).text().toLowerCase().replace(' ','-');
var filterVal = item.toLowerCase().replace(/ /g,'-');
// var filterVal = $(this).text().toLowerCase().replace(/ /g,'-');
changeContent (filterVal);
return false;
});
}
function changeContent (filterVal) {
$('ul.SignupTVT_sort li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeOut('normal').addClass('hidden');
} else {
$(this).fadeIn('slow').removeClass('hidden');
}
});
}
function pickvideoTVT_Tabs() {
$('.pickvideoTVT ul.sort li').eq(0).addClass('current');
changeContent ('sign-up');
$('.pickvideoTVT ul.sort a').click(function() {
$(this).css('outline','none');
$('ul.sort .current').removeClass('current');
$(this).parent().addClass('current');
var filterVal = $(this).text().toLowerCase().replace(/ /g,'-');
changeContentVideo (filterVal);
return false;
});
}
function changeContentVideo (filterVal) {
$('ul.pickvideoTVT_sort li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeOut('normal').addClass('hidden');
} else {
$(this).fadeIn('slow').removeClass('hidden');
}
});
}
function goto_top() {
$("#footer #sub_footer a.back_to_top").click(function(){
$('html, body').animate({scrollTop:0}, 400);
return false;
});
}
function contact_form()
{
$('#contact_send').on('click', function() {
var name = $('input#name').val();
var email = $('input#email').val();
var country = $("#country option:selected").val();
var officeTo = $('input#officeTo').val();
var message = $('textarea#message').val();
var toSend="";
$("#e_email").removeClass("Nshow_span");
$("#e_name").removeClass("Nshow_span");
$("#e_message").removeClass("Nshow_span");
$("#e_country").removeClass("Nshow_span");
$("#e_email").removeClass("show_span");
$("#e_name").removeClass("show_span");
$("#e_message").removeClass("show_span");
$("#e_country").removeClass("show_span");
$("#e_email").addClass("Nshow_span");
$("#e_name").addClass("Nshow_span");
$("#e_message").addClass("Nshow_span");
$("#e_country").addClass("Nshow_span");
if(email==""){
$("#e_email").removeClass("Nshow_span");
$("#e_email").addClass("show_span");
$("#e_email").html("Required");
toSend=1;
}
if(name==""){
$("#e_name").removeClass("Nshow_span");
$("#e_name").addClass("show_span");
$("#e_name").html("Required");
toSend=1;
}
if(message==""){
$("#e_message").removeClass("Nshow_span");
$("#e_message").addClass("show_span");
$("#e_message").html("Required");
toSend=1;
}
if(country==""){
$("#e_country").removeClass("Nshow_span");
$("#e_country").addClass("show_span");
$("#e_country").html("Required");
toSend=1;
}
if (toSend!=""){
return;
}
var post = 'name=' + name + '&email=' + email + '&country=' + country + '&officeTo=' + officeTo + '&message=' + message;
$.post('sendmail.php', post, function(data) {
$("div#responce").html(data);
});
});
}
function loginTVT() {
$('#loginTVTsend').on('click', function() {
doLogin ();
});
}
function doLogin () {
$("div#responce").html(" Please Wait
");
var U_name = $('input#U_name').val();
var pwd_1 = $('input#pwd_1').val();
var post='U_name=' + U_name + '&pwd_1=' + pwd_1;
$.post('act_login.php', post, function(data) {
if(data==1) {
$("div#responce").html("Login Successfully
");
window.location.href= "myDashboard.php";
//$("div#menuUpdate").load();
} else {
$("div#responce").html(" Either username Or password mismatched. Please try again! ");
}
});
}
function course_timezone()
{
$('#course_timezone_btn').on('click', function() {
var optionSelected = $(this).find("option:selected");
var valueSelected = optionSelected.val();
var textSelected = optionSelected.text();
confirm("value is changed");
$.ajax({
type:"post",
url:"act_courseTimezone.php",
data:"tzone_off="+valueSelected+"&tzone="+textSelected,
success:function(data){
$("div#responce").html(data);
}
});
});
}
function form_institute_course()
{
$('#institute_Coursesend').on('click', function() {
var CTitle = $('input#CTitle').val();
var CDesc = $('input#CDesc').val();
var CCreator = $('input#CCreator').val();
var CEmail = $('input#CEmail').val();
var post='CTitle=' + CTitle + '&CDesc=' + CDesc + '&CCreator=' + CCreator + '&CEmail=' + CEmail;
$.post('Post_course_institute.php', post, function(data) {
$("div#responce").html(data);
});
});
}
function form_upload_file()
{
$('#SendfileUpload').on('click', function() {
var Fileupload = $('input#Fileupload').val();
var FileDetail = $('input#FileDetail').val();
var post='Fileupload=' + Fileupload + '&FileDetail=' + FileDetail;
$.post('Post_course_file.php', post, function(data) {
$("div#responce").html(data);
});
});
}
function tabs_ui() {
$(".tab_content").hide();
$("ul.tabs_nav li:first").addClass("active").show();
$(".tab_content:first").show();
$("ul.tabs_nav li").click(function() {
$("ul.tabs_nav li").removeClass("active");
$(this).addClass("active");
$(".tab_content").hide();
var activeTab = $(this).find("a").attr("href");
if ($(activeTab).hasClass("courses")) {
// alert ("courses");
LoadAllCourses ();
} else if ($(activeTab).hasClass("course-bundles")) {
// alert ("course-buldles");
LoadAllCourseBundles ();
} else if ($(activeTab).hasClass("add-questions")) {
CKEDITOR.instances['qnTx'].setData('');
$('.option-windows').empty ();
} else if ($(activeTab).hasClass("school-tab")) {
LoadSchools (1); // function present in My_dashboard_Trainer.php
} else if ($(activeTab).hasClass("students-in-groups-tab")) {
LoadStudentsInGroups ();
} else if ($(activeTab).hasClass('Performance-Section1')) {
EmptyAllContainers ();
LoadStudentPerformances ();
} else if ($(activeTab).hasClass("students-groups-tab")) {
LoadGroupsList ();
} else if ($(activeTab).hasClass("students-grades-tab")) {
LoadGradesList ();
} else if ($(activeTab).hasClass("students-comment-labels-tab")) {
LoadCommentLabelsList ();
} else if ($(activeTab).hasClass("forums-tab")) {
LoadForumsList ();
} else if ($(activeTab).hasClass("course-study-guideline-master-tab")) {
LoadCourseStudyGuidelineMaster ();
} else if ($(activeTab).hasClass("existing-questions")) {
var quiz2 = 0;
$($(activeTab).attr('class').split(' ')).each (function () {
var arr = this.split('-');
if (arr[0] == 'quiz') {
quiz2 = arr[1];
}
});
// alert (quizID + "|" + quiz2);
$('.option-windows').empty ();
getQuizQuestionsData (quiz2);
}
$(activeTab).fadeIn(1000);
return false;
});
}
function getQuizQuestionsData (quizID) {
$("#existing-questions-list").html(" Getting existing questions list, please wait ...");
$.ajax({
url: 'getCourseQuizQuestions.php?quiz_id='+quizID, //Server script to process data
type: 'POST',
success: function (data) {
$("#existing-questions-list").html (data);
// accordion_ui();
question_accordion_ui ();
InitializeSortable (); // Present in Manage_quiz.php
},
error: function() {
$("#existing-questions-list").html ("Can not get the list of existing quiz questions at this time");
},
// Form data
data: {quiz_id: quizID},
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: true
});
}
function accordion_ui() {
$(".accordion h3").eq(0).addClass("active");
$(".accordion h3 .icon").eq(0).removeClass("icon-plus").addClass("icon-minus");
$(".acc_content").eq(0).show();
$(".accordion h3").click(function(){
var handle = $(this).next(".acc_content");
$(this).next(".acc_content").slideToggle("slow").siblings(".acc_content:visible").slideUp("slow");
$(this).toggleClass("active");
$(this).siblings("h3").removeClass("active");
$('.accordion h3').each(function(index,value) {
if($('.accordion h3:eq('+index+')').hasClass('active')) {
$('.accordion h3:eq('+index+') .icon').removeClass('icon-plus').addClass('icon-minus');
} else {
$('.accordion h3:eq('+index+') .icon').removeClass('icon-minus').addClass('icon-plus');
}
});
});
}
/*
function question_accordion_ui() {
$(".question.accordion h3").click(function(){
// alert ("called");
var handle = $(this).next(".acc_content");
$(this).next(".acc_content").slideToggle("slow").siblings(".acc_content:visible").slideUp("slow");
$(this).toggleClass("active");
$(this).siblings("h3").removeClass("active");
$('.question.accordion h3').each(function(index,value) {
if($('.question.accordion h3:eq('+index+')').hasClass('active')) {
$('.question.accordion h3:eq('+index+') .icon').removeClass('icon-plus').addClass('icon-minus');
} else {
$('.question.accordion h3:eq('+index+') .icon').removeClass('icon-minus').addClass('icon-plus');
}
});
$('.question.accordion .acc_content span').html("");
var elementID = $(this).attr("id");
if (elementID != null) {
handle.find("span").html(" Getting question data, please wait ...");
var questionID = elementID.split("-")[1];
$.ajax({
url: 'getCourseQuizQuestionInEditMode.php?qid='+questionID, //Server script to process data
type: 'POST',
success: function (data) {
handle.find("span").html(data);
applyEditQuestionFunctions ();
},
error: function() {
alert ("error");
handle.next("span").html ("Can not get the list of existing quiz questions at this time");
},
// Form data
data: {qid: questionID},
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: true
});
}
var str = "";
$('.question.accordion .acc_content span').each(function(index,value) {
str += $('.question.accordion .acc_content span:eq('+index+')').html();
});
});
}
*/
function question_accordion_ui() {
$(".question.accordion h3").click(function(){
// alert ("called");
var handle = $(this).next(".acc_content");
$(this).next(".acc_content").slideToggle("slow").siblings(".acc_content:visible").slideUp("slow");
$(this).toggleClass("active");
$(this).parent().siblings("div.group").find('h3').removeClass("active");
$('.question.accordion div.group').each(function(index,value) {
if($(this).find('h3').hasClass('active')) {
$(this).find('h3 .icon').removeClass('icon-plus').addClass('icon-minus');
} else {
$(this).find('h3 .icon').removeClass('icon-minus').addClass('icon-plus');
}
});
$('.question.accordion .acc_content span').html("");
var elementID = $(this).attr("id");
if (elementID != null) {
handle.find("span").html(" Getting question data, please wait ...");
var questionID = elementID.split("-")[1];
$.ajax({
url: 'getCourseQuizQuestionInEditMode.php?qid='+questionID, //Server script to process data
type: 'POST',
success: function (data) {
handle.find("span").html(data);
applyEditQuestionFunctions ();
},
error: function() {
alert ("error");
handle.next("span").html ("Can not get the list of existing quiz questions at this time");
},
// Form data
data: {qid: questionID},
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: true
});
}
/*
var str = "";
$('.question.accordion .acc_content span').each(function(index,value) {
str += $('.question.accordion .acc_content span:eq('+index+')').html();
});
*/
});
}
function custom_lists_ui() {
$("ul.arrow li").prepend(' ');
$("ul.plus li").prepend(' ');
$("ul.check li").prepend(' ');
}
var thresholdcolors=[['20%','darkred'], ['10%','red']] //[chars_left_in_pct, CSS color to apply to output]
var uncheckedkeycodes=/(8)|(13)|(16)|(17)|(18)/ //keycodes that are not checked, even when limit has been reached.
thresholdcolors.sort(function(a,b){return parseInt(a[0])-parseInt(b[0])}) //sort thresholdcolors by percentage, ascending
function setformfieldsize($fields, optsize, optoutputdiv){
var $=jQuery
$fields.each(function(i){
var $field=$(this)
$field.data('maxsize', optsize || parseInt($field.attr('data-maxsize'))) //max character limit
var statusdivid=optoutputdiv || $field.attr('data-output') //id of DIV to output status
$field.data('$statusdiv', $('#'+statusdivid).length==1? $('#'+statusdivid) : null)
$field.unbind('keypress.restrict').bind('keypress.restrict', function(e){
setformfieldsize.restrict($field, e)
})
$field.unbind('keyup.show').bind('keyup.show', function(e){
setformfieldsize.showlimit($field)
})
setformfieldsize.showlimit($field) //show status to start
})
}
setformfieldsize.restrict=function($field, e){
var keyunicode=e.charCode || e.keyCode
if (!uncheckedkeycodes.test(keyunicode)){
if ($field.val().length >= $field.data('maxsize')){ //if characters entered exceed allowed
if (e.preventDefault)
e.preventDefault()
return false
}
}
}
setformfieldsize.showlimit=function($field){
if ($field.val().length > $field.data('maxsize')){
var trimmedtext=$field.val().substring(0, $field.data('maxsize'));
$field.val(trimmedtext);
}
if ($field.data('$statusdiv')){
// $field.data('$statusdiv').css('color', '').html($field.val().length);
$field.data('$statusdiv').css('color', '').html(' Current ' + $field.val().length + ' : Remaining ' + ($field.data('maxsize')-$field.val().length));
var pctremaining=($field.data('maxsize')-$field.val().length)/$field.data('maxsize')*100; //calculate chars remaining in terms of percentage
for (var i=0; i" + data + "");
} else {
$("#responce").html ("File uploaded successfully. ");
$("#existing-course-files").html (" Getting course files, please wait ...");
getCourseFiles ();
}
$('#SendfileUpload1').show();
return false;
},
error: function() {
alert("Error Occurred...");
$('#SendfileUpload1').show();
},
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
});
$('progress').hide();
getCourseFiles ();
myFancyBox ();
}
function progressHandlingFunction(e){
if(e.lengthComputable){
// $('progress').attr({value:e.loaded,max:e.total});
console.log (e.loaded + ' / ' + e.total);
}
}
function getCourseFiles () {
$.ajax({
url: 'getCourseFiles.php', //Server script to process data
type: 'POST',
success: function (data) {
$("#existing-course-files").html (data);
myFancyBox () ;
},
error: function() {
$("#existing-course-files").html ("Can not get the list of existing course files at this time.");
},
// Form data
data: false,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
}
function myFancyBox () {
$('.asim.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 500,
'height' : 300,
'onClosed': function () {getCourseFiles ();}
});
}
function getCourseQuizzes () {
$.ajax({
url: 'getCourseQuizzes.php', //Server script to process data
type: 'POST',
success: function (data) {
$("#existing-quizzes").html (data);
ApplyQuizEvents ();
manageQuizFancyBox ();
deleteQuizFancyBox ();
// putCheckMark ('quizzes-list');
ShowQuantity ('quizzes-list');
},
error: function() {
$("#existing-quizzes").html ("Can not get the list of existing quizzes at this time.");
},
// Form data
data: false,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
}
function getCourseFilesForTrainerDashboard () {
$.ajax({
url: 'getCourseFilesForTrainerDashboard.php', //Server script to process data
type: 'POST',
success: function (data) {
$("#existing-files").html (data);
editFileFancyBox ();
deleteFileFancyBox ();
putCheckMark ('files-list');
},
error: function() {
$("#existing-files").html ("Can not get the list of existing course files at this time.");
},
// Form data
data: false,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
}
function addCourseFilePageForTrainerDashboard () {
$('#SendfileUpload2').click(function(){
$(this).hide();
$('progress').show();
$("#responce").html ("");
// StartUploadCourseFile ();
// alert ($('#file').val());
var arr = $('input[type=file]').val().split('\\');
var selected_filename = arr[arr.length-1];
var post = 'f=' + selected_filename;
$.post ('CheckFileExist.php', post, function (data) {
data = data.trim();
if (data == "yes") {
$("#responce").html ("File already exists, choose some other ... ");
$('#SendfileUpload2').show();
$('progress').hide();
} else if (data == "no") {
StartUploadCourseFile ();
}
});
});
$('progress').hide();
}
function StartUploadCourseFile () {
var formData = new FormData($('form')[0]);
$.ajax({
url: 'uploadScriptForTrainerDashboard.php', //Server script to process data
type: 'POST',
xhr: function() { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // Check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
//Ajax events
// beforeSend: beforeSendHandler,
success: function (data) {
if (data != '0') {
$("#responce").html ("");
} else {
$("#responce").html ("File uploaded successfully. ");
}
$('#SendfileUpload2').show();
return false;
},
error: function() {
alert("Error Occurred...");
$('#SendfileUpload2').show();
},
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
}
function RashidFrame () {
$('.fancyboxRashid').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 850,
'height' : 400,
'onClosed': function () {window.location.reload();}
});
}
function Step08_trainer_signup() {
// alert ("asim 1");
getCourseFilesForTrainerDashboard ();
addFileFancyBox ();
editFileFancyBox ();
deleteFileFancyBox ();
getCourseQuizzes ();
addQuizFancyBox ();
manageQuizFancyBox ();
deleteQuizFancyBox ();
addQuizQuestionAjaxCalled ();
addCourseFilePageForTrainerDashboard ();
scheduleFancyBox ();
// CourseScheduleFancyBox ();
InvitationFancyBox ();
EmailTemplatesFancyBox ();
personalInfoFancyBox ();
// alert ("asim");
}
function deleteFileFancyBox () {
$('.delete-file.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 500,
'height' : 800,
'onClosed': function () {getCourseFilesForTrainerDashboard ();}
});
}
function editFileFancyBox () {
$('.edit-file.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '500',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 500,
'onClosed': function () {getCourseFilesForTrainerDashboard ();}
});
}
function addFileFancyBox () {
$('.add-file.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 600,
'onClosed': function () {getCourseFilesForTrainerDashboard ();}
});
}
function deleteQuizFancyBox () {
$('.delete-quiz.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 500,
'height' : 300,
'onClosed': function () {getCourseQuizzes ();}
});
}
function manageQuizFancyBox () {
$('.manage-quiz.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '500',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 820,
'height' : 800,
'onClosed': function () {getCourseQuizzes ();}
});
}
function addQuizFancyBox () {
$('.add-quiz.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 500,
'onClosed': function () {getCourseQuizzes ();}
});
}
function vlm () {
$('.vlm1.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 920,
'height' : 400
});
}
function scheduleFancyBox () {
$('.schedule.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 1200,
'height' : 530,
'onStart': function () {
$(this).attr("href", "act_courseTimezone.php?timezone=" + $("#timezone").val());
}
});
}
function CourseScheduleFancyBox () {
$('.course-schedule.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 1200,
'height' : 530
});
}
function InvitationFancyBox () {
$('.invitation.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 500
});
}
function EmailTemplatesFancyBox () {
$('.email-templates.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 500
});
}
function personalInfoFancyBox () {
var folName = "";
$('.per_InfoFancyBox.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 1000,
'height' : 550,
'onClosed': function () {window.location.reload();}
// 'onClosed': function () {alert($("a#my-page-anchor").attr("href"));}
// 'onCleanup': function () {alert(folName);}
});
}
function StudentInfoFancybox () {
$('.btn-student-details.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 500
});
}
function putCheckMark (strType) {
var num = 0;
$('ul.check').each(function() {
if ($(this).hasClass(strType)) {
$(this).find("li").prepend(' ');
num = $(this).find("li").length;
}
});
$('span').filter('#'+strType+'-number').html (num);
// alert (num);
}
function ShowQuantity (strType) {
var num = $('ul.'+strType).find("li").length;
$('span').filter('#'+strType+'-number').html (num);
// alert (num);
}
function addQuizQuestionAjaxCalled () {
console.log ("Loaded addQuizQuestionAjaxCalled");
$('#btnAddQuizQuestion').on('click', function() {
$("span.responce1").html(" Saving data, please wait ...");
var qnSt = $('#qnSt').val();
var qnType = $('#qnType').val();
var qTitle = $('#qTitle').val();
var qTitle_2 = $('#qTitle-2').val();
var qTitle_3 = $('#qTitle-3').val();
var UseTitleDutch_2 = $('input#use-title-dutch-new-2').prop("checked") ? 1:0;
var UseTitleDutch_3 = $('input#use-title-dutch-new-3').prop("checked") ? 1:0;
var qnTx = CKEDITOR.instances['qnTx'].getData();
var qnTx_2 = CKEDITOR.instances['qnTx-2'].getData();
var qnTx_3 = CKEDITOR.instances['qnTx-3'].getData();
var UseQuestionDutch_2 = $('input#use-question-dutch-new-2').prop("checked") ? 1:0;
var UseQuestionDutch_3 = $('input#use-question-dutch-new-3').prop("checked") ? 1:0;
var qnS1 = $('#qnS1').val();
var qnS2 = $('#qnS2').val();
var qnS3 = $('#qnS3').val();
var qnS4 = $('#qnS4').val();
var qnS5 = $('#qnS5').val();
var qnOp = $('#qnOp:checked').val();
var library_video = $('#library-video').val();
var qnSn = $('#qnSn:checked').val();
var file_qnSn = $('#file-qnSn:checked').val();
// var file_qnSn = $('input[name="file-qnSn"]:checked').val();
var qnSnc = "";
var file_qnSnc = "";
$('#option-check-add input:checkbox').each (function () {
qnSnc += (this.checked ? $(this).val() : "");
});
$('#options-files-div input:checkbox').each (function () {
file_qnSnc += (this.checked ? $(this).val() : "");
});
// alert (qnType + " - " + qnSn + " - " + qnSnc);
if (qnType == 1) {
if (qnTx == '' || qnTx == undefined || qnSn == "" || qnSn == undefined) {
$("span.responce1").html("You must select some answer ");
return;
}
} else if (qnType == 2) {
if (qnTx == '' || qnTx == undefined || qnSnc == "" || qnSnc == "undefined") {
$("span.responce1").html("You must select some answer ");
return;
}
} else if (qnType == 4) {
$('.tester').html(qnTx);
var num = 1;
var arr_blank = new Array();
var arr_options = new Array();
var empty_alert = false;
// alert ($('.tester').html());
$('.tester').find('input[class="blank"]').each (function (ind) {
var id = $(this).attr('id').split('-')[1];
var temp_arr = new Array();
$('.blank-' + id + ' .option-row input[type="text"]').each (function (n) {
if ($(this).val() != '') {
temp_arr.push($(this).val());
}
});
var blank_options = temp_arr.join('|');
if (blank_options == '') {
empty_alert = true;
return;
}
arr_options.push (blank_options);
// alert ($(this).html());
$(this).prop('id', 'id-' + num);
// alert ($(this).html());
num++;
});
if (empty_alert) {
$("span.responce1").html("There are some blanks with no answer set. ");
return;
}
qnS1 = arr_options.join('|||');
qnTx = $('.tester').html();
// alert ($('.tester').html());
$('.tester').empty ();
} else if (qnType == 6) {
$('.tester').html(qnTx);
var num = 1;
var arr_blank = new Array();
var arr_options = new Array();
var empty_alert = false;
$('.tester').find('select[class="blank"]').each (function (ind) {
var id = $(this).attr('id').split('-')[1];
var temp_arr = new Array();
var chk = '';
var input_val = '';
$('.blank-' + id + ' .option-row').each (function (n) {
input_val = $(this).find('input[type="text"]').val();
if (input_val != '') {
chk = ($(this).find('input[type="checkbox"]').is(':checked') ? 1 : 0);
temp_arr.push(chk + '^' + input_val);
}
});
var blank_options = temp_arr.join('|');
if (blank_options == '') {
empty_alert = true;
return;
}
arr_options.push (blank_options);
$(this).attr('id', 'id-' + num).empty();
num++;
});
if (empty_alert) {
$("span.responce1").html("There are some blanks with no answer set. ");
return;
}
qnS1 = arr_options.join('|||');
qnTx = $('.tester').html();
$('.tester').empty ();
} else if (qnType == 8) {
if (qnTx == '' || qnTx == undefined || file_qnSn == "" || file_qnSn == undefined) {
$("span.responce1").html("You must select some answer ");
return;
}
}
// alert (qnS1);
// return;
// var qnEx = encodeURIComponent($('#qnEx').val());
var qnEx = $('#qnEx').val();
// var post = 'qnSt=' + qnSt + '&qnType=' + qnType + '&qnTx=' + qnTx + '&qnS1=' + qnS1 + '&qnS2=' + qnS2 + '&qnS3=' + qnS3 + '&qnS4=' + qnS4 + '&qnS5=' + qnS5 + '&qnSn=' + qnSn + '&qnSnc=' + qnSnc + '&qnEx=' + qnEx;
var post = new FormData();
post.append('qnSt', qnSt);
post.append('qnType', qnType);
post.append('qTitle', qTitle);
post.append('qTitle_2', qTitle_2);
post.append('qTitle_3', qTitle_3);
post.append('UseTitleDutch_2', UseTitleDutch_2);
post.append('UseTitleDutch_3', UseTitleDutch_3);
post.append('qnTx', qnTx);
post.append('qnTx_2', qnTx_2);
post.append('qnTx_3', qnTx_3);
post.append('UseQuestionDutch_2', UseQuestionDutch_2);
post.append('UseQuestionDutch_3', UseQuestionDutch_3);
if (qnType == 8 || qnType == 9) {
post.append('file-qnS1', document.getElementById('file-qnS1').files[0]);
post.append('file-qnS2', document.getElementById('file-qnS2').files[0]);
post.append('file-qnS3', document.getElementById('file-qnS3').files[0]);
post.append('file-qnS4', document.getElementById('file-qnS4').files[0]);
post.append('file-qnS5', document.getElementById('file-qnS5').files[0]);
post.append('file-qnSn', file_qnSn);
post.append('file-qnSnc', file_qnSnc);
} else {
post.append('qnS1', qnS1);
post.append('qnS2', qnS2);
post.append('qnS3', qnS3);
post.append('qnS4', qnS4);
post.append('qnS5', qnS5);
}
post.append('qnOp', qnOp);
post.append('qnSn', qnSn);
post.append('qnSnc', qnSnc);
post.append('qnEx', qnEx);
post.append('library-video', library_video);
post.append('question-file', document.getElementById('question-file').files[0]);
// alert (post);
$.ajax({
url: 'AjaxAddQuizQuestion.php', //Server script to process data
type: 'POST',
xhr: function() { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // Check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
//Ajax events
// beforeSend: beforeSendHandler,
success: function (data) {
$("#qnTx").val("");
$("#qnEx").val("");
$("#qTitle").val("");
CKEDITOR.instances['qnTx'].setData('');
$('.option-windows').empty ();
$('#question-file').val('');
$('#library-video').val('');
$('#qnType').change ();
$('#qnSn').prop('checked', false);
$('.add-radio').each (function () {
this.checked = false;
});
for (var n=1; n<=5; n++) {
$('#qnS'+n).val("");
$('#qnSn'+n).prop('checked', false);
$('#file-qnSn'+n).prop('checked', false);
}
$('#file-qnS1').val('');
$('#file-qnS2').val('');
$('#file-qnS3').val('');
$('#file-qnS4').val('');
$('#file-qnS5').val('');
$('#file-qnSn').val('');
$('.preview-file').html('').css('height', '0px');
$("span.responce1").html(data);
return false;
},
error: function() {
alert("Error Occurred...");
$('#SendfileUpload1').show();
},
// Form data
data: post,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
});
}
function editQuizQuestionAjaxCalled () {
$('#btnEditQuizQuestion').on('click', function() {
$("span.responce2").html(" Saving data, please wait ...");
var qid = $('#qid').val();
var qnSte = $('#qnSte').val();
var qnTypee = $('#qnTypee').val();
var qTitlee = $('#qTitlee').val();
var qTitlee_2 = $('#qTitlee-2').val();
var qTitlee_3 = $('#qTitlee-3').val();
var UseTitleDutch_2 = $('input#use-title-dutch-edit-2').prop("checked") ? 1:0;
var UseTitleDutch_3 = $('input#use-title-dutch-edit-3').prop("checked") ? 1:0;
var qnTxe = CKEDITOR.instances['qnTxe'].getData();
var qnTxe_2 = CKEDITOR.instances['qnTxe-2'].getData();
var qnTxe_3 = CKEDITOR.instances['qnTxe-3'].getData();
var UseQuestionDutch_2 = $('input#use-question-dutch-edit-2').prop("checked") ? 1:0;
var UseQuestionDutch_3 = $('input#use-question-dutch-edit-3').prop("checked") ? 1:0;
var qnSe1 = $('#qnSe1').val();
var qnSe2 = $('#qnSe2').val();
var qnSe3 = $('#qnSe3').val();
var qnSe4 = $('#qnSe4').val();
var qnSe5 = $('#qnSe5').val();
var qnOpe = $('#qnOpe:checked').val();
var library_video = $('#library-video-e').val();
var qnSne = $('#qnSne:checked').val();
var file_qnSne = $('#file-qnSne:checked').val();
var qnSnce = "";
var file_qnSnce = "";
$('#option-check-edit input:checkbox').each (function () {
qnSnce += (this.checked ? $(this).val() : "");
});
$('#options-files-div-edit input:checkbox').each (function () {
file_qnSnce += (this.checked ? $(this).val() : "");
});
if (qnTypee == 1) {
if (qnSne == "" || qnSne == undefined) {
$("span.responce2").html("You must select some answer ");
return;
}
} else if (qnTypee == 2) {
if (qnSnce == "" || qnSnce == "undefined") {
$("span.responce2").html("You must select some answer ");
return;
}
} else if (qnTypee == 4) {
$('.tester').html(qnTxe);
var num = 1;
var arr_blank = new Array();
var arr_options = new Array();
var empty_alert = false;
$('.tester').find('input[class="blank"]').each (function (ind) {
var id = $(this).attr('id').split('-')[1];
var temp_arr = new Array();
$('.blank-' + id + ' .option-row input[type="text"]').each (function (n) {
if ($(this).val() != '') {
temp_arr.push($(this).val());
}
});
var blank_options = temp_arr.join('|');
if (blank_options == '') {
empty_alert = true;
return;
}
arr_options.push (blank_options);
$(this).prop('id', 'id-' + num);
num++;
});
if (empty_alert) {
$("span.responce2").html("There are some blanks with no answer set. ");
return;
}
qnSe1 = arr_options.join('|||');
qnTxe = $('.tester').html();
$('.tester').empty ();
} else if (qnTypee == 6) {
$('.tester').html(qnTxe);
var num = 1;
var arr_blank = new Array();
var arr_options = new Array();
var empty_alert = false;
$('.tester').find('select[class="blank"]').each (function (ind) {
var id = $(this).attr('id').split('-')[1];
var temp_arr = new Array();
var chk = '';
var input_val = '';
$('.blank-' + id + ' .option-row').each (function (n) {
input_val = $(this).find('input[type="text"]').val();
if (input_val != '') {
chk = ($(this).find('input[type="checkbox"]').is(':checked') ? 1 : 0);
temp_arr.push(chk + '^' + input_val);
}
});
var blank_options = temp_arr.join('|');
if (blank_options == '') {
empty_alert = true;
return;
}
arr_options.push (blank_options);
$(this).attr('id', 'id-' + num).empty();
num++;
});
if (empty_alert) {
$("span.responce2").html("There are some blanks with no answer set. ");
return;
}
qnSe1 = arr_options.join('|||');
qnTxe = $('.tester').html();
$('.tester').empty ();
} else if (qnTypee == 8) {
if (qnTxe == '' || qnTxe == undefined || file_qnSne == "" || file_qnSne == undefined) {
$("span.responce1").html("You must select some answer ");
return;
}
}
// var qnExe = encodeURIComponent($('#qnExe').val());
var qnExe = $('#qnExe').val();
// var post = 'qid=' + qid + '&qnSte=' + qnSte + '&qnTypee=' + qnTypee + '&qnTxe=' + qnTxe + '&qnTxe_2=' + qnTxe_2 + '&qnTxe_3=' + qnTxe_3 + '&qnSe1=' + qnSe1 + '&qnSe2=' + qnSe2 + '&qnSe3=' + qnSe3 + '&qnSe4=' + qnSe4 + '&qnSe5=' + qnSe5 + '&qnSne=' + qnSne + '&qnSnce=' + qnSnce + '&qnExe=' + qnExe;
var post = new FormData();
post.append('qid', qid);
post.append('qnSte', qnSte);
post.append('qnTypee', qnTypee);
post.append('qTitlee', qTitlee);
post.append('qTitlee_2', qTitlee_2);
post.append('qTitlee_3', qTitlee_3);
post.append('UseTitleDutch_2', UseTitleDutch_2);
post.append('UseTitleDutch_3', UseTitleDutch_3);
post.append('qnTxe', qnTxe);
post.append('qnTxe_2', qnTxe_2);
post.append('qnTxe_3', qnTxe_3);
post.append('UseQuestionDutch_2', UseQuestionDutch_2);
post.append('UseQuestionDutch_3', UseQuestionDutch_3);
if (qnTypee == 8 || qnTypee == 9) {
post.append('file-qnSe1', document.getElementById('file-qnSe1').files[0]);
post.append('file-qnSe2', document.getElementById('file-qnSe2').files[0]);
post.append('file-qnSe3', document.getElementById('file-qnSe3').files[0]);
post.append('file-qnSe4', document.getElementById('file-qnSe4').files[0]);
post.append('file-qnSe5', document.getElementById('file-qnSe5').files[0]);
post.append('file-qnSne', file_qnSne);
post.append('file-qnSnce', file_qnSnce);
} else {
post.append('qnSe1', qnSe1);
post.append('qnSe2', qnSe2);
post.append('qnSe3', qnSe3);
post.append('qnSe4', qnSe4);
post.append('qnSe5', qnSe5);
}
post.append('qnOpe', qnOpe);
post.append('qnSne', qnSne);
post.append('qnSnce', qnSnce);
post.append('qnExe', qnExe);
post.append('library-video-e', library_video);
post.append('question-file-e', document.getElementById('question-file-e').files[0]);
// alert (qnOpe);
$.ajax({
url: 'AjaxEditQuizQuestion.php', //Server script to process data
type: 'POST',
xhr: function() { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // Check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
}
return myXhr;
},
//Ajax events
// beforeSend: beforeSendHandler,
success: function (data) {
$("span.responce2").html(data);
if (qnTypee == 4 || qnTypee == 5) {
$('#Q-'+qid+' span').html(qTitlee);
} else {
$('#Q-'+qid+' span').html($(qnTxe).text());
}
doNumbering ();
LoadMediaForQuestion (qid);
return false;
},
error: function() {
alert("Error Occurred...");
$('#SendfileUpload1').show();
},
// Form data
data: post,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
});
}
function LoadMediaForQuestion (qid) {
console.log ('loading media');
var post = 'qid=' + qid;
$.post('LoadMediaForQuestion.php', post, function (data) {
$('.mc-' + qid).html(data);
console.log(data);
ApplyRemoveMediaButton ();
});
}
function ApplyRemoveMediaButton () {
$('.remove-media').off('click');
$('.remove-media').click (function () {
var qid = $(this).attr('id').split('-')[1];
var post = 'qid=' + qid;
$.post('RemoveMediaFromQuestion.php', post, function (data) {
$('#question-file-e').val('');
$('#library-video-e').val('');
LoadMediaForQuestion (qid);
});
});
}
function ApplyVideoBankButton () {
$('.library-videos-e').hide();
var scrt = $("
").append($('.library-videos .wms-main-strip').clone()).html();
$('.library-videos-e').append(scrt);
$('a.btn-open-bank-e').click (function () {
// alert ('called');
/*
if ($('.library-videos-e').css('display') == 'block') {
$('.library-videos-e').hide();
isBankOpen = false;
} else {
$('.library-videos-e').show();
isBankOpen = true;
}
*/
$('.library-videos-e').show();
// alert ('called 2');
});
$('#question-file-e').change(function () {
if ($(this).val() != '') {
$('.selected-video-e span.media-container').empty();
$('#library-video-e').val('');
}
});
$('.library-videos-e ul.video-strip li a').click (function () {
var video_name = $(this).attr('data-video');
var str = '';
// console.log (video_name);
// console.log ($(this).parent().find('img').attr('src'));
str += 'Selected Video From Course Videos ';
str += ''
str += ' ';
str += ' ';
str += ' ';
str += '
';
$('.selected-video-e span.media-container').empty().html (str);
$('#question-file-e').val('');
$('#library-video-e').val(video_name);
});
}
function deleteQuizQuestionAjaxCalled () {
$('#btnDeleteQuizQuestion').on('click', function() {
$("span.responce2").html(" Deleting question, please wait ...");
var qid = $('#qid').val();
var post = 'qid=' + qid;
// window.open('AjaxDeleteQuizQuestion.php?'+post, "popupWindow", "width=600,height=600,scrollbars=yes");
$.post('AjaxDeleteQuizQuestion.php', post, function(data) {
$("span.responce3").html(data);
Init_ManageQuizPage ();
});
});
}
function Init_ManageQuizPage () {
$('progress').show();
if ($(".tab_content").hasClass("existing-questions")) {
classes = {};
$(".tab_content").each(function() {
$($(this).attr('class').split(' ')).each(function() {
if (this !== '') {
classes[this] = this;
}
});
});
//build the classnames
quizID = '';
for (class_name in classes) {
if (class_name.split('-')[0] == 'quiz') {
quizID = class_name.split('-')[1];
}
}
getQuizQuestionsData (quizID);
}
$('#qnType').change (function () {
var selectedOption = $(this).val();
// alert (selectedOption);
$('.question-new-2').show ();
$('.question-new-3').show ();
switch (selectedOption) {
case "1": { // Single Answer with Text Options
$("#option-radio-add").show();
$("#option-check-add").hide();
$("#possible-solutions-add").show();
$('#caption-option').show();
$("#possible-drop-options").hide();
$("#options-boxes-div").show();
$("#options-files-div").hide();
$('#open-ended-options-add').hide ();
$(".qTitle").hide();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx');
CKEDITOR.replace( 'qnTx-2');
CKEDITOR.replace( 'qnTx-3');
break;
}
case "2": { // Multiple Answer with Text Options
$("#option-radio-add").hide();
$("#option-check-add").show();
$("#possible-solutions-add").show();
$('#caption-option').show();
$("#possible-drop-options").hide();
$("#options-boxes-div").show();
$("#options-files-div").hide();
$('#open-ended-options-add').hide ();
$(".qTitle").hide();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx');
CKEDITOR.replace( 'qnTx-2');
CKEDITOR.replace( 'qnTx-3');
break;
}
case "3": { // Open Ended
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").hide();
$('#caption-option').hide();
$("#possible-drop-options").hide();
$(".qTitle").hide();
$('#open-ended-options-add').show ();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx');
CKEDITOR.replace( 'qnTx-2');
CKEDITOR.replace( 'qnTx-3');
break;
}
case "4": { // Type in the blank
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").hide();
$("#possible-drop-options").hide();
$('#open-ended-options-add').hide ();
$(".qTitle").show();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx', {
extraPlugins: 'colorbutton,custom-type-in-the-blank'
});
CKEDITOR.replace( 'qnTx-2', {
extraPlugins: 'colorbutton,custom-type-in-the-blank'
});
CKEDITOR.replace( 'qnTx-3', {
extraPlugins: 'colorbutton,custom-type-in-the-blank'
});
$('.question-new-2').hide ();
$('.question-new-3').hide ();
break;
}
case "5": { // Drop in the blank
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").hide();
$("#possible-drop-options").show();
$('#open-ended-options-add').hide ();
$(".qTitle").show();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx', {
extraPlugins: 'colorbutton,custom-drop-in-the-blank'
});
CKEDITOR.replace( 'qnTx-2', {
extraPlugins: 'colorbutton,custom-drop-in-the-blank'
});
CKEDITOR.replace( 'qnTx-3', {
extraPlugins: 'colorbutton,custom-drop-in-the-blank'
});
$('.question-new-2').hide ();
$('.question-new-3').hide ();
break;
}
case "6": { // Select in the blank
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").hide();
$("#possible-drop-options").hide();
$('#open-ended-options-add').hide ();
$(".qTitle").show();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx', {
extraPlugins: 'colorbutton,custom-select-in-the-blank'
});
CKEDITOR.replace( 'qnTx-2', {
extraPlugins: 'colorbutton,custom-select-in-the-blank'
});
CKEDITOR.replace( 'qnTx-3', {
extraPlugins: 'colorbutton,custom-select-in-the-blank'
});
$('.question-new-2').hide ();
$('.question-new-3').hide ();
break;
}
case "8": { // Single Answer (Audio/Video/Image Options)
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").show();
$("#possible-drop-options").hide();
$('#caption-option').hide();
$("#options-boxes-div").hide();
$("#options-files-div").show();
$('#options-files-div input[type="radio"]').show();
$('#options-files-div input[type="checkbox"]').hide();
$('#open-ended-options-add').hide ();
$(".qTitle").hide();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx');
CKEDITOR.replace( 'qnTx-2');
CKEDITOR.replace( 'qnTx-3');
break;
}
case "9": { // Multiple Answers (Audio/Video/Image Options)
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").show();
$("#possible-drop-options").hide();
$('#caption-option').hide();
$("#options-boxes-div").hide();
$("#options-files-div").show();
$('#options-files-div input[type="radio"]').hide();
$('#options-files-div input[type="checkbox"]').show();
$('#open-ended-options-add').hide ();
$(".qTitle").hide();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx');
CKEDITOR.replace( 'qnTx-2');
CKEDITOR.replace( 'qnTx-3');
break;
}
case "10": { // Multiple Correct Answers With Any Selection (Audio/Video/Image Options)
$("#option-radio-add").hide();
$("#option-check-add").hide();
$("#possible-solutions-add").show();
$("#possible-drop-options").hide();
$('#caption-option').hide();
$("#options-boxes-div").hide();
$("#options-files-div").show();
$('#options-files-div input[type="radio"]').hide();
$('#options-files-div input[type="checkbox"]').show();
$('#open-ended-options-add').hide ();
$(".qTitle").hide();
CKEDITOR.instances['qnTx'].destroy();
CKEDITOR.instances['qnTx-2'].destroy();
CKEDITOR.instances['qnTx-3'].destroy();
CKEDITOR.replace( 'qnTx');
CKEDITOR.replace( 'qnTx-2');
CKEDITOR.replace( 'qnTx-3');
break;
}
}
// alert (selectedOption);
});
$('#add-drop-option').click (function () {
var txt = $('#drop-option-text').val();
});
}
function applyEditQuestionFunctions () {
$('#qnTypee').change (function () {
var selectedOption = $(this).val();
onChangeQuestionTypeInEditMode (selectedOption);
});
editQuizQuestionAjaxCalled ();
deleteQuizQuestionAjaxCalled ();
ApplyRemoveMediaButton ();
ApplyVideoBankButton ();
CKEDITOR.replace('qnTxe');
CKEDITOR.replace('qnTxe-2');
CKEDITOR.replace('qnTxe-3');
onChangeQuestionTypeInEditMode ($('#qnTypee').val());
$('input[type="file"]').off('change');
$('input[type="file"]').change(function(){
readURL(this);
});
ExpandPreviewBox ();
// $('span.responce2').html ("applied");
}
function onChangeQuestionTypeInEditMode (selectedOption) {
$('.question-edit-2').show ();
$('.question-edit-3').show ();
switch (selectedOption) {
case "1": {
$("#option-radio-edit").show();
$("#option-check-edit").hide();
$("#possible-solutions-edit").show();
$('#caption-option-edit').show();
$("#possible-drop-options-edit").hide();
$("#options-boxes-div-edit").show();
$("#options-files-div-edit").hide();
$('#open-ended-options-edit').hide ();
$(".qTitlee").hide();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe');
CKEDITOR.replace( 'qnTxe-2');
CKEDITOR.replace( 'qnTxe-3');
break;
}
case "2": {
$("#option-radio-edit").hide();
$("#option-check-edit").show();
$("#possible-solutions-edit").show();
$('#caption-option-edit').show();
$("#possible-drop-options-edit").hide();
$("#options-boxes-div-edit").show();
$("#options-files-div-edit").hide();
$('#open-ended-options-edit').hide ();
$(".qTitlee").hide();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe');
CKEDITOR.replace( 'qnTxe-2');
CKEDITOR.replace( 'qnTxe-3');
break;
}
case "3": {
$("#option-radio-edit").show();
$("#option-check-edit").show();
$("#possible-solutions-edit").hide();
$("#possible-drop-options-edit").hide();
$('#open-ended-options-edit').show ();
$(".qTitlee").hide();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe');
CKEDITOR.replace( 'qnTxe-2');
CKEDITOR.replace( 'qnTxe-3');
break;
}
case "4": { // Type in the blank
$("#option-radio-edit").hide();
$("#option-check-edit").hide();
$("#possible-solutions-edit").hide();
$("#possible-drop-options-edit").hide();
$('#open-ended-options-edit').hide ();
$(".qTitlee").show();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe', {
extraPlugins: 'colorbutton,custom-type-in-the-blank',
on: {
instanceReady: function() {
// alert( this.name ); // 'editor1'
ApplyCloseOption ();
ApplyNewAddOption ();
ApplyFillOptions ();
ApplyFirstValuesToBlanks ();
$.MyVars.cntr = 1000; // Initialized in Manage_Quiz.php
$.MyVars.int_cntr = 1000; // Initialized in Manage_Quiz.php
}
}
});
CKEDITOR.replace( 'qnTxe-2', {
extraPlugins: 'colorbutton,custom-type-in-the-blank',
on: {
instanceReady: function() {
// alert( this.name ); // 'editor1'
ApplyCloseOption ();
ApplyNewAddOption ();
ApplyFillOptions ();
ApplyFirstValuesToBlanks ();
$.MyVars.cntr = 1000; // Initialized in Manage_Quiz.php
$.MyVars.int_cntr = 1000; // Initialized in Manage_Quiz.php
}
}
});
CKEDITOR.replace( 'qnTxe-3', {
extraPlugins: 'colorbutton,custom-type-in-the-blank',
on: {
instanceReady: function() {
// alert( this.name ); // 'editor1'
ApplyCloseOption ();
ApplyNewAddOption ();
ApplyFillOptions ();
ApplyFirstValuesToBlanks ();
$.MyVars.cntr = 1000; // Initialized in Manage_Quiz.php
$.MyVars.int_cntr = 1000; // Initialized in Manage_Quiz.php
}
}
});
$('.question-edit-2').hide ();
$('.question-edit-3').hide ();
break;
}
case "5": {
$("#option-radio-edit").hide();
$("#option-check-edit").hide();
$("#possible-solutions-edit").hide();
$("#possible-drop-options-edit").show();
$('#open-ended-options-edit').hide ();
$(".qTitlee").show();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe', {
extraPlugins: 'colorbutton,custom-drop-in-the-blank'
});
CKEDITOR.replace( 'qnTxe-2', {
extraPlugins: 'colorbutton,custom-drop-in-the-blank'
});
CKEDITOR.replace( 'qnTxe-3', {
extraPlugins: 'colorbutton,custom-drop-in-the-blank'
});
break;
}
case "6": { // Select in the blank
$("#option-radio-edit").hide();
$("#option-check-edit").hide();
$("#possible-solutions-edit").hide();
$("#possible-drop-options-edit").hide();
$('#open-ended-options-edit').hide ();
$(".qTitlee").show();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe', {
extraPlugins: 'colorbutton,custom-select-in-the-blank',
on: {
instanceReady: function() {
// alert( this.name ); // 'editor1'
ApplyCloseOptionForSelectBlank ();
ApplyNewAddOptionForSelectBlank ();
ApplyFillOptionsForSelectBlank ();
ApplyFirstValuesToBlanksForSelectBlank ();
$.MyVars.cntr = 1000; // Initialized in Manage_Quiz.php
$.MyVars.int_cntr = 1000; // Initialized in Manage_Quiz.php
}
}
});
CKEDITOR.replace( 'qnTxe-2', {
extraPlugins: 'colorbutton,custom-select-in-the-blank',
on: {
instanceReady: function() {
// alert( this.name ); // 'editor1'
ApplyCloseOptionForSelectBlank ();
ApplyNewAddOptionForSelectBlank ();
ApplyFillOptionsForSelectBlank ();
ApplyFirstValuesToBlanksForSelectBlank ();
$.MyVars.cntr = 1000; // Initialized in Manage_Quiz.php
$.MyVars.int_cntr = 1000; // Initialized in Manage_Quiz.php
}
}
});
CKEDITOR.replace( 'qnTxe-3', {
extraPlugins: 'colorbutton,custom-select-in-the-blank',
on: {
instanceReady: function() {
// alert( this.name ); // 'editor1'
ApplyCloseOptionForSelectBlank ();
ApplyNewAddOptionForSelectBlank ();
ApplyFillOptionsForSelectBlank ();
ApplyFirstValuesToBlanksForSelectBlank ();
$.MyVars.cntr = 1000; // Initialized in Manage_Quiz.php
$.MyVars.int_cntr = 1000; // Initialized in Manage_Quiz.php
}
}
});
$('.question-edit-2').hide ();
$('.question-edit-3').hide ();
break;
}
case "8": { // Single Answer (Audio/Video/Image Options)
$("#option-radio-edit").hide();
$("#option-check-edit").hide();
$("#possible-solutions-edit").show();
$("#possible-drop-options").hide();
$('#caption-option-edit').hide();
$("#options-boxes-div-edit").hide();
$("#options-files-div-edit").show();
$('#options-files-div-edit input[type="radio"]').show();
$('#options-files-div-edit input[type="checkbox"]').hide();
$('#open-ended-options-edit').hide ();
$(".qTitlee").hide();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe');
CKEDITOR.replace( 'qnTxe-2');
CKEDITOR.replace( 'qnTxe-3');
break;
}
case "9": { // Multiple Answers (Audio/Video/Image Options)
$("#option-radio-edit").hide();
$("#option-check-edit").hide();
$("#possible-solutions-edit").show();
$("#possible-drop-options").hide();
$('#caption-option-edit').hide();
$("#options-boxes-div-edit").hide();
$("#options-files-div-edit").show();
$('#options-files-div-edit input[type="radio"]').hide();
$('#options-files-div-edit input[type="checkbox"]').show();
$('#open-ended-options-edit').hide ();
$(".qTitlee").hide();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe');
CKEDITOR.replace( 'qnTxe-2');
CKEDITOR.replace( 'qnTxe-3');
break;
}
case "10": { // Multiple Correct Answers With Any Selection (Audio/Video/Image Options)
$("#option-radio-edit").hide();
$("#option-check-edit").hide();
$("#possible-solutions-edit").show();
$("#possible-drop-options").hide();
$('#caption-option-edit').hide();
$("#options-boxes-div-edit").hide();
$("#options-files-div-edit").show();
$('#options-files-div-edit input[type="radio"]').hide();
$('#options-files-div-edit input[type="checkbox"]').show();
$('#open-ended-options-edit').hide ();
$(".qTitlee").hide();
CKEDITOR.instances['qnTxe'].destroy();
CKEDITOR.instances['qnTxe-2'].destroy();
CKEDITOR.instances['qnTxe-3'].destroy();
CKEDITOR.replace( 'qnTxe');
CKEDITOR.replace( 'qnTxe-2');
CKEDITOR.replace( 'qnTxe-3');
break;
}
}
// alert (selectedOption);
}
function applySubTrainerCourseFunctions () {
onChangePublishForSubTrainerCourse ();
onPreviewForSubTrainerCourse ();
}
function onChangePublishForSubTrainerCourse () {
$('.sub-trainer-course-publish').click (function () {
var cid = $(this).val();
var post = "cid=" + cid;
$.post('AjaxPublishSubTrainerCourse.php', post, function(data) {
/* $(this).parent().find('i').hide();*/
$('#cb-'+cid).parent().find('i').hide();
});
});
}
function onPreviewForSubTrainerCourse () {
$('.sub-trainer-course-preview').click (function () {
// var selectedOption = $(this).val();
});
}
function YoutubeFancyBox () {
$('.youtube.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 420,
'height' : 323
});
}
function addTrainerFancyBox () {
// alert ("ccc");
$('.add-trainer.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 800,
'height' : 500,
'onClosed': function () {
LoadTrainerList ();
LoadAssistantTrainerList ();
/*
LoadTraineeList ('unassigned');
LoadStudentInGroupList ('ungrouped');
ApplyCourseEvents ();
ApplyTraineeButtonEvents ();
ApplyGroupButtonEvents ();
*/
}
});
}
function addTraineeFancyBox () {
$('.add-trainee.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 900,
'height' : 650,
'onClosed': function () {
LoadStudentsInGroups ();
// LoadTrainerList ();
// LoadTraineeList ('unassigned');
// LoadStudentInGroupList ('ungrouped');
// ApplyCourseEvents ();
// ApplyTraineeButtonEvents ();
// ApplyGroupButtonEvents ();
}
});
}
//==================================== Functions Used in CKEDITOR for Quizzes (Start) =======================================
//------------------------ Function For Type in The Blanks (Start) ------------------------------------
function ApplyNewAddOption () {
$('.add-new-option').off('click');
$('.add-new-option').click (function () {
var id = $(this).attr('data-id');
// alert (id);
var str = ' ';
$.MyVars.int_cntr ++;
// $('.blank-' + id).append (str);
$(str).insertAfter ($(this).parent().parent());
ApplyNewAddOption ();
ShowHideRemoveOption (id);
});
$('.remove-new-option').off('click');
$('.remove-new-option').click (function () {
var id = $(this).attr('data-id');
$(this).parent().parent().remove();
ShowHideRemoveOption (id);
});
}
function ApplyCloseOption () {
$('.btn-close').off('click');
$('.btn-close').click (function () {
var id = $(this).attr('data-id').split('-')[1];
var first_value = $(this).parent().find('.option-row input[type="text"]').val();
var len = first_value.length;
var iframe = $('iframe').contents();
/* iframe.find('input#id-' + id).attr('value', first_value);*/
iframe.find('input#id-' + id).val(first_value);
if (len > 20) {
// iframe.find('input#id-' + id).attr('size', Math.ceil(len*0.85));
iframe.find('input#id-' + id).attr('style', 'width: ' + (7 * Math.ceil(len*0.85)) + 'px');
}
$(this).parent().fadeOut ();
});
}
function ApplyFillOptions () {
var iframe = $('iframe').contents();
// alert (iframe.find('.blank').length);
iframe.find('.blank').off('dblclick');
iframe.find('.blank').dblclick (function () {
var id = $(this).attr('id').split('-')[1];
// alert (id);
$('.option-window').fadeOut ();
$('.blank-' + id).fadeIn ();
});
}
function ShowHideRemoveOption (id) {
// alert (".blank-" + id + " = " + $('.blank-' + id + ' .option-row').length);
if ($('.blank-' + id + ' .option-row').length > 1) {
$('.blank-' + id + ' .option-row a.remove-new-option').show ();
} else {
$('.blank-' + id + ' .option-row a.remove-new-option').hide ();
}
}
function ApplyFirstValuesToBlanks () {
console.log ("ApplyFirstValuesToBlanks called");
var iframe = $('iframe').contents();
iframe.find('.blank').each (function (ind) {
var id = $(this).attr('id').split('-')[1];
var first_value = $('.option-windows .option-window.blank-' + id).find('.option-row input[type="text"]').val();
var len = first_value.length;
var iframe = $('iframe').contents();
iframe.find('input#id-' + id).val(first_value);
if (len > 30) {
// iframe.find('input#id-' + id).attr('size', Math.ceil(len*0.85));
iframe.find('input#id-' + id).attr('style', 'width: ' + (7 * Math.ceil(len*0.85)) + 'px');
}
});
}
//------------------------ Function For Type in The Blanks (End) ------------------------------------
//------------------------ Function For Select In The Blanks (Start) ------------------------------------
function ApplyNewAddOptionForSelectBlank () {
$('.add-new-option').off('click');
$('.add-new-option').click (function () {
var id = $(this).attr('data-id');
// alert (id);
var str = ' ';
$.MyVars.int_cntr ++;
// $('.blank-' + id).append (str);
$(str).insertAfter ($(this).parent().parent());
ApplyNewAddOptionForSelectBlank ();
ShowHideRemoveOption (id);
});
$('.remove-new-option').off('click');
$('.remove-new-option').click (function () {
var id = $(this).attr('data-id');
$(this).parent().parent().remove();
ShowHideRemoveOption (id);
});
}
function ApplyCloseOptionForSelectBlank () {
$('.btn-close').off('click');
$('.btn-close').click (function () {
var id = $(this).attr('data-id').split('-')[1];
var first_value = '';
$(this).parent().find('.option-row').each (function () {
if ($(this).find('input[type="checkbox"]').is(':checked')) {
first_value = $(this).find('input[type="text"]').val();
return false;
}
});
// var first_value = $(this).parent().find('.option-row input[type="text"]').val();
var iframe = $('iframe').contents();
iframe.find('select#id-' + id).empty().append('' + first_value + ' ');
$(this).parent().fadeOut ();
});
}
function ApplyFillOptionsForSelectBlank () {
var iframe = $('iframe').contents();
// alert (iframe.find('.blank').length);
iframe.find('.blank').off('dblclick');
iframe.find('.blank').dblclick (function () {
var id = $(this).attr('id').split('-')[1];
// alert (id);
$('.option-window').fadeOut ();
$('.blank-' + id).fadeIn ();
});
}
function ApplyFirstValuesToBlanksForSelectBlank () {
var iframe = $('iframe').contents();
iframe.find('.blank').each (function (ind) {
var id = $(this).attr('id').split('-')[1];
// var first_value = $('.option-windows .option-window.blank-' + id).find('.option-row input[type="text"]').val();
var first_value = '';
$('.option-windows .option-window.blank-' + id).find('.option-row').each (function () {
if ($(this).find('input[type="checkbox"]').is(':checked')) {
first_value = $(this).find('input[type="text"]').val();
return false;
}
});
var iframe = $('iframe').contents();
// iframe.find('input#id-' + id).val(first_value);
iframe.find('select#id-' + id).empty().append('' + first_value + ' ');
});
}
//------------------------ Function For Select in The Blanks (End) ------------------------------------
//==================================== Functions Used in CKEDITOR for Quizzes (End) ========================================
function LoginFancybox () {
$('.login.fancybox').fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'speedIn' : '800',
'speedOut' : '400',
'overlayShow' : true,
'overlayColor' : '#fcfcfc',
'padding' : '3',
'hideOnContentClick' : true,
'titlePosition' : 'outside',
'titleFormat' : null,
'width' : 350,
'height' : 350
});
}
function logoutFunctionR(){
$(this).html('Please wait..');
var post = "id=1";
// alert (post);
$.post('logout.php', post, function(data) {
// alert (data);
//$(this).html(data);
location.reload();
// window.location.href= "index.php";
});
}
$(function() {
$('.slogout').click(logoutFunctionR);
});
$(document).ready(function () {
// preloader
$(window).load(function(){
$('.preloader').delay(400).fadeOut(500);
})
})