Infinity-1995 commited on
Commit
680f02d
·
verified ·
1 Parent(s): 89e26bf

Update log.html

Browse files
Files changed (1) hide show
  1. log.html +37 -105
log.html CHANGED
@@ -1,81 +1,3 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
6
- <title>NourishNet AI</title>
7
-
8
- <script src="https://cdn.tailwindcss.com"></script>
9
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
10
-
11
- <style>
12
- body{font-family:'Inter',sans-serif;background:#F7F5F0;}
13
- .card{background:white;border-radius:16px;padding:20px;margin-bottom:20px;border:1px solid #e5e7eb;}
14
- .btn{padding:8px 14px;border-radius:999px;font-weight:600;margin-right:6px;cursor:pointer;}
15
- .high{background:#ef4444;color:white;}
16
- .medium{background:#f59e0b;color:white;}
17
- .low{background:#10b981;color:white;}
18
- .title{font-size:22px;font-weight:800;}
19
- .big{font-size:18px;}
20
- .small{font-size:14px;color:#6b7280;}
21
- </style>
22
- </head>
23
-
24
- <body>
25
-
26
- <div class="bg-emerald-600 text-white p-6 text-2xl font-bold">
27
- NourishNet AI System
28
- </div>
29
-
30
- <div class="p-8">
31
-
32
- <div class="card">
33
- <h2 class="title mb-4">Food Input</h2>
34
-
35
- <label>Food Type</label>
36
- <select id="foodType" class="w-full border p-3 rounded-lg mt-2 mb-4">
37
- <option>Cooked</option>
38
- <option>Baked</option>
39
- <option>Raw</option>
40
- <option>Packaged</option>
41
- </select>
42
-
43
- <label>Portions: <span id="portionValue">50</span></label>
44
- <input type="range" min="1" max="250" value="50" id="portions" class="w-full mb-4">
45
-
46
- <label>Expiry</label>
47
- <select id="expiry" class="w-full border p-3 rounded-lg mt-2">
48
- <option value="2">2–4 hours</option>
49
- <option value="4">4–6 hours</option>
50
- <option value="6">6–8 hours</option>
51
- <option value="8">8–10 hours</option>
52
- <option value="24">24 hours</option>
53
- <option value="48">48 hours</option>
54
- </select>
55
- </div>
56
-
57
- <div class="card">
58
- <h2 class="title mb-4">AI Recommendations</h2>
59
- <div id="aiBox">Click Ask AI</div>
60
-
61
- <button onclick="runAI()" class="mt-4 bg-emerald-600 text-white px-6 py-2 rounded-full">
62
- Ask AI
63
- </button>
64
- </div>
65
-
66
- <div class="card">
67
- <h2 class="title mb-4">Matched Recipients</h2>
68
- <div id="matchedBox">No matches yet</div>
69
- </div>
70
-
71
- <div class="text-center">
72
- <button onclick="confirmDonation()" class="bg-emerald-600 text-white px-8 py-3 rounded-full font-bold">
73
- Confirm Donation
74
- </button>
75
- </div>
76
-
77
- </div>
78
-
79
  <script>
80
 
81
  let current = [];
@@ -88,7 +10,7 @@ document.getElementById("portions").oninput = e=>{
88
  document.getElementById("portionValue").innerText = e.target.value;
89
  };
90
 
91
- /* FIXED AI CALL (IMPORTANT) */
92
  async function runAI(){
93
 
94
  document.getElementById("aiBox").innerHTML = "Thinking...";
@@ -101,7 +23,7 @@ async function runAI(){
101
  meals:document.getElementById("portions").value,
102
  foodType:document.getElementById("foodType").value,
103
  expiry:document.getElementById("expiry").value,
104
- t: Date.now()
105
  })
106
  });
107
 
@@ -113,34 +35,31 @@ async function runAI(){
113
  function renderAI(){
114
 
115
  document.getElementById("aiBox").innerHTML =
116
- current.map((x,i)=>{
117
-
118
- let color =
119
- x.priority === "High" ? "high" :
120
- x.priority === "Medium" ? "medium" : "low";
121
 
122
- return `
123
  <div class="border p-4 rounded-xl mb-3">
124
 
125
  <div class="text-xl font-bold">${x.recipient}</div>
126
-
127
  <div class="small">📍 ${x.km} km away</div>
128
-
129
  <div class="big mt-1">${x.reason}</div>
130
 
131
- <span class="btn ${color} inline-block mt-2">
132
- ${x.priority}
133
- </span>
 
134
 
135
  <div class="mt-3">
136
 
137
- <button class="btn high" onclick="accept(${i})">Accept</button>
138
- <button class="btn medium" onclick="rejectAI(${i})">Reject</button>
 
 
 
139
 
140
  </div>
141
 
142
- </div>`;
143
- }).join("");
144
  }
145
 
146
  /* ACCEPT */
@@ -161,12 +80,25 @@ function rejectAI(i){
161
  function renderAccepted(){
162
 
163
  document.getElementById("matchedBox").innerHTML =
164
- accepted.length ? accepted.map(a=>`
165
- <div class="border p-3 rounded-xl mb-2">
166
- <div class="font-bold">${a.recipient}</div>
167
- <div class="small">${a.km} km away</div>
 
 
 
 
 
 
168
  </div>
169
- `).join("") : "No matches yet";
 
 
 
 
 
 
 
170
  }
171
 
172
  /* CONFIRM */
@@ -178,13 +110,13 @@ function confirmDonation(){
178
  }
179
 
180
  localStorage.setItem("donationData", JSON.stringify({
181
- accepted
 
 
 
182
  }));
183
 
184
  window.location.href = "confirmation.html";
185
  }
186
 
187
- </script>
188
-
189
- </body>
190
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <script>
2
 
3
  let current = [];
 
10
  document.getElementById("portionValue").innerText = e.target.value;
11
  };
12
 
13
+ /* FIXED AI CALL */
14
  async function runAI(){
15
 
16
  document.getElementById("aiBox").innerHTML = "Thinking...";
 
23
  meals:document.getElementById("portions").value,
24
  foodType:document.getElementById("foodType").value,
25
  expiry:document.getElementById("expiry").value,
26
+ t:Date.now()
27
  })
28
  });
29
 
 
35
  function renderAI(){
36
 
37
  document.getElementById("aiBox").innerHTML =
38
+ current.map((x,i)=>`
 
 
 
 
39
 
 
40
  <div class="border p-4 rounded-xl mb-3">
41
 
42
  <div class="text-xl font-bold">${x.recipient}</div>
 
43
  <div class="small">📍 ${x.km} km away</div>
 
44
  <div class="big mt-1">${x.reason}</div>
45
 
46
+ <span class="btn ${
47
+ x.priority=="High"?"high":
48
+ x.priority=="Medium"?"medium":"low"
49
+ }">${x.priority}</span>
50
 
51
  <div class="mt-3">
52
 
53
+ <button class="btn" style="background:#10b981;color:white"
54
+ onclick="accept(${i})">Accept</button>
55
+
56
+ <button class="btn" style="background:#ef4444;color:white"
57
+ onclick="rejectAI(${i})">Reject</button>
58
 
59
  </div>
60
 
61
+ </div>
62
+ `).join("");
63
  }
64
 
65
  /* ACCEPT */
 
80
  function renderAccepted(){
81
 
82
  document.getElementById("matchedBox").innerHTML =
83
+ accepted.length
84
+ ? accepted.map((a,i)=>`
85
+ <div class="border p-3 rounded-xl mb-2 flex justify-between">
86
+ <div>
87
+ <div class="font-bold">${a.recipient}</div>
88
+ <div class="small">${a.km} km</div>
89
+ </div>
90
+ <button onclick="removeMatched(${i})"
91
+ style="background:#ef4444;color:white"
92
+ class="btn">Reject</button>
93
  </div>
94
+ `).join("")
95
+ : "No matches yet";
96
+ }
97
+
98
+ /* REMOVE FROM MATCHED */
99
+ function removeMatched(i){
100
+ accepted.splice(i,1);
101
+ renderAccepted();
102
  }
103
 
104
  /* CONFIRM */
 
110
  }
111
 
112
  localStorage.setItem("donationData", JSON.stringify({
113
+ accepted,
114
+ portions:document.getElementById("portions").value,
115
+ foodType:document.getElementById("foodType").value,
116
+ expiry:document.getElementById("expiry").value
117
  }));
118
 
119
  window.location.href = "confirmation.html";
120
  }
121
 
122
+ </script>