mirror of
https://codeberg.org/JasterV/rick-and-morty-wiki.git
synced 2026-04-26 18:10:09 +00:00
first commit
This commit is contained in:
commit
2bd3acfc97
8 changed files with 426 additions and 0 deletions
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# RICK & MORTY LIBRARY
|
||||
BIN
assets/fonts/get-schwifty.ttf
Normal file
BIN
assets/fonts/get-schwifty.ttf
Normal file
Binary file not shown.
BIN
assets/img/wp1822750-rick-and-morty-wallpapers.png
Normal file
BIN
assets/img/wp1822750-rick-and-morty-wallpapers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
BIN
assets/img/wp1822796-rick-and-morty-wallpapers.jpg
Normal file
BIN
assets/img/wp1822796-rick-and-morty-wallpapers.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 165 KiB |
34
src/index.html
Normal file
34
src/index.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Rick & Morty</title>
|
||||
|
||||
<link rel="stylesheet" href="styles/reset.css">
|
||||
<link rel="stylesheet" href="styles/style.css">
|
||||
|
||||
<!--SCRIPTS-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
|
||||
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="rick-style">
|
||||
<h1>Rick and Morty Wiki</h1>
|
||||
</header>
|
||||
<aside class="rick-style">
|
||||
<h1>Episodes</h1>
|
||||
<ul class="episodes">
|
||||
</ul>
|
||||
<button id="load-more" class="rick-btn">Load More</button>
|
||||
</aside>
|
||||
<section role="main">
|
||||
|
||||
</section>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
109
src/script.js
Normal file
109
src/script.js
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
var ENDPOINT = "https://rickandmortyapi.com/api/";
|
||||
|
||||
var controller = {
|
||||
next: null,
|
||||
episodes: {},
|
||||
characters: {},
|
||||
locations: {},
|
||||
}
|
||||
|
||||
$(function () {
|
||||
axios.get(ENDPOINT).then(function (result) {
|
||||
var routes = result.data;
|
||||
controller.next = routes.episodes;
|
||||
loadNextPage().then(function () {
|
||||
showEpisode(1);
|
||||
});
|
||||
});
|
||||
/* EVENT LISTENERS */
|
||||
$("#load-more").click(loadNextPage);
|
||||
$(".episodes").on("click", "li", function (e) {
|
||||
var episode = $(e.target).attr("data-episode");
|
||||
var currentEpisode = $('[role="main"]').attr("data-episode");
|
||||
if(episode != currentEpisode)
|
||||
showEpisode(episode);
|
||||
});
|
||||
});
|
||||
|
||||
/* AJAX FUNCTIONS */
|
||||
function getData(url) {
|
||||
return axios.get(url).then(function (result) {
|
||||
return result.data;
|
||||
});
|
||||
}
|
||||
|
||||
function getAll(arr) {
|
||||
return axios.all(
|
||||
arr.map(function (url) {
|
||||
return getData(url);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/* PAGES FUNCTIONS */
|
||||
|
||||
function loadNextPage() {
|
||||
if (controller.next == null) return;
|
||||
return getData(controller.next).then(function (page) {
|
||||
controller.next = page.info.next;
|
||||
page.results.forEach(function (episode) {
|
||||
controller.episodes[episode.id] = episode;
|
||||
$(".episodes").append($('<li data-episode="' + episode.id + '">Episode ' + episode.id + '</li>'))
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/* EPISODES FUNCTIONS */
|
||||
|
||||
function showEpisode(id) {
|
||||
var episode = controller.episodes[id];
|
||||
$('[role="main"]').empty();
|
||||
$('[role="main"]').append(createEpisodeTemplate(episode));
|
||||
$('[role="main"]').attr("data-episode", episode.id);
|
||||
loadEpisodeCharacters(episode.id);
|
||||
}
|
||||
|
||||
function loadEpisodeCharacters(episodeId) {
|
||||
getEpisodeCharacters(episodeId).then(function (characters) {
|
||||
characters.forEach(function (character) {
|
||||
controller.characters[character.id] = character;
|
||||
$(".cards-list").append(createCharacterCard(character));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createEpisodeTemplate(episode) {
|
||||
return $("<h1>" + episode.name + "</h1>" +
|
||||
"<p class=\"subtitle\"> " + episode.air_date + " <strong>" + episode.episode + "</strong></p>" +
|
||||
"<div class=\"cards-list\"></div>");
|
||||
}
|
||||
|
||||
/* CHARACTERS FUNCTIONS */
|
||||
|
||||
function getEpisodeCharacters(episodeId) {
|
||||
var episode = controller.episodes[episodeId];
|
||||
var visiteds = [], urls = [];
|
||||
for(var i = 0; i < episode.characters.length; i++) {
|
||||
var splited = episode.characters[i].split('/');
|
||||
var id = splited[splited.length - 1];
|
||||
if(id in controller.characters)
|
||||
visiteds.push(controller.characters[id]);
|
||||
else
|
||||
urls.push(episode.characters[i]);
|
||||
}
|
||||
return getAll(urls).then(function(characters) {
|
||||
return visiteds.concat(characters);
|
||||
});
|
||||
}
|
||||
|
||||
function createCharacterCard(character) {
|
||||
return $("<div class=\"character-card\"><img src=\"" + character.image +
|
||||
"\"/><h3>" + character.name + "</h3><p>" +
|
||||
character.species + " <strong>| " +
|
||||
character.status + "</strong></p> </div>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
102
src/styles/reset.css
Normal file
102
src/styles/reset.css
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
html5doctor.com Reset Stylesheet
|
||||
v1.6.1
|
||||
Last Updated: 2010-09-17
|
||||
Author: Richard Clark - http://richclarkdesign.com
|
||||
Twitter: @rich_clark
|
||||
*/
|
||||
|
||||
html, body, div, span, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
abbr, address, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, samp,
|
||||
small, sub, sup, var,
|
||||
b, i,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin:0;
|
||||
padding:0;
|
||||
border:0;
|
||||
outline:0;
|
||||
font-size:100%;
|
||||
vertical-align:baseline;
|
||||
background:transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height:1;
|
||||
}
|
||||
|
||||
article,aside,details,figcaption,figure,
|
||||
footer,header,hgroup,menu,nav,section {
|
||||
display:block;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
list-style:none;
|
||||
}
|
||||
|
||||
blockquote, q {
|
||||
quotes:none;
|
||||
}
|
||||
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content:'';
|
||||
content:none;
|
||||
}
|
||||
|
||||
a {
|
||||
margin:0;
|
||||
padding:0;
|
||||
font-size:100%;
|
||||
vertical-align:baseline;
|
||||
background:transparent;
|
||||
}
|
||||
|
||||
/* change colours to suit your needs */
|
||||
ins {
|
||||
background-color:#ff9;
|
||||
color:#000;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
/* change colours to suit your needs */
|
||||
mark {
|
||||
background-color:#ff9;
|
||||
color:#000;
|
||||
font-style:italic;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
del {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
abbr[title], dfn[title] {
|
||||
border-bottom:1px dotted;
|
||||
cursor:help;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse:collapse;
|
||||
border-spacing:0;
|
||||
}
|
||||
|
||||
/* change border colour to suit your needs */
|
||||
hr {
|
||||
display:block;
|
||||
height:1px;
|
||||
border:0;
|
||||
border-top:1px solid #cccccc;
|
||||
margin:1em 0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
input, select {
|
||||
vertical-align:middle;
|
||||
}
|
||||
180
src/styles/style.css
Normal file
180
src/styles/style.css
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Grandstander:wght@300;400;500;600;700;800&display=swap');
|
||||
|
||||
:root {
|
||||
--rick-green: #D2E766;
|
||||
--rick-blue: #12B0C9;
|
||||
--rick-text: #010101;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 4rem;
|
||||
}
|
||||
|
||||
.rick-style {
|
||||
font-family: 'get-schwifty';
|
||||
text-shadow: 0px 0px 20px var(--rick-text);
|
||||
color: var(--rick-blue);
|
||||
-webkit-text-stroke: 2px var(--rick-green); /* width and color */
|
||||
}
|
||||
|
||||
body {
|
||||
display: -ms-grid;
|
||||
display: grid;
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
-ms-grid-columns: 1fr 3.5fr;
|
||||
grid-template-columns: 1fr 3.5fr;
|
||||
-ms-grid-rows: 15vh 85vh;
|
||||
grid-template-rows: 15vh 85vh;
|
||||
grid-template-areas: "header header"
|
||||
"sidebar main";
|
||||
background-image: url("../../assets/img/wp1822796-rick-and-morty-wallpapers.jpg");
|
||||
font-family: 'Grandstander', cursive;
|
||||
}
|
||||
|
||||
header {
|
||||
-ms-grid-row: 1;
|
||||
-ms-grid-column: 1;
|
||||
-ms-grid-column-span: 2;
|
||||
grid-area: header;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* MAIN CONTAINER STYLE */
|
||||
|
||||
[role="main"] {
|
||||
-ms-grid-row: 2;
|
||||
-ms-grid-column: 2;
|
||||
grid-area: main;
|
||||
background-color: white;
|
||||
border-radius: 15px;
|
||||
margin: 1rem 4rem 3rem 0rem;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
[role="main"] h1 {
|
||||
color: var(--rick-blue);
|
||||
margin: 1.5rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.subtitle strong {
|
||||
margin-left: .5rem;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: var(--rick-blue);
|
||||
}
|
||||
|
||||
.cards-list {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 1rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* CHARACTER CARD STYLE */
|
||||
|
||||
.character-card {
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.character-card img {
|
||||
width: 200px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.character-card h3 {
|
||||
color: var(--rick-blue);
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
/* SIDEBAR STYLE */
|
||||
|
||||
aside {
|
||||
-ms-grid-row: 2;
|
||||
-ms-grid-column: 1;
|
||||
min-width: 250px;
|
||||
grid-area: sidebar;
|
||||
text-align: center;
|
||||
padding-top: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.episodes {
|
||||
-webkit-text-stroke: 1px var(--rick-green); /* width and color */
|
||||
font-size: 2.5rem;
|
||||
padding: 0rem 1rem;
|
||||
margin: 0 auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
aside h1 {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.episodes li {
|
||||
padding: .7rem 0rem;
|
||||
}
|
||||
|
||||
.episodes li:hover {
|
||||
cursor: pointer;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.rick-btn {
|
||||
font-family: 'get-schwifty';
|
||||
border-radius: 5px;
|
||||
border: 2px var(--rick-green);
|
||||
border-style: solid;
|
||||
background-color: transparent;
|
||||
padding: .7rem 1rem;
|
||||
font-size: 2rem;
|
||||
text-shadow: 0px 0px 20px var(--rick-text);
|
||||
color: var(--rick-blue);
|
||||
-webkit-text-stroke: 1px var(--rick-green); /* width and color */
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
.rick-btn:hover {
|
||||
cursor: pointer;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'get-schwifty';
|
||||
src: url('../../assets/fonts/get-schwifty.ttf') format('truetype');
|
||||
}
|
||||
|
||||
/* SCROLLBAR STYLE */
|
||||
|
||||
*::-webkit-scrollbar-track
|
||||
{
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar
|
||||
{
|
||||
width: 10px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-thumb
|
||||
{
|
||||
border-radius: 5px;
|
||||
background-color: var(--rick-green);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in a new issue