From f7a2e027928d8bf603e4e6ae2a047898047795ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Tue, 10 Oct 2017 17:35:46 +0200 Subject: [PATCH] cleanup things a bit --- .gitignore | 1 + beer.js | 15 ++++++++------- config.js.example | 17 +++++++++++++++++ flags.js | 33 +++++++++++++++++++++++++++++++++ index.html | 8 +++++--- 5 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 .gitignore create mode 100644 config.js.example create mode 100644 flags.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bf4259 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.js diff --git a/beer.js b/beer.js index 9ae4fe2..bf0c5df 100644 --- a/beer.js +++ b/beer.js @@ -1,9 +1,9 @@ -var flags = { "Belgium": "๐Ÿ‡ง๐Ÿ‡ช", "Germany": "๐Ÿ‡ฉ๐Ÿ‡ช" }; -var baseURL = "http://beer-catalog.staging.app.itix.fr/rest/Beer%20Catalog%20API/0.9" - -function initBeerUI(baseURL, headers) { +define(function(require, exports, module) { +module.exports = function () { + var flags = require("flags.js"); + var config = require("config.js"); $.ajax({ - "url": baseURL + "/beer?page=0", + "url": config.baseURL + "/beer?page=0" + (config.extraQueryStringSuffix != null ? "&" + config.extraQueryStringSuffix : ""), "success": function (data, status, xhr) { try { var count = data.length; @@ -24,6 +24,7 @@ function initBeerUI(baseURL, headers) { console.log(e); } }, - "headers": headers + "headers": config.additionalHeaders != null ? config.additionalHeaders : {} }); -} +}; +}); diff --git a/config.js.example b/config.js.example new file mode 100644 index 0000000..b8a9aec --- /dev/null +++ b/config.js.example @@ -0,0 +1,17 @@ +/* + * Sample config file for the Beer UI + * + * Usage: edit this file and save it as "config.js" + */ +define(function(require, exports, module) { + module.exports = { + // The base URL of the Beer API + baseURL: "http://microcks/rest/Beer%20Catalog%20API/0.9", + + // If a user-key is required, you can pass it as HTTP Header: + additionalHeaders: { "user-key": "" }, + + // Or in the Query String + extraQueryStringSuffix: "user_key=" + }; +}); diff --git a/flags.js b/flags.js new file mode 100644 index 0000000..063b0a2 --- /dev/null +++ b/flags.js @@ -0,0 +1,33 @@ +define(function(require, exports, module) { + module.exports = { + "Austria": "๐Ÿ‡ฆ๐Ÿ‡น", + "Belgium": "๐Ÿ‡ง๐Ÿ‡ช", + "Bulgaria": "๐Ÿ‡ง๐Ÿ‡ฌ", + "Croatia": "๐Ÿ‡ญ๐Ÿ‡ท", + "Cyprus": "๐Ÿ‡จ๐Ÿ‡พ", + "The Czech Republic": "๐Ÿ‡จ๐Ÿ‡ฟ", + "Denmark": "๐Ÿ‡ฉ๐Ÿ‡ฐ", + "Estonia": "๐Ÿ‡ช๐Ÿ‡ช", + "Finland": "๐Ÿ‡ซ๐Ÿ‡ฎ", + "France": "๐Ÿ‡ซ๐Ÿ‡ท", + "Germany": "๐Ÿ‡ฉ๐Ÿ‡ช", + "Gibraltar": "๐Ÿ‡ฌ๐Ÿ‡ฎ", + "Greece": "๐Ÿ‡ฌ๐Ÿ‡ท", + "Hungary": "๐Ÿ‡ญ๐Ÿ‡บ", + "Ireland": "๐Ÿ‡ฎ๐Ÿ‡ช", + "Italy": "๐Ÿ‡ฎ๐Ÿ‡น", + "Latvia": "๐Ÿ‡ฑ๐Ÿ‡ป", + "Lithuania": "๐Ÿ‡ฑ๐Ÿ‡น", + "Luxembourg": "๐Ÿ‡ฑ๐Ÿ‡บ", + "Malta": "๐Ÿ‡ฒ๐Ÿ‡น", + "The Netherlands": "๐Ÿ‡ณ๐Ÿ‡ฑ", + "Poland": "๐Ÿ‡ต๐Ÿ‡ฑ", + "Portugal": "๐Ÿ‡ต๐Ÿ‡น", + "Romรขnia": "๐Ÿ‡ท๐Ÿ‡ด", + "Slovakia": "๐Ÿ‡ธ๐Ÿ‡ฐ", + "Slovenia": "๐Ÿ‡ธ๐Ÿ‡ฎ", + "Spain": "๐Ÿ‡ช๐Ÿ‡ธ", + "Sweden": "๐Ÿ‡ธ๐Ÿ‡ช", + "United Kingdom": "๐Ÿ‡ฌ๐Ÿ‡ง" + }; +}); diff --git a/index.html b/index.html index 4db243e..83be6e0 100644 --- a/index.html +++ b/index.html @@ -4,10 +4,12 @@ Beer Catalog - +