Skip to content

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".

  1. 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>
  1. 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>
  1. Handle form submissions.
const form = document.querySelector('.tomp-form');
const input = document.querySelector('.tomp-input');

form.addEventListener('submit', tompSubmit);
  1. 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);
}
Clone this wiki locally