covas-bo/web/js/library.js

41 lines
941 B
JavaScript
Raw Normal View History

2022-07-25 20:35:54 +02:00
function checkToken(){
instance.get("token", { withCredentials: true})
.then(function(response) {
2022-07-28 00:15:57 +02:00
if(location.pathname == "/")
{
location.href="/html/home.html";
}
})
2022-07-25 20:35:54 +02:00
.catch(function(error){
2022-07-28 00:15:57 +02:00
if(location.pathname != "/"){
location.href="/";
}
2022-07-25 20:35:54 +02:00
});
2022-08-04 00:03:57 +02:00
}
function signOut(){
document.getElementById("signout").addEventListener("click", function(){
instance.delete("token" , {withCredentials:true}).then(function(response){
if(response.status == 200){
location.href="/"
}
});
});
2022-08-05 21:20:14 +02:00
}
function getQuery(param){
query = location.search.split("?")[1];
var variables = query.split("&")
var result = "";
for (var i=0; i<variables.length; i++){
if(variables[i].split("=")[0] == param){
result = variables[i].split("=")[1];
}
}
return result;
2022-07-25 20:35:54 +02:00
}