diff --git a/Source/ApiTransform.js b/Source/ApiTransform.js index 6d6e88d..1e47578 100644 --- a/Source/ApiTransform.js +++ b/Source/ApiTransform.js @@ -22,7 +22,25 @@ var TransSchemas = { */ var ApiSchema = { - __Account__: { + Note: { // TODO: Figure out renotes + Content: { + Mastodon: "content", + Misskey: "text", + }, + Profile: { + Mastodon: "account", + Misskey: "user", + }, + Time: { + Mastodon: "created_at", + Misskey: "createdAt", + }, + Url: { + Mastodon: "url", + }, + }, + Profile: { + Avatar: {}, // would "Character" be better? Banner: { Mastodon: "header", Misskey: "bannerUrl", @@ -39,36 +57,18 @@ var ApiSchema = { Mastodon: "display_name", Misskey: "name", }, - Url: { - Mastodon: "url", - }, - }, - Note: { - Author: { - Mastodon: "account", - Misskey: "user", - }, - Content: { - Mastodon: "content", - Misskey: "text", - }, - Time: { - Mastodon: "created_at", - Misskey: "createdAt", - }, + Type: {}, // user, bot, channel, group Url: { Mastodon: "url", }, }, }; -ApiSchema.Author = CopyObj(ApiSchema.__Account__); -ApiSchema.Channel = CopyObj(ApiSchema.__Account__); var TransParsers = { Mastodon: { Account(Data) { //return JsonTransformA(Data, TransSchemas.Mastodon.Author, TransSchemas.Mastodon); - return JsonTransformB(Data, ApiSchema, ApiSchema.Author, 'Mastodon'); + return JsonTransformB(Data, ApiSchema, ApiSchema.Profile, 'Mastodon'); }, /* Instance(Data) { diff --git a/Source/Friendiiverse.html b/Source/Friendiiverse.html index 7c1dc3a..4b7c4fd 100644 --- a/Source/Friendiiverse.html +++ b/Source/Friendiiverse.html @@ -34,7 +34,8 @@ var UseFakeApi = true; -->
- Source Code + ↩ī¸ Back + 📜ī¸ Source Code
diff --git a/Source/Main.js b/Source/Main.js index ad7328a..0a05f68 100644 --- a/Source/Main.js +++ b/Source/Main.js @@ -1,8 +1,9 @@ -var CurrTasks = {}; +var Tasker = {}; +var ApiCache = {Notes: {}, Profiles: {},}; function DoAsync(First, Then, Data) { var Job = RndId(); - CurrTasks[Job] = { + Tasker[Job] = { Remains: 0, Return(Data) { this.Remains -= 1; @@ -13,20 +14,20 @@ function DoAsync(First, Then, Data) { ForceList(First).forEach(function(Fun, Data){ var Task = RndId(); var Proc = [Job, Task]; - CurrTasks[Job][Task] = {}; - CurrTasks[Job].Remains += 1; + Tasker[Job][Task] = {}; + Tasker[Job].Remains += 1; //Fun(Proc, Data); Data ? Fun(Data, Proc) : Fun(Proc); }); // Continuosly check when First functs completed - CurrTasks[Job].Interval = setInterval(function(Job, Then){ - if (CurrTasks[Job].Remains <= 0) { - clearInterval(CurrTasks[Job].Interval); + Tasker[Job].Interval = setInterval(function(Job, Then){ + if (Tasker[Job].Remains <= 0) { + clearInterval(Tasker[Job].Interval); // Call all Then functs ForceList(Then).forEach(function(Fun){ - Fun(CurrTasks[Job].Result); + Fun(Tasker[Job].Result); }); - delete CurrTasks[Job]; + delete Tasker[Job]; }; }, 50, Job, Then); return Job; @@ -107,19 +108,20 @@ function MakeWindow(Attrs) { return Window; }; -function DisplayChannel(Channel) { - var Window = MakeWindow({className: "Channel"}); +function DisplayProfile(Profile) { + var Window = MakeWindow({className: "Profile"}); Window.innerHTML += `
- +
- +
- - ${Channel.Name} + + ${Profile.Name}
`; + DoAsync(FetchMastodon, FillTimeline); }; function FetchMastodon(Proc) { @@ -132,15 +134,15 @@ function FetchMastodon(Proc) { function ResFetchMastodon(Res) { var Notes = TransParsers.Mastodon.Status(Res.responseJson); LogDebug(Notes, 'l'); - CurrTasks[Res.Proc[0]].Return(Notes); + Tasker[Res.Proc[0]].Return(Notes); }; function FillTimeline(Notes) { Notes.forEach(function(Note){ - TimelineView.innerHTML += `
- - - ${Note.Author.Name} + Root.lastChild.innerHTML += `
+ + + ${Note.Profile.Name} ${Note.Content} ${Note.Time} @@ -150,7 +152,13 @@ function FillTimeline(Notes) { function FetchFeatured(Proc) { //if (UseFakeApi) { - CurrTasks[Proc[0]].Return(FakeApi.Friendiiverse.Featured); + var Featured = FakeApi.Friendiiverse.Featured; + Object.values(Featured).forEach(function(Profiles){ + Profiles.forEach(function(Profile){ + ApiCache.Profiles[Profile.Url] = Profile; + }); + }); + Tasker[Proc[0]].Return(Featured); //} else { //}; @@ -158,16 +166,16 @@ function FetchFeatured(Proc) { function FillFeatured(Categories) { var Window = MakeWindow({className: "Gallery"}); - Object.values(Categories).forEach(function(Channels){ - Channels.forEach(function(Channel){ - Window.innerHTML += `
- + Object.values(Categories).forEach(function(Profiles){ + Profiles.forEach(function(Profile){ + Window.innerHTML += `
+
- +
- - ${Channel.Name} + + ${Profile.Name}
`; diff --git a/Source/Style.css b/Source/Style.css index 577435f..cd670a8 100644 --- a/Source/Style.css +++ b/Source/Style.css @@ -1,3 +1,17 @@ +:root { + --BarHeight: 3em; +} + +* { + box-sizing: border-box; +} + +body { + margin: 0; + padding: 0; + overflow-y: hidden; +} + img, video { max-width: 100%; } @@ -9,11 +23,13 @@ img, video { #Bottom { display: block; width: 100%; + height: var(--BarHeight); + position: fixed; bottom: 0; left: 0; + border: 2px solid black; - margin-top: 4em; } #DataView { @@ -23,13 +39,14 @@ img, video { .Window { background: white; position: absolute; - + width: 100%; max-width: 100%; min-width: 100%; - - min-height: calc(100% - 4em); - padding-bottom: 2em; + + height: 100vh; + overflow-y: auto; + padding-bottom: var(--BarHeight); } .View.Note { @@ -37,7 +54,7 @@ img, video { margin: 12px; } -.View.Note .Author.Icon { +.View.Note .Profile.Icon { width: 64px; }