0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 52.14.125.137


Current Path : /var/www/html/stph/js/
Upload File :
Current File : /var/www/html/stph/js/index.js

//var $host_url='http://10.10.200.172/activity/app.php?a=';
//var $image_path='http://10.10.200.172/activity/libs/jquery/themes/basic/images/';
//var $host_url="http://"+window.location.host+"/"+window.location.pathname.split('/')[1]+"/app.php?a=";
//var $image_path="http://"+window.location.host+"/"+window.location.pathname.split('/')[1]+"/jqGrid3.5/cmes/tarka/images/";
if (location.protocol != "https:") {
  var protocol = "http://";
} else {
  var protocol = "https://";
}
var urlarr = window.location.pathname.split("/");
var $url = protocol + window.location.host + "/";
var $hoststr = "";
for (var j = 1; j < urlarr.length - 1; j++) {
  $hoststr += window.location.pathname.split("/")[j] + "/";
}
$host_url = $url + $hoststr + "app.php?a=";
$image_path = $url + $hoststr + "jqGrid3.5/cmes/tarka/images/";
//var $host_url="http://"+window.location.host+"/"+window.location.pathname.split('/')[1]+"/"+window.location.pathname.split('/')[2]+"/"+window.location.pathname.split('/')[3]+"/app.php?a=";
//var $image_path="http://"+window.location.host+"/"+window.location.pathname.split('/')[1]+"/"+window.location.pathname.split('/')[2]+"/"+window.location.pathname.split('/')[3]+"/jqGrid3.5/cmes/tarka/images/";

function trim($str) {
  return $str.replace(/^\s*|\s*$/g, "");
}
function loadwindow() {
  loadUniversityDetails();

  CheckIE6Version();
  if (getCookie("username")) {
    document.getElementById("user_name").value = getCookie("username");
  } else {
    document.getElementById("user_name").value = "Username";
  }
  /* if(getCookie('pswd'))
			{
				//document.getElementById('password').value = getCookie('pswd');
			}
			else
			{
			   document.getElementById('password').value ='******';
			} */
  if (getCookie("college_code")) {
    document.getElementById("college_code").value = getCookie("college_code");
  } else {
    document.getElementById("college_code").value = "";
  }
}

function validate() {
  return true;
}

function login() {
  if (trim(document.getElementById("college_code").value) == "") {
    alert("Enter College Code");
    document.getElementById("college_code").focus();
    return;
  }
  if (trim(document.getElementById("user_name").value) == "") {
    alert("Enter Username");
    document.getElementById("user_name").focus();
    return;
  } else if (trim(document.getElementById("password").value) == "") {
    alert("Enter Password");
    document.getElementById("password").focus();
    return;
  }
  if (CheckIE6Version()) {
    var college_code = document.getElementById("college_code").value;
    var user_name = document.getElementById("user_name").value;
    var password = document.getElementById("password").value;
    var $parameters =
      "usr=" +
      user_name +
      "&password=" +
      password +
      "&login_college_code=" +
      college_code;
    $.ajax({
      url: $host_url + "validateUsernameAndPassword.demo",
      data: $parameters,
      success: validateUsernameAndPasswordResponse
    });
  }
}

