-
Notifications
You must be signed in to change notification settings - Fork 0
Bootstrapper quickstart
waterswat edited this page Mar 13, 2022
·
4 revisions
This documentation assumes your TOMP directory is on the root of your webserver in a folder named "TOMP".
- Include the bootstrapper script
IMPORTANT: Make sure the bootstrapper loads before other scripts.
Place this in your head or body tag:
<script src='/tomp/bootstrapper.js'></script>
- Create a form.
This HTML snippet will take form submissions
<form class='tomp-form'>
<input type='text' class='tomp-input' placeholder='Search or enter web address' />
<input type='submit' />
</form>
- Handle form submissions.
const form = document.querySelector('.tomp-form');
const input = document.querySelector('.tomp-input');
form.addEventListener('submit', tompSubmit);
- Create a TOMP bootstrapper and a search builder. Define the submission handler.
const boot = new TOMPBoot({
bare: '/bare/',
directory: '/tomp/',
});
const search = new TOMPBoot.SearchBuilder('https://searx.ru/search?q=%s');
async function tompSubmit(event){
event.preventDefault();
await boot.ready;
const newAddress = boot.html(search.query(input.value));
location.assign(newAddress);
}