Accueil/modules/todo/js/index.js

4 lines
972 B
JavaScript
Raw Permalink Normal View History

function cbfunc(o){ var token = o.api_token; if(token == undefined){ $('#error').html('Identification erronnée'); }else{ $.post('../ajax/saveTodoist.php', {token: token}, function(data){ $('body').append('<a href="getProjectsList.php">Etape suivante</a>'); if(data=="ok"){
location.reload(); }else{ alert(data); }
}); } }
$(document).ready(function(){ $('#loginBtn').click(function(){ var email = $('#email').val(); var password = $('#password').val(); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://todoist.com/API/login?email='+email+'&password='+password+'&format=json&callback=cbfunc'; document.getElementsByTagName('head')[0].appendChild(script); }); $('#email').keydown(function(e){ if(e.which == 13){ $('#loginBtn').trigger('click'); } }); $('#password').keydown(function(e){ if(e.which == 13){ $('#loginBtn').trigger('click'); } }); });