From 61adbb4c79fce39d287cd6833ac7bed03c0eb151 Mon Sep 17 00:00:00 2001 From: octospacc Date: Tue, 25 Apr 2023 23:35:34 +0200 Subject: [PATCH] Some i --- App/ApiStatic.js | 14 +++++++++++- App/Elems.js | 23 ++++++++++++++++++++ App/Friendiiverse.html | 1 + App/Main.js | 49 ++++++++++++++++++++++-------------------- App/Utils.js | 3 +++ 5 files changed, 66 insertions(+), 24 deletions(-) diff --git a/App/ApiStatic.js b/App/ApiStatic.js index 8d1c8b6..fe88792 100644 --- a/App/ApiStatic.js +++ b/App/ApiStatic.js @@ -1 +1,13 @@ - +var ApiStatic = {Servers: {}, Featured: {},}; +["https://mastodon.uno", "https://mastodon.social",].forEach(function(Serv){ + ApiStatic.Servers[Serv] = {Software: "Mastodon"}; +}); +["https://misskey.social",].forEach(function(Serv){ + ApiStatic.Servers[Serv] = {Software: "Misskey"}; +}); +ApiStatic.Featured.Servers = []; +Object.keys(ApiStatic.Servers).forEach(function(Serv){ + ApiStatic.Featured.Servers.push({ + Url: `${Serv}`, + }); +}); diff --git a/App/Elems.js b/App/Elems.js index 2775778..f38b810 100644 --- a/App/Elems.js +++ b/App/Elems.js @@ -1,3 +1,9 @@ +var ElsCfg = { + ListMenu: { + FullControl: {Append: true, Remove: true,}, + }, +}; + function MkHtmlEl(Tag, Attrs) { var El = document.createElement(Tag); if (Attrs) { @@ -5,6 +11,7 @@ function MkHtmlEl(Tag, Attrs) { El[Attr] = Attrs[Attr]; }); }; + El.className += ` ${RndHtmlId(Tag)}`; return El; }; @@ -32,3 +39,19 @@ function MkSelectMenu(Opts, Attrs) { Menu.className += ' SelectMenu'; return Menu; }; + +function MkListMenu(Opts, Conf, Attrs) { + var Menu = MkHtmlEl('div', Attrs); + var OptsHtml = ''; + Object.keys(Opts).forEach(function(Opt){ + OptsHtml += `
  • `; + }); + Menu.innerHTML = ` + + `; + Menu.className += ' ListMenu'; + return Menu; +}; diff --git a/App/Friendiiverse.html b/App/Friendiiverse.html index a068e5f..10824b1 100644 --- a/App/Friendiiverse.html +++ b/App/Friendiiverse.html @@ -48,6 +48,7 @@ var Assets = { + diff --git a/App/Main.js b/App/Main.js index 0fba337..f6e6842 100644 --- a/App/Main.js +++ b/App/Main.js @@ -65,6 +65,16 @@ function DoAsync(First, Then, Data) { return Job; }; +function HtmlAssign(Id, Data) { + Array.from(document.getElementsByClassName(`${Id}`)).forEach(function(El){ + var Toks = El.dataset.assign.split(' '); + var Prop = Toks.slice(1).join(' '); + if (Data[Prop] !== undefined) { + El[Toks[0]] = Data[Prop]; + }; + }); +}; + function DisplayProfile(Profile) { var Window = MkWindow({className: "Profile"}); Window.innerHTML += `
    @@ -133,35 +143,28 @@ function FillTimeline(Notes) { }); }; -function FetchFeatured(Proc) { - //if (UseFakeApi) { - var Featured = FakeApi.Friendiiverse.Featured; - Object.values(Featured).forEach(function(Profiles){ - Profiles.forEach(function(Profile){ - ApiCache.Urls[Profile.Url] = Profile; - }); - }); - Tasker[Proc[0]].Return(Featured); - //} else { - - //}; -}; - -function FillFeatured(Categories) { +function FillHome() { var Window = MkWindow({className: "Gallery"}); - Object.values(Categories).forEach(function(Profiles){ - Profiles.forEach(function(Profile){ + var Categories = ApiStatic.Featured; + Object.keys(Categories).forEach(function(Category){ + Window.innerHTML += `

    Featured ${Category}

    `; + Categories[Category].forEach(function(Profile){ + ApiCache.Urls[Profile.Url] = Profile; + var Rnd = RndHtmlId(); Window.innerHTML += `
    - +
    - - ${Profile.Name} + + ${Profile.Url}
    `; + NetApiCall({Target: Profile.Url, Method: "GET instance", CallFine: function(Res){ + HtmlAssign(Rnd, Res.responseJson); + }}); }); }); }; @@ -213,9 +216,9 @@ function ManageSettings() {

    Identities

    - ... + ${MkListMenu(Present.Identities, ElsCfg.ListMenu.FullControl).outerHTML}

    Sources

    - ... + ${MkListMenu(Present.Sources, ElsCfg.ListMenu.FullControl).outerHTML}

    Data

    @@ -227,5 +230,5 @@ function ManageSettings() { `; }; -DoAsync(FetchFeatured, FillFeatured); +FillHome(); CoverView.remove(); diff --git a/App/Utils.js b/App/Utils.js index 4ac2f1d..2dc5f7c 100644 --- a/App/Utils.js +++ b/App/Utils.js @@ -5,6 +5,9 @@ function ForceList(Item) { function RndId() { return `${Date.now()}${Math.random() + Math.random()}`; }; +function RndHtmlId(Tag) { + return `Rnd-${Tag}-${RndId().replace('.', '-')}`; +}; function UrlBase(Url) { var Lower = Url.toLowerCase();