def __init__(self, idAli, cb): DIALOG.__init__(self) tab = TABLE() self <= tab self.callback = cb #self.inText = INPUT(Class="form-control") #self.inText.bind('keyup',self.entrou) #tab<=TR(TD('Peso (g):')+TD(self.inText)) self.sel = SELECT(Class='form-control', size=8) # style={'max_width':'90px'}) ##self.sel.bind('input',self.selected) #tab<=TH("Escolha medida", colspan=2) self.inMedQty = INPUT(Class="form-control", size=4) tab <= TR(TD('Medida caseira, quantidade') + TD(self.inMedQty)) tab <= TR(TD(self.sel, colspan=2)) add = SPAN(Class='glyphicon glyphicon-ok-circle') add.bind('click', self.added) can = SPAN(Class='glyphicon glyphicon-remove-circle') can.bind('click', self.cancelled) tab <= TR( TD(can, style={ 'text-align': 'right', 'padding': '6pw' }) + TD(add, style={ 'text-align': 'center', 'padding': '6pw' })) req = ajax.ajax() req.bind('complete', self.complete) req.open('POST', '/nutsvc', True) req.set_header('content-type', 'application/x-www-form-urlencoded') d = {'op': 'MEDIDAS', 'q': idAli} req.send(d)
def tableau_dict(colonnes, donnees, entete=True, trier=True, obj='ouvrages'): titres = TR() if entete: for colonne in colonnes: if colonne[1]: titre = A(colonne[0], href='#') titre.bind('click', lambda ev, col=colonne[1]: charger_liste( ev, obj, col, actualiser=False)) else: titre = P(colonne[0]) titres <= TH(titre.clone()) if trier: donnees = donnees if ASC else reversed(donnees) corps = TBODY() for element in donnees: lgn = TR() for colonne in colonnes: if 'id' in element: lien = '{}:{}'.format(obj, element['id']) cel = A(element[colonne[1]], href='#' + lien) cel.bind('click', lambda ev, col=lien: charger(ev, col)) else: cel = element[colonne[1]] lgn <= TD(cel) corps <= lgn return TABLE((THEAD(titres), corps))
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 init_weight(version): t = TABLE() th = TR() th <= TH("Damage") th <= TH("Jewel Mod") t <= th for m in mjson[version]: t <= TR(TD(f'<input type="number" id="{m["name"]}" value="0" data-normal="{m["count"]}" step="0.1" class="dps_val">') + TD(m['desc'])) doc['Weights'] <= t
def init_flags(): data = [('useFrenzyCharges', 'Frenzy'), ('usePowerCharges', 'Power'), ('useEnduranceCharges', 'Endurance')] t = make_table(data, 3, 'Charges') doc['Flags'] <= STRONG('Charges:') + ' Do you sustain charges?' + t + BR() t = TABLE() t <= TR(TD(INPUT(type="number", Id="PowerCount", value="0", data_normal="1", style={"width": "3em"}, Class="dps_val")) + TD('Power')) t <= TR(TD(INPUT(type="number", Id="FrenzyCount", value="0", data_normal="1", style={"width": "3em"}, Class="dps_val")) + TD('Frenzy')) t <= TR(TD(INPUT(type="number", Id="EnduranceCount", value="0", data_normal="1", style={"width": "3em"}, Class="dps_val")) + TD('Endurance')) t <= TR(TD(INPUT(type="number", Id="ImpaleStacks", value="0", data_normal="1", style={"width": "3em"}, Class="dps_val")) + TD('Number of Impales on Target')) doc['Flags'] <= STRONG('Misc Counts:') + ' The "count" of various things affecting your build.' + t + BR() data = ['Attack', 'Spell'] t = make_table(data, 2, 'Type') doc['Flags'] <= STRONG('Type:') + ' Generally select 1 based on your combat style' + t + BR() data = ['Mace', 'Bow', 'Wand', 'Claw', 'Staff', 'Sword', 'Axe', 'Dagger', 'Trap', 'Mine', 'Totem'] t = make_table(data, 4, 'Class') doc['Flags'] <= STRONG('Class:') + ' Select your weilded weapon types. Trap/Mine/Totem if you are using those supports' + t + BR() data = ['Elemental', 'Fire', 'Cold', 'Lightning', 'Projectile', 'Melee', 'Area', 'Spectre', 'Exerted', 'Trigger', 'Vaal'] t = make_table(data, 4, 'Tags') doc['Flags'] <= STRONG('Tags:') + ' Check all the tags that match your primary skill' + t + BR() data = ['Shield', ('DualWielding', 'Dual Wielding'), ('TwoHandedWeapon', 'Two Handed Weapon')] t = make_table(data, 3, 'Hands') doc['Flags'] <= STRONG('Hands:') + ' Choose 1 based on wielded weapons' + t + BR() data = [('KilledRecently', 'You Kill'), ('MinionsKilledRecently', 'Minion Kill'), ('NoRecentKill', 'Not Kill'), ('CritRecently', 'Crit'), ('NoRecentCrit', 'Not Crit'), ('UsedMinionSkillRecently', 'Minion Skill'), 'Stun', 'Shatter', ('beShocked', 'Be Shocked')] t = make_table(data, 3, 'Recently') doc['Flags'] <= STRONG('Recently:') + " Tic all the things your build can do 'recently'" + t + BR() data = [('EnemyPoisoned', 'Poisoned'), ('EnemyBlinded', 'Blinded'), ('EnemyIgnited', 'Ignited'), ('EnemyBurning', 'Burning'), ('EnemyChilled', 'Chilled'), ('EnemyFrozen', 'Frozen'), ('EnemyShocked', 'Shocked'), ('EnemyMaimed', 'Maimed')] t = make_table(data, 4, 'Enemy is') doc['Flags'] <= STRONG('Enemy is:') + ' Status effects on your target' + t + BR() data = ['Spellslinger', ('SpellslingerDW', 'Spellslinger(DW)'), 'BattleMage', ('Leeching', 'Leeching (Generic)'), ('leechLife', 'Leeching Life'), ('leechMana', 'Leeching Mana'), ('UsingFlask', 'Flasked'), ] t = make_table(data, 3, 'You are/have') doc['Flags'] <= STRONG('You are/have:') + ' Tic all the things affecting you' + t + P(STRONG('Spellslinger/Battlemage Notes:') + " Only select, at max, one of the Spellslingers and remember Spellslinger only works with wands. Physical damage is not correct as it depends on base item, quality, %ipd. Existing search mods don't allow for a meaningful weight to be generated.") + BR() data = [('NearbyRareUnique', 'Nearby Rare or Unique Monster'), ('NearbyEnemy', 'Nearby Enemy (helm mods)'), ('otherringshaper', 'Other Ring is Shaper'), ('otherringelder', 'Other Ring is Elder')] t = make_table(data, 1, 'Other Options') doc['Flags'] <= STRONG('Other options:') + ' choices that don\'t neatly fit a section' + BR() + t
def __init__(self): DIV.__init__(self) #, style={'max-width':'90px'}) selTable = TABLE() self <= selTable self.inText = INPUT(Class="form-control") self.inText.bind('keyup', self.entrou) selTable <= TR(TD(P("Busca: ") + self.inText)) #,name="intext")) self.sel = SELECT(size=8, Class='form-control') # style={'max_width':'90px'}) self.sel.bind('input', self.selec) selTable <= TR(TD(self.sel)) self.sel.style.display = 'none' self.nutTab = MostraNut() self <= self.nutTab
def make_table(data, w, section): t = TABLE() tr = TR() for c, d in enumerate(data, 1): if isinstance(d, str): tr <= TD(LABEL(INPUT(type='checkbox', Id=d, Class='flag_val', data_id=d, data_type=section) + d)) else: tr <= TD(LABEL(INPUT(type='checkbox', Id=d[0], Class='flag_val', data_id=d[1], data_type=section) + d[1])) if not c % w: t <= tr tr = TR() if c % w: t <= tr return t
def table_summary(dat): from browser.html import TABLE, TR, TH, TD from browser import html tbl = TABLE() row = TR() for h in dat[0].split(";"): row <= TH(h) tbl <= row for r in dat[1].split("#"): row = TR() for f in r.split(";"): row <= TD(f) tbl <= row document['table-container'].clear() document['table-container'] <= html.H5("Summary of first 10 accounts") document['table-container'] <= tbl
def create_index(self): dtop.clear() doutput.clear() # document.title = f'{self.release}' dtop <= SPAN(f'{self.release}') # dindex.style.display = '' if dindex.html: return table = TABLE(Class='toctable') for i, row in enumerate(self.toc): flag, level, sid, width, sname = row tr = TR() tr <= TD(flag, Class='flag') tr <= TD(level) span = SPAN(sid) span.style.width = f"{width}ch" span.style.display = 'inline-block' if self.get_section(sid).aoa: td = TD(span + A(sname, href=f'#{sid}')) else: td = TD(span + sname) tr <= td set_indent(td, level - 2) tr <= TD(i) table <= tr dindex <= table ready.ready_table(table)
def create_index(self): dtop.clear() doutput.clear() # document.title = f'{self.release}' dtop <= SPAN(f'{self.release}') dtop <= SPAN(A('Search', href=f'#search')) dtop <= SPAN(A('ASN1', href=self.asn1html)) # dindex.style.display = '' if dindex.html: return table = TABLE(Class='toctable') for i, row in enumerate(self.toc): flag, level, name = row tr = TR() tr <= TD(flag, Class='flag') tr <= TD(level) if level: td = TD(A(name, href=f'#{name}')) else: td = TD(name) tr <= td set_indent(td, level) tr <= TD(i) table <= tr dindex <= table ready.ready_table(table)
def tableau(tbl, entete=True, trier=True): titres = TR() if entete: titres <= TH(P(colonne[0]) for colonne in tbl[0]) tbl = tbl[1] if trier: tbl = tbl if ASC else reversed(tbl) corps = TBODY() for ligne in tbl: lgn = TR() for cellule in ligne: if isinstance(cellule, list): cel = A(cellule[0], href='#{}'.format(cellule[1])) cel.bind('click', lambda ev, col=cellule[1]: charger(ev, col)) else: cel = cellule lgn <= TD(cel) corps <= lgn return TABLE((THEAD(titres), corps))
def jogo(): jogo = TABLE(Class="jogo") aux = "" for line in range(len(tabuleiro)): for coluna in range(len(tabuleiro[line])): aux += TD(A(tabuleiro[line][coluna], onclick='celula()'), value=coluna) jogo <= TR(aux, value=line) aux = "" return jogo
def dump(obj): document <= P() table = TABLE() document <= table for x in sorted(dir(obj)): tr = TR() table <= tr tr <= TD(x) tr <= TD('???')
def put_the_sorting_hat(tab, student_selected, k): neighborhood_tab = pooling(tab, student_selected, k) student_house = str(search_house(neighborhood_tab)) table = TABLE() keys = [] values = [[], [], [], [], []] i = 0 for cle in neighborhood_tab[0].keys(): keys.append(cle) for neighborhood in neighborhood_tab: for valeur in neighborhood.values(): values[i].append(valeur) i += 1 table <= TR(TH(keys[i]) for i in range(len(keys))) for liste in values: table <= TR(TD(liste[i]) for i in range(len(liste))) document['tableau'] <= table document[student_house].style.display = 'inline' document['maison'].textContent = student_house document['partie_2'].style.display = "none" document['partie_3'].style.display = 'inline'
def completeFetch(self, r): if r.status == 200 or r.status == 0: result = json.loads(r.text) self.clear() if len(result) == 0: alert("Nenhum nutriente encontrado") self.style.display = 'none' return for l in result: self.style.display = 'block' #self.sel.style.width='90pw' #self.sel<=OPTION(l[1], value=l[0]) self <= TR(TD(l[0]) + TD(l[1]) + TD(l[2]))
def make_table(m_data, w, header=False, item_class=''): t = TABLE() tr = TR() for c, d in enumerate(m_data, 1): if isinstance(d, str): new_id = f"{item_class + '_' if item_class else ''}{d}" for a, b in [(' ', '_'), ('\'', '_'), ('+', '_')]: new_id = new_id.replace(a, b) tr <= TD( LABEL( INPUT( type='checkbox', Id=new_id, Class=f'save {"header" if header else "flag_val"}', data_id=f"{item_class + '_' if item_class else ''}{d}") + d)) if not c % w: t <= tr tr = TR() if c % w: t <= tr return t
def init_main(): t = doc['Main'] t.text = '' t <= P("This page is updated as you make changes on the Weights and Flags page and only shows non-zero weights and set flags. Changes to weights here are also reflected on those pages.") table = TABLE() th = TR() th <= TH("Damage") th <= TH("Jewel Mod") table <= th for m in mjson[current_version]: if float(doc[m['name']].value): table <= TR(TD(f'<input type="number" data-id="{m["name"]}" value="{doc[m["name"]].value}" step="0.1", class="main_weight">') + TD(m['desc'])) t <= table table = TABLE(TR(TH("Flag Group") + TH("Value"))) flags = {} for elt in doc.get(selector='.flag_val'): temp = elt if temp.checked and temp['data-type'] != 'ignore': if temp['data-type'] not in flags: flags[temp['data-type']] = [] flags[temp['data-type']].append(temp['data-id']) # Special section for charge counts charge_count = [] for elt in [doc['PowerCount'], doc['FrenzyCount'], doc['EnduranceCount'], doc['ImpaleStacks']]: if int(elt.value): name = elt['id'][:-5] if elt['id'] != 'ImpaleStacks' else "Number of Impales on Target" charge_count.append(f"{name} ({elt.value})") if charge_count: flags['Misc Counts'] = charge_count for f in flags: table <= TR(TD(f) + TD(', '.join(flags[f]))) t <= P("Summary of set flags. Make changes on Flags page.") + table @bind('.main_weight', 'change') def update_weight(ev): tmp = ev.target doc[tmp['data-id']].value = tmp.value
def afficherPlateauTexte(id, plateau): document[id].text = "" table = TABLE("", id="tableau") for i in range(0, tailleTableau): row = TR() for j in range(0, tailleTableau): if plateau[i][j] == -1: cell = TD(" ") else: cell = TD(plateau[i][j]) cell.bind("click", cellClickEvent) row <= cell table <= row document[id] <= table
def create_tree_tr(self, row, pad_prefix='', start_level=0): flag, pad, level, ie, udf, vrange, need, desc, ch5link = row pad = pad_prefix + pad level += start_level tr = TR() tr <= TD(flag, Class='flag') tr <= TD(level) tr <= TD(SPAN(pad, Class='iepad', treepad=pad, tablepad='>'*level+' ')+SPAN(ie, Class='ie', desc=ch5link)) tr <= TD(need) if udf: tr <= TD(A(udf, href=f'#{udf}')) else: tr <= TD() tr <= TD(vrange, Class='vrange') tr <= TD(desc, Class='desc') tr <= TD() return tr
def send_data(doc, data): date = js.Date.new(data['date']) tr = doc.get(selector="tr") tr_data = TR( TD(data['number']) + TD(data['province']) + TD(f'{date.toString()}') + TD('<img onclick="modal_picture(\'{}\')" src="{}" width="120">'.format( data['image-path'], data['image-path']))) ntr = tr_data if data['mark'] == 'black': ntr.className = 'red' elif data['mark'] == 'white': ntr.className = 'green' if len(tr) > 0: doc.insertBefore(ntr, tr[0]) elif len(tr) == 0: doc <= tr_data if len(tr) == MAXTABLEROW: doc.removeChild(tr[-1])
def gerarCampoDePossibilidades(tabuleiro): document['tabelajogo'].clear() tabela = TABLE(Class="jogo") for line in range(7): aux = '' for coluna in range(7): if (jogo.acao[0] == line and jogo.acao[1] == coluna): aux += TD(A({tabuleiro[line][coluna]}).bind('click', incrlog), Class='acao') elif (jogo.acao[0] == line and (jogo.acao[1] - 2) == coluna and jogo.validacao[0]): aux += TD(A({tabuleiro[line][coluna]}).bind('click', incrlog), id=0, Class='possibilidade') elif (jogo.acao[0] == line and (jogo.acao[1] + 2) == coluna and jogo.validacao[1]): aux += TD(A({tabuleiro[line][coluna]}).bind('click', incrlog), id=1, Class='possibilidade') elif ((jogo.acao[0] - 2) == line and jogo.acao[1] == coluna and jogo.validacao[2]): aux += TD(A({tabuleiro[line][coluna]}).bind('click', incrlog), id=2, Class='possibilidade') elif ((jogo.acao[0] + 2) == line and jogo.acao[1] == coluna and jogo.validacao[3]): aux += TD(A({tabuleiro[line][coluna]}).bind('click', incrlog), id=3, Class='possibilidade') else: aux += TD(A({tabuleiro[line][coluna]})) tabela <= TR(aux, id=line) aux = "" return tabela
def gerarCampoVisao(tabuleiro): document['tabelajogo'].clear() def hovertrueposition(event): event.target.style.background = 'rgba(0, 255, 0, 0.3)' def hoverfalseposition(event): event.target.style.background = 'rgba(255, 0, 0, 0.3)' def hoverleaveposition(event): event.target.style.background = '' def toast(event): new = DIV(event.path[2].id + " / " + event.path[1].id, Class='toast') document['desenv'] <= new def hidden(): new.style.display = 'none' timer.set_timeout(hidden, 3000) jogo = TABLE(Class="jogo") for line in range(7): aux = '' for coluna in range(7): if tabuleiro[line][coluna] == '.': aux += TD(A({tabuleiro[line][coluna] }).bind('click', incr).bind('click', toast), id=coluna).bind('mouseenter', hovertrueposition).bind( 'mouseleave', hoverleaveposition) else: aux += TD(A({tabuleiro[line][coluna]}).bind('click', toast), id=coluna).bind('mouseenter', hoverfalseposition).bind( 'mouseleave', hoverleaveposition) jogo <= TR(aux, id=line) aux = "" return jogo
def create_table(name): global ie_desc_array ie_desc_array = [] # m = name_msg_map[name] document.title = f'{g.release}: {m.id} {m.name}' document['title'] <= document.title # button = BUTTON('show IE description') document['top'] <= button button.bind('click', toggle_ie_desc) # document['top'] <= SPAN(' ') document['top'] <= A('Index', href='') document['output'] <= PRE(m.id + ' ' + m.name + '\n' + m.definition, Class='definition') table = TABLE(id='msgtable') document['output'] <= table for r, row in enumerate(m.aoa): tr = TR(Class=f'r{r}') table <= tr for c, v in enumerate(row): title = '' if r == 0 and c in (2, 3, 4, 5): title, v = v, '' elif c == 2: lst = v.replace('\n', ' ').split(' ') lst2 = [ie for ieid, ie in id_ie_map.items() if ieid in lst] if len(lst2) == 1: ie = lst2[0] title = f'{ie.id} {ie.name}\n{ie.definition}' v = A(f'{ie.id}', href=f'#ie{ie.id}') ie_desc_array.append(title) elif r != 0 and c == 6: if v: v = DIV(v) + DIV('', Class='iedescdiv', needsep='y') else: v = DIV('', Class='iedescdiv', needsep='n') tr <= TD(v, title=title, Class=f'c{c}')
def send_data(doc, data): date = js.Date.new(data["date"]) tr = doc.get(selector="tr") tr_data = TR( TD(data["number"]) + TD(data["province"]) + TD(show_datetime(date)) + TD( '<img onclick="modal_picture(\'{}\')" src="{}" width="120">'.format( data["image-path"], data["image-path"] ) ) ) ntr = tr_data if data["mark"] == "black": ntr.className = "red" elif data["mark"] == "white": ntr.className = "green" if len(tr) > 0: doc.insertBefore(ntr, tr[0]) elif len(tr) == 0: doc <= tr_data if len(tr) == MAXTABLEROW: doc.removeChild(tr[-1])
def create_index_24008(): document.title = g.release document['title'] <= g.release document['top'] <= '' msg_list = g.msg_list table = TABLE(id='indextable') document['output'] <= table table <= TR(TD(HR(), colspan='2')) table <= TR(TD('Messages', colspan='2')) for m in msg_list: table <= TR(TD(m.id) + TD(A(f'{m.name}', href=f'#{m.name}'))) table <= TR(TD(HR(), colspan='2')) table <= TR(TD('information elements', colspan='2')) for ie in g.ie_list: table <= TR(TD(ie.id) + TD(A(f'{ie.name}', href=f'#ie{ie.id}')))
def init_inventory(): # Create a table of items we might need and store their ids in a lookup table # char xp, weapon xp, and mora t_own = TABLE(Class='borders center') t_own <= TR(TH(strings["item"]) + TH(strings["need"]) + TH(strings["have"]) + TH(strings["missing_"])) t_own <= TR(TD(IMG(src=f"img/wep_xp.png", alt=strings['wep_xp'], title=strings['wep_xp'], loading="lazy")) + TD('0', Id='wep_xp-total') + TD(INPUT(Type='number', min='0', step="1", value='0', Id='wep_xp-user', Class='save')) + TD('0', Id='wep_xp-need', Class='good')) t_own <= TR(TD(IMG(src=f"img/wep_xp_sub_1.png", alt=strings['wep_xp'], title=strings['wep_xp'], loading="lazy")) + TD() + TD(INPUT(Type='number', min='0', step="1", value='0', Id='wep_xp_sub_1-user', Class='save')) + TD()) t_own <= TR(TD(IMG(src=f"img/wep_xp_sub_0.png", alt=strings['wep_xp'], title=strings['wep_xp'], loading="lazy")) + TD() + TD(INPUT(Type='number', min='0', step="1", value='0', Id='wep_xp_sub_0-user', Class='save')) + TD()) t_own <= TR(TD(IMG(src=f"img/mora.png", alt=strings['mora'], title=strings['mora'], loading="lazy")) + TD('0', Id='mora-total') + TD(INPUT(Type='number', min='0', step="1", value='0', Id='mora-user', Class='save')) + TD('0', Id='mora-need', Class='good')) t_own <= TR(TD(IMG(src=f"img/xp.png", alt=strings['xp'], title=strings['xp'], loading="lazy")) + TD('0', Id='xp-total') + TD(INPUT(Type='number', min='0', step="1", value='0', Id='xp-user', Class='save')) + TD('0', Id='xp-need', Class='good')) t_own <= TR(TD(IMG(src=f"img/xp_sub_1.png", alt=strings['xp'], title=strings['xp'], loading="lazy")) + TD() + TD(INPUT(Type='number', min='0', step="1", value='0', Id='xp_sub_1-user', Class='save')) + TD()) t_own <= TR(TD(IMG(src=f"img/xp_sub_0.png", alt=strings['xp'], title=strings['xp'], loading="lazy")) + TD() + TD(INPUT(Type='number', min='0', step="1", value='0', Id='xp_sub_0-user', Class='save')) + TD()) doc['inventory'] <= P(strings['convert_notice']) + t_own width = 3 alt_width = 2 row = 0 prev_section = "init" t_own = TABLE(Class='borders center spacer') t_head = TR() for c in range(width): t_head <= TH(strings["item"]) + TH(strings["need"]) + TH(strings["have"]) + TH(strings["missing_"]) if c < width - 1: t_head <= TH(Class="spacer") c = 0 t_own <= t_head t_row = TR(Class='tr_odd') lookup = {0: 14, 1: 9, 2: 4, 3: 0} for section, item in ingame_order: if section != prev_section: if c % width: if lookup[c]: t_row <= TD(colspan=lookup[c], Class='notvis') t_own <= t_row t_row = TR(Class='tr_odd' if row % 2 else 'tr_even') row += 1 c = 0 if prev_section != 'init': c = 0 t_own <= TR(TD(colspan=14), Class='empty_row') prev_section = section if section in ['element_1', 'common', 'common_rare', 'wam', 'talent']: if section in ['element_1', 'wam']: if c: if lookup[c]: t_row <= TD(colspan=lookup[c], Class='notvis') t_own <= t_row t_row = TR(Class='tr_odd' if row % 2 else 'tr_even') row += 1 c = 0 t_width = alt_width else: t_width = width prev_section = 'end section' for i in range(len(strings[item])-1, -1, -1): t_td = TD(IMG(src=f"img/{item}_{i}.png", alt=strings[item][i], title=strings[item][i], loading="lazy")) + TD('0', Id=f"{item}_{i}-total") + TD(INPUT(Type='number', min='0', step="1", value='0', Id=f"{item}_{i}-user", Class='save')) + TD('0', Id=f"{item}_{i}-need") c += 1 t_row <= t_td if not (c % t_width): if lookup[c]: t_row <= TD(colspan=lookup[c] if t_width == 3 else lookup[c] + 1, Class='notvis') t_own <= t_row t_row = TR(Class='tr_odd' if row % 2 else 'tr_even') c = 0 row += 1 elif c % width < width: t_row <= TD() else: # section in ['boss', 'element_2', 'local', 'special']: t_td = TD(IMG(src=f"img/{item}.png", alt=strings[item], title=strings[item], loading="lazy")) + TD('0', Id=f"{item}-total") + TD(INPUT(Type='number', min='0', step="1", value='0', Id=f"{item}-user", Class='save')) + TD('0', Id=f"{item}-need") c += 1 t_row <= t_td if not (c % width): if lookup[c]: t_row <= TD(colspan=lookup[c], Class='notvis') t_own <= t_row t_row = TR(Class='tr_odd' if row % 2 else 'tr_even') row += 1 c = 0 elif c % width < width: t_row <= TD() if c % width: if lookup[c]: t_row <= TD(colspan=lookup[c], Class='notvis') t_own <= t_row doc['inventory'] <= t_own b_reset = BUTTON(strings["reset_all_data"], Id='reset_all') doc["reset"] <= b_reset b_reset = BUTTON(strings["reset_character"], Id='reset_character') doc["reset"] <= b_reset b_reset = BUTTON(strings["reset_inventory"], Id='reset_inventory') doc["reset"] <= b_reset
def init_information(): order_index = [x[1] for x in ingame_order] data = {k: set() for k in order_index} char_data = {} # iterate all the characters and add items they need to data for character in characters: char_data[character] = set() for field in characters[character]: # keys with subkeys if field in ['ascension', 'talent']: for key in characters[character][field]: val = characters[character][field][key] if val in data: data[val].add(character) char_data[character].add(val) else: val = characters[character][field] if val in data: data[val].add(character) char_data[character].add(val) trav_data = {} # do the same thing for traveler talents for tal_group in traveler: trav_data[tal_group] = set() for row in traveler[tal_group]: for field in row: trav_data[tal_group].add(row[field]) for t_char in traveler_talent: char_data[t_char] = set() for talent in traveler_talent[t_char]: for item in trav_data[talent]: data[item].add(t_char) char_data[t_char].add(item) # create a table with the character->item dictionary we just built t_chars = TABLE(TR(TH(strings["character"]) + TH(strings["item_s"])), Class='borders body') for char in sorted(char_data): item_set = {} for item in char_data[char]: if item in strings: i_idx = order_index.index(item) if isinstance(strings[item], list): c = len(strings[item]) - 1 item_set[i_idx] = [f"{item}_{c}", strings[item][c]] else: item_set[i_idx] = [item, strings[item]] i = (IMG(src=f"img/{item_set[x][0]}.png", alt=item_set[x][1], title=item_set[x][1], loading="lazy") for x in sorted(item_set)) c = IMG(src=f"img/{char}.png", alt=strings[char], title=strings[char], loading="lazy") t_chars <= TR(TD(c) + TD(i)) # create a table with the item->character dictionary we just built t_items = TABLE(TR(TH(strings["item_s"]) + TH(strings["character_s"])), Class='borders body') for typ, item in ingame_order: if item in data: if data[item]: # only show items used by a character if isinstance(strings[item], list): i = (IMG(src=f"img/{item}_{c}.png", alt=strings[item][c], title=strings[item][c], loading="lazy") for c in range(len(strings[item]))) else: i = IMG(src=f"img/{item}.png", alt=strings[item], title=strings[item], loading="lazy") c = (IMG(src=f"img/{x}.png", alt=strings[x], title=strings[x], loading="lazy") for x in sorted(data[item])) t_items <= TR(TD(i) + TD(c)) doc['information'] <= SECTION(P(strings['character_mats']) + t_chars + BR()+ BR() + t_items, Class='grind')
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
# This is done to have this function usable in js window.click = click window.promote_pawn = promote_pawn #################################################################### # Create table s = TABLE(id='squares') p = TABLE(id='pieces') colors = [(0, 0, 0), (255, 255, 255)] for row in range(8): sr = TR() pr = TR() color = row % 2 == 0 for column in range(8): _id = str(row * 8 + column) sr <= TD(id=_id, style={'background-color': f'rgb{colors[int(color)]}'}) pr <= TD(id=_id, onclick=f"click('{_id}');") color = not color s <= sr p <= pr document['squares-div'] <= s
def update_character(): char_tracker = {} for val in grind_table_state['total']: grind_table_state['total'][val] = 0 for char in grind_table_state['checked']: update_per_character(char, char_tracker) # Get a list of all chosen artifacts so we know what to farm for elt in doc.get(selector=f'.saved_arti'): char = elt.id.split('-')[1] if char in grind_table_state['checked'] and char in grind_table_state[ 'arti_check']: add_value_set(char_tracker, elt.id.split('-')[-1], elt.id.split('-')[1]) # adjust xp totals to units of their base type. grind_table_state['total']['mora'] += grind_table_state['total'][ 'xp'] // 5 + grind_table_state['total']['wep_xp'] // 10 grind_table_state['total']['xp'] = round( grind_table_state['total']['xp'] / 20000, 2) grind_table_state['total']['wep_xp'] = round( grind_table_state['total']['wep_xp'] / 10000, 2) # Build up and display farm table data = { 'any': { 0: {}, 20: {}, 40: {}, 60: {} }, 'mon': {}, 'tue': {}, 'wed': {}, 'thu': {}, 'fri': {}, 'sat': {}, 'sun': {}, } resin = { 'stormterror': 60, 'wolf_of_the_north': 60, 'golden_house': 60, 'azhdaha': 60, '60_boss': 60, '40_boss': 40, 'anemo_hypostasis': 40, 'cryo_regisvine': 40, 'cryo_hypostasis': 40, 'electro_hypostasis': 40, 'geo_hypostasis': 40, 'oceanid': 40, 'pyro_regisvine': 40, 'primo_geovishap': 40, 'maguu_kenki': 40, 'pyro_hypostasis': 40, 'perpetual_mechanical_array': 40, 'clear_pool_and_mountain_cavern': 20, 'domain_of_guyun': 20, 'hidden_palace_of_zhou_formula': 20, 'midsummer_courtyard': 20, 'valley_of_remembrance': 20, 'peak_of_vindagnyr': 20, 'court_of_flowing_sand': 20, 'violet_court': 20, 'momiji_dyed_court': 20, 'ridge_watch': 20, 'xp_leyline': 20, 'mora_leyline': 20 } arti_keys = [('arti', x) for x in char_tracker if x not in ingame_order] for section, item in [('base', 'xp'), ('base', 'wep_xp'), ('base', 'mora')] + ingame_order + arti_keys: if item in char_tracker: for day in farming_data[item]['when']: for loc in farming_data[item]['where']: if day == 'any': cost = 0 if loc not in resin else resin[loc] if loc not in data[day][cost]: data[day][cost][loc] = [] data[day][cost][loc].append(item) else: if loc not in data[day]: data[day][loc] = [] data[day][loc].append(item) d = SECTION(Class='grind') for day in ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']: d <= H2([strings[day]]) t = TABLE(TR( TH(strings["location"]) + TH(strings["item_s"]) + TH(strings["character_s"])), Class='borders body') empty = True for loc in sorted(data[day]): char_set = set() item_set = {} for x in data[day][loc]: if isinstance(strings[x], str) and grind_table_state['total'][ x] - grind_table_state['user'][x] > 0: char_set.update(char_tracker[x]) item_set[x] = { 'text': strings[x], 'count': readable_number(grind_table_state['total'][x] - grind_table_state['user'][x]) } else: for i in range(len(strings[x])): if grind_table_state['total'][ f"{x}_{i}"] - grind_table_state['user'][ f"{x}_{i}"] > 0: char_set.update(char_tracker[x]) item_set[f"{x}_{i}"] = { 'text': strings[x][i], 'count': readable_number( grind_table_state['total'][f"{x}_{i}"] - grind_table_state['user'][f"{x}_{i}"]) } if item_set: empty = False v = (DIV(IMG(src=f"img/{x}.png", alt=item_set[x]['text'], title=item_set[x]['text'], loading="lazy") + DIV(item_set[x]['count'], Class='bottom-right'), Class='container') for x in item_set) c = (IMG(src=f"img/{x}.png", alt=strings[x], title=strings[x], loading="lazy") for x in sorted(char_set)) t <= TR(TD(strings[loc], Class="location") + TD(v) + TD(c)) if empty: t <= TR( TD(strings['nothing'], Class="location") + TD(strings['nothing']) + TD(strings['nothing'])) d <= t if any([data['any'][x] for x in [0, 20, 40, 60]]): d <= H2([strings['any']]) for cost in [0, 20, 40, 60]: if data['any'][cost]: d <= H3(f"{cost} {strings['resin']}") t = TABLE(TR( TH(strings["location"]) + TH(strings["item_s"]) + TH(strings["character_s"])), Class='borders body') for loc in sorted(data['any'][cost]): char_set = set() item_set = {} for x in data['any'][cost][loc]: if isinstance(strings[x], str): if x in grind_table_state['total']: if 'xp' == x: val = int(grind_table_state['total'][x] - grind_table_state['user'][x] - grind_table_state['user'] [f"{x}_sub_1"] / 4 - grind_table_state['user'] [f"{x}_sub_0"] / 20 + .5) elif 'wep_xp' == x: val = int(grind_table_state['total'][x] - grind_table_state['user'][x] - grind_table_state['user'] [f"{x}_sub_1"] / 5 - grind_table_state['user'] [f"{x}_sub_0"] / 25 + .5) else: val = grind_table_state['total'][ x] - grind_table_state['user'][x] if val > 0: if x in ['xp', 'wep_xp', 'mora' ] and len(char_tracker[x]) > 5: char_set.add('many') else: char_set.update(char_tracker[x]) item_set[x] = { 'text': strings[x], 'count': readable_number(val) } else: char_set.update(char_tracker[x]) item_set[x] = {'text': strings[x], 'count': ''} else: for i in range(len(strings[x])): if grind_table_state['total'][ f"{x}_{i}"] - grind_table_state[ 'user'][f"{x}_{i}"] > 0: char_set.update(char_tracker[x]) item_set[f"{x}_{i}"] = { 'text': strings[x][i], 'count': readable_number( grind_table_state['total'] [f"{x}_{i}"] - grind_table_state['user'] [f"{x}_{i}"]) } if item_set: v = (DIV( IMG(src=f"img/{x}.png", alt=item_set[x]['text'], title=item_set[x]['text'], loading="lazy") + DIV(item_set[x]['count'], Class='bottom-right'), Class='container') for x in item_set) c = (IMG(src=f"img/{x}.png", alt=strings[x], title=strings[x], loading="lazy") for x in sorted(char_set)) t <= TR( TD(strings[loc], Class="location") + TD(v) + TD(c)) d <= t doc['daily'].text = '' doc['daily'] <= d