diff --git a/Source/ApiTransform.js b/Source/ApiTransform.js index 1e47578..79e9d01 100644 --- a/Source/ApiTransform.js +++ b/Source/ApiTransform.js @@ -31,6 +31,9 @@ var ApiSchema = { Mastodon: "account", Misskey: "user", }, + Quoting: { + Mastodon: "reblog", + }, Time: { Mastodon: "created_at", Misskey: "createdAt", @@ -57,24 +60,34 @@ var ApiSchema = { Mastodon: "display_name", Misskey: "name", }, - Type: {}, // user, bot, channel, group + Type: { // user, bot, channel, group + Mastodon: {"__Eval__": ` + var Type; + if (TreeOld.bot) Type = 'Bot'; + if (TreeOld.group) Type = 'Group'; + TreeNew[KeyNew] = Type; + `}, + }, Url: { Mastodon: "url", }, }, }; +function ApiTransform(Data, FromSource, DestType) { + return JsonTransformB(Data, ApiSchema, ApiSchema[DestType], FromSource); +}; + +/* var TransParsers = { Mastodon: { Account(Data) { //return JsonTransformA(Data, TransSchemas.Mastodon.Author, TransSchemas.Mastodon); return JsonTransformB(Data, ApiSchema, ApiSchema.Profile, 'Mastodon'); }, - /* Instance(Data) { return JsonTransformA(Data, TransSchemas.Mastodon.Instance, TransSchemas.Mastodon); }, - */ Status(Data) { //return JsonTransformA(Data, TransSchemas.Mastodon.Status, TransSchemas.Mastodon); return JsonTransformB(Data, ApiSchema, ApiSchema.Note, 'Mastodon'); @@ -83,3 +96,4 @@ var TransParsers = { Misskey: { }, }; +*/ diff --git a/Source/FakeApi.js b/Source/FakeApi.js index 80dece3..636ecfe 100644 --- a/Source/FakeApi.js +++ b/Source/FakeApi.js @@ -30,7 +30,7 @@ FakeApi.Mastodon.Account = { url: "https://mastodon.example.com/@Tester", }; FakeApi.Friendiiverse.Featured.Featured.push( - TransParsers.Mastodon.Account(FakeApi.Mastodon.Account)); + ApiTransform(FakeApi.Mastodon.Account, 'Mastodon', 'Profile')); FakeApi.Mastodon.Status = { account: FakeApi.Mastodon.Account, diff --git a/Source/Friendiiverse.html b/Source/Friendiiverse.html index 4b7c4fd..167135b 100644 --- a/Source/Friendiiverse.html +++ b/Source/Friendiiverse.html @@ -13,6 +13,7 @@ var FriendicaCredentials = 'redacted:redacted'; // Development var Debug = true; var UseFakeApi = true; +var UserData = {};
@@ -26,15 +27,12 @@ var UseFakeApi = true;+ +
+ `; +}; +function PostNote(Text) { + Obj = ExtrimObj(ApiSchema.Note); +}; + DoAsync(FetchFeatured, FillFeatured); CoverView.remove(); diff --git a/Source/Strings.js b/Source/Strings.js index 2d0bd8c..8ca9685 100644 --- a/Source/Strings.js +++ b/Source/Strings.js @@ -1,3 +1,10 @@ var Strings = { - + Back: { + en: "Back", + it: "Indietro", + }, + Note: { + en: "Note", + it: "Nota", + }, }; diff --git a/Source/Style.css b/Source/Style.css index cd670a8..a69d924 100644 --- a/Source/Style.css +++ b/Source/Style.css @@ -16,6 +16,10 @@ img, video { max-width: 100%; } +#Bottom > button { + height: 100%; +} + #Root { /*margin-bottom: 2em;*/ } diff --git a/Source/Utils.js b/Source/Utils.js index 980a654..13c4e67 100644 --- a/Source/Utils.js +++ b/Source/Utils.js @@ -28,6 +28,14 @@ function CopyObj(Obj) { return JSON.parse(JSON.stringify(Obj)); }; +function ExtrimObj(Obj) { + Obj = CopyObj(Obj); + Object.keys(Obj).forEach(function(Key){ + Obj[Key] = undefined; + }); + return Obj; +}; + function B64Obj(Obj) { return btoa(JSON.stringify(Obj)); }; @@ -81,6 +89,7 @@ function JsonTransformCycleA(TreeOld, SchemaCurr, SchemaRoot) { }); return TreeNew; }; + function JsonTransformB(TreesOld, SchemaNew, NodeNew, TypeOld) { if (Array.isArray(TreesOld)) { var ListNew = []; @@ -99,10 +108,14 @@ function JsonTransformCycleB(TreeOld, SchemaNew, NodeNew, TypeOld) { var KeyOld = TreeNew[KeyNew][TypeOld]; var ObjOld = TreeOld[KeyOld]; if (IsObj(KeyOld)) { - // Deep nested children in TreeOld - + // Object in SchemaNew / Deep nested children in TreeOld + Object.keys(KeyOld).forEach(function(KeyObj){ + if (KeyObj === '__Eval__') { + eval(KeyOld[KeyObj]); + }; + }); } else { - // Direct children in TreeOld + // Value in SchemaNew / Direct children in TreeOld if (IsObj(ObjOld)) { TreeNew[KeyNew] = JsonTransformB(ObjOld, SchemaNew, SchemaNew[KeyNew], TypeOld); } else { @@ -111,5 +124,6 @@ function JsonTransformCycleB(TreeOld, SchemaNew, NodeNew, TypeOld) { }; }; }); + TreeNew.__TreeOld__ = TreeOld; return TreeNew; };