start suggestions page
This commit is contained in:
parent
6fbc2b7e9a
commit
2f29378f99
|
@ -1,4 +1,6 @@
|
||||||
<?php require("template/header.html")?>
|
<?php require("template/header.html")?>
|
||||||
You are connected to Mastodon as <b><span class='mastodon_user'></span></b> on server <b><span class="mastodon_server"></span></b>
|
You are connected to Mastodon as <b><span class='mastodon_user'></span></b> on server <b><span class="mastodon_server"></span></b>
|
||||||
|
|
||||||
|
<br><br><a href="suggestions.php">Go to your suggestions</a>
|
||||||
|
|
||||||
<?php $script = 'js/index.js'; require("template/footer.php")?>
|
<?php $script = 'js/index.js'; require("template/footer.php")?>
|
|
@ -49,4 +49,4 @@ export function message_box(type, message) {
|
||||||
message_box.style.display = 'block';
|
message_box.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
export { account, databases, functions, accountDetails };
|
export { client, account, databases, functions, accountDetails };
|
|
@ -0,0 +1,42 @@
|
||||||
|
import {client, databases, accountDetails} from "./setup.js";
|
||||||
|
|
||||||
|
document.querySelectorAll('.mastodon_server').forEach((element) => {
|
||||||
|
element.innerHTML = accountDetails.prefs.user_server_uri
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('.mastodon_user').forEach((element) => {
|
||||||
|
element.innerHTML = JSON.parse(accountDetails.prefs.account_details).acct
|
||||||
|
});
|
||||||
|
|
||||||
|
let suggestions = await databases.listDocuments(APPWRITE_DB_ID, 'suggested', [
|
||||||
|
Appwrite.Query.orderDesc('points')
|
||||||
|
]);
|
||||||
|
|
||||||
|
suggestions = suggestions.documents;
|
||||||
|
|
||||||
|
function display_suggestions(suggestions) {
|
||||||
|
let suggestion_body = '';
|
||||||
|
|
||||||
|
suggestions.forEach(element => {
|
||||||
|
suggestion_body += '<a href="' + element.post_link + '">' + element.post_link + ' - ' + element.points + ' points</a><br>';
|
||||||
|
});
|
||||||
|
|
||||||
|
if(suggestion_body !== '') {
|
||||||
|
document.getElementById('suggestions').innerHTML = suggestion_body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
display_suggestions(suggestions);
|
||||||
|
|
||||||
|
console.log(suggestions);
|
||||||
|
|
||||||
|
client.subscribe('databases.' + APPWRITE_DB_ID + '.collections.suggested.documents', async (response) => {
|
||||||
|
// suggestions.push(response.payload);
|
||||||
|
let suggestions = await databases.listDocuments(APPWRITE_DB_ID, 'suggested', [
|
||||||
|
Appwrite.Query.orderDesc('points')
|
||||||
|
]);
|
||||||
|
|
||||||
|
suggestions = suggestions.documents;
|
||||||
|
|
||||||
|
display_suggestions(suggestions);
|
||||||
|
});
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php require("template/header.html")?>
|
||||||
|
You are connected to Mastodon as <b><span class='mastodon_user'></span></b> on server <b><span class="mastodon_server"></span></b>
|
||||||
|
|
||||||
|
<h4>Your suggestions</h4>
|
||||||
|
<span id="suggestions">You have no suggestions yet</span>
|
||||||
|
|
||||||
|
<?php $script = 'js/suggestions.js'; require("template/footer.php")?>
|
Loading…
Reference in New Issue