This commit is contained in:
LubuWest 2019-12-10 21:12:32 +01:00
commit 7119d5bdf4
292 changed files with 790 additions and 16347 deletions

View file

@ -172,21 +172,25 @@ function deleteContacts(database,user,callback) { // does nothing useful at the
// })
//}
function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){
function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){print("newRequestFriendsAlbumPictures");
// screenscraping of albums page of contact with remoteAuth
Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){
try {var obj=JSON.parse(photohtml);
//commented out for broken remoteauth
//Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
try {var obj=JSON.parse(photohtml);print ("Photohtml: "+photohtml)
if (obj.hasOwnProperty('status')){
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
getAlbumFromHtml(photohtml,false,rootwindow,callback)})
}}
catch (e){
getAlbumFromHtml(photohtml,true,rootwindow,callback)
//getAlbumFromHtml(photohtml,true,rootwindow,callback)
getAlbumFromHtml(photohtml,false,rootwindow,callback)
}
})
}
function getAlbumFromHtml(photohtml,remoteAuthBool,rootwindow,callback){
print(photohtml);
var photoarray=[];
var arr = photohtml.split("sidebar-photos-albums-li");
for (var i=2;i<arr.length;i++){

View file

@ -68,15 +68,19 @@ function requestGroups(login,database,rootwindow,callback){
function listFriends(login,database,callback,filter){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
var filtertext='';
try {filtertext=' AND screen_name like "' + filter+'%"'}catch(e){}
//try {filtertext=' AND screen_name like "' + filter+'%"'}catch(e){}
var filtertext=new RegExp(".*"+filter.toLowerCase()+".*")
// if (filter){filtertext=' AND (screen_name like "' + filter+'%" OR name like "' + Qt.btoa(filter)+'%")'}
db.transaction( function(tx) {
//var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend>0'+filtertext);
//print('SELECT * from contacts WHERE username="'+login.username+'"'+filtertext);
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend>0'+filtertext);
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend>0');
// check for friends
var contactlist=[];
for (var i=0;i<result.rows.length;i++){
contactlist.push(result.rows.item(i))
var contact=result.rows.item(i)
contact.name=Qt.atob(contact.name);
if(filtertext.test(contact.name.toLowerCase())|| filtertext.test(contact.screen_name.toLowerCase())){
contactlist.push(contact)}
}
callback(contactlist)
});
@ -183,7 +187,7 @@ function storeNews(login,database,news,rootwindow){
// save news after contacts download, call next function
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
for (var i=0;i<news.length;i++){
//print('store news data for ' + news[i].id+JSON.stringify(news[i].friendica_author));
print('store news data for ' + login.username+news[i].messagetype+Qt.btoa(news[i].text)+news[i].created_at+ news[i].in_reply_to_status_id+ news[i].source+ news[i].id+news[i].in_reply_to_user_id+news[i].geo+news[i].favorited+ news[i].user.id+Qt.btoa(news[i].statusnet_html)+news[i].statusnet_conversation_id+ Qt.btoa(JSON.stringify(friendica_activities))+"[]"+attachments+news[i].friendica_author.url);
//var ausdruck=news[i];
var likearray=[];var dislikearray=[];var attendyesarray=[];var attendnoarray=[];var attendmaybearray=[];
if(news[i].hasOwnProperty('friendica_activities')){
@ -277,8 +281,9 @@ function newsfromdb(database,login,messagetype,callback,contact,stop_time){
stop="<="+rs.rows.item(0).created_at}catch(e){stop="<99999999999999"}}
else{var stop="<"+stop_time}
var contactfilter="";if(contact){contactfilter=" AND (uid='"+contact+"' OR friendica_owner='"+contact+"')"}
//print('select * from news WHERE username="'+username+'" AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
var newsrs=tx.executeSql('select * from news WHERE username="'+login.username+'" AND messagetype="'+messagetype+'" AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
if (messagetype=="0"){messagetype="0,5"}
//print('select * from news WHERE username="'+login.username+'" AND messagetype IN ( '+messagetype+' ) AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
var newsrs=tx.executeSql('select * from news WHERE username="'+login.username+'" AND messagetype IN ( '+messagetype+' ) AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
var newsArray=[];
var allcontacts=getAllContacts(database,login.username);
@ -462,7 +467,8 @@ function chatsfromdb(database,login,messagetype,callback,stop_time){
try{var rs = tx.executeSql('select created_at from news WHERE username="'+login.username+'" AND messagetype="'+messagetype+'" ORDER BY created_at DESC LIMIT 1');
stop="<="+rs.rows.item(0).created_at}catch(e){stop="<99999999999999"}}
else{var stop="<"+stop_time}
var conversationsrs=tx.executeSql('select DISTINCT statusnet_conversation_id from news WHERE username="'+login.username+'" AND created_at'+stop+' AND messagetype="'+messagetype+'" ORDER BY created_at DESC LIMIT 20'); //+' ORDER BY created_at DESC LIMIT 20');
if (messagetype=="1"){messagetype="1,5"}
var conversationsrs=tx.executeSql('select DISTINCT statusnet_conversation_id from news WHERE username="'+login.username+'" AND created_at'+stop+' AND messagetype IN ( "'+messagetype+'" ) ORDER BY created_at DESC LIMIT 20'); //+' ORDER BY created_at DESC LIMIT 20');
var result = tx.executeSql('SELECT status_id from news WHERE username="'+login.username+'" AND messagetype=0 ORDER BY status_id DESC LIMIT 1');
try{var lastid=result.rows.item(0).status_id;}catch(e){var lastid=0};
var conversations=[];

View file

@ -56,7 +56,7 @@ else{
var forumname="";
try{if (newsitemobject.messagetype==0&&newsitemobject.hasOwnProperty('friendica_author')&&
((newsitemobject.friendica_author.url)!=(newsitemobject.user.url))&&((newsitemobject.friendica_author.url)!=null)){
print(" Friendica Author "+JSON.stringify(newsitemobject.friendica_author));
//print(" Friendica Author "+JSON.stringify(newsitemobject));
forumname=" via "+newsitemobject.user.name;
newsitemobject.user=newsitemobject.friendica_author;
}}catch(e){print("forum name "+e)}
@ -138,20 +138,21 @@ else{
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=ptvideohelper.url)){attachmentList.push(ptvideohelper)}
}
}
// if (newsitemobject.text.indexOf("https://www.youtube.com/watch")>-1){
// //print("message "+msg.options.showWebsiteForLinks);
// if (msg.options.showYoutube!="false"){
// var ythelper={mimetype:"video/youtube"}
// var yttext=newsitemobject.text;
// while (yttext.indexOf("https://www.youtube.com/watch")>-1){
// var ythelperstringposition=linktext.indexOf("watch?v=");
// var ytposend=findend(yttext,ythelperstringposition);
// ythelper.url=yttext.substring(yttext.lastIndexOf("http",linkhelperstringposition),linkposend);
// linktext=linktext.substring(linkhelperstringposition+5,linktext.length)
// if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=linkhelper.url)){attachmentList.push(linkhelper)}
// }
// }
// }
if (newsitemobject.text.indexOf("youtube.com/watch?v")>-1){
//print("message "+msg.options.showWebsiteForLinks);
//if (msg.options.showYoutube!="false"){
var yttext=newsitemobject.text;
while (yttext.indexOf("youtube.com/watch?v")>-1){
var ythelperstringposition=yttext.indexOf("watch?v=");
var ytposend=findend(yttext,ythelperstringposition);
var ythelper={mimetype:"video/youtube"}
ythelper.url=yttext.substring(ythelperstringposition+8,ytposend);
yttext=yttext.substring(ytposend,yttext.length);
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=ythelper.url)){attachmentList.push(ythelper)}
}
//}
}
// if (newsitemobject.text.indexOf(".html")>-1){
// //print("message "+msg.options.showWebsiteForLinks);
@ -169,6 +170,11 @@ else{
// }
newsitemobject.attachmentList=attachmentList;
if ((msg.options.hasOwnProperty("hide_nsfw"))&&(msg.options.hide_nsfw==1)&&(newsitemobject.text.indexOf("#nsfw")>-1)){
newsitemobject.nsfw=true
} else{newsitemobject.nsfw=false}
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
var timestring="";
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}

View file

@ -340,12 +340,15 @@ function cleanNews(database,callback){
//var maxnewsrs = tx.executeSql("SELECT DISTINCT maxnews FROM config");
var maxnewsrs = tx.executeSql("SELECT v FROM globaloptions WHERE k='max_news'");
var maxnews=1000; if(maxnewsrs.rows.length>0){ maxnews=maxnewsrs.rows.item(0).v};
var newscountrs = tx.executeSql('SELECT COUNT(*) from news');
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;
var deleters = tx.executeSql('DELETE from news WHERE created_at<='+lastvalidtime)}
for (var i=0; i<6;i++){
if (i!=0){maxnews=maxnews/5}
var newscountrs = tx.executeSql('SELECT COUNT(*) from news WHERE messagetype='+i);
var newscount = newscountrs.rows.item(0)["COUNT(*)"];//print("newscount "+newscount)
if (newscount>maxnews){
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnews));
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnews-1).created_at;
var deleters = tx.executeSql('DELETE from news WHERE messagetype='+i+' AND created_at<='+lastvalidtime)}
}
callback()
})
}
@ -394,13 +397,40 @@ function processNews(api,data){
Helperjs.showMessage(qsTr("JSON status Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
}
else if (!(Array.isArray(newslist))){
//print("processNews not array"+newslist+JSON.stringify(newslist));
// print("processNews not array"+newslist+JSON.stringify(newslist));
// if(newslist.hasOwnProperty('id')){
// newslist.created_at=Date.parse(Newsjs.cleanDate(newslist.created_at));
// newslist.messagetype=5;
// newslist.friendica_author=cleanUser(newslist.friendica_author);
// newslist.user=cleanUser(newslist.user);
// if(newslist.in_reply_to_user_id){newslist.reply_user=Newsjs.objFromArray(allcontacts,"id",newslist.in_reply_to_user_id)}
// var dummynewslist=[newslist];
// Newsjs.storeNews(login,db,dummynewslist,root);
// switch(newsSwipeview.stacktype){
// case "Home":messagetype=0;break;
// case "DirectMessages": messagetype=1;break;
// case "Notifications":messagetype=2;break;
// case "Replies":messagetype=3;break;
// default:messagetype=0;
// }
// if((login.newsViewType=="Conversations")&&(newsSwipeview.stacktype=="Home")){
// Newsjs.chatsfromdb(db,login,messagetype,function(dbnews,lastid){
// lastnewsid=lastid;
// showNews(dbnews);
// })
// }
// else{Newsjs.newsfromdb(db,login,messagetype,function(dbnews,lastid){
// lastnewsid=lastid;
// showNews(dbnews)
// })}
// }
replytimer.restart()
}
else {
var allcontacts=[];
allcontacts=Newsjs.getAllContacts(db,login.username);
if (api=="/api/direct_messages/all"){
if (api=="/api/direct_messages/all" || api=="/api/direct_messages/conversation"){
for (var n in newslist){
newslist[n].created_at=Date.parse(Newsjs.cleanDate(newslist[n].created_at));
newslist[n].messagetype=1;
@ -412,6 +442,8 @@ function processNews(api,data){
newslist[n].friendica_owner=newslist[n].user;
newslist[n].friendica_author=newslist[n].user;
newslist[n].statusnet_html=newslist[n].text;
newslist[n].in_reply_to_user_id=newslist[n].recipient_id
if(newslist[n].in_reply_to_user_id){newslist[n].reply_user=Newsjs.objFromArray(allcontacts,"id",newslist[n].in_reply_to_user_id)}
}}
else if (api=="/api/friendica/notifications"){
for (var n in newslist){
@ -488,7 +520,7 @@ function processNews(api,data){
}
if (api=="/api/conversation/show"){
if (api=="/api/conversation/show"|| api=="/api/direct_messages/conversation"){
newslist.reverse();
newstab.conversation=newslist
}

View file

@ -16,8 +16,9 @@
var player;
function onYouTubeIframeAPIReady() {
console.log("Videoid: "+getVideoId());
player = new YT.Player('player', {
playerVars: { 'html5': 1, 'iv_load_policy': 3 },
playerVars: { 'html5': 1, 'iv_load_policy': 3, 'autoplay': 1 },
frameborder: '0',
height: '100%',
width: '100%',
@ -31,6 +32,7 @@
function onPlayerReady(event) {
document.title = 0;
event.target.playVideo();
}
function onPlayerStateChange(event) {
@ -42,4 +44,4 @@
}
</script>
</body>
</html>
</html>