Skip to content

Commit

Permalink
Create list.html
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sapletta-com authored Jan 7, 2024
1 parent ae5110a commit 241e84a
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>YAML Requirements Loader</title>
<script src="https://cdn.jsdelivr.net/npm/js-yaml@3/dist/js-yaml.min.js"></script>
</head>
<body>

<h1>Pobieranie i wyświetlanie pola 'requirements' z plików YAML</h1>
<textarea id="yaml-urls" rows="10" cols="50">
https://github.com/apiunit/www/new/master/project.yaml
https://github.com/apiunit/www/new/master/project.yaml

</textarea><br>
<button onclick="loadYAMLFiles()">Pobierz i wyświetl 'requirements'</button>
<div id="requirements-container"></div>

<script>
async function loadYAMLFiles() {
const urlsTextarea = document.getElementById('yaml-urls');
const urls = urlsTextarea.value.trim().split('\n');

const requirementsContainer = document.getElementById('requirements-container');
requirementsContainer.innerHTML = '';

for (const url of urls) {
try {
const response = await fetch(url);
const yamlText = await response.text();
const yamlData = jsyaml.load(yamlText);
const requirements = yamlData.requirements || [];

const requirementsList = document.createElement('ul');
for (const requirement of requirements) {
const listItem = document.createElement('li');
listItem.textContent = requirement;
requirementsList.appendChild(listItem);
}

requirementsContainer.appendChild(requirementsList);
} catch (error) {
console.error(`Błąd podczas ładowania pliku YAML z ${url}:`, error);
const errorMessage = document.createElement('p');
errorMessage.textContent = `Błąd podczas ładowania pliku YAML z ${url}: ${error.message}`;
requirementsContainer.appendChild(errorMessage);
}
}
}
</script>
</body>
</html>

0 comments on commit 241e84a

Please sign in to comment.