mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
script js pour recherche par moteur externe
This commit is contained in:
parent
530b8b7553
commit
c20b6a1b4d
10 changed files with 78 additions and 9 deletions
16
templates/js/main_script.js
Normal file
16
templates/js/main_script.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
// search bar to send a request to a search engine for the current domain when sent
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Obtient le nom de domaine de la page courante
|
||||
const currentDomain = window.location.hostname;
|
||||
const form = document.getElementById('recherche');
|
||||
|
||||
// Ajoute un écouteur d'événement pour l'événement 'submit'
|
||||
form.addEventListener('submit', function(event) {
|
||||
// Empêche le comportement par défaut du formulaire
|
||||
event.preventDefault()
|
||||
const query = document.getElementById('query').value
|
||||
const url = `https://duckduckgo.com/?q=${encodeURIComponent(query)}+site%3A${encodeURIComponent(currentDomain)}`;
|
||||
|
||||
window.location.href = url;
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue