Verified Commit 1f5e7639 authored by Haelwenn's avatar Haelwenn

Worker.js: Fix some formatting

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