mirror of
https://github.com/Justuser3310/ss14_chemistry_site.git
synced 2025-02-08 09:07:38 +00:00
Merge branch 'main' of github.com:Justuser3310/ss14_chemistry_site
This commit is contained in:
commit
7d06879e2a
32
assets/style.css
Normal file
32
assets/style.css
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
body {
|
||||||
|
background-color: #242829;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select {
|
||||||
|
background-color: rgb(27, 29, 30);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select-input > input {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select .Select-value {
|
||||||
|
background-color: rgb(27, 29, 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select-control {
|
||||||
|
background-color: rgb(25, 25, 25) !important;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select-menu-outer {
|
||||||
|
background-color: rgb(27, 29, 30);
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.has-value.Select--single>.Select-control .Select-value .Select-value-label, .has-value.is-pseudo-focused.Select--single>.Select-control .Select-value .Select-value-label{
|
||||||
|
color: white
|
||||||
|
}
|
70
calc.py
70
calc.py
@ -6,18 +6,60 @@ db = read_db()
|
|||||||
# Составные
|
# Составные
|
||||||
recipe = {}
|
recipe = {}
|
||||||
|
|
||||||
# Функция для спец. округления
|
'''
|
||||||
# 16.666...8 => 15
|
def sround(num, parts):
|
||||||
def sround(num):
|
acc = [1,2,3,4,5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
|
||||||
|
amount = num*parts
|
||||||
|
|
||||||
|
# Ловим частые повторения
|
||||||
|
tries = 0
|
||||||
|
|
||||||
|
# Пока не вывели хорошее число
|
||||||
|
good = False
|
||||||
|
while not good:
|
||||||
|
num = floor(num)
|
||||||
|
print(good, ' ', num)
|
||||||
|
st = 1 ; good = True
|
||||||
|
# Перебираем различное количество частей
|
||||||
|
while st < parts:
|
||||||
|
# Если в допустимых значениях
|
||||||
|
if num*st in acc:
|
||||||
|
st += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
good = False
|
||||||
|
# Перебираем допустимые значения
|
||||||
|
for i in acc:
|
||||||
|
if abs(i - num*st) <= 2:
|
||||||
|
num = i
|
||||||
|
break
|
||||||
|
st += 1
|
||||||
|
|
||||||
|
# Ловим частые повторения
|
||||||
|
tries += 1
|
||||||
|
if tries > 500:
|
||||||
|
return sround1(num, parts)
|
||||||
|
|
||||||
|
if num*parts > amount:
|
||||||
|
return sround1(num, parts)
|
||||||
|
|
||||||
|
return num
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def sround(num, parts):
|
||||||
|
acc = [1,2,3,4,5]
|
||||||
num = floor(num)
|
num = floor(num)
|
||||||
|
|
||||||
# Подмены
|
if num == 0:
|
||||||
rep = [[16,15], [33,30], [21,20], [12,10], [8,5], [6,5]]
|
return 1
|
||||||
|
if num in acc:
|
||||||
for i in rep:
|
return num
|
||||||
if num == i[0]:
|
elif num%5 == 0:
|
||||||
num = i[1]
|
return num
|
||||||
|
|
||||||
|
while num%5 != 0:
|
||||||
|
num -= 1
|
||||||
return num
|
return num
|
||||||
|
|
||||||
def calc(el, amount, main = False):
|
def calc(el, amount, main = False):
|
||||||
@ -36,8 +78,8 @@ def calc(el, amount, main = False):
|
|||||||
# Делаем поправку на выход
|
# Делаем поправку на выход
|
||||||
while out < parts:
|
while out < parts:
|
||||||
# Предварительная часть
|
# Предварительная часть
|
||||||
part = sround(amount/parts)
|
part = sround(amount/parts, parts)
|
||||||
print(el, ': ',out,' < ', parts)
|
#print(el, ': ',out,' < ', parts)
|
||||||
# Если итоговый объём <= входного объёма
|
# Если итоговый объём <= входного объёма
|
||||||
if (parts+1)*part <= amount:
|
if (parts+1)*part <= amount:
|
||||||
parts += 1
|
parts += 1
|
||||||
@ -47,7 +89,7 @@ def calc(el, amount, main = False):
|
|||||||
# parts = out
|
# parts = out
|
||||||
|
|
||||||
# Считаем 1 часть
|
# Считаем 1 часть
|
||||||
part = sround(amount/parts)
|
part = sround(amount/parts, parts)
|
||||||
|
|
||||||
# Перебираем составные и делаем рекурсию
|
# Перебираем составные и делаем рекурсию
|
||||||
for i in comps:
|
for i in comps:
|
||||||
@ -57,6 +99,7 @@ def calc(el, amount, main = False):
|
|||||||
# 50/3, часть = 16, ИТОГ: 16*3=48 <
|
# 50/3, часть = 16, ИТОГ: 16*3=48 <
|
||||||
try:
|
try:
|
||||||
if lpart < part:
|
if lpart < part:
|
||||||
|
print("LPART: ",lpart)
|
||||||
part = lpart
|
part = lpart
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -80,3 +123,6 @@ def calc(el, amount, main = False):
|
|||||||
return part*parts
|
return part*parts
|
||||||
|
|
||||||
#print( calc("Лексорин", 100, True))
|
#print( calc("Лексорин", 100, True))
|
||||||
|
#print( calc("Бикаридин", 100, True))
|
||||||
|
#print( calc("Диловен", 100, True))
|
||||||
|
#print( calc("Эфедрин", 100, True))
|
||||||
|
26
site.py
26
site.py
@ -7,7 +7,7 @@ els = list(db.keys())
|
|||||||
###### ОФОРМЛЕНИЕ #######
|
###### ОФОРМЛЕНИЕ #######
|
||||||
|
|
||||||
from dash import Dash, dcc, html, Input, Output,callback
|
from dash import Dash, dcc, html, Input, Output,callback
|
||||||
app = Dash(__name__, title="SS14 Tools")
|
app = Dash(__name__, title="SS14 Tools", update_title=None)
|
||||||
|
|
||||||
|
|
||||||
# Форматируем список для красоты
|
# Форматируем список для красоты
|
||||||
@ -19,14 +19,20 @@ def list_form(ll):
|
|||||||
'chemicals': '🧪'}
|
'chemicals': '🧪'}
|
||||||
|
|
||||||
for i in ll:
|
for i in ll:
|
||||||
|
if type(i) == int:
|
||||||
|
formatted.append(i)
|
||||||
#print(db[i][1])
|
#print(db[i][1])
|
||||||
if db[i][1] in imgs:
|
elif db[i][1] in imgs:
|
||||||
|
# formatted.append({"label": html.Span(f"{imgs[db[i][1]]} {i}", style={'background-color': 'rgb(27, 29, 30)', 'color': 'rgb(0,0,0)'}),
|
||||||
|
# 'value': f"{imgs[db[i][1]]} {i}"})
|
||||||
|
# formatted.append(html.P(f"{imgs[db[i][1]]} {i}", style={'background-color': 'rgb(27, 29, 30)', 'color': 'rgb(0,0,0)'}))
|
||||||
formatted.append(imgs[db[i][1]] + ' ' + i)
|
formatted.append(imgs[db[i][1]] + ' ' + i)
|
||||||
else:
|
else:
|
||||||
formatted.append(i)
|
formatted.append(i)
|
||||||
|
|
||||||
return formatted
|
return formatted
|
||||||
|
|
||||||
|
# 'background-color': 'rgb(27, 29, 30)', 'color': 'rgb(255,255,255)'
|
||||||
|
|
||||||
app.layout = html.Div([
|
app.layout = html.Div([
|
||||||
|
|
||||||
@ -34,14 +40,15 @@ app.layout = html.Div([
|
|||||||
html.Div([
|
html.Div([
|
||||||
# Реакция
|
# Реакция
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Dropdown(list_form(els), id='reaction', placeholder="Реакция", maxHeight=500, style={'font-size': '120%'})
|
dcc.Dropdown(list_form(els), id='reaction', placeholder="Реакция", maxHeight=500,
|
||||||
|
style={'font-size': '120%'}) #, 'background-color': 'rgb(27, 29, 30)'})
|
||||||
], style={'flex': 4}),
|
], style={'flex': 4}),
|
||||||
|
|
||||||
# Объём
|
# Объём
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Dropdown([30, 50, 100, 300, 1000], 100, id='amount', clearable=False, searchable=False
|
dcc.Dropdown(list_form([30, 50, 100, 300, 1000]), 100, id='amount', clearable=False, searchable=False
|
||||||
, style={'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'})
|
, style={'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) #, 'background-color': 'rgb(27, 29, 30)'})
|
||||||
], style={'flex': 1, 'padding-left': 25})
|
], style={'flex': 1, 'padding-left': 25}) #, 'background-color': 'rgb(27, 29, 30)'})
|
||||||
|
|
||||||
], style={'display': 'flex', 'flexDirection': 'row'}),
|
], style={'display': 'flex', 'flexDirection': 'row'}),
|
||||||
|
|
||||||
@ -50,6 +57,9 @@ html.Div([
|
|||||||
|
|
||||||
], style={'padding': '5%', 'margin-left': '30%', 'margin-right': '30%'})
|
], style={'padding': '5%', 'margin-left': '30%', 'margin-right': '30%'})
|
||||||
|
|
||||||
|
# vh - высота окна, vw - ширина окна
|
||||||
|
#
|
||||||
|
# 'background-color': '#242829',
|
||||||
# padding - отступ
|
# padding - отступ
|
||||||
# [#####]
|
# [#####]
|
||||||
# margin - сужение
|
# margin - сужение
|
||||||
@ -78,11 +88,11 @@ def update_output(reaction, amount):
|
|||||||
result = []
|
result = []
|
||||||
for i in comps:
|
for i in comps:
|
||||||
result.append( html.Div(i + ': ' + str(comps[i])
|
result.append( html.Div(i + ': ' + str(comps[i])
|
||||||
, style={'background-color': '#3f3b17', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) )
|
, style={'background-color': 'rgb(213, 193, 86)', 'color': '#ffffff', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) )
|
||||||
|
|
||||||
# Выходное вещество
|
# Выходное вещество
|
||||||
result.append( html.Div(f'{reaction}: {res}'
|
result.append( html.Div(f'{reaction}: {res}'
|
||||||
, style={'background-color': '#183929', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) )
|
, style={'background-color': 'rgb(61, 164, 113)', 'color': '#ffffff', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) )
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user