Skip to content

Commit

Permalink
Split test buttons into separate divs
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere committed Jul 12, 2024
1 parent b917ece commit 67e1fea
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Fluff4me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ export default class Fluff4me {
return button;
};


const oauthDiv = document.createElement("div");
document.body.append(oauthDiv);

const OAuthServices = await fetch(`${Env.API_ORIGIN}auth/services`, {})
.then(response => response.json());

for (const service of Object.values(OAuthServices.data) as any[]) {
const oauthButton = document.createElement("button");
oauthButton.textContent = `OAuth ${service.name}`;
document.body.append(oauthButton);
oauthDiv.append(oauthButton);
oauthButton.addEventListener("click", async () => {
await popup(service.url_begin, 600, 900)
.then(() => true).catch(err => { console.warn(err); return false; });
Expand All @@ -88,7 +89,7 @@ export default class Fluff4me {

const unoauthbutton = document.createElement("button");
unoauthbutton.textContent = `UnOAuth ${service.name}`;
document.body.append(unoauthbutton);
oauthDiv.append(unoauthbutton);
unoauthbutton.addEventListener("click", async () => {
const id = Session.getAuthServices()[service.id]?.[0]?.id;
if (id === undefined)
Expand All @@ -106,9 +107,12 @@ export default class Fluff4me {
}

// document.body.append(createButton(BUTTON_REGISTRY.createAuthor, "test author 1", "hi-im-an-author"));
document.body.append(createButton(BUTTON_REGISTRY.clearSession));
oauthDiv.append(createButton(BUTTON_REGISTRY.clearSession));

const profileButtons = document.createElement("div");
document.body.append(profileButtons);

document.body.append(createButton({
profileButtons.append(createButton({
name: "Create Profile 1",
async execute () {
await BUTTON_REGISTRY.createAuthor.execute("prolific author", "somanystories");
Expand All @@ -121,14 +125,14 @@ export default class Fluff4me {
},
}));

document.body.append(createButton({
profileButtons.append(createButton({
name: "View Profile 1",
async execute () {
await BUTTON_REGISTRY.viewAuthor.execute("somanystories");
},
}));

document.body.append(createButton({
profileButtons.append(createButton({
name: "Create Profile 2",
async execute () {
await BUTTON_REGISTRY.createAuthor.execute("single story author", "justonestory");
Expand All @@ -140,14 +144,14 @@ export default class Fluff4me {
},
}));

document.body.append(createButton({
profileButtons.append(createButton({
name: "View Profile 2",
async execute () {
await BUTTON_REGISTRY.viewAuthor.execute("justonestory");
},
}));

document.body.append(createButton({
profileButtons.append(createButton({
name: "Create Profile 3",
async execute () {
await BUTTON_REGISTRY.createAuthor.execute("prolific follower", "ifollowpeople");
Expand All @@ -160,7 +164,7 @@ export default class Fluff4me {
},
}));

document.body.append(createButton({
profileButtons.append(createButton({
name: "View Profile 3",
async execute () {
await BUTTON_REGISTRY.viewAuthor.execute("ifollowpeople");
Expand Down

0 comments on commit 67e1fea

Please sign in to comment.