commit
093f258118
3 changed files with 93 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||
body { |
|||
font-family: "-apple-system", "BlinkMacSystemFont", "Helvetica Neue", "Roboto", sans-serif; |
|||
|
|||
/* Zoom page at 300% */ |
|||
zoom: 3; |
|||
-moz-transform: scale(3); |
|||
-moz-transform-origin: 0 0; |
|||
|
|||
/* Homebrew.sh colors */ |
|||
color: #f9d094; |
|||
background: #2e2a24; |
|||
} |
|||
|
|||
ul { |
|||
list-style: none; |
|||
} |
|||
|
|||
h1 { |
|||
text-align: center; |
|||
font-weight: 900; |
|||
} |
|||
|
|||
img { |
|||
height: 128px; |
|||
width: 128px; |
|||
display: block; |
|||
margin-left: auto; |
|||
margin-right: auto; |
|||
} |
|||
|
|||
.flag { |
|||
margin-right: 10px; |
|||
} |
|||
|
|||
.status_out_of_stock { |
|||
text-decoration: line-through; |
|||
} |
|||
|
|||
.rating { |
|||
float: right; |
|||
margin-right: 30px; |
|||
font-size: 50%; |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
var flags = { "Belgium": "🇧🇪", "Germany": "🇩🇪" }; |
|||
var baseURL = "http://beer-catalog.staging.app.itix.fr/rest/Beer%20Catalog%20API/0.9" |
|||
|
|||
function initBeerUI(baseURL, headers) { |
|||
$.ajax({ |
|||
"url": baseURL + "/beer?page=0", |
|||
"success": function (data, status, xhr) { |
|||
try { |
|||
var count = data.length; |
|||
for (var i = 0; i < count; i++) { |
|||
var flag = flags[data[i].country] ? flags[data[i].country] : "🏳️"; |
|||
var rating = ""; |
|||
var stop = data[i].rating; |
|||
for (var r = 1; r < stop; r++) { |
|||
rating += "🍺"; |
|||
} |
|||
$("<li>").toggleClass("status_" + data[i].status) |
|||
.text(data[i].name) |
|||
.prepend($("<span>").text(flag).toggleClass("flag")) |
|||
.append($("<span>").text(rating).toggleClass("rating")) |
|||
.appendTo($(".catalog")); |
|||
} |
|||
} catch (e) { |
|||
console.log(e); |
|||
} |
|||
}, |
|||
"headers": headers |
|||
}); |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<!doctype html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Beer Catalog</title> |
|||
<script type='text/javascript' src='https://code.jquery.com/jquery-3.1.1.js'></script> |
|||
<script type='text/javascript' src='beer.js'></script> |
|||
<script type='text/javascript'> |
|||
$(document).ready(function() { |
|||
initBeerUI("http://microcks/rest/Beer%20Catalog%20API/0.9", { "user-key": "<YOUR USER KEY HERE>" }); |
|||
}); |
|||
</script> |
|||
<link rel="stylesheet" type="text/css" href="beer.css"> |
|||
</head> |
|||
<body> |
|||
<img src="https://brew.sh/img/homebrew-256x256.png" /> |
|||
<h1>BEER CATALOG</h1> |
|||
<ul class="catalog"> |
|||
</ul> |
|||
</body> |
|||
</html> |
|||
Loading…
Reference in new issue