forked from v4l3n71n/covas-bo
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
function checkToken(){
|
|
|
|
instance.get("token", { withCredentials: true})
|
|
.then(function(response) {
|
|
if(location.pathname == "/")
|
|
{
|
|
location.href="/html/users.html";
|
|
}
|
|
})
|
|
.catch(function(error){
|
|
if(location.pathname != "/"){
|
|
location.href="/";
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
function signOut(){
|
|
|
|
document.getElementById("signout").addEventListener("click", function(){
|
|
instance.delete("token" , {withCredentials:true}).then(function(response){
|
|
if(response.status == 200){
|
|
location.href="/"
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function closeButton(){
|
|
var btnclose = document.getElementsByClassName("btn-close");
|
|
for (var i = 0; i<btnclose.length; i++){
|
|
btnclose[i].addEventListener("click", function(e){
|
|
var parent = e.currentTarget.parentElement;
|
|
if(!parent.classList.contains("hidden")){
|
|
parent.classList.add("hidden");
|
|
}
|
|
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
function getQuery(param){
|
|
var result = "";
|
|
if(location.search.length >0){
|
|
query = location.search.split("?")[1];
|
|
var variables = query.split("&")
|
|
for (var i=0; i<variables.length; i++){
|
|
if(variables[i].split("=")[0] == param){
|
|
result = variables[i].split("=")[1];
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
} |