def world_online(pageContext): doc = pageContext.htmldoc doc.newline() world = pageContext.get_selected_world() after = int(time.time()) - 300 #after = 0 onlineChars = dbiface.get_online_chars(after, world=world) doc.write("There are {0} players online.".format(len(onlineChars))) onlineChars.sort(key=lambda x: int(x["level"]), reverse=True) with doc.open_tag("table"): with doc.open_tag("tr"): doc.add_tag("th", "Name") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") if not world: doc.add_tag("th", "World") for char in onlineChars: doc.newline() with doc.open_tag("tr"): doc.add_tag("td", char_link(char["name"])) for field in ("level", "vocation"): doc.add_tag("td", data=str(char[field])) doc.add_tag("td", pageContext.guild_link(char["guild"])) if not world: doc.add_tag("td", char["world"])
def world_online(doc, pageContext): doc.newline() world = pageContext.get_selected_world() #after = update.next_tibiacom_whoisonline_update() - 300 onlineChars = list(dbiface.get_online_chars(world=world)) #doc.write("This page is still being optimized.<br>") doc.write("There are {0} players online on the worlds you have selected.".format(len(onlineChars))) onlineChars.sort(key=lambda x: int(x["level"]), reverse=True) with stattab_table_tag(doc.open_tag): with doc.open_tag("tr"): doc.add_tag("th", "Name") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") if not world: doc.add_tag("th", "World") rowClass = stattab_row_class() for char in onlineChars: doc.newline() rowAttrs = {"class": rowClass.next()} if char["level"] < 45: rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs): doc.add_tag("td", char_link(char["name"])) for field in ("level", "vocation"): doc.add_tag("td", data=str(char[field])) doc.add_tag("td", pageContext.guild_link(char["guild"])) if not world: doc.add_tag("td", char["world"])
def world_online(doc, pageContext): doc.newline() world = pageContext.get_selected_world() #after = update.next_tibiacom_whoisonline_update() - 300 onlineChars = list(dbiface.get_online_chars(world=world)) #doc.write("This page is still being optimized.<br>") doc.write( "There are {0} players online on the worlds you have selected.".format( len(onlineChars))) onlineChars.sort(key=lambda x: int(x["level"]), reverse=True) with stattab_table_tag(doc.open_tag): with doc.open_tag("tr"): doc.add_tag("th", "Name") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") if not world: doc.add_tag("th", "World") rowClass = stattab_row_class() for char in onlineChars: doc.newline() rowAttrs = {"class": rowClass.next()} if char["level"] < 45: rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs): doc.add_tag("td", char_link(char["name"])) for field in ("level", "vocation"): doc.add_tag("td", data=str(char[field])) doc.add_tag("td", pageContext.guild_link(char["guild"])) if not world: doc.add_tag("td", char["world"])