2023-04-18 16:10:26 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8"/>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
|
|
<title></title>
|
|
|
|
<style>
|
|
|
|
img, video { max-width: 100%; }
|
2023-04-18 16:12:12 +02:00
|
|
|
#DataView { white-space: break-spaces; }
|
|
|
|
.PostView { border: 4px solid purple; margin: 12px; }
|
2023-04-18 16:10:26 +02:00
|
|
|
</style>
|
2023-04-18 16:12:12 +02:00
|
|
|
<script>
|
|
|
|
// Credentials hardcoding for now
|
|
|
|
var MastodonUrl = 'https://mastodon.uno';
|
|
|
|
var FriendicaUrl = 'https://poliverso.org';
|
|
|
|
var FriendicaCredentials = 'redacted:redacted';
|
|
|
|
|
|
|
|
// Development
|
|
|
|
var Debug = true;
|
|
|
|
var UseFakeApi = true;
|
|
|
|
</script>
|
2023-04-18 16:10:26 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
2023-04-18 16:12:12 +02:00
|
|
|
<div id=CoverView>
|
|
|
|
LOGO
|
|
|
|
Loading...
|
|
|
|
</div>
|
|
|
|
<div id=NoscriptView>
|
|
|
|
No Script!
|
|
|
|
</div>
|
|
|
|
<div id=PlazasView></div>
|
|
|
|
<div id=TimelineView></div>
|
|
|
|
<xmp id=DataView></xmp>
|
2023-04-18 16:10:26 +02:00
|
|
|
<script>
|
2023-04-18 16:12:12 +02:00
|
|
|
NoscriptView.remove();
|
|
|
|
|
|
|
|
var FakeApi = {};
|
|
|
|
FakeApi.F = {};
|
|
|
|
FakeApi.My = {};
|
|
|
|
|
|
|
|
function LogDebug(Data, Status) {
|
|
|
|
if (Debug) {
|
|
|
|
for (var i=0; i<Data.length; i++) {
|
|
|
|
try {
|
|
|
|
Data[i] = JSON.parse(Data[i]);
|
|
|
|
} catch(_){};
|
|
|
|
};
|
|
|
|
console[{l: "log", e: "error"}[Status]](Data);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
function ApiCall(Data) {
|
|
|
|
// Data = {Target: "Friendica", Method: "...", Data: {}, Call: (), CallFine: (), CallFail: ()}
|
|
|
|
var Req = new XMLHttpRequest();
|
|
|
|
Req.onreadystatechange = function(){
|
|
|
|
if (this.readyState == 4) {
|
|
|
|
var Status = String(this.status);
|
|
|
|
if (Data.Call) Data.Call(this);
|
|
|
|
if (Status.startsWith(4) || Status.startsWith(5)) {
|
|
|
|
if (Data.CallFail) Data.CallFail(this);
|
|
|
|
LogDebug([Status, this.responseText], 'e');
|
|
|
|
} else {
|
|
|
|
if (Data.CallFine) Data.CallFine(this);
|
|
|
|
LogDebug([Status, this.responseText], 'l');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (Data.Target == 'Mastodon') {
|
|
|
|
Req.open('GET', `${MastodonUrl}/api/v1/${Data.Method}`, true);
|
|
|
|
};
|
|
|
|
if (Data.Target == 'Friendica') {
|
|
|
|
Req.open('GET', `${FriendicaUrl}/api/${Data.Method}.json`, true);
|
|
|
|
Req.setRequestHeader('Authorization', `Basic ${btoa(FriendicaCredentials)}`);
|
|
|
|
};
|
|
|
|
Req.send();
|
|
|
|
};
|
|
|
|
|
|
|
|
function MastodonParse(Data, Type) {
|
|
|
|
{
|
|
|
|
Status: function(Data){
|
|
|
|
|
|
|
|
},
|
|
|
|
}[Type](Data);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
function DisplayMastodonTimeline(Timeline) {
|
|
|
|
ApiCall({Target: "Mastodon", Method: Timeline, CallFine: function(Res){
|
|
|
|
DataView.innerHTML = Res.responseText;
|
|
|
|
JSON.parse(DataView.innerHTML).forEach(function(Item){
|
|
|
|
TimelineView.innerHTML += `<div class=PostView>
|
|
|
|
<a href="${Item.external_url}">${Item.created_at}</a>
|
|
|
|
${Item.friendica_author.url}
|
|
|
|
${Item.friendica_html}
|
|
|
|
</div>`;
|
|
|
|
});
|
|
|
|
}});
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
function DisplayFriendicaTimeline(Timeline) {
|
|
|
|
ApiCall({Target: "Friendica", Method: Timeline, CallFine: function(Res){
|
|
|
|
DataView.innerHTML = Res.responseText;
|
|
|
|
JSON.parse(DataView.innerHTML).forEach(function(Item){
|
2023-04-18 16:10:26 +02:00
|
|
|
var Title = Item.friendica_title ? `<h2>${Item.friendica_title}</h2>` : '';
|
2023-04-18 16:12:12 +02:00
|
|
|
TimelineView.innerHTML += `<div class=PostView>
|
2023-04-18 16:10:26 +02:00
|
|
|
<a href="${Item.external_url}">${Item.created_at}</a>
|
|
|
|
${Item.friendica_author.url}
|
|
|
|
${Title}
|
|
|
|
${Item.friendica_html}
|
|
|
|
</div>`;
|
|
|
|
});
|
2023-04-18 16:12:12 +02:00
|
|
|
}});
|
2023-04-18 16:10:26 +02:00
|
|
|
};
|
2023-04-18 16:12:12 +02:00
|
|
|
|
|
|
|
PlazasView.innerHTML = `
|
|
|
|
<div>
|
|
|
|
<h3>Featured</h3>
|
|
|
|
<ul>
|
|
|
|
<li onclick="DisplayFriendicaTimeline('statuses/networkpublic_timeline');">Federation</li>
|
|
|
|
<li onclick="DisplayFriendicaTimeline('statuses/public_timeline');">${FriendicaUrl}</li>
|
|
|
|
<li onclick="DisplayMastodonTimeline('timelines/public');">${MastodonUrl}</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h3>Categories</h3>
|
|
|
|
<ul>
|
|
|
|
<li>Testing</li>
|
|
|
|
<li>#fediverse</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
`;
|
2023-04-18 16:10:26 +02:00
|
|
|
</script>
|
2023-04-18 16:12:12 +02:00
|
|
|
<script src="https://cdn.jsdelivr.net/npm/eruda" onload="eruda.init();" defer async></script>
|
2023-04-18 16:10:26 +02:00
|
|
|
</body>
|
|
|
|
</html>
|