forked from lubuwest/Friendiqa
Friendiqa v0.3.1
This commit is contained in:
parent
6f9aad9099
commit
2afa7cbe6b
29 changed files with 490 additions and 465 deletions
|
@ -151,8 +151,8 @@ var where = " AND "+ filter +" = '" + filtervalue+"'";
|
|||
});
|
||||
}
|
||||
|
||||
function showMessage(header,message,rootwindow){print("message: "+message);
|
||||
var cleanmessage=message.replace(/"/g,"-"); //print(cleanmessage);
|
||||
function showMessage(header,message,rootwindow){
|
||||
var cleanmessage=message.replace(/"/g,"-");
|
||||
if(cleanmessage.length>200){cleanmessage=cleanmessage.slice(0,200)+'...'}
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:"'+header+'";standardButtons: StandardButton.Ok; text:" '+cleanmessage+'"}';
|
||||
var messageObject=Qt.createQmlObject(messageString,rootwindow,"messageOutput");
|
||||
|
|
|
@ -326,7 +326,7 @@ function favorite(login,favorite,newsid,rootwindow){
|
|||
// toggle favorites
|
||||
if(favorite){ Helperjs.friendicaPostRequest(login,"/api/favorites/create?id="+newsid,"","POST", rootwindow,function (obj){
|
||||
})}
|
||||
else {Helperjs.friendicaPostRequest(login,"/api/favorites/destroy?id="+newsid, "POST",rootwindow,function (obj){
|
||||
else {Helperjs.friendicaPostRequest(login,"/api/favorites/destroy?id="+newsid,"","POST",rootwindow,function (obj){
|
||||
})}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,15 +82,27 @@ else{
|
|||
if (newsitemobject.friendica_activities_self.indexOf(2)!=-1){self.disliked=1}
|
||||
}}} catch(e){print("Activities "+e+ " "+JSON.stringify(newsitemobject.friendica_activities))}
|
||||
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText,self:self}
|
||||
|
||||
var attachmentList=[];try{if(newsitemobject.attachments){
|
||||
var attachmentList=[];
|
||||
try{if(newsitemobject.attachments){
|
||||
var attachArray=newsitemobject.attachments;
|
||||
for (var image in attachArray){if(attachArray[image].mimetype=="image/gif"){
|
||||
attachmentList.push(attachArray[image])
|
||||
for (var image in attachArray){
|
||||
var attachhelper={mimetype:attachArray[image].mimetype}
|
||||
var attachhelperstring=Qt.btoa(attachArray[image].url)
|
||||
var helperstringposition=newsitemobject.text.indexOf(attachhelperstring);
|
||||
if (helperstringposition>-1){attachhelper.url=newsitemobject.text.substring(newsitemobject.text.lastIndexOf("http",helperstringposition),helperstringposition+attachhelperstring.length);
|
||||
if (attachArray[image].mimetype=="image/jpeg"){attachhelper.url=attachhelper.url+".jpg"}
|
||||
else if (attachArray[image].mimetype=="image/gif"){attachhelper.url=attachhelper.url+".gif"}
|
||||
else if (attachArray[image].mimetype=="image/png"){attachhelper.url=attachhelper.url+".png"}
|
||||
}
|
||||
else {attachhelper.url=attachArray[image].url}
|
||||
attachmentList.push(attachhelper)
|
||||
newsitemobject.text=newsitemobject.text.replace(attachhelper.url,"")
|
||||
newsitemobject.text=newsitemobject.text.replace(attachhelper.url.substring(0,attachhelper.url.length-4)+".jpeg","")
|
||||
newsitemobject.text=newsitemobject.text.replace(attachhelper.url.substring(0,attachhelper.url.length-4),"")
|
||||
}
|
||||
}}catch(e){print("attachment "+e)}
|
||||
}}catch(e){print("attachment "+e)}
|
||||
newsitemobject.attachmentList=attachmentList;
|
||||
|
||||
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
|
||||
var timestring="";
|
||||
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
|
||||
|
|
|
@ -39,6 +39,7 @@ function initDatabase(database) { // initialize the database object
|
|||
var db =Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
print('initDatabase()'+database[0]+database[1]+database[2]+database[3])
|
||||
db.transaction( function(tx) {
|
||||
//var version=tx.executeSql('PRAGMA user_version');print(JSON.stringify(version.rows.item(0)))
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS imageData(username TEXT,id INT, created TEXT,edited TEXT, title TEXT, desc TEXT, album TEXT,filename TEXT, type TEXT, height INT, width INT, profile INT, link TEXT,location TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS config(server TEXT, username TEXT, password TEXT, imagestore TEXT, maxnews INT, timerInterval INT, newsViewType TEXT,isActive INT, permissions TEXT,maxContactAge INT,APIVersion TEXT,layout TEXT, addons TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,friendica_activities TEXT, friendica_activities_self TEXT, attachments TEXT, friendica_owner TEXT)');
|
||||
|
@ -313,7 +314,7 @@ function cleanNews(database,callback){
|
|||
var maxnewsrs = tx.executeSql("SELECT DISTINCT maxnews FROM config");
|
||||
var maxnews=maxnewsrs.rows.item(0).maxnews;
|
||||
var newscountrs = tx.executeSql('SELECT COUNT(*) from news');
|
||||
var newscount = newscountrs.rows.item(0)["COUNT(*)"];
|
||||
var newscount = newscountrs.rows.item(0)["COUNT(*)"];//print("newscount "+newscount)
|
||||
if (newscount>maxnews){
|
||||
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news ORDER BY created_at ASC LIMIT ' +(newscount-maxnews));
|
||||
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnews-1).created_at;
|
||||
|
@ -329,6 +330,7 @@ function cleanContacts(login,database,callback){
|
|||
if (oldestnewsrs.rows.length>0){ var oldestnewsTime=oldestnewsrs.rows.item(0).created_at- 604800000;} else{var oldestnewsTime=0} //contacts can be 7 days old
|
||||
//print(login.username+" älteste news: "+ oldestnewsTime);
|
||||
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend=0 AND imageAge<'+oldestnewsTime); // check for friends
|
||||
//print ("Contact result length: "+ result.rows.length)
|
||||
for (var i=0;i<result.rows.length;i++){
|
||||
filesystem.rmFile(result.rows.item(i).profile_image);
|
||||
var deleters = tx.executeSql('DELETE from contacts WHERE username="'+login.username+'" AND url="'+result.rows.item(i).url+'"');
|
||||
|
@ -355,9 +357,7 @@ function updateContactInDB(login,database,isFriend,contact){// for newstab and f
|
|||
}
|
||||
|
||||
function processNews(api,data){
|
||||
try{var newslist=JSON.parse(data);
|
||||
} catch(e){
|
||||
Helperjs.showMessage(qsTr("Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)};
|
||||
try{var newslist=JSON.parse(data)} catch(e){newsBusy.running=false;};
|
||||
if (typeof(newslist)=='undefined'){
|
||||
Helperjs.showMessage(qsTr("Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
|
||||
}
|
||||
|
@ -461,6 +461,7 @@ function processNews(api,data){
|
|||
var newstabarray=["Conversations","Favorites","Timeline","DirectMessage"];
|
||||
if (newstabarray.indexOf(newstab.newstabstatus)>-1){contacttimer.start()}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -535,6 +536,7 @@ function updateView(viewtype){
|
|||
newstab.newstabstatus="Conversations";
|
||||
}
|
||||
xhr.get();
|
||||
|
||||
if (viewtype==="Conversations"){Newsjs.allchatsfromdb(db,login.username,function(temp){
|
||||
newsStack.allchats=temp
|
||||
})}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue