This commit is contained in:
octospacc 2023-04-29 00:06:16 +02:00
parent d8f35afa53
commit 8dedcc9c50
7 changed files with 49 additions and 32 deletions

View File

@ -1,10 +1,19 @@
var ApiStatic = {Servers: {}, Featured: {},};
["https://mastodon.uno", "https://mastodon.social",].forEach(function(Serv){
[ "https://mastodon.uno",
"https://livellosegreto.it",
"https://sociale.network",
"https://mastodon.social",
].forEach(function(Serv){
ApiStatic.Servers[Serv] = {ServerSoftware: "Mastodon"};
});
["https://misskey.social",].forEach(function(Serv){
[ "https://misskey.social",
"https://misskey.io"
].forEach(function(Serv){
ApiStatic.Servers[Serv] = {ServerSoftware: "Misskey"};
});
ApiStatic.Featured.Servers = [];
Object.keys(ApiStatic.Servers).forEach(function(Url){
var Serv = ApiStatic.Servers[Url];

View File

@ -49,7 +49,7 @@ var ApiSchema = {
Misskey: "createdAt",
},
Url: {
Mastodon: "url",
__All__: {__OldOr__: ["url", "uri"]},
},
},
Profile: {
@ -81,8 +81,8 @@ var ApiSchema = {
`},
},
Url: {
__All__: {__OldOr__: ["url", "uri"]},
Mastodon: "url",
Misskey: "uri",
},
},
};
@ -93,7 +93,10 @@ var ApiEndpoints = {
return `GET api/v1/accounts/${Profile.Id}/statuses`;
},
Misskey(Profile) {
return ``;
return {
Method: "POST api/users/show",
Data: {"username": Profile.Id},
};
},
},
ServerInfo: {

View File

@ -54,6 +54,7 @@ var Assets = {
<script src="./ApiFake.js"></script>
<script src="./Net.js"></script>
<script src="./Elems.js"></script>
<script src="./Templating.js"></script>
<script src="./Main.js"></script>
<script>(function(){
if (Debug && new URLSearchParams(window.location.hash).get('#Eruda')) {

View File

@ -64,16 +64,16 @@ function JsonTransformB(TreesOld, SchemaNew, NodeNew, TypeOld) {
};
function JsonTransformCycleB(TreeOld, SchemaNew, NodeNew, TypeOld) {
var TreeNew = CopyObj(NodeNew);
var TreeNew = structuredClone(NodeNew);
if (SchemaNew.__All__) {
//TreeNew.__All__ = CopyObj(SchemaNew.__All__);
//TreeNew.__All__ = structuredClone(SchemaNew.__All__);
//console.log(1, '__All__')
//_.forOwn(TreeNew, function(KeyNewVal, KeyNew){
// console.log(1, KeyNew)
//});
_.forOwn(SchemaNew.__All__, function(Val, Key){
//console.log(1, Key)
TreeNew[Key] = CopyObj(Val);
TreeNew[Key] = structuredClone(Val);
});
};
_.forOwn(TreeNew, function(KeyNewVal, KeyNew){

View File

@ -1,5 +1,5 @@
var Persist = {Servers: {}, Sources: {}, Identities: {},};
var Present = CopyObj(Persist);
var Present = structuredClone(Persist);
var Tasker = {};
var ApiCache = {
__Store__(Data, Key, Where) {
@ -152,21 +152,11 @@ function ResFetchMastodon(Res) {
function FillTimeline(Notes) {
Notes.forEach(function(Note){
ApiCache.__UrlStore__(Note.Profile);
if (Note.Quoting) {
Note = Note.Quoting;
};
Root.lastChild.innerHTML += `<div class="View Note">
<a href="${Note.Profile.Url}" onclick="DisplayProfile('${Note.Profile.Url}'); return false;">
<img class="Profile Icon" src="${Note.Profile.Icon}"/>
${Note.Profile.Name}
</a>
${SanitizeHtml(Note.Content)}
<a href="${Note.Url}">${Note.Time}</a>
</div>`;
Root.lastChild.innerHTML += Templating.ViewNote(Note);
});
};
function DisplayThread() {
function DisplayThread(Note) {
};

13
App/Templating.js Normal file
View File

@ -0,0 +1,13 @@
var Templating = {
ViewNote(Note) {
return `<div class="View Note">
<a href="${Note.Profile.Url}" onclick="DisplayProfile('${Note.Profile.Url}'); return false;">
<img class="Profile Icon" src="${Note.Profile.Icon}"/>
${Note.Profile.Name}
</a>
${Note.Content ? Note.Content : 'renoted:'}
${Note.Quoting ? Templating.ViewNote(Note.Quoting) : ''}
<a href="${Note.Url}" onclick="DisplayThread('${Note.Url}'); return false;">${Note.Time}</a>
</div>`;
},
};

View File

@ -12,14 +12,19 @@ function RndHtmlId(Tag) {
function UrlBase(Url) {
var Lower = Url.toLowerCase();
var Domain = UrlDomain(Url);
if (Lower.startsWith('http://')) return `http://${Domain}`;
else
if (Lower.startsWith('https://')) return `https://${Domain}`;
else
return `//${Domain}`;
if (Lower.startsWith('https://')) {
return `https://${Domain}`;
} else {
return `http://${Domain}`;
};
};
function UrlDomain(Url) {
return Url.split('//')[1].split('/')[0];
if (_.some(['//', 'http://', 'https://'], function(Sub){ return Url.toLowerCase().startsWith(Sub); })) {
return Url.split('//')[1].split('/')[0];
} else {
return Url.split('/')[0];
};
};
function FuncName(Fun) {
@ -59,12 +64,8 @@ function IsObj(Item) {
return typeof(Item) === 'object';
};
function CopyObj(Obj) {
return JSON.parse(JSON.stringify(Obj));
};
function ExtrimObj(Obj) {
Obj = CopyObj(Obj);
Obj = structuredClone(Obj);
Object.keys(Obj).forEach(function(Key){
Obj[Key] = undefined;
});