forked from lubuwest/Friendiqa
Version 0.002 with working FriendsTabView
This commit is contained in:
parent
bc4adba50c
commit
42de63fe63
77 changed files with 6830 additions and 387 deletions
48
v0.002/Develop/source-linux/js/newsworker.js
Normal file
48
v0.002/Develop/source-linux/js/newsworker.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
WorkerScript.onMessage = function(msg) {
|
||||
if(msg.appendnews!==true){ msg.model.clear()};
|
||||
for (var j=0;j<msg.news.length;j++){
|
||||
if (msg.news[j]) {
|
||||
var newsitemobject=msg.news[j];
|
||||
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText="";
|
||||
if (newsitemobject.messagetype==0){
|
||||
if (msg.news[j].like.length>0){
|
||||
if (msg.news[j].like.length==1){likeText= Qt.atob(msg.news[j].like[0].name)+" "+ qsTr("likes this.")}
|
||||
else {likeText= msg.news[j].like.length+" "+ qsTr("like this.")}
|
||||
}
|
||||
if (msg.news[j].dislike.length>0){
|
||||
if (msg.news[j].dislike.length==1){dislikeText= QT.atob(msg.news[j].dislike[0].name)+" "+ qsTr("doesn't like this.")}
|
||||
else {dislikeText= msg.news[j].dislike.length+" "+ qsTr("don't like this.")}
|
||||
}
|
||||
if (msg.news[j].attendyes.length>0){
|
||||
if (msg.news[j].attendyes.length==1){attendyesText= Qt.atob(msg.news[j].attendyes[0].name)+" "+ qsTr("will attend.")}
|
||||
else {attendyesText= msg.news[j].attendyes.length+" "+ qsTr("persons will attend.")}
|
||||
}
|
||||
if (msg.news[j].attendno.length>0){
|
||||
if (msg.news[j].attendno.length==1){attendnoText= Qt.atob(msg.news[j].attendno[0].name)+" "+ qsTr("will not attend.")}
|
||||
else {attendnoText= msg.news[j].attendno.length+" "+ qsTr("persons will not attend.")}
|
||||
}
|
||||
if (msg.news[j].attendmaybe.length>0){
|
||||
if (msg.news[j].attendmaybe.length==1){attendmaybeText= Qt.atob(msg.news[j].attendmaybe[0].name)+" "+ qsTr("may attend.")}
|
||||
else {attendmaybeText= msg.news[j].attendmaybe.length+" "+ qsTr("persons may attend.")}
|
||||
}
|
||||
}
|
||||
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText}
|
||||
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
|
||||
var timestring="";
|
||||
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
|
||||
else if (seconds<90){timestring=Math.round(seconds/60)+" "+qsTr("minute") +" "+qsTr("ago");}
|
||||
else if (seconds<3600){timestring=Math.round(seconds/60)+" "+qsTr("minutes") +" "+qsTr("ago");}
|
||||
else if (seconds<5400){timestring=Math.round(seconds/3600)+" "+qsTr("hour") +" "+qsTr("ago");}
|
||||
else if (seconds<86400){timestring=Math.round(seconds/3600)+" "+qsTr("hours") +" "+qsTr("ago");}
|
||||
else if (seconds<129600){timestring=Math.round(seconds/86400)+" "+qsTr("day") +" "+qsTr("ago");}
|
||||
else if (seconds<3888000){timestring=Math.round(seconds/86400)+" "+qsTr("days") +" "+qsTr("ago");}
|
||||
else if (seconds<5832000){timestring=Math.round(seconds/3888000)+" "+qsTr("month") +" "+qsTr("ago");}
|
||||
else if (seconds<69984000){timestring=Math.round(seconds/3888000)+" "+qsTr("months") +" "+qsTr("ago");}
|
||||
else {timestring=Math.round(seconds/69984000)+" "+qsTr("years") +" "+qsTr("ago");}
|
||||
var data=({"newsitemobject": newsitemobject,"dateDiff":timestring,"friendica_activities":friendica_activities})}
|
||||
// print("News:"+j+msg.news.length+JSON.stringify(data));
|
||||
msg.model.append(data);}
|
||||
if (j==msg.news.length){
|
||||
msg.model.sync()
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue