summaryrefslogtreecommitdiff
path: root/graphs/js/foodTruck/static
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/js/foodTruck/static
add: graphs et rushs
Diffstat (limited to 'graphs/js/foodTruck/static')
-rw-r--r--graphs/js/foodTruck/static/failedOnload.js9
-rw-r--r--graphs/js/foodTruck/static/index.js78
-rw-r--r--graphs/js/foodTruck/static/style.css200
3 files changed, 287 insertions, 0 deletions
diff --git a/graphs/js/foodTruck/static/failedOnload.js b/graphs/js/foodTruck/static/failedOnload.js
new file mode 100644
index 0000000..cf47073
--- /dev/null
+++ b/graphs/js/foodTruck/static/failedOnload.js
@@ -0,0 +1,9 @@
+function scriptFailedLoad(src) {
+ const container = document.getElementById("order");
+ const errorDiv = document.createElement("div");
+
+ errorDiv.id = "errorscript";
+ errorDiv.innerHTML = `
+ <p><b>Script '${src.split("/").pop()}' does not exist.</b></p>`;
+ container.appendChild(errorDiv);
+}
diff --git a/graphs/js/foodTruck/static/index.js b/graphs/js/foodTruck/static/index.js
new file mode 100644
index 0000000..6d84098
--- /dev/null
+++ b/graphs/js/foodTruck/static/index.js
@@ -0,0 +1,78 @@
+function addFood(name) {
+ const container = document.getElementById("order");
+ const foodDiv = document.createElement("div");
+
+ foodDiv.classList.add("food");
+ foodDiv.innerHTML = `
+ <p>${name}</p>
+ <button onclick=" order('${name}')">Order</button>`;
+ container.appendChild(foodDiv);
+}
+
+function logToDisplay(message, type = "info") {
+ const displayElement = document.getElementById("display");
+ const logMessage = document.createElement("div");
+
+ logMessage.textContent = message;
+ logMessage.classList.add("log-message", type);
+ displayElement.appendChild(logMessage);
+
+ displayElement.scrollTop = displayElement.scrollHeight;
+ setTimeout(() => {
+ logMessage.remove();
+ }, 5000);
+}
+
+console.log = logToDisplay;
+
+function loadMenu() {
+ if (document.getElementById("errorscript") === null) {
+ Object.keys(recipes).forEach((category) => {
+ Object.keys(recipes[category]).forEach((recipeName) => {
+ addFood(recipeName);
+ });
+ });
+ }
+}
+
+var isDirtyFoodtruck = false;
+var pageTitle = document.getElementById("page-title");
+var switchButton = document.getElementById("switch-button");
+
+function loadScript(isDirty) {
+ var scriptContainer = document.body;
+ var currentScripts = [...scriptContainer.querySelectorAll("script")].filter(
+ (script) => {
+ var name_script = script.src.split("/").pop();
+
+ return /(dirty)?foodtruck\.js/i.test(name_script);
+ },
+ );
+
+ // currentScripts should return only one value
+ scriptToLoad = isDirty ? "dirtyFoodTruck.js" : "foodTruck.js";
+ document.body.removeChild(currentScripts[0]);
+
+ const script = document.createElement("script");
+
+ script.src = scriptToLoad;
+
+ script.onerror = () => scriptFailedLoad(scriptToLoad);
+ script.onload = () => loadMenu();
+ document.body.appendChild(script);
+}
+
+switchButton.addEventListener("click", () => {
+ isDirtyFoodtruck = !isDirtyFoodtruck;
+ pageTitle.textContent = isDirtyFoodtruck ? "Dirty Foodtruck" : "Foodtruck";
+ switchButton.querySelector("a").textContent = isDirtyFoodtruck
+ ? "Switch to Foodtruck"
+ : "Switch to Dirty Foodtruck";
+ var orderDiv = document.getElementById("order");
+
+ orderDiv.innerHTML = "";
+
+ loadScript(isDirtyFoodtruck);
+});
+
+loadMenu();
diff --git a/graphs/js/foodTruck/static/style.css b/graphs/js/foodTruck/static/style.css
new file mode 100644
index 0000000..c094d98
--- /dev/null
+++ b/graphs/js/foodTruck/static/style.css
@@ -0,0 +1,200 @@
+:root {
+ --main-color: #21344a;
+ --background-color: #333;
+ --own-white: #FDF0E7;
+}
+
+* {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ font-family: Arial, sans-serif;
+
+}
+
+body {
+ background-color: var(--background-color);
+ color: #333;
+ font-size: 16px;
+ line-height: 1.5;
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+ margin: 0;
+}
+
+header {
+ background-color: var(--main-color);
+ color: var(--own-white);
+ text-align: center;
+ flex-shrink: 0;
+ padding: 20px 0;
+ position: relative;
+}
+
+header h1 {
+ font-size: 50px;
+ margin-bottom: 5px;
+}
+
+header p {
+ font-size: 20px;
+}
+
+header button {
+ position: absolute;
+ right: 20px;
+ top: 50%;
+ transform: translateY(-50%);
+ background-color: var(--own-white);
+ color: var(--main-color);
+ padding: 10px 15px;
+ font-size: 1rem;
+ font-weight: bold;
+ border-radius: 10px;
+ border-style: solid;
+ border-color: #000;
+ border-width: 1px;
+ cursor: pointer;
+ transition: background-color 0.3s, color 0.3s;
+ text-decoration: none;
+}
+
+header button:hover {
+ background-color: #f5f5f5;
+ color: var(--main-color);
+}
+
+header button a {
+ text-decoration: none;
+ color: inherit;
+}
+
+#order {
+ flex-shrink: 0;
+ margin: 0;
+
+ display: flex;
+ flex-wrap: wrap;
+ gap: 20px;
+ padding: 30px;
+ margin-top: 20px;
+ justify-content: space-between;
+}
+
+.food {
+ background-color: var(--own-white);
+ padding: 15px;
+ border-radius: 8px;
+ text-align: center;
+ flex: 1 1 calc(25% - 20px);
+ box-sizing: border-box;
+}
+
+.food p {
+ font-size: 20px;
+ margin-bottom: 10px;
+}
+
+.food button {
+ background-color: var(--main-color);
+ color: white;
+ border: none;
+ padding: 10px;
+ font-size: 16px;
+ border-radius: 5px;
+ cursor: pointer;
+ width: 100%;
+ transition: background-color 0.3s;
+}
+
+.food button:hover {
+ background-color: #972615;
+}
+
+#display {
+ flex-grow: 1;
+ overflow-y: auto;
+ background-color: var(--background-color);
+ color: white;
+ padding: 10px;
+ font-family: monospace;
+ white-space: pre-wrap;
+ box-sizing: border-box;
+ height: 0;
+ max-height: calc(100vh - 200px);
+ overflow-y: scroll;
+}
+
+.log-message {
+ padding: 5px;
+ border-radius: 5px;
+ animation: fadeOut 5s forwards;
+ overflow-y: hidden;
+ justify-content: center;
+ text-align: center;
+ align-items: center;
+}
+
+.log-message.info {
+ color: var(--own-white);
+ font-size: 20px;
+}
+
+.log-message.error {
+ color: #f44336;
+}
+
+.log-message.warn {
+ color: #ffc107;
+}
+
+@keyframes fadeOut {
+ 0% {
+ opacity: 1;
+ }
+
+ 80% {
+ opacity: 1;
+ }
+
+ 100% {
+ opacity: 0;
+ }
+}
+
+#errorscript {
+ color: red;
+ font-size: 30px;
+ font-weight: bold;
+ text-align: center;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(255, 255, 255, 0.8);
+ box-sizing: border-box;
+ border-radius: 15px;
+ padding: 20px;
+}
+
+footer img {
+ size: 15px;
+}
+
+footer {
+ flex-shrink: 0;
+ background-color: var(--main-color);
+ color: white;
+ text-align: center;
+ padding: 20px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 20px;
+}
+
+footer p {
+ font-size: 20px;
+} \ No newline at end of file