var collegeInfoPopup;
function validateUsernameAndPasswordResponse($responce) {
  $responce = eval("(" + $responce + ")");
  if ($responce.error_code == -1) {
    document.getElementById("user_name").focus();
    document.getElementById("password").value = "";
    alert($responce.data);
  } else {
    var user_type = $responce.data.html["user_type"];
    var user_id = $responce.data.internal_code;
    var college_name = $responce.data.html["college_name"];
    var university_name = $responce.data.html["university_name"];
    var real_name = $responce.data.html["real_name"];
    var FCOLLCODE = $responce.data.html["FCOLLCODE"];
    var FCOLLNAME = $responce.data.html["FCOLLNAME"];
    var FTOWN = $responce.data.html["FTOWN"];
    var FPRINCIPALNAME = $responce.data.html["FPRINCIPALNAME"];
    var FPHONE = $responce.data.html["FPHONE"];
    var FMOBILE = $responce.data.html["FMOBILE"];
    var FFAX = $responce.data.html["FFAX"];
    var FALTMOBILE = $responce.data.html["FALTMOBILE"];
    var FCOLLADD1 = $responce.data.html["FCOLLADD1"];
    var FCOLLADD2 = $responce.data.html["FCOLLADD2"];
    var FCOLLADD3 = $responce.data.html["FCOLLADD3"];
    var FCOLLADD4 = $responce.data.html["FCOLLADD4"];
    var FEMAIL = $responce.data.html["FEMAIL"];
    var FUNIVCODE = $responce.data.html["funivcode"];

    var can_edit_help_text = $responce.data.html["can_edit_help_text"];
    var logo_path = $responce.data.html["university_logo"];
    var a_p = "";
    var d = new Date();
    var curr_hour = d.getHours();
    if (curr_hour < 12) a_p = "AM";
    else a_p = "PM";

    if (curr_hour == 0) {
      curr_hour = 12;
    }
    if (curr_hour > 12) {
      curr_hour = curr_hour - 12;
    }
    var curr_min = d.getMinutes();
    var login_time = curr_hour + ":" + curr_min + " " + a_p;

    var cookie_value =
      "username=" +
      document.getElementById("user_name").value +
      "&pswd=" +
      document.getElementById("password") +
      "&adminlogin=" +
      document.getElementById("user_name").value +
      "&userlogintime=" +
      login_time;
    //setCookie("Qx0",cookie_value,1);
    setCookie("FCOLLCODE", FCOLLCODE, 1);
    setCookie("FUNIVCODE", FUNIVCODE, 1);
    setCookie("FCOLLNAME", FCOLLNAME, 1);
    setCookie("FPHONE", FPHONE, 1);
    setCookie("FPHONE", FPHONE, 1);
    setCookie("FTOWN", FTOWN, 1);
    setCookie("FFAX", FFAX, 1);
    setCookie("FALTMOBILE", FALTMOBILE, 1);
    setCookie("FCOLLADD1", FCOLLADD1, 1);
    setCookie("FCOLLADD2", FCOLLADD2, 1);
    setCookie("FCOLLADD3", FCOLLADD3, 1);
    setCookie("FCOLLADD4", FCOLLADD4, 1);

    setCookie("FPRINCIPALNAME", FPRINCIPALNAME, 1);
    setCookie("FMOBILE", FMOBILE, 1);

    setCookie("FEMAIL", FEMAIL, 1);
    setCookie("username", trim(document.getElementById("user_name").value), 1);
    setCookie(
      "college_code",
      trim(document.getElementById("college_code").value),
      1
    );
    setCookie("login_time", login_time, 1);
    //setCookie("login_date",login_date,1);
    setCookie("user_type", user_type, 1);
    setCookie("college_name", college_name, 1);
    //setCookie("pswd",trim(document.getElementById('password').value),1);
    setCookie("host_url", $host_url, 1);
    setCookie("image_path", $image_path, 1);
    setCookie("university_name", university_name, 1);
    setCookie("real_name", real_name, 1);
    setCookie("user_id", user_id, 1);
    //setCookie("university_logo",logo_path,1);

    var collegeInfoStatus = $responce.data.html["fupdated"];
    if (user_type == "Admin" && collegeInfoStatus != "T") {
      window.location.href = "collegeInfoPopup.html#modal";
    } else {
      window.location.href = "MainPage.html";
    }
  }
}

function loadCollegePopupInfo() {
  $("#fcollegecode").val(getCookie("FCOLLCODE"));
  $("#fcollegename").val(getCookie("FCOLLNAME"));
  $("#fplace").val(getCookie("FTOWN"));
  //document.getElementById('fplace').value = 'BELAGAVI';
  $("#coll_addr1").val(getCookie("FCOLLADD1"));
  $("#coll_addr2").val(getCookie("FCOLLADD2"));
  $("#coll_addr3").val(getCookie("FCOLLADD3"));
  $("#coll_addr4").val(getCookie("FCOLLADD4"));
  $("#flandlinenumb").val(getCookie("FPHONE"));
  $("#ffaxnumb").val(getCookie("FFAX"));
  $("#fprincipalname").val(getCookie("FPRINCIPALNAME"));
  $("#fmobnumb").val(getCookie("FMOBILE"));
  $("#fcollemail").val(getCookie("FEMAIL"));
  $("#faltmobnumb").val(getCookie("FALTMOBILE"));
}

