This repository was archived by the owner on Feb 21, 2025. It is now read-only.
forked from aureliojargas/moneylog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.js
More file actions
52 lines (49 loc) · 1.46 KB
/
fetch.js
File metadata and controls
52 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// -------------------------------------------------------------------
// This file extends some functions of MoneyLog
//
// It has the same licence as the rest of the MoneyLog
// and it's source is available at:
// SourceCode - https://github.com/RafaelEstevamReis/moneylog
//
// License/Licença:
// MIT - http://en.wikipedia.org/wiki/MIT_license
// -------------------------------------------------------------------
$tk = localStorage.getItem("data_token");
if($tk == null){
window.location.href = "tokenLogon.html";
}
else{
doFetch($tk);
}
function doFetch($token){
$baseUrl = "https://DOMAIN_HERE/mlGet.php?acesso=[TK]";
$url = $baseUrl.replace("[TK]", $token);
$.ajax({
url: $url,
beforeSend: function( xhr ) {
xhr.overrideMimeType( "text/plain; charset=utf-8" );
}
})
.fail(function( jqXHR, textStatus, errorThrown ) {
$('#report').html("<p>O perfil não contém dados</p>");
exibeSair();
})
.done(function( data ) {
$('#data').text(data);
// Restart process
init();
exibeSair();
});
}
function exibeSair(){
// Permite sair
//<div id="app-flavor">online</div>
$('#app-flavor').text("Sair");
$('#app-flavor').css('cursor', 'pointer');
$('#app-flavor').css('text-transform','');
$('#app-flavor').on('click',logout);
}
function logout(){
localStorage.removeItem("data_token");
window.location.href = "tokenLogon.html";
}