-
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.
- Loading branch information
Showing
8 changed files
with
198 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
main { | ||
padding: 10em; | ||
} |
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
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 |
---|---|---|
|
@@ -27,8 +27,8 @@ | |
</nav> | ||
</header> | ||
<main> | ||
<h1>Ponte en contacto</h1> | ||
<p>Dirección de contacto <a href="mailto:[email protected]?Subject=Página%20personal%20Alf">[email protected]</a></p> | ||
<h1 id="contacto-section">Ponte en contacto</h1> | ||
<p id="contacto">Dirección de contacto <a href="mailto:[email protected]?Subject=Página%20personal%20Alf">[email protected]</a></p> | ||
<div id="mapa" class="mapa-responsivo"> | ||
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2889.073233734748!2d-5.853527684501019!3d43.35476717913216!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd368d6e7b1b1b1b%3A0x1f577d1f9f3b1d0c!2sEscuela%20de%20Ingenier%C3%ADa%20Inform%C3%A1tica%20de%20Oviedo!5e0!3m2!1ses!2ses!4v1611810471047!5m2!1ses!2ses" | ||
title="EII Oviedo" allowfullscreen="" loading="lazy"></iframe> | ||
|
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html lang="es"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Resultados de Búsqueda</title> | ||
<link rel="stylesheet" href="../css/resultados-styles.css" type="text/css"> | ||
<link rel="stylesheet" href="../css/styles.css" type="text/css"> | ||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> | ||
</head> | ||
<body> | ||
<header> | ||
<nav aria-label="Menú principal"> | ||
<a href="#" class="active" aria-current="page">Inicio</a> | ||
<a href="pages/aficiones.html">Aficiones</a> | ||
<a href="pages/proyectos.html">Proyectos</a> | ||
<a href="pages/contacto.html">Contacto</a> | ||
</nav> | ||
<div class="search-bar"> | ||
<input type="text" id="searchInput" placeholder="Buscar..."> | ||
<button id="searchButton" onclick="performSearch()">Buscar</button> | ||
</div> | ||
</header> | ||
|
||
<main id="searchResultsContainer"> | ||
<h1>Resultados de Búsqueda</h1> | ||
<!-- Results will be dynamically added here --> | ||
</main> | ||
<script> | ||
$(document).ready(function () { | ||
// Retrieve search term from the URL | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const searchTerm = urlParams.get('q')?.toLowerCase(); | ||
|
||
if (searchTerm) { | ||
const pages = [ | ||
'aficiones.html', | ||
'proyectos.html', | ||
'contacto.html', | ||
'../' | ||
]; | ||
|
||
pages.forEach(page => { | ||
$.get(page, function (data) { | ||
const pageContent = $(data); | ||
const matches = []; | ||
|
||
// Find all paragraphs and headings in the page content | ||
pageContent.find("p, h1, h2, h3, h4, h5, h6, figcaption").each(function () { | ||
const content = $(this).text().toLowerCase(); | ||
const distance = levenshteinDistance(searchTerm, content); | ||
|
||
// Show results with exact match or close matches | ||
if (content.includes(searchTerm) || distance <= 1) { | ||
const snippet = $(this).text().substring(0, 100) + "..."; | ||
const elementId = $(this).attr("id") || ""; // Grab the element ID (if available) | ||
matches.push({ | ||
snippet: snippet, | ||
url: `${page}#${elementId}` | ||
}); | ||
} | ||
}); | ||
|
||
// Display matches | ||
if (matches.length > 0) { | ||
$('#searchResultsContainer').append(`<h2>Resultados en ${page}</h2>`); | ||
matches.forEach(match => { | ||
$('#searchResultsContainer').append(` | ||
<p><a href="${match.url}">${match.snippet}</a></p> | ||
`); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
// Levenshtein distance function to find close matches | ||
function levenshteinDistance(a, b) { | ||
const matrix = []; | ||
let i, j; | ||
|
||
for (i = 0; i <= b.length; i++) { | ||
matrix[i] = [i]; | ||
} | ||
for (j = 0; j <= a.length; j++) { | ||
matrix[0][j] = j; | ||
} | ||
for (i = 1; i <= b.length; i++) { | ||
for (j = 1; j <= a.length; j++) { | ||
if (b.charAt(i - 1) === a.charAt(j - 1)) { | ||
matrix[i][j] = matrix[i - 1][j - 1]; | ||
} else { | ||
matrix[i][j] = Math.min( | ||
matrix[i - 1][j - 1] + 1, | ||
matrix[i][j - 1] + 1, | ||
matrix[i - 1][j] + 1 | ||
); | ||
} | ||
} | ||
} | ||
return matrix[b.length][a.length]; | ||
} | ||
</script> | ||
</body> | ||
</html> |