forked from lubuwest/Friendiqa
Version 0.002 code cleanup and event attending
This commit is contained in:
parent
dc7e6cdee5
commit
d8186978e7
42 changed files with 925 additions and 968 deletions
|
@ -292,32 +292,32 @@ function like(login,database,toggle,verb,newsid,rootwindow){
|
|||
|
||||
function attend(login,database,attend,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/attend"+attend+"?id="+newsid, rootwindow,function (obj){
|
||||
var attendReturn=JSON.parse(obj);
|
||||
// print("attend: "+obj);
|
||||
if (attendReturn=="OK")
|
||||
{var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
//print("attend: "+attend+obj);
|
||||
if (obj=='"ok"')
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var currentActivities_rs=tx.executeSql('select friendica_activities_self from news WHERE username="'+login.username+'" AND status_id='+newsid) ;
|
||||
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0));
|
||||
print("currentActivities "+JSON.stringify(currentActivities));
|
||||
if ((attend=="attendyes")&&(currentActivities.indexOf(3)==-1)){
|
||||
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0).friendica_activities_self);
|
||||
if ((attend=="yes")&&(currentActivities.indexOf(3)==-1)){
|
||||
currentActivities.push(3);
|
||||
currentActivities.splice(currentActivities.indexOf(4),1)
|
||||
currentActivities.splice(currentActivities.indexOf(5),1)
|
||||
if (currentActivities.indexOf(4)!=-1){currentActivities.splice(currentActivities.indexOf(4),1)}
|
||||
if (currentActivities.indexOf(5)!=-1){currentActivities.splice(currentActivities.indexOf(5),1)}
|
||||
print(JSON.stringify(currentActivities));
|
||||
}
|
||||
if ((attend=="attendno")&&(currentActivities.indexOf(4)==-1)){
|
||||
if ((attend=="no")&&(currentActivities.indexOf(4)==-1)){
|
||||
currentActivities.push(4);
|
||||
currentActivities.splice(currentActivities.indexOf(3),1)
|
||||
currentActivities.splice(currentActivities.indexOf(5),1)
|
||||
if (currentActivities.indexOf(3)!=-1){currentActivities.splice(currentActivities.indexOf(3),1)}
|
||||
if (currentActivities.indexOf(5)!=-1){currentActivities.splice(currentActivities.indexOf(5),1)}
|
||||
}
|
||||
if ((attend=="attendmaybe")&&(currentActivities.indexOf(5)==-1)){
|
||||
if ((attend=="maybe")&&(currentActivities.indexOf(5)==-1)){
|
||||
currentActivities.push(5);
|
||||
currentActivities.splice(currentActivities.indexOf(3),1)
|
||||
currentActivities.splice(currentActivities.indexOf(4),1)
|
||||
if (currentActivities.indexOf(3)!=-1){currentActivities.splice(currentActivities.indexOf(3),1)}
|
||||
if (currentActivities.indexOf(4)!=-1){currentActivities.splice(currentActivities.indexOf(4),1)}
|
||||
}
|
||||
|
||||
var result = tx.executeSql('UPDATE news SET friendica_activities_self ="'+JSON.stringify(currentActivities)+'" where username="'+login.username+'" AND status_id ='+newsid);
|
||||
callback();
|
||||
})}})}
|
||||
})})}
|
||||
|
||||
function requestConversation(login,database,newsid,contacts,rootwindow,callback){
|
||||
Helperjs.friendicaRequest(login,"/api/conversation/show?id="+newsid,rootwindow, function (obj){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue