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: {},}; 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"}; 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.Servers[Serv] = {ServerSoftware: "Misskey"};
}); });
ApiStatic.Featured.Servers = []; ApiStatic.Featured.Servers = [];
Object.keys(ApiStatic.Servers).forEach(function(Url){ Object.keys(ApiStatic.Servers).forEach(function(Url){
var Serv = ApiStatic.Servers[Url]; var Serv = ApiStatic.Servers[Url];

View File

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

View File

@ -54,6 +54,7 @@ var Assets = {
<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>
<script src="./Templating.js"></script>
<script src="./Main.js"></script> <script src="./Main.js"></script>
<script>(function(){ <script>(function(){
if (Debug && new URLSearchParams(window.location.hash).get('#Eruda')) { 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) { function JsonTransformCycleB(TreeOld, SchemaNew, NodeNew, TypeOld) {
var TreeNew = CopyObj(NodeNew); var TreeNew = structuredClone(NodeNew);
if (SchemaNew.__All__) { if (SchemaNew.__All__) {
//TreeNew.__All__ = CopyObj(SchemaNew.__All__); //TreeNew.__All__ = structuredClone(SchemaNew.__All__);
//console.log(1, '__All__') //console.log(1, '__All__')
//_.forOwn(TreeNew, function(KeyNewVal, KeyNew){ //_.forOwn(TreeNew, function(KeyNewVal, KeyNew){
// console.log(1, KeyNew) // console.log(1, KeyNew)
//}); //});
_.forOwn(SchemaNew.__All__, function(Val, Key){ _.forOwn(SchemaNew.__All__, function(Val, Key){
//console.log(1, Key) //console.log(1, Key)
TreeNew[Key] = CopyObj(Val); TreeNew[Key] = structuredClone(Val);
}); });
}; };
_.forOwn(TreeNew, function(KeyNewVal, KeyNew){ _.forOwn(TreeNew, function(KeyNewVal, KeyNew){

View File

@ -1,5 +1,5 @@
var Persist = {Servers: {}, Sources: {}, Identities: {},}; var Persist = {Servers: {}, Sources: {}, Identities: {},};
var Present = CopyObj(Persist); var Present = structuredClone(Persist);
var Tasker = {}; var Tasker = {};
var ApiCache = { var ApiCache = {
__Store__(Data, Key, Where) { __Store__(Data, Key, Where) {
@ -152,21 +152,11 @@ function ResFetchMastodon(Res) {
function FillTimeline(Notes) { function FillTimeline(Notes) {
Notes.forEach(function(Note){ Notes.forEach(function(Note){
ApiCache.__UrlStore__(Note.Profile); ApiCache.__UrlStore__(Note.Profile);
if (Note.Quoting) { Root.lastChild.innerHTML += Templating.ViewNote(Note);
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>`;
}); });
}; };
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) { function UrlBase(Url) {
var Lower = Url.toLowerCase(); var Lower = Url.toLowerCase();
var Domain = UrlDomain(Url); var Domain = UrlDomain(Url);
if (Lower.startsWith('http://')) return `http://${Domain}`; if (Lower.startsWith('https://')) {
else return `https://${Domain}`;
if (Lower.startsWith('https://')) return `https://${Domain}`; } else {
else return `http://${Domain}`;
return `//${Domain}`; };
}; };
function UrlDomain(Url) { 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) { function FuncName(Fun) {
@ -59,12 +64,8 @@ function IsObj(Item) {
return typeof(Item) === 'object'; return typeof(Item) === 'object';
}; };
function CopyObj(Obj) {
return JSON.parse(JSON.stringify(Obj));
};
function ExtrimObj(Obj) { function ExtrimObj(Obj) {
Obj = CopyObj(Obj); Obj = structuredClone(Obj);
Object.keys(Obj).forEach(function(Key){ Object.keys(Obj).forEach(function(Key){
Obj[Key] = undefined; Obj[Key] = undefined;
}); });