Friendiqa v0.3.2

This commit is contained in:
LubuWest 2018-08-25 16:17:09 +02:00
commit 99ae53f624
54 changed files with 2771 additions and 437 deletions

View file

@ -132,6 +132,21 @@ function deleteImage(database,login,type,location,filesystem,rootwindow,callback
})
}
function updateImage(database,login,type,filesystem,imageId,rootwindow,callback) { // delete image locally and on server
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
Helperjs.readData(database,"imageData",login.username,function(obj){
db.transaction( function(tx) {
if (type=='image'){
var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+obj[0].location+'" AND filename="'+obj[0].filename+'"');
filesystem.Directory=obj[0].location
filesystem.rmFile(obj[0].filename)
}
})
},"id",imageId);
callback()
}
function deleteContacts(database,user,callback) { // does nothing useful at the moment
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
//print(' delete Image Data() for ' + field +"="+selection)

View file

@ -35,9 +35,9 @@ if(msg.deleteId!==undefined)
msg.model.sync()
}
else{
if(msg.appendnews!==true){msg.model.clear()};
msg.model.sync()
for (var j=0;j<msg.news.length;j++){
if(msg.method=="refresh"){msg.model.clear()};
msg.model.sync()
for (var j=0;j<msg.news.length;j++){
if (msg.news[j]) {
var newsitemobject=msg.news[j];
//print("Newsitem"+JSON.stringify(newsitemobject.friendica_owner+" userid: "+newsitemobject.user.id));
@ -83,24 +83,37 @@ else{
}}} 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=[];
var videoformats=["mp4", "avi", "webm","ogg","mp3"]
try{if(newsitemobject.attachments){
var attachArray=newsitemobject.attachments;
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);
var helperstringposition=newsitemobject.statusnet_html.indexOf(attachhelperstring);
if (helperstringposition>-1){attachhelper.url=newsitemobject.statusnet_html.substring(newsitemobject.statusnet_html.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),"")
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url,"")
}
}}catch(e){print("attachment "+e)}
}
}catch(e){print("attachment "+e)}
for (var format in videoformats){
if (newsitemobject.text.indexOf("."+videoformats[format])>-1){
var videohelper={mimetype:"video/"+videoformats[format]}
var videotext=newsitemobject.text;
while (videotext.indexOf("."+videoformats[format])>-1){
var videohelperstringposition=videotext.indexOf("."+videoformats[format]);
videohelper.url=videotext.substring(videotext.lastIndexOf("http",videohelperstringposition),videohelperstringposition+4);
videotext=videotext.substring(videohelperstringposition+4,videotext.length)
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=videohelper.url)){attachmentList.push(videohelper)}
}
}
}
newsitemobject.attachmentList=attachmentList;
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
@ -118,12 +131,15 @@ else{
var data=({"newsitemobject": newsitemobject,"dateDiff":timestring,"friendica_activities":friendica_activities,"forumname":forumname})}
//print("News:"+j+msg.news.length+JSON.stringify(data));
msg.model.append(data)
if(msg.method=="append") {
msg.model.insert(j, data)}
else{
msg.model.append(data)}
}
if (j==msg.news.length){
//print("j: "+j+" msg.model.count: "+msg.model.count);
msg.model.sync()
}
}
}
}

View file

@ -358,14 +358,17 @@ function updateContactInDB(login,database,isFriend,contact){// for newstab and f
function processNews(api,data){
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)
if (data==""){}
else if (typeof(newslist)=='undefined'){
Helperjs.showMessage(qsTr("Undefined Array Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
}
else if (newslist.hasOwnProperty('status')){
Helperjs.showMessage(qsTr("Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
} else if (!(Array.isArray(newslist))){
Helperjs.showMessage(qsTr("JSON status Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
}
else if (!(Array.isArray(newslist))){
replytimer.restart()
} else {
}
else {
var allcontacts=[];
allcontacts=Newsjs.getAllContacts(db,login.username);
if (api=="/api/direct_messages/all"){
@ -389,6 +392,7 @@ function processNews(api,data){
newslist[n].user=cleanUser(newslist[n].user);
}
newslist[n].statusnet_html=newslist[n].msg_html;
newslist[n].text=newslist[n].msg;
}
} else {
var chatlist=[];