function validateCollegeInfo() {
  if (trim(document.getElementById("fcollegecode").value) == "") {
    alert("Enter the College Code");
    document.getElementById("fcollegecode").focus();
    return;
  }
  if (trim(document.getElementById("fplace").value) == "") {
    alert("Enter the Place");
    document.getElementById("fplace").focus();
    return;
  }
  if (trim(document.getElementById("fcollegename").value) == "") {
    alert("Enter the College Name");
    document.getElementById("fcollegename").focus();
    return;
  }
  if (trim(document.getElementById("coll_addr1").value) == "") {
    alert("Enter the Address");
    document.getElementById("coll_addr1").focus();
    return;
  }
  if (trim(document.getElementById("flandlinenumb").value) == "") {
    alert("Enter the Landline Number");
    document.getElementById("flandlinenumb").focus();
    return;
  }
  if (trim(document.getElementById("ffaxnumb").value) == "") {
    alert("Enter the Fax Number");
    document.getElementById("ffaxnumb").focus();
    return;
  }
  if (trim(document.getElementById("fprincipalname").value) == "") {
    alert("Enter the Principle Name");
    document.getElementById("fprincipalname").focus();
    return;
  }
  var mobileNumber = trim(document.getElementById("fmobnumb").value);
  if (mobileNumber == "" || mobileNumber.length != 10) {
    alert("Enter the Mobile Number");
    document.getElementById("fmobnumb").focus();
    return;
  }
  if (trim(document.getElementById("fcollemail").value) == "") {
    alert("Enter the College Email");
    document.getElementById("fcollemail").focus();
    return;
  } else {
    var x = trim(document.getElementById("fcollemail").value);
    var atpos = x.indexOf("@");
    var dotpos = x.lastIndexOf(".");
    if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
      alert("Not a valid e-mail address");
      return false;
    }
  }
  var altMobileNumber = trim(document.getElementById("fmobnumb").value);
  if (altMobileNumber == "" || altMobileNumber.length != 10) {
    alert("Enter the Alternate Mobile Number");
    document.getElementById("faltmobnumb").focus();
    return;
  }
  var $lstr_data = "";
  $lstr_data += "&fcollegecode=" + encodeURIComponent($("#fcollegecode").val());
  $lstr_data += "&fcollegename=" + encodeURIComponent($("#fcollegename").val());
  $lstr_data += "&fplace=" + encodeURIComponent($("#fplace").val());
  $lstr_data +=
    "&fprincipalname=" + encodeURIComponent($("#fprincipalname").val());
  $lstr_data +=
    "&flandlinenumb=" + encodeURIComponent($("#flandlinenumb").val());
  $lstr_data += "&fcollemail=" + encodeURIComponent($("#fcollemail").val());
  $lstr_data += "&ffaxnumb=" + encodeURIComponent($("#ffaxnumb").val());
  $lstr_data += "&fmobnumb=" + encodeURIComponent($("#fmobnumb").val());
  $lstr_data += "&faltmobnumb=" + encodeURIComponent($("#faltmobnumb").val());
  $lstr_data += "&coll_addr1=" + encodeURIComponent($("#coll_addr1").val());
  $lstr_data += "&coll_addr2=" + encodeURIComponent($("#coll_addr2").val());
  $lstr_data += "&coll_addr3=" + encodeURIComponent($("#coll_addr3").val());
  $lstr_data += "&coll_addr4=" + encodeURIComponent($("#coll_addr4").val());

  $.ajax({
    url: $host_url + "saveCollegeInfoPopup.demo",
    data: $lstr_data,
    success: saveCollegeInfoPopupResponce
  });
}
function saveCollegeInfoPopupResponce($responce) {
  $responce = eval("(" + $responce + ")");
  if ($responce.error_code == 0) {
    window.location.href = "MainPage.html";
  } else {
    logout();
  }
}

function setCookie(c_name, value, expiredays) {
  var exdate = new Date();
  exdate.setDate(exdate.getDate() + expiredays);
  document.cookie =
    c_name +
    "=" +
    escape(value) +
    (expiredays == null ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
  if (document.cookie.length > 0) {
    c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1;
      c_end = document.cookie.indexOf(";", c_start);
      if (c_end == -1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start, c_end));
    }
  }
  return "";
}

function dologin(event) {
  if (event.keyCode == 13) login();
}

