Jira Code: ISO-81
DESCRIPTION:-
How to make login page:
Validation for the entering email and the password,
Log in to the page when email and password correctly match.
The session will time out after a definite period
/*******************************************************************************
*
*
* NetSuite Name :home-page.html
*
* ************************************************************
* ISO-83
*
* $Author: Jobin & Jismi IT Services LLP $
*
*
*
*
******************************************************************************/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<!--Core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link href="https://system.eu1.netsuite.com/core/media/media.nl?id=194787&c=4494215_SB1&h=a24d0395aaa7daa53377&_xt=.css" rel="stylesheet" / media="All">
<!-- Isogoed_03_10/html/js/sweetalert.min.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.0/sweetalert.min.js"></script>
<!-- Isogoed_03_10/html/css/sweetalert.css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.0/sweetalert.min.css" media="All">
<script>
var LOGIN_SCRIPT="https://forms.eu1.netsuite.com/app/site/hosting/scriptlet.nl?script=296&deploy=1&compid=4494215_SB1&h=eb1929531ed7e707bf58";
//var HOME_URL="https://system.netsuite.com/c.TSTDRV1584391/site/Isogoed_03_10/html/calendar - Copy.html";
var HOME_URL="https://forms.eu1.netsuite.com/app/site/hosting/scriptlet.nl?script=303&deploy=1&compid=4494215_SB1&h=826da51da56f79e0c696";
</script>
<style>
.bg-img {
background-size: contain;
height: 84px;
background-color: #7f7f7f;
background-repeat: no-repeat;
background-position: center;
background-image: url(https://system.eu1.netsuite.com/core/media/media.nl?id=195824&c=4494215_SB1&h=f33e4d15ecbb028727f6);
}
</style>
</head>
<body class="login-body" onload="myFunction()">
<script>
function myFunction() {
//alert("Page is loaded");
checkCookie();
}
function getCookie(session) {
var name = session + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var cookiearray = decodedCookie.split(';');
for(var i = 0; i < cookiearray.length; i++) {
var check = cookiearray[i];
while (check.charAt(0) == ' ') {
check = check.substring(1);
}
if (check.indexOf(name) == 0) {
return check.substring(name.length, check.length);
}
}
return "";
}
function checkCookie() {
//alert("checkCookie()");
var user=getCookie("sessid");
var username=getCookie("name");
if (user != "") {
// window.location("index.html")
}
}
</script>
<div class="container">
<form class="form-signin" action="index.html">
<div class="bg-img"></div>
<div class="login-wrap">
<div class="user-login-info">
<span id="p_emailid"></span> <input type="text" class="form-control" placeholder="Email" id="emailid" onchange="emailcheck(this.id);" onkeydown="focus_next(event);" autofocus>
<span id="p_passwordid"></span> <input type="password" class="form-control" placeholder="Wachtwoord" id="passwordid" onchange="IsValidPassword(this.id)" onkeydown="function_enter(event);">
<script>
function emailcheck(mail)
{
var x=document.getElementById(mail).value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
var numbers=/^[0-9]+$/;
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
document.getElementById(mail).focus();
document.getElementById("p_"+mail).style="color:red"
document.getElementById("p_"+mail).innerHTML =" ongeldig";
document.getElementById(mail).focus();
return false;
}
else {document.getElementById("p_"+mail).style="color:green"
document.getElementById("p_"+mail).innerHTML =" ";
return true;
}}
function IsValidPassword(userpass)
{
var x=document.getElementById(userpass).value;
if (x.length>=6)
{ document.getElementById("p_"+userpass).style="color:green"
document.getElementById("p_"+userpass).innerHTML =" ";
return true;
}
else {
document.getElementById(userpass).focus();
document.getElementById("p_"+userpass).style="color:red"
document.getElementById("p_"+userpass).innerHTML =" ongeldig";
return false;
}
}
function function_enter(event) {
var x = event.which || event.keyCode;
console.log("x"+x);
if((x==13)||(x==9)){
logto_next_page();
}
}
function focus_next(event){
var y = event.which || event.keyCode;
console.log("y"+y);
if(y==13){
document.getElementById("passwordid").focus();
}
}
</script>
</div>
<button style="background-color:grey;" "font-size:16px" class="btn btn-lg btn-login btn-block" type="button" id="login_button" onclick="logto_next_page()"><b style="font-size:25px;">Log in</b></button>
<label class="checkbox">
<span class="pull-right">
<a data-toggle="modal" href="#myModal">Wachtwoord vergeten?</a>
</span>
</label>
<br>
</div>
<!-- Modal -->
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" onclick="reloadpage()" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Wachtwoord vergeten?</h4>
</div>
<div class="modal-body">
<p>Vul hier onder uw emailadres in om uw wachtwoord te resetten</p>
<span id="p_reset_email"></span>
<input type="text" id="reset_email" onchange="emailcheck(this.id)" name="email" placeholder="Email" autocomplete="off" class="form-control placeholder-no-fix">
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" onclick="reloadpage()" type="button">Annuleer</button>
<button class="btn btn-success" style="background-color:#767676;" id="reset_pass" onclick="resetpass()" type="button">Voorleggen</button>
</div>
</div>
</div>
<script>
//reset password request
function resetpass() {
var inputemail = document.getElementById("reset_email").value;
document.getElementById('reset_pass').disabled = true;
var flag = true;
flag = flag && emailcheck("reset_email");
console.log('flag', flag)
if (flag) {
cb = "employeeExist";
var u = "https://forms.eu1.netsuite.com/app/site/hosting/scriptlet.nl?script=310&deploy=1&compid=4494215_SB1&h=7c54eecf6d1635f45765&email=" + inputemail;
cb = 'employeeExist';
getJSONP(u + '&callback=' + cb);
} else {
swal("Fout", "Vul een geldig emailadress in", "error");
document.getElementById('reset_pass').disabled = false;
}
}
// reload page by cancel
function reloadpage() {
location.reload();
}
function employeeExist(result) {
var myObj = JSON.parse(result);
console.log(myObj)
if (myObj == 'email_sent') {
swal("Done", "email_send", "success");
} else {
swal("Fout", "no_customer", "error");
}
}
</script>
</div>
<!-- modal -->
</form>
</div>
<!-- Placed js at the end of the document so the pages load faster -->
<script language="javascript" type="text/javascript">
function logto_next_page() {
flag = true;
flag = flag && IsValidPassword("passwordid");
IsValidPassword("passwordid");
flag = flag && emailcheck("emailid");
emailcheck("emailid");
var emailid = document.getElementById("emailid").value;
var passwordid = document.getElementById("passwordid").value;
console.log(passwordid);
document.getElementById("login_button").disabled = true;
if (flag) {
var cb = 'login_call_back'
var u = LOGIN_SCRIPT + "&email=" + emailid + "&password=" + passwordid + "&callback=" + cb;
showloading("Uw gegevens controleren", 3000);
getJSONP(u);
} else {
swal("Error", "Foutief gegevens", "error");
document.getElementById("login_button").disabled = false;
}
}
function showloading(title, time) {
swal({
title: title,
text: "<img width='100' src='https://system.eu2.netsuite.com/core/media/media.nl?id=52213&c=4494215&h=8b941e26b4978cf3310b'>",
html: true,
timer: time,
showConfirmButton: false
});
}
function login_call_back(result) {
console.log("login call back", result);
result = JSON.parse(result);
if (result.status == "SUCCESS") {
console.log("SUCCESS");
if (typeof(Storage) !== "undefined") {
// Code for localStorage/sessionStorage.
setCookie("sessid", result.status + result.userid, 30);
setCookie("name", result.name, 30)
//sessionStorage.sessid = result;
window.location = HOME_URL;
}
} else if (result.status == "failure") {
console.log(result);
swal("Fout", "Uw login gegevens komen niet overeen \nControleer uw email / wachtwoord", "error");
document.getElementById("login_button").disabled = false;
}
}
function getJSONP(url) {
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0] || document.documentElement;
script.src = url
head.appendChild(script);
}
function setCookie(session, sessionid, day) {
var currentdate = new Date();
currentdate.setTime(currentdate.getTime() + (day * 24 * 60 * 60 * 1000));
var expires = "expires=" + currentdate.toGMTString();
document.cookie = session + "=" + sessionid + ";" + expires + ";path=/";
}
</script>
<!--Core js-->
<!-- Isogoed_03_10/html/js/jquery.js -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Isogoed_03_10/html/bs3/js/bootstrap.min.js -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<!-- Isogoed_03_10/html/ jj_lib.js-->
<script src="https://system.eu1.netsuite.com/core/media/media.nl?id=195791&c=4494215_SB1&h=fb445677f4ddb1ae9263&_xt=.js"></script>
</body>
</html>