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 : 18.218.63.176


Current Path : /proc/thread-self/root/var/www/html/college/js/
Upload File :
Current File : //proc/thread-self/root/var/www/html/college/js/userpasswordreset.js

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 = "";
console.log(urlarr.length);
for (var j = 1; j < urlarr.length - 2; j++) {
  $hoststr += window.location.pathname.split("/")[j] + "/";
}
var db = window.location.pathname.split("/")[urlarr.length - 2];

$host_url = $url + $hoststr + "app.php?db=" + db + "&a=";

function callUserPasswordReset() {
  $("#page_main_div").load(
    "../html_modules/userpasswordreset.html",
    function () {
      document.getElementById("display_module_name").innerHTML =
        "Reset password";
      document.getElementById("module_name_for_save").value = "Reset password";
      getDefaultHeadFooterLinks("Reset password");
      userdata();
    }
  );
}
function userdata() {
  // var colle_code = document.getElementById("collge_code").value;
  $.ajax({
    type: "GET",
    url: $host_url + "passwordresetforuser",
    // data: "collge_code=" + colle_code,
    success: function (res) {
      var response = JSON.parse(res);
      console.log(response.data.data, "hiiii");

      if (response.status == "success") {
        let table = "";
        table += `<table id="resetbutton" class='table' width='100%' cellspacing='0' cellpadding='0' border='0' width:60%;
        overflow: auto;
        margin: 20px; 
       >`;
        table += `<thead style='position:sticky; top:0'>
                    <tr style='position: sticky; top: 0;background: white;'>
                      <th colspan='5' align='left' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; height:22px; 
                      '>User Data</th>
                    </tr>
                    <tr align='center' class='ui-widget-content jqgrow'>
                      <th class='column'  style='font-size:12px;  height:22px '>College Code</th>
                      <th class='column' style='font-size:12px;  height:22px;'>User Name</th>
                      <th class='column' style='font-size:12px;  height:22px;'>Real Name</th>
                      <th class='column' style='font-size:12px;  height:22px; '>Email Id</th>
                      <th class='column' style='font-size:12px;  height:22px; '>Actions</th>
                      
                    </tr>
                  </thead>`;
        for (let i = 0; i < response.data.data.length; i++) {
          table += `<tr align='center' class='ui-widget-content jqgrow'>
                      <td class='column' style="border-bottom: 1px solid #c5dbec; border-right: 1px solid #c5dbec; border-left: 1px solid #c5dbec;  text-align: center">${response.data.data[i].college_code}</td>
                      <td class='column' style="border-bottom: 1px solid #c5dbec; border-right: 1px solid #c5dbec; text-align: center">${response.data.data[i].username}</td>
                      <td class='column' style="border-bottom: 1px solid #c5dbec; border-right: 1px solid #c5dbec; text-align: center">${response.data.data[i].realname}</td>
                      <td class='column' style="border-bottom: 1px solid #c5dbec; border-right: 1px solid #c5dbec; text-align: left">${response.data.data[i].emailid}</td>
                      <td class='column' style="border-bottom: 1px solid #c5dbec; border-right: 1px solid #c5dbec; text-align: center">
                        <span span class='btn'  onclick="reset('${response.data.data[i].college_code}','${response.data.data[i].username}')">Reset</span> 
                      </td>
                    </tr>`;
        }
        table += `</table>`;
        document.getElementById("tabledata").innerHTML = table;
      }
    },
  });
}
function reset(collcode, uname) {
  $("#passwordtable").show();
  $("#resetbutton").hide();
  // $("#backtoresetpage").show();
  console.log("vjhdschsvch");
  document.getElementById("collcode").value = collcode;
  document.getElementById("user").value = uname;
  document.getElementById("user").disabled = true;
  return;
}

function passwordrequired() {
  var myInput = document.getElementById("newpass");
  var letter = document.getElementById("letter");
  var capital = document.getElementById("capital");
  var number = document.getElementById("number");
  var length = document.getElementById("length");

  myInput.onkeyup = function () {
    var lowerCaseLetters = /[a-z]/g;
    if (myInput.value.match(lowerCaseLetters)) {
      letter.classList.remove("invalid");
      letter.classList.add("valid");
    } else {
      letter.classList.remove("valid");
      letter.classList.add("invalid");
    }

    // Validate capital letters
    var upperCaseLetters = /[A-Z]/g;
    if (myInput.value.match(upperCaseLetters)) {
      capital.classList.remove("invalid");
      capital.classList.add("valid");
    } else {
      capital.classList.remove("valid");
      capital.classList.add("invalid");
    }

    // Validate numbers
    var numbers = /[0-9]/g;
    if (myInput.value.match(numbers)) {
      number.classList.remove("invalid");
      number.classList.add("valid");
    } else {
      number.classList.remove("valid");
      number.classList.add("invalid");
    }

    // Validate length
    if (myInput.value.length >= 8) {
      length.classList.remove("invalid");
      length.classList.add("valid");
    } else {
      length.classList.remove("valid");
      length.classList.add("invalid");
    }
  };
}

function handleSubmit() {
  var colle_code = document.getElementById("collcode").value;
  var user = document.getElementById("user").value;

  var newpass = document.getElementById("newpass").value;

  var comfirmpass = document.getElementById("confirmpass").value;

  if (newpass == comfirmpass) {
    $.ajax({
      type: "POST",
      url: $host_url + "newpasswordsubmit",
      data:
        "collge_code=" +
        colle_code +
        "&confirmpass=" +
        comfirmpass +
        "&user=" +
        user,

      success: function (res) {
        var response = JSON.parse(res);
        console.log(response, "bsdhv");
        if (response.status == "success") {
          alert("Password Update Successfully");
        }
      },
    });
  } else {
    alert("Newpassword and Confirmpassword should be same!");
  }
}
function backtoresetpage() {
  // window.location.href = "userpasswordreset.html";
  $("#page_main_div").load("../html_modules/userpasswordreset.html");
  userdata();
}