This commit is contained in:
octospacc 2023-04-25 23:35:34 +02:00
parent fd0abd9df1
commit 61adbb4c79
5 changed files with 66 additions and 24 deletions

View File

@ -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}`,
});
});

View File

@ -1,3 +1,9 @@
var ElsCfg = {
ListMenu: {
FullControl: {Append: true, Remove: true,},
},
};
function MkHtmlEl(Tag, Attrs) { function MkHtmlEl(Tag, Attrs) {
var El = document.createElement(Tag); var El = document.createElement(Tag);
if (Attrs) { if (Attrs) {
@ -5,6 +11,7 @@ function MkHtmlEl(Tag, Attrs) {
El[Attr] = Attrs[Attr]; El[Attr] = Attrs[Attr];
}); });
}; };
El.className += ` ${RndHtmlId(Tag)}`;
return El; return El;
}; };
@ -32,3 +39,19 @@ function MkSelectMenu(Opts, Attrs) {
Menu.className += ' SelectMenu'; Menu.className += ' SelectMenu';
return Menu; return Menu;
}; };
function MkListMenu(Opts, Conf, Attrs) {
var Menu = MkHtmlEl('div', Attrs);
var OptsHtml = '';
Object.keys(Opts).forEach(function(Opt){
OptsHtml += `<li><button>${Opt}</button><button>X</button></li>`;
});
Menu.innerHTML = `
<ul>
${Conf.Append ? '<li><button>Add New</button></li>' : ''}
${OptsHtml}
</ul>
`;
Menu.className += ' ListMenu';
return Menu;
};

View File

@ -48,6 +48,7 @@ var Assets = {
<script src="./Utils.js"></script> <script src="./Utils.js"></script>
<script src="./Strings.js"></script> <script src="./Strings.js"></script>
<script src="./ApiTransform.js"></script> <script src="./ApiTransform.js"></script>
<script src="./ApiStatic.js"></script>
<script src="./ApiFake.js"></script> <script src="./ApiFake.js"></script>
<script src="./Net.js"></script> <script src="./Net.js"></script>
<script src="./Elems.js"></script> <script src="./Elems.js"></script>

View File

@ -65,6 +65,16 @@ function DoAsync(First, Then, Data) {
return Job; 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) { function DisplayProfile(Profile) {
var Window = MkWindow({className: "Profile"}); var Window = MkWindow({className: "Profile"});
Window.innerHTML += `<div class="" style="display: inline-block;"> Window.innerHTML += `<div class="" style="display: inline-block;">
@ -133,35 +143,28 @@ function FillTimeline(Notes) {
}); });
}; };
function FetchFeatured(Proc) { function FillHome() {
//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) {
var Window = MkWindow({className: "Gallery"}); var Window = MkWindow({className: "Gallery"});
Object.values(Categories).forEach(function(Profiles){ var Categories = ApiStatic.Featured;
Profiles.forEach(function(Profile){ Object.keys(Categories).forEach(function(Category){
Window.innerHTML += `<h2>Featured ${Category}</h2>`;
Categories[Category].forEach(function(Profile){
ApiCache.Urls[Profile.Url] = Profile;
var Rnd = RndHtmlId();
Window.innerHTML += `<div> Window.innerHTML += `<div>
<a href="${Profile.Url}" onclick="${Profile.__Display__}('${Profile.Url}'); return false;"> <a href="${Profile.Url}" onclick="${Profile.__Display__}('${Profile.Url}'); return false;">
<div> <div>
<img src="${Profile.Banner}"/> <img class="${Rnd}" data-assign="src thumbnail" src="${Profile.Banner}"/>
</div> </div>
<div> <div>
<img src="${Profile.Icon}"/> <img class="${Rnd}" data-assign="src Icon" src="${Profile.Icon}"/>
${Profile.Name} <span class="${Rnd}" data-assign="innerHTML title">${Profile.Url}</span>
</div> </div>
</a> </a>
</div>`; </div>`;
NetApiCall({Target: Profile.Url, Method: "GET instance", CallFine: function(Res){
HtmlAssign(Rnd, Res.responseJson);
}});
}); });
}); });
}; };
@ -213,9 +216,9 @@ function ManageSettings() {
<label>Wait <input type="number"/> seconds after clicking send for a note to be sent</label> <label>Wait <input type="number"/> seconds after clicking send for a note to be sent</label>
</p> </p>
<h3>Identities</h3> <h3>Identities</h3>
... ${MkListMenu(Present.Identities, ElsCfg.ListMenu.FullControl).outerHTML}
<h3>Sources</h3> <h3>Sources</h3>
... ${MkListMenu(Present.Sources, ElsCfg.ListMenu.FullControl).outerHTML}
<h3>Data</h3> <h3>Data</h3>
<p> <p>
<button>Import User Data</button> <button>Import User Data</button>
@ -227,5 +230,5 @@ function ManageSettings() {
`; `;
}; };
DoAsync(FetchFeatured, FillFeatured); FillHome();
CoverView.remove(); CoverView.remove();

View File

@ -5,6 +5,9 @@ function ForceList(Item) {
function RndId() { function RndId() {
return `${Date.now()}${Math.random() + Math.random()}`; return `${Date.now()}${Math.random() + Math.random()}`;
}; };
function RndHtmlId(Tag) {
return `Rnd-${Tag}-${RndId().replace('.', '-')}`;
};
function UrlBase(Url) { function UrlBase(Url) {
var Lower = Url.toLowerCase(); var Lower = Url.toLowerCase();