function CheckIE6Version() {
  var BrowserType = BrowserDetect.browser;
  var BrowserVersion = BrowserDetect.version;
  if (BrowserType == "Explorer" && BrowserVersion == 6) {
    alert(" You are using IE6 Version,Use Mozilla Firefox or IE8");
    return false;
  }
  return true;
}

function loadUniversityDetails() {
  $.ajax({
    url: $host_url + "loadUniversityDetails.demo",
    success: loadUniversityDetailsResponce
  });
}

function loadUniversityDetailsResponce($responce) {
  $responce = eval("(" + $responce + ")");
  if ($responce.error_code == 0) {
    var university_logo = $responce.data.pdf_logo_path;
    setCookie("university_logo", university_logo, 1);
    setCookie("date", $responce.data.date, 1);
    $("#university_name").html($responce.data.FUNIVNAME);
    $("#university_logo").attr("src", $responce.data.pdf_logo_path);
    $("#jdate").html($responce.data.date);
  }
}

function resetPasswordValidation() {
  window.location.href = "popup/resetPasswordUserInfo.html#modal";
}
function resetPasswordOTP() {
  window.location.href = "resetPasswordUserInfo.html#modal";
}
function resetPasswordValidationTosendOTP() {
  var username = trim(document.getElementById("fusername").value);
  var mobileno = trim(document.getElementById("fmabileno").value);
  var emailid = trim(document.getElementById("femailid").value);
  if (username == "") {
    alert("Enter User Name");
    document.getElementById("fusername").focus();
    return;
  }
  if (mobileno == "") {
    alert("Enter Mobile Number");
    document.getElementById("fmabileno").focus();
    return;
  }
  if (emailid == "") {
    alert("Enter Email Id");
    document.getElementById("femailid").focus();
    return;
  }
  //window.location.href="resetPasswordOTP.html#modal";

  $.ajax({
    url: $host_url + "resetPasswordDetailsValidation.demo",
    data:
      "username=" + username + "&mobileno=" + mobileno + "&emailid=" + emailid,
    success: resetPasswordValidationTosendOTPresponce
  });
}

function resetPasswordValidationTosendOTPresponce($responce) {
  $responce = eval("(" + $responce + ")");

  if ($responce.error_code == 0) {
    setCookie("otpusrname", $responce.data["name"], 1);
    setCookie("otpmobile", $responce.data["mobile"], 1);
    setCookie("otpemail", $responce.data["email"], 1);
    window.location.href = "resetPasswordEnterOTP.html#modal";
    /* $("div.error span").html($responce.data['eotp_responce']);
			$("div.error").show(); */
  } else {
    $("div.error span").html($responce.data);
    $("div.error").show();
  }
}

function validateResetPasswordOTP() {
  var mreOTP = trim(document.getElementById("fmreotp").value);

  if (mreOTP == "") {
    alert("Enter OTP sent to Mobile or Email");
    document.getElementById("mreOTP").focus();
    return;
  }

  $.ajax({
    url: $host_url + "validateResetPasswordOTP.demo",
    data:
      "username=" +
      getCookie("otpusrname") +
      "&mobileno=" +
      getCookie("otpmobile") +
      "&emailid=" +
      getCookie("otpemail") +
      "&mreOTP=" +
      mreOTP,
    success: validateResetPasswordOTPresponce
  });
}

function validateResetPasswordOTPresponce($responce) {
  $responce = eval("(" + $responce + ")");
  if ($responce.error_code == 0) {
    //window.location.href="resetPasswordSuccess.html#modal";
    //myRedirect("resetPasswordSuccess.html#modal", "paswd", $responce.data);
    //$.redirect('resetPasswordSuccess.html#modal', {"paswd": $responce.data },'POST');
    $("#temp_password").html($responce.data);
    $("div.error span").html(
      "This password is Temporary ,Login and Reset the Password ."
    );
    $("#otpEntry").hide();
    $("#otpVsucess").show();
    $("div.error").show();
  } else {
    //alert($responce.data);
    $("div.error span").html($responce.data);
    $("div.error").show();
  }
}

var myRedirect = function(redirectUrl, arg, value) {
  var form = $(
    '<form action="' +
      redirectUrl +
      '" method="post">' +
      '<input type="hidden" name="' +
      arg +
      '" id="' +
      arg +
      '" value="' +
      value +
      '"></input>' +
      "</form>"
  );
  $("body").append(form);
  $(form).submit();
};