Browse Source

sort

master
parent
commit
e01ae6cd48
  1. 48
      table_distributor.html

48
table_distributor.html

@ -1,6 +1,6 @@
<!-- Copyright 2022 by Alexei Bezborodov <AlexeiBv@narod.ru> -->
<!DOCTYPE html>
<html>
<html lang="ru">
<head>
<meta charset="UTF-8">
@ -56,6 +56,7 @@
</div>
<div>
<button id="table_distrib">Расставить по столам</button>
<button id="table_distrib_load">Загрузить расстановку</button>
</div>
</details>
<details>
@ -127,6 +128,7 @@ def load_input(val):
cur_meet_list = cur_meet_list | {int(s)}
p = Person(cur_beig_id,cur_name, cur_meet_list)
persons.append(p)
persons = sorted(persons, key=lambda person: len(person.meet_set))
def show_meet_table_data():
global persons
@ -155,7 +157,10 @@ def get_result():
global persons
result = ""
for p in persons:
result += str(p.beig_id) + ";" + p.name + ";" + str(p.meet_set) + "\n"
result += str(p.beig_id) + ";" + p.name + ";"
if len(p.meet_set):
result += str(p.meet_set)
result += "\n"
return result
def print_result_table():
@ -173,14 +178,20 @@ def print_result_table():
for t in tables:
html += "<tr>"
html += "<td>" + str(table_names[t.id]) + "</td>"
html += "<td>" + str(t.person_set) + "</td>"
if len(t.person_set):
html += "<td>" + str(t.person_set) + "</td>"
else:
html += "<td></td>"
html += "</tr>"
html += "</table>"
document["result_table"].innerHTML = html
result_txt = ""
for t in tables:
result_txt += str(t.id) + ";" + str(t.person_set) + "\n"
result_txt += str(t.id) + ";"
if len(t.person_set):
result_txt += str(t.person_set)
result_txt += "\n"
document["result_table_txt"].value = result_txt
@ -235,7 +246,6 @@ def get_beig_id_set():
result = result | {p.beig_id}
return result
def fill_tables():
global persons
global tables
@ -271,6 +281,25 @@ def fill_persons():
if p.beig_id in t.person_set:
p.meet_set = t.person_set | p.meet_set
def load_input_table(val):
global tables
tables = []
input_data = val
for t in input_data.split("\n"):
if t == "":
continue
tmp = t.split(";")
cur_id = int(tmp[0])
str_meet_list = []
if len(tmp) > 1:
str_meet_list = tmp[1].replace(" ", "").replace("{", "").replace("}", "").split(",")
cur_meet_list = set()
for s in str_meet_list:
if len(s) != 0:
cur_meet_list = cur_meet_list | {int(s)}
t = Table(cur_id, cur_meet_list)
tables.append(t)
def make_result():
fill_tables()
fill_persons()
@ -285,12 +314,19 @@ def table_distrib(event):
print_result_table()
document["output_data"].value = get_result()
def table_distrib_load(event):
load_data(event)
load_input_table(document["result_table_txt"].value)
fill_persons()
document["output_data"].value = get_result()
def load_to_start_data(event):
document["input_data"].value = document["output_data"].value
document["load_data"].bind("click", load_data)
document["table_distrib"].bind("click", table_distrib)
document["load_to_start_data"].bind("click", load_to_start_data)
document["table_distrib_load"].bind("click", table_distrib_load)
</script>

Loading…
Cancel
Save