-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GET functionality, misc. adjustments (#12)
* Add GET message functionality * Convert webhook handlers to extended classes to reduce redundancy * Check for JavaScript, add noscript warning * Update styling, including styling form sections as cards * Fix paths (because deployed site doesn't use root URL) * Stylelint tuning
- Loading branch information
1 parent
cff083b
commit 2d15264
Showing
9 changed files
with
415 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
import * as Send from "/modules/send.js"; | ||
import * as ConditionalInput from "/modules/conditional-input.js"; | ||
import * as JsCheck from "./modules/js-check.js"; | ||
import { SendHandler } from "./modules/send-handler.js"; | ||
import * as ConditionalInput from "./modules/conditional-input.js"; | ||
import { GetHandler } from "./modules/get-handler.js"; | ||
|
||
const form = document.querySelector("form"); | ||
const output = document.querySelector("output"); | ||
JsCheck.setJsAvailable(); | ||
|
||
Send.initialize(form, output); | ||
ConditionalInput.initialize(form); | ||
// set up send form | ||
const sendForm = document.getElementById("form-send"); | ||
const sendOutput = document.getElementById("output-send"); | ||
const sendHandler = new SendHandler(sendForm, sendOutput); | ||
|
||
sendHandler.register(); | ||
ConditionalInput.initialize(sendForm); | ||
|
||
// set up get form | ||
const getForm = document.getElementById("form-get"); | ||
const getOutput = document.getElementById("output-get"); | ||
const getHandler = new GetHandler(getForm, getOutput); | ||
|
||
getHandler.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { WebhookHandler } from "./webhook-handler.js"; | ||
|
||
class GetHandler extends WebhookHandler { | ||
constructor(form, output) { | ||
super(form, output); | ||
|
||
this.method = "GET"; | ||
} | ||
|
||
constructUrl(elements) { | ||
let baseUrl = elements.action.value.trim(); | ||
let threadId = elements.thread_id.value.trim(); | ||
let messageId = elements.message_id.value.trim(); | ||
|
||
let composite = `${baseUrl}/messages/${messageId}`; | ||
|
||
if (threadId) { | ||
composite = `${composite}?thread_id=${threadId}`; | ||
} | ||
|
||
return composite; | ||
} | ||
|
||
constructFetchInit(elements) { | ||
return { | ||
method: this.method, | ||
}; | ||
} | ||
|
||
displayResponse(response) { | ||
response.text().then((text) => { | ||
this.output.append(text); | ||
}); | ||
} | ||
} | ||
|
||
export { GetHandler }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function setJsAvailable() { | ||
document.body.dataset.jsAvailable = true; | ||
} |
Oops, something went wrong.