Verified Commit 1f5e7639 authored by Haelwenn's avatar Haelwenn

Worker.js: Fix some formatting

parent c52715ae
......@@ -23,11 +23,11 @@ WorkerScript.onMessage =
console.log("Not loggedin")
return;
}
if(typeof msg.conf['loadImages'] !== "undefined")
loadImages = msg.conf['loadImages']
var API =
MastodonAPI({instance : msg.conf.instance, api_user_token : msg.conf.api_user_token});
if(typeof msg.conf['loadImages'] !== "undefined") loadImages = msg.conf['loadImages'];
var API = MastodonAPI({instance : msg.conf.instance, api_user_token : msg.conf.api_user_token});
if(msg.method === "POST")
{
API.post(msg.action, msg.params, function(data) {
......@@ -163,7 +163,7 @@ function addDataToModel(model, mode, items) {
res[prefix + 'account_created_at'] = data["created_at"]
res[prefix + 'account_avatar'] = data["avatar"]
// /console.log(JSON.stringify(res))
// console.log(JSON.stringify(res))
return (res);
}
......@@ -184,7 +184,7 @@ function parseNotification(data) {
item = parseAccounts(item, "", data["status"]["account"])
item['status_reblog'] = true;
item['type'] = "reblog";
item['typeIcon'] = "image://theme/icon-s-retweet"
item['typeIcon'] = "image://theme/icon-s-retweet";
break;
case "favourite":
item = parseToot(data.status)
......@@ -197,12 +197,11 @@ function parseNotification(data) {
break;
case "follow":
item['type'] = "follow";
item = parseAccounts(item, "", data["account"])
item = parseAccounts(item, "reblog_", data["account"])
item['content'] = data['account']['note']
item['typeIcon'] = "image://theme/icon-s-installed"
item['attachments'] = []
item = parseAccounts(item, "", data["account"]);
item = parseAccounts(item, "reblog_", data["account"]);
item['content'] = data['account']['note'];
item['typeIcon'] = "image://theme/icon-s-installed";
item['attachments'] = [];
break;
default: item['typeIcon'] = "image://theme/icon-s-sailfish"
}
......@@ -228,10 +227,14 @@ collect() {
}
}
return ret;
} function getDate(dateStr) {
}
function getDate(dateStr) {
var ts = new Date(dateStr);
return new Date(ts.getFullYear(), ts.getMonth(), ts.getDate(), 0, 0, 0)
} function parseToot(data) {
}
function parseToot(data) {
var i = 0;
var item = {};
......@@ -243,7 +246,9 @@ collect() {
item['status_in_reply_to_account_id'] = data["in_reply_to_account_id"]
item['status_reblog'] = data["reblog"] ? true : false
item['status_content'] = data["content"]
item['status_created_at'] = item['created_at'] = new Date(data["created_at"]);
item['section'] = getDate(data["created_at"]);
item['reblogs_count'] = data["reblogs_count"]
item['favourites_count'] = data["favourites_count"]
......@@ -264,8 +269,9 @@ collect() {
item = parseAccounts(item, "", data['reblog']["account"])
item = parseAccounts(item, "reblog_", data["account"])
}
else {item = parseAccounts(item, "", data["account"])} item['content'] =
data['content']
else {item = parseAccounts(item, "", data["account"])}
item['content'] = data['content']
.replaceAll('</span><span class="invisible">', '')
.replaceAll('<span class="invisible">', '')
.replaceAll('</span><span class="ellipsis">', '')
......@@ -276,6 +282,7 @@ collect() {
{
var attachments = data['media_attachments'][i];
item['content'] = item['content'].replaceAll(attachments['text_url'], '')
var tmp = {
id : attachments['id'],
id : attachments['id'],
......@@ -287,12 +294,14 @@ collect() {
} item['attachments']
.push(tmp)
}
if(item['status_reblog'])
{
for(i = 0; i < data['reblog']['media_attachments'].length; i++)
{
var attachments = data['reblog']['media_attachments'][i];
item['content'] = item['content'].replaceAll(attachments['text_url'], '')
var tmp = {
id : attachments['id'],
type : attachments['type'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment