def charger_ouvrage(rq): prp = json.loads(rq.text) sel_auteur = SELECT(name='auteur', id='auteur') sel_auteur <= (OPTION('{titre} {prenom} {particule} {nom}'.format( **auteur).replace("' ", "'"), value=auteur['id'], selected=(auteur['id'] == prp['auteur']['id'])) for auteur in json.loads(requete('/db/liste/auteurs'))) sel_editeur = SELECT(name='editeur', id='editeur') sel_editeur <= (OPTION(editeur['nom'], value=editeur['id'], selected=(editeur['id'] == prp['editeur']['id'])) for editeur in json.loads(requete('/db/liste/editeurs'))) bouton = BUTTON('Modifier') bouton.bind('click', lambda ev: enregistrer(ev, 'ouvrage')) return ( INPUT(type='hidden', value=str(prp['id']), id='id') + tableau([ [ 'Titre', INPUT( type='text', name='titre', value=prp['titre'], id='titre') ], ['Auteur', sel_auteur], ['Éditeur', sel_editeur], ], entete=False, trier=False) + bouton)
def init_show_hide(): # initialize options element = set() weapon = set() for char in characters: if char == 'traveler': continue element.add(characters[char]['element']) weapon.add(characters[char]['weapon']) # selected cst = SELECT(Id=f"selected", Class=f"save onehundred") for s in ['any', 'checked', 'unchecked']: cst <= OPTION(s.capitalize(), value=s) # element est = SELECT(Id=f"element", Class=f"save onehundred") for s in ['any'] + sorted(element): est <= OPTION(s.capitalize(), value=s) # weapon wst = SELECT(Id=f"weapon", Class=f"save onehundred") for s in ['any'] + sorted(weapon): wst <= OPTION(s.capitalize(), value=s) t = TABLE(TR(TH() + TH('Option'))) t <= TR(TD('Character', Class="right_text") + TD(cst)) t <= TR(TD('Element', Class="right_text") + TD(est)) t <= TR(TD('Weapon', Class="right_text") + TD(wst)) t <= TR(TD('Character Search', Class="right_text") + TD(INPUT(Type='text', Id="keywords") + BUTTON('x', Id='clear_keywords'))) doc['show_hide'] <= t + P("Note that all selections have to be true for a character to be visible. Additionally the keyword search overrides all other filter settings so clear it to use them.")
def complete(self, r): if r.status == 200 or r.status == 0: result = json.loads(r.text) for l in result: nome = l[0] if nome == '': nome = 'Peso em gramas' self.sel <= OPTION(nome)
def create_base_list(): sel = SELECT(size=1, multiple=False, id="base") for base in bases: sel <= OPTION(base) doc['baselist'] <= sel if check_storage('base') and get_storage('base') in bases: doc['base'].value = get_storage('base')
def create_league_list(): sel = SELECT(size=1, multiple=False, id="league") for league in leagues: sel <= OPTION(league) doc['leaguelist'] <= sel if check_storage('league') and get_storage('league') in leagues: doc['league'].value = get_storage('league')
def complete(self, r): if r.status == 200 or r.status == 0: result = json.loads(r.text) if len(result) == 0: alert("Nenhum alimento encontrado") self.sel.style.display = 'none' return self.sel.clear() for l in result: self.sel.style.display = 'block' self.sel.style.width = '90pw' self.sel <= OPTION(l[1], value=l[0])
def init_characters(): t = TABLE(Class='body') t <= COLGROUP( COL() + COL() + COL(Class='left_border') + COL(Class='left_dotted') + COL(Class='left_border') + COL(Class='left_dotted') + COL(Class='left_border') + COL(Class='left_dotted') + COL(Class='left_border') + COL(Class='left_dotted') + COL(Class='left_border') + COL(Class='left_dotted') + COL(Class='left_dotted') + COL(Class='left_border') + COL(Class='left_dotted') + COL(Class='left_dotted') ) t <= TR( TH(strings["character"], colspan=2) + TH(strings["level"], colspan=2) + TH(strings["normal"], colspan=2) + TH(strings["skill"], colspan=2) + TH(strings["burst"], colspan=2) + TH(strings["weapon"], colspan=3) + TH(strings["artifacts"], colspan=3) ) t <= TR( TH() + TH(strings["name"]) + TH(strings["now"]) + TH(strings["goal"]) + TH(strings["now"]) + TH(strings["goal"]) + TH(strings["now"]) + TH(strings["goal"]) + TH(strings["now"]) + TH(strings["goal"]) + TH() + TH(strings["now"]) + TH(strings["goal"]) + TH(strings["click_to_remove"], colspan=3) ) for char in sorted(characters): if char == 'traveler': continue # set up level select lvlc = SELECT(Id=f"level_c-{char}", Class=f"{char} save") lvlt = SELECT(Id=f"level_t-{char}", Class=f"{char} save") for lvl in [lvlc, lvlt]: for c, val in [(0, "1"), (1, "20"), (11, "20 A"), (2, "40"), (12, "40 A"), (3, "50"), (13, "50 A"), (4, "60"), (14, "60 A"), (5, "70"), (15, "70 A"), (6, "80"), (16, "80 A"), (7, "90")]: lvl <= OPTION(f"{val}", value=c) # Set up talent select t1c = SELECT(Id=f"talent_1_c-{char}", Class=f"{char} save") t1t = SELECT(Id=f"talent_1_t-{char}", Class=f"{char} save") t2c = SELECT(Id=f"talent_2_c-{char}", Class=f"{char} save") t2t = SELECT(Id=f"talent_2_t-{char}", Class=f"{char} save") t3c = SELECT(Id=f"talent_3_c-{char}", Class=f"{char} save") t3t = SELECT(Id=f"talent_3_t-{char}", Class=f"{char} save") for st in [t1t, t1c, t2t, t2c, t3t, t3c]: for cost in costs['talent']: st <= OPTION(cost) # Set up weapon select ws = SELECT(Id=f"weapon-{char}", data_id=f"select-{char}", Class=f'weapon {char} save') ws <= OPTION('--', value='--') sort_dict_wep = {} for item in weapons[characters[char]['weapon']]: if weapons[characters[char]['weapon']][item]['wam'] != 'unk': sort_dict_wep[strings[item]] = item else: if f"missing-{item}" not in doc: doc['missing'] <= LI(strings[item], Id=f"missing-{item}") for k in sorted(sort_dict_wep): ws <= OPTION(k, value=sort_dict_wep[k]) wlvlc = SELECT(Id=f"weapon_c-{char}", Class=f"{char} save") wlvlt = SELECT(Id=f"weapon_t-{char}", Class=f"{char} save") for lvl in [wlvlc, wlvlt]: for c, val in [(0, "1"), (1, "20"), (11, "20 A"), (2, "40"), (12, "40 A"), (3, "50"), (13, "50 A"), (4, "60"), (14, "60 A"), (5, "70"), (15, "70 A"), (6, "80"), (16, "80 A"), (7, "90")]: lvl <= OPTION(f"{val}", value=c) # Create table row for character t <= TR( TD(INPUT(Id=f"check-{char}", type='checkbox', data_id=f"check-{char}", Class='char_select save')) + TD(IMG(src=f"img/{char}.png", alt=strings[char], title=strings[char], loading="lazy")) + TD(lvlc) + TD(lvlt) + TD(t1c) + TD(t1t) + TD(t2c) + TD(t2t) + TD(t3c) + TD(t3t) + TD(ws) + TD(wlvlc) + TD(wlvlt) + TD(INPUT(Id=f"use_arti-{char}", type='checkbox', Class='save', checked='checked')) + TD(BUTTON(strings["add"], Class='arti_list text_button', data_id=f"arti-{char}")) + TD(DIV(Id=f"arti-{char}", Class=f'arti_span')) , data_id=f"check-{char}", Class='unchecked', data_color=characters[char]['element'], data_weapon=characters[char]['weapon'] ) # set up traveler base row # set up level select char = 'traveler' lvlc = SELECT(Id=f"level_c-{char}", Class=f"{char} save") lvlt = SELECT(Id=f"level_t-{char}", Class=f"{char} save") for lvl in [lvlc, lvlt]: for c, val in [(0, "1"), (1, "20"), (11, "20 A"), (2, "40"), (12, "40 A"), (3, "50"), (13, "50 A"), (4, "60"), (14, "60 A"), (5, "70"), (15, "70 A"), (6, "80"), (16, "80 A"), (7, "90")]: lvl <= OPTION(f"{val}", value=c) # Set up weapon select ws = SELECT(Id=f"weapon-{char}", data_id=f"select-{char}", Class=f'weapon {char} save') ws <= OPTION('--', value='--') sort_dict_wep = {} for item in weapons[characters[char]['weapon']]: if weapons[characters[char]['weapon']][item]['wam'] != 'unk': sort_dict_wep[strings[item]] = item else: if f"missing-{item}" not in doc: doc['missing'] <= LI(strings[item], Id=f"missing-{item}") for k in sorted(sort_dict_wep): ws <= OPTION(k, value=sort_dict_wep[k]) wlvlc = SELECT(Id=f"weapon_c-{char}", Class=f"{char} save") wlvlt = SELECT(Id=f"weapon_t-{char}", Class=f"{char} save") for lvl in [wlvlc, wlvlt]: for c, val in [(0, "1"), (1, "20"), (11, "20 A"), (2, "40"), (12, "40 A"), (3, "50"), (13, "50 A"), (4, "60"), (14, "60 A"), (5, "70"), (15, "70 A"), (6, "80"), (16, "80 A"), (7, "90")]: lvl <= OPTION(f"{val}", value=c) # Create table row for character t <= TR( TD(INPUT(Id=f"check-{char}", type='checkbox', data_id=f"check-{char}", Class='char_select save')) + TD(IMG(src=f"img/{char}.png", alt=strings[char], title=strings[char], loading="lazy")) + TD(lvlc) + TD(lvlt) + TD() + TD() + TD() + TD() + TD() + TD() + TD(ws) + TD(wlvlc) + TD(wlvlt) + TD(INPUT(Id=f"use_arti-{char}", type='checkbox', Class='save', checked='checked')) + TD(BUTTON(strings["add"], Class='arti_list text_button', data_id=f"arti-{char}")) + TD(DIV(Id=f"arti-{char}", Class=f'arti_span')) , data_id=f"check-{char}", Class='unchecked', data_color='multi', data_weapon=characters[char]['weapon'] ) # set up traveler anemo/geo row for char in sorted(traveler_talent): ele = char.split('_')[1] # Set up talent select t1c = SELECT(Id=f"talent_1_c-{char}", Class=f"{char} save") t1t = SELECT(Id=f"talent_1_t-{char}", Class=f"{char} save") t2c = SELECT(Id=f"talent_2_c-{char}", Class=f"{char} save") t2t = SELECT(Id=f"talent_2_t-{char}", Class=f"{char} save") t3c = SELECT(Id=f"talent_3_c-{char}", Class=f"{char} save") t3t = SELECT(Id=f"talent_3_t-{char}", Class=f"{char} save") for st in [t1t, t1c, t2t, t2c, t3t, t3c]: for cost in costs['talent']: st <= OPTION(cost) # Create table row for character t <= TR( TD(INPUT(Id=f"check-{char}", type='checkbox', data_id=f"check-{char}", Class='char_select save')) + TD(IMG(src=f"img/{char}.png", alt=strings['traveler'], title=strings['traveler'], loading="lazy")) + TD() + TD() + TD(t1c) + TD(t1t) + TD(t2c) + TD(t2t) + TD(t3c) + TD(t3t) + TD() + TD() + TD() + TD() + TD() + TD() , data_id=f"check-{char}", Class='unchecked', data_color=ele, data_weapon=characters['traveler']['weapon'] ) doc['character_list'] <= t