-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
208 lines (193 loc) · 9.23 KB
/
Copy pathindex.html
File metadata and controls
208 lines (193 loc) · 9.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Закуп-лист — Сплав по Нёману</title>
<style>
:root{
--bg:#f7f8fa; --card:#ffffff; --accent:#ffe6d1; --font:#222; --muted:#888;
--price:#047857; --badge:#e0e7ff; --badge-txt:#2436c9;
}
body{font-family:system-ui,sans-serif;padding:1rem;max-width:1050px;margin:auto;background:var(--bg);color:var(--font)}
h1{font-size:1.7rem;text-align:center;margin:.2rem 0 .6rem}
p.subtitle{text-align:center;margin:0 0 1rem;font-size:.85rem;color:var(--muted)}
details{margin:.5rem 0 1.2rem;background:var(--card);border-radius:.6rem;box-shadow:0 1px 4px rgba(0,0,0,.06);overflow:hidden}
summary{display:flex;justify-content:space-between;align-items:center;padding:.75rem 1rem;font-weight:600;cursor:pointer;background:var(--accent)}
summary button{all:unset;font-size:1.2rem;cursor:pointer;color:var(--badge-txt);margin-left:.6rem;line-height:1}
summary button:hover{transform:scale(1.15)}
summary::-webkit-details-marker{display:none}
ul{list-style:none;margin:0;padding:0 1rem .9rem}
li{display:flex;align-items:flex-start;gap:.55rem;padding:.23rem 0;font-size:.9rem}
li.done span{opacity:.55;text-decoration:line-through}
span.prod{font-weight:600}
.price{color:var(--price);font-weight:600}
.weight{color:var(--muted);font-size:.8rem}
.badge{background:var(--badge);color:var(--badge-txt);border-radius:9999px;padding:0 .55rem;font-size:.72rem;font-weight:700}
#totals{margin-top:2rem;text-align:center;font-weight:600;font-size:1rem}
#totals span{display:inline-block;margin:0 .6rem}
</style>
<!-- Gun DB CDN (no keys, no auth) -->
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
</head>
<body>
<h1>🛶 Закуп-лист (5 дней × 5 мужчин)</h1>
<p class="subtitle">Сплав по Нёману · июль · Unistore (Минск)</p>
<div id="root"></div>
<div id="totals"></div>
<script>
/* ===================== ДАННЫЕ (реальные средние цены 2025) ===================== */
const DATA=[
{cat:"🍖 Основное горячее",items:[
"Каша с мясом 338 г — 25 бан — 3,40 × — 85,0 BYN — 8,5 кг",
"Тушёнка говяжья 338 г — 12 бан — 7,50 × — 90,0 BYN — 4,1 кг",
"Макароны 400 г — 4 пач — 2,40 × — 9,6 BYN — 1,6 кг",
"Картофель свежий — 5 кг — 1,10 × — 5,5 BYN — 5 кг",
"Пюре быстр. 40 г — 10 пак — 1,20 × — 12,0 BYN — 0,4 кг"
]},
{cat:"🥓 Мясной день №1",items:[
"Свинина шейка (вакуум) — 3 кг — 18,5 × — 55,5 BYN — 3 кг",
"Лук — 2 кг — 2,40 × — 4,8 BYN — 2 кг",
"Морковь — 1,5 кг — 1,20 × — 1,8 BYN — 1,5 кг",
"Чеснок — 0,2 кг — 9,00 × — 1,8 BYN — 0,2 кг"
]},
{cat:"🍳 Завтраки / гарниры",items:[
"Овсянка порц. 40 г — 25 пак — 0,25 × — 6,25 BYN — 1 кг",
"Лаваш / хлебцы — 1 кг — 4,80 × — 4,8 BYN — 1 кг",
"Сахар — 1 кг — 2,50 × — 2,5 BYN — 1 кг"
]},
{cat:"🥤 Напитки",items:[
"Пиво 0,5 л — 150 шт — 3,50 × — 525 BYN — 75 кг",
"Водка 0,5 л — 15 бут — 17,0 × — 255 BYN — 7,5 кг",
"Вода 6 л — 5 бут — 3,60 × — 18 BYN — 30 кг",
"Соки / газ 2 л — 10 бут — 6,10 × — 61 BYN — 20 кг",
"Электролит порошок — 10 пак — 0,60 × — 6,0 BYN — 0,2 кг"
]},
{cat:"🧂 Соусы / приправы",items:[
"Подсолнечное масло 1 л ×2 — 5,50 × — 11,0 BYN — 2 кг",
"Кетчуп 0,9 кг — 6,50 × — 6,5 BYN — 0,9 кг",
"BBQ соус 0,5 кг — 6,00 × — 6,0 BYN — 0,5 кг",
"Майонез 0,5 л — 5,00 × — 5,0 BYN — 0,5 кг",
"Горчица 0,3 кг — 3,50 × — 3,5 BYN — 0,3 кг",
"Соевый соус 0,2 л — 4,00 × — 4,0 BYN — 0,2 кг",
"Томат-паста 0,4 кг — 4,80 × — 4,8 BYN — 0,4 кг",
"Соль / специи (набор) — 9,50 BYN — 0,8 кг"
]},
{cat:"🍪 Перекусы",items:[
"Орехи ассорти 2 кг — 14,0 × — 28,0 BYN — 2 кг",
"Сухофрукты 1 кг — 11,0 × — 11,0 BYN — 1 кг",
"Печенье 1,5 кг — 6,0 × — 9,0 BYN — 1,5 кг",
"Шоколад / батончики 1 кг — 12,0 × — 12,0 BYN — 1 кг",
"Чипсы 1,5 кг — 7,0 × — 10,5 BYN — 1,5 кг",
"Семечки 1 кг — 4,5 × — 4,5 BYN — 1 кг"
]},
{cat:"🔥 Camp-fire / Grill",items:[
"Сосиски охотничьи 1,5 кг — 22,0 × — 33,0 BYN — 1,5 кг",
"Marshmallow 1 кг — 12,0 × — 12,0 BYN — 1 кг"
]},
{cat:"☕ Горячие напитки",items:[
"Кофе растворимый 250 г — 13,0 BYN — 0,25 кг",
"Чай чёрный 100 г — 5,0 BYN — 0,10 кг",
"Сгущёнка 400 г ×5 — 3,5 × — 17,5 BYN — 2 кг"
]},
{cat:"🪵 Топливо / кухня",items:[
"Уголь 10 кг — 17,0 BYN — 10 кг",
"Газ 450 г ×2 — 6,0 × — 12,0 BYN — 0,9 кг",
"Решётка-гриль — 14,0 BYN — 0,7 кг",
"Фольга 10 м — 6,0 BYN — 0,3 кг"
]},
{cat:"🍽️ Одноразовая посуда",items:[
"Комплект 100 шт — 21,0 BYN — 2 кг",
"Мешки для мусора 60 л ×25 — 2,5 BYN — 0,4 кг",
"Моющее + губки — 3,5 BYN — 0,5 кг"
]},
{cat:"🧻 Гигиена / безопасность",items:[
"Т/бумага 12 рул — 6,0 BYN — 1,2 кг",
"Влажные салфетки 3×120 — 13,0 BYN — 1 кг",
"Полотенца бумажные 4 рул — 4,8 BYN — 0,6 кг",
"Аптечка базовая — 22,0 BYN — 0,8 кг",
"Репеллент + SPF — 12,0 BYN — 0,6 кг",
"Sawyer Mini + таблетки — 9,0 BYN — 0,2 кг"
]},
{cat:"🔧 Мелочи",items:[
"Лёд-пак 3 кг — 3,5 BYN — 3 кг",
"Паракорд 20 м — 6,0 BYN — 0,3 кг",
"Карабины / изолента — 6,0 BYN — 0,3 кг",
"Спички / огниво — 6,0 BYN — 0,2 кг"
]},
];
/* ===================== UI + Gun ===================== */
const gun=Gun({peers:['https://gun-manhattan.herokuapp.com/gun']});
const root=document.getElementById('root');
const totalDiv=document.getElementById('totals');
const refs={};
DATA.forEach((sec,sIdx)=>{
const det=document.createElement('details');det.open=true;
const sum=document.createElement('summary');
const add=document.createElement('button');add.textContent='+';add.title='Добавить пункт';
add.onclick=()=>{
const t=prompt('Новый пункт (пример: Товар — цена BYN — вес кг):');if(!t)return;
const id=`${sIdx}-${Date.now()}`;
const ul=det.querySelector('ul');
renderItem(ul,t,id,sIdx);
gun.get('checklist').get(id).put(false);
DATA[sIdx].items.push(t);
updateBadges();
recalcTotals();
};
sum.innerHTML=`${sec.cat} <span class="badge" id="b${sIdx}"></span>`;
sum.append(add);
det.append(sum);
const ul=document.createElement('ul');
sec.items.forEach((txt,i)=>renderItem(ul,txt,`${sIdx}-${i}`,sIdx));
det.append(ul);
root.append(det);
});
function renderItem(ul,txt,id,sIdx){
const li=document.createElement('li');
const cb=document.createElement('input');cb.type='checkbox';
cb.onchange=()=>gun.get('checklist').get(id).put(cb.checked);
const span=document.createElement('span');span.innerHTML=highlight(txt);
li.append(cb,span);
ul.append(li);
refs[id]={li,cb,sIdx,txt};
}
function highlight(str){
const [first,...rest]=str.split('—');
let out=`<span class="prod">${first.trim()}</span>`;
if(rest.length){out+=' — '+rest.join('—').trim();}
return out.replace(/(\d+[\d.,]*\s?BYN)/g,'<span class="price">$1</span>')
.replace(/(\d+[\d.,]*\s?кг)/g,'<span class="weight">$1</span>');
}
function parseNumbers(str){
const priceMatch=str.match(/(\d+[\d.,]*)\s?BYN/);
const weightMatch=str.match(/(\d+[\d.,]*)\s?кг/);
return {
price: priceMatch?parseFloat(priceMatch[1].replace(',','.')):0,
weight: weightMatch?parseFloat(weightMatch[1].replace(',','.')):0
};
}
function recalcTotals(){
let sum=0,kg=0;
DATA.forEach(sec=>sec.items.forEach(it=>{
const {price,weight}=parseNumbers(it);sum+=price;kg+=weight;
}));
totalDiv.innerHTML=`ИТОГО: <span class="price">${sum.toFixed(1)} BYN</span> · <span class="weight">${kg.toFixed(1)} кг</span>`;
}
function updateBadges(state={}){
DATA.forEach((sec,idx)=>{
const done=sec.items.filter((_,i)=>state[`${idx}-${i}`]).length;
document.getElementById(`b${idx}`).textContent=`${done}/${sec.items.length}`;
});
}
gun.get('checklist').on(s=>{
if(!s)return;
Object.entries(refs).forEach(([id,{li,cb}])=>{
const v=!!s[id];cb.checked=v;li.className=v?'done':'';
});
updateBadges(s);
});
recalcTotals();
</script>
</body>
</html>