Skip to content

Commit

Permalink
base data
Browse files Browse the repository at this point in the history
  • Loading branch information
xavi-mat committed Feb 18, 2022
1 parent 11e1a22 commit c5eb230
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.htaccess
index.php
97 changes: 97 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html lang="ca">
<head>
<meta charset="utf-8">
<title>Prova Router</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="js.js"></script>
<style>
.fakeimg {
height: 200px;
background: #aaa;
}
</style>
</head>
<body>

<div class="p-5 bg-primary text-white text-center">
<h1>Proves de router</h1>
<p>Proves de pàgina única amb fetch i server API amb php.</p>
</div>

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<div class="container-fluid">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>

<div class="container mt-5">
<div class="row">
<div class="col-sm-4">
<div class="p-3 bg-dark text-white">
<p>
<input type="text" id="txt" placeholder="Escriu la request">&nbsp;
<button id="reqbtn" class="btn btn-primary" onclick="sendRequest()">Enviar</button>
</p>
<div id="resp" class="lead text-center">RESPONSE</div>
</div>

<h2>About Me</h2>
<h5>Photo of me:</h5>
<div class="fakeimg">Fake Image</div>
<p>Some text about me in culpa qui officia deserunt mollit anim..</p>
<h3 class="mt-4">Some Links</h3>
<p>Lorem ipsum dolor sit ame.</p>
<ul class="nav nav-pills flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<hr class="d-sm-none">
</div>
<div class="col-sm-8">
<h2>TITLE HEADING</h2>
<h5>Title description, Dec 7, 2020</h5>
<div class="fakeimg">Fake Image</div>
<p>Some text..</p>
<p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>

<h2 class="mt-5">TITLE HEADING</h2>
<h5>Title description, Sep 2, 2020</h5>
<div class="fakeimg">Fake Image</div>
<p>Some text..</p>
<p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
</div>
</div>
</div>

<div class="mt-5 p-4 bg-dark text-white text-center">
<p>Footer</p>
</div>

</body>
</html>
26 changes: 26 additions & 0 deletions js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

function sendRequest() {

let req = document.querySelector('#txt').value;
let resp = document.querySelector('#resp');
resp.innerHTML = '<span class="spinner-grow spinner-grow-sm"></span> <span class="spinner-grow spinner-grow-sm"></span> <span class="spinner-grow spinner-grow-sm"></span> ';
resp.innerHTML += '<span class="spinner-grow spinner-grow-sm"></span> <span class="spinner-grow spinner-grow-sm"></span> <span class="spinner-grow spinner-grow-sm"></span>';

if (req) {
req = 'http://localhost/xavi-mat.github.io/' + req;
let reqbtn = document.querySelector('#reqbtn');
reqbtn.disabled = true;
reqbtn.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Enviando...';
fetch(req)
.then((resp)=>resp.json())
.then((data)=>{
resp.innerHTML = data.url;
reqbtn.innerHTML = 'Enviar';
reqbtn.disabled = false;
});

} else {
resp.innerHTML = 'Please enter a URL';
}
}

0 comments on commit c5eb230

Please sign in to comment.