diff --git a/ajax/saveTodoist.php b/ajax/saveTodoist.php
index e881b4c..8a72978 100644
--- a/ajax/saveTodoist.php
+++ b/ajax/saveTodoist.php
@@ -1,21 +1,21 @@
$xmla = simplexml_load_file('../db/todoist.xml');
-if(isset($_GET['token'])){
-$token = trim($_GET['token']);
+if(isset($_POST['token'])){
+$token = trim($_POST['token']);
$xmla->addChild("token", $token);
$xmla->asXML('../db/todoist.xml');
-echo $token;
-}else if(isset($_GET['name']) && isset($_GET['id'])){
- $name = trim($_GET['name']);
- $id = trim($_GET['id']);
+echo "ok";
+}else if(isset($_POST['name']) && isset($_POST['id'])){
+ $name = trim($_POST['name']);
+ $id = trim($_POST['id']);
$xmla->addChild("name", $name);
$xmla->addChild("id", $id);
$xmla->asXML('../db/todoist.xml');
-echo $id;
+echo "ok";
}
\ No newline at end of file
diff --git a/getProjectsList.php b/getProjectsList.php
index 180ec35..f89a6a4 100644
--- a/getProjectsList.php
+++ b/getProjectsList.php
@@ -1,10 +1,10 @@
-$xmla = simplexml_load_file('todoist.xml');
+$xmla = simplexml_load_file('db/todoist.xml');
if($xmla->token== '' || $xmla->token == null)
- header('Location: index.php');
+ header('Location: install-todoist.php');
if($xmla->name == '' || $xmla->name == null):?>
-
+
Todoist : getProjects
@@ -14,5 +14,5 @@ if($xmla->name == '' || $xmla->name == null):?>
else:
- header('Location: getUncompletedTasks.php');
+ header('Location: index.php');
endif;
\ No newline at end of file
diff --git a/index.php b/index.php
index ff00216..4385d23 100644
--- a/index.php
+++ b/index.php
@@ -150,13 +150,13 @@ if($config = simplexml_load_file('db/config.xml')){
}?>
visibility == "true"){
$xmla = simplexml_load_file('db/todoist.xml');
-echo '
';
+echo '';
if($xmla->token== '' || $xmla->token == null || $xmla->id == '' || $xmla->id == null)
-echo 'Impossible de trouver votre configuration. Merci de bien vouloir la recommencer.';
+echo 'Impossible de trouver votre configuration.
Cliquez ici pour la mettre en place.
';
else{
$token = $xmla->token;
$id = $xmla->id;?>
-
+
}}?>
diff --git a/install-todoist.php b/install-todoist.php
new file mode 100644
index 0000000..a752127
--- /dev/null
+++ b/install-todoist.php
@@ -0,0 +1,24 @@
+
+$xmla = simplexml_load_file('db/todoist.xml');
+if($xmla->token == '' || $xmla->token == null):?>
+
+
+ Todoist : Login
+
+
+
+
+
+
+
+
+ Cliquez ici pour vous identifier
+
+
+
+
+
+ else:
+ header('Location: getProjectsList.php');
+ endif;
+
\ No newline at end of file
diff --git a/js/getProjectsList.php b/js/getProjectsList.php
index 3411298..13a27f3 100644
--- a/js/getProjectsList.php
+++ b/js/getProjectsList.php
@@ -1,23 +1,6 @@
-function cbfunc(o){
- var name = o[0].name;
- var id = o[0].id;
-
- if(id == undefined){
- $('body').append('ERROR ');
- }else{
- $.get('saveTodoist.php', {name: name, id: id}, function(){
- window.location.reload();
- });
- }
-}
-
-$(document).ready(function(){
- var token = "=$token?>";
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = 'https://todoist.com/API/getProjects?token='+token+'&format=json&callback=cbfunc';
- document.getElementsByTagName('head')[0].appendChild(script);
+function cbfunc(o){
$('body').append('
Select your project ');
$('#results').append('');
for(var i in o)
{
$('#uncompletedList').append(''+o[i].name+' ');
}
}
+$(document).ready(function(){
var token = "=$token?>";
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://todoist.com/API/getProjects?token='+token+'&format=json&callback=cbfunc';
document.getElementsByTagName('head')[0].appendChild(script);
$('.selectableProject').live('click', function(){
var name = $(this).text();
var id = $(this).attr('id');
$.post('ajax/saveTodoist.php', {name: name, id: id}, function(msg){
$('body').append('Etape suivante ');
if(msg=="ok"){
location.reload();
}else{
alert(msg);
}
});
});
});
\ No newline at end of file
diff --git a/js/index.js b/js/index.js
index 944f3d8..2b3746c 100644
--- a/js/index.js
+++ b/js/index.js
@@ -3,8 +3,8 @@ function cbfunc(o){
if(token == undefined){
$('#error').html('Identification erronnée');
}else{
- $.get('saveTodoist.php', {token: token}, function(){
- location.reload(true);
+ $.post('ajax/saveTodoist.php', {token: token}, function(data){
$('body').append('Etape suivante ');
if(data=="ok"){
+ location.reload();
}else{
alert(data);
}
});
}
}