Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML
- <form method="get" id="searchBarForm" autocomplete="off" >
- <div id="textoBusqueda"> <input onkeydown="fAction(event)" id="searchBar" type="text" name="q" placeholder="honestly, it really do be like that . . ." required autofocus="autofocus" onfocus="this.select()" >
- <hr id="line">
- </form>
- JS
- function fAction(event) {
- var x = event.key;
- if (x == "Enter") {
- event.preventDefault()
- let text = document.getElementById("searchBar").value;
- let pre= text.substring(0, 3);
- let next= text.substring(3);
- if (pre == "red" || pre == "4ch") {
- switch (next) {
- case ("red"):
- switch (siguiente) {
- case ("d2"):
- url = "https://www.reddit.com/r/dota2/"
- break;
- .
- .
- .
- default:
- url = "https://www.reddit.com/";
- break;
- }
- break;
- case ("4ch"):
- switch (next) {
- case ("wg"):
- url = "https://boards.4chan.org/wg/";
- break;
- .
- .
- .
- default:
- url = "https://boards.4chan.org";
- break;
- }
- }
- } else {
- switch (text) {
- case ("yt"):
- url = "https://www.youtube.com/";
- break;
- .
- .
- .
- default:
- url = 'https://duckduckgo.com/?q=' + text;
- break;
- }
- }
- window.open(url, '_self');
- }
- }
Add Comment
Please, Sign In to add comment