// "use strict"; toastr.options = { closeButton: false, debug: false, newestOnTop: false, progressBar: false, positionClass: "toastr-top-right", preventDuplicates: true, onclick: null, showDuration: "300", hideDuration: "1000", timeOut: "2000", extendedTimeOut: "1000", showEasing: "swing", hideEasing: "linear", showMethod: "fadeIn", hideMethod: "fadeOut", tapToDismiss: false, }; let gapiLoaded = false; let auth2; class Index { signIn() { $("#sign_in").removeClass("btn-main").addClass("btn-secondary"); $("#sign_in").removeAttr("onclick"); let email = $("#email").val().trim(); let password = $("#password").val(); if (email.length < 1) { toastr.error("Please enter your email", "Error!"); } else if (password.length < 1) { toastr.error("Please enter your password", "Error!"); } else { $(".indicator-label").hide(); $(".indicator-progress").show(); dopost({ type: "POST", url: api_link + "/auth/login", data: { email: email, password: password, }, success: function (response) { try { let json = JSON.parse(response); if (json.statuscode == 0) { $(".indicator-label").show(); $(".indicator-progress").hide(); toastr.success("Login successful", "Success!"); var page = json.data.userpage; var ret = { sessionid: json.data.sessionid, userid: json.data.userid, }; window.location.href = page + "?" + serialize(ret); } else { toastr.error(json.status, "Error!"); $(".indicator-label").show(); $(".indicator-progress").hide(); $("#sign_in").removeClass("btn-secondary").addClass("btn-main"); $("#sign_in").attr("onclick", "index.signIn()"); } } catch (e) { toastr.error(e.message, "Error!"); $(".indicator-label").show(); $(".indicator-progress").hide(); $("#sign_in").removeClass("btn-secondary").addClass("btn-main"); $("#sign_in").attr("onclick", "index.signIn()"); } }, // "error": loadingerr }); } } logOutx() { index.blockUI("Signing out"); dopost({ url: api_link + "/auth/logout", data: { action: "logout", userid: getItem("userid"), sessionid: getItem("sessionid"), }, type: "POST", success: function (response) { try { let json = JSON.parse(response); $.unblockUI(); window.localStorage.clear(); resetItems(true); window.location.href = "/"; } catch (e) { console.log(e.message); } }, }); } logOut() { $("#continueBrowsing").modal("show"); } verifySession() { index.blockUI("Verifying session"); let password = $("#verify_password").val(); if (password.length < 1) { toastr.error("Please enter your password", "Error!"); } else { $("#verify_btn .indicator-label").hide(); $("#verify_btn .indicator-progress").show(); dopost({ url: api_link + "/auth/confirm_session_owner", data: { userid: getItem("userid"), sessionid: getItem("sessionid"), password: password, }, type: "POST", success: function (response) { try { let json = JSON.parse(response); if (json.statuscode === 0) { $.unblockUI(); $("#verify_password").val(""); $("#continueBrowsing").modal("hide"); $("#verify_btn .indicator-label").show(); $("#verify_btn .indicator-progress").hide(); // window.localStorage.clear(); // resetItems(true); // window.location.href = '/'; } else { setTimeout(index.logOutx, 2000); } } catch (e) { console.log(e.message); } }, }); } } signOut() { toastr.options = { closeButton: true, debug: false, newestOnTop: false, progressBar: false, positionClass: "toastr-top-right", preventDuplicates: false, showDuration: "300", hideDuration: "1000", timeOut: 0, extendedTimeOut: 0, showEasing: "swing", hideEasing: "linear", showMethod: "fadeIn", hideMethod: "fadeOut", tapToDismiss: false, }; toastr.info( `
${ val[i].user .first_name } ${ val[i].user.surname }
${ val[i].description }${val[ i ].user.role.replace( /_/g, " " )}
${ val[i].user.email }${cell} | `; }); htmlContent += '
${cell} | `; }); htmlContent += '