def setstore(self, store): self.store = store self.container.x() self.pieces = {} for pieceletter in self.store.split(""): p = piecelettertopiece(pieceletter) if p.color == self.color: if p.kind in self.pieces: self.pieces[p.kind]["mul"] += 1 else: pcdiv = Div().pr().w(self.piecesize).h(self.piecesize) pdiv = Div().pa().cp().ac(getclassforpiece(p, self.parent.piecestyle)).w(self.piecesize).h(self.piecesize) pdivcopy = Div().pa().cp().ac(getclassforpiece(p, self.parent.piecestyle)).w(self.piecesize).h(self.piecesize) pdiv.t(0).l(0).sa("draggable", True).ae("dragstart", self.dragstartfactory(p, pdiv, pdivcopy)) pcdiv.a(pdiv) self.pieces[p.kind] = { "mul": 1, "p": p, "pcdiv": pcdiv } for pkind, pdesc in self.pieces.items(): muldiv = Div().pa().w(self.muldivsize).h(self.muldivsize).fs(self.muldivsize * 1.3).html("{}".format(pdesc["mul"])) muldiv.l(self.piecesize - self.muldivsize).t(0).ac("storemuldiv") pdesc["pcdiv"].a(muldiv) self.container.a(pdesc["pcdiv"]) return self
def __init__(self, obj): super().__init__("div") self.container = Div("diritem") for field in DIR_ITEM_FIELDS: self[field[1]] = obj[field[0]] fdiv = Div(field[1]) self[field[1] + "div"] = fdiv self.container.a(fdiv) if self.isdir: self.container.ac("isdir") self.filenamelabel = Div().html(self.filename) self.filenamediv.a([self.filenamelabel]) self.deletebutton = None if self.filename == "..": self.filenamediv.ac("parent") else: self.deletebutton = Button("Delete").ac("delete") self.isdirdiv.a(self.deletebutton) self.mtimediv.html( __new__(Date(self.mtime * 1000)).toLocaleString()) if self.isdir: self.sizediv.html("dir") else: self.editbutton = Button("Edit") self.filenamediv.a(self.editbutton) self.sizediv.html(self.size) if self.rwx: self.rwxdiv.html(self.rwx) self.a(self.container)
def __init__(self): super().__init__("div") self.messagediv = Div().disp("inline-block").pad(3).ff("monospace") self.contentdiv = Div() self.a([self.messagediv, self.contentdiv]) self.reqfenunderway = False self.reqnode = None self.requestforumgame() self.ae("mousemove", self.mousemove) self.ae("mouseup", self.mouseup) self.ae("mouseleave", self.mouseleave)
def __init__(self, args): super().__init__("div") self.BARWIDTH = args.get("barwidth", 20) self.BARSEPARATION = int(self.BARWIDTH * 1.1) self.YHEIGHT = args.get("yheight", 2) self.CLUSTER = args.get("cluster", 50) self.data = args.get("data", []) first = True for d in self.data: mind = d["min"] maxd = d["max"] if first: miny = mind maxy = maxd first = False else: if mind < miny: miny = mind if maxd > maxy: maxy = maxd miny = miny - ( miny % self.CLUSTER ) maxy = maxy - ( maxy % self.CLUSTER ) + self.CLUSTER chartwidth = self.BARSEPARATION * len(self.data) self.w(chartwidth) range = maxy - miny chartheight = range * self.YHEIGHT self.h(chartheight) self.pr().bc("#ffc") for i in range(1, range / self.CLUSTER): rt = maxy - ( i * self.CLUSTER ) yt = i * self.CLUSTER * self.YHEIGHT linediv = Div().pa().t(yt).l(0).w(chartwidth).h(1).bc("#000") ratingdiv = Div().pa().t(yt + 5).ms().html(rt) self.a([ linediv, ratingdiv ]) i = 0 for d in self.data: mind = d["min"] minr = range - ( mind - miny ) mint = minr * self.YHEIGHT maxd = d["max"] maxr = range - ( maxd - miny ) maxt = maxr * self.YHEIGHT open = d["open"] openr = range - ( open - miny ) opent = openr * self.YHEIGHT close = d["close"] closer = range - ( close - miny ) closet = closer * self.YHEIGHT xcoord = i * self.BARSEPARATION bardiv = Div().pa().t(min(opent, closet)).l(xcoord + 1).w(self.BARWIDTH).h(abs(opent - closet)).bc(cpick(opent < closet, "#f00", "#0f0")) minmaxdiv = Div().pa().t(maxt).l(xcoord + int(self.BARWIDTH / 2) - 1 + 1).w(2).h(mint - maxt).bc("#007") self.a([ minmaxdiv, bardiv ]) i += 1
def __init__(self, args={}): super().__init__("div") self.ac("dirbrowser") self.id = args.get("id", None) self.drive = args.get("drive", False) self.editclickedcallback = args.get("editclickedcallback", None) self.pathlist = [] self.listing = [] self.filesdiv = SplitPane({"controlheight": 40}) self.pathlabel = Div("pathlabel") self.createfilebutton = Button("Create file", self.createfileclicked) self.createdirbutton = Button("Create dir", self.createdirclicked) self.refreshbutton = Button("Refresh", self.refreshclicked) self.filesdiv.controlpanel.a([ self.pathlabel, self.createfilebutton, self.createdirbutton, self.refreshbutton ]) if self.drive: self.ziptocloudbutton = Button("Zip to cloud", self.ziptocloudclicked) self.unzipfromcloudbutton = Button("Unzip from cloud", self.unzipfromcloudclicked) self.filesdiv.controlpanel.a( [self.ziptocloudbutton, self.unzipfromcloudbutton]) self.filescontentdiv = Div() self.filesdiv.setcontentelement(self.filescontentdiv) self.editor = Editor() self.editor.reloadbutton.ae("mousedown", self.reloadclicked) self.editor.savebutton.ae("mousedown", self.saveclicked) self.uploader = FileUploader({ "url": "/dirbrowserupload", "accept": "*", "acceptdisplay": "file", "drive": self.drive, "dirbrowseruploadedcallback": self.dirbrowseruploadedcallback, "dirbrowsergetpathcallback": self.path, "getuid": getconn().getuid }) self.tabs = TabPane({ "id": self.id + "tabpane", "tabs": [ Tab("files", "Files", self.filesdiv), Tab("edit", "Edit", self.editor), Tab("upload", "Upload", self.uploader), ], "selected": "files" }) self.tabs.controlpanel.ac("subcontrolpanel") self.a(self.tabs) self.requestdirlist()
def buildprominput(self): promkinds = prompiecekindsforvariantkey(self.variantkey) promsq = self.dragmove.tosq.copy() dir = cpick(promsq.rank >= ( self.numranks / 2 ), -1, 1) ppks = prompiecekindsforvariantkey(self.variantkey) for ppk in ppks: fapromsq = self.flipawaresquare(promsq) pp = Piece(ppk, self.turn()) psqdiv = Div().pa().cp().zi(150).w(self.squaresize).h(self.squaresize).ac("boardpromotionsquare") psqdiv.pv(self.squarecoordsvect(fapromsq)) ppdiv = Div().pa().cp().zi(200).w(self.piecesize).h(self.piecesize).ac(getclassforpiece(pp, self.piecestyle)) ppdiv.pv(self.piececoordsvect(fapromsq)).ae("mousedown", self.prompiececlickedfactory(ppk)) self.container.a([psqdiv, ppdiv]) promsq = promsq.p(Square(0, dir))
def build(self): self.x().ac("schema") self.itemdiv = Div(["item", self.disposition]) self.valuediv = Div(["value", self.disposition]) if self.kind == "scalar": if self.disposition == "string": self.stringvalueinput = TextInput().ac("string").setText( self.value) self.stringvalueinput.ae("keyup", self.stringvalueinputchanged) self.valuediv.a(self.stringvalueinput) self.helpdiv = Div(["box", "help"]).html("?") self.copydiv = Div(["box", "copy"]).html("C").ae("mousedown", self.copydivclicked) if isdict(self.parent): self.keydiv = Div("key") self.keyinput = TextInput().ac("key").setText(self.key) self.keyinput.ae("keyup", self.keyinputchanged) self.keydiv.a(self.keyinput) self.itemdiv.a(self.keydiv) self.itemdiv.a([self.valuediv, self.helpdiv, self.copydiv]) if self.parent: self.deletediv = Div(["box", "delete" ]).html("X").ae("mousedown", self.deletedivclicked) self.itemdiv.a(self.deletediv) if iscollection(self): self.openbutton = Div("openbutton").ae("mousedown", self.openbuttonclicked) self.valuediv.a(self.openbutton) self.childsdiv = Div("childs") if self.childsopened: self.creatediv = Div("create") cc = self.createcombo self.createcombo = ComboBox().setoptions( [["create", "Create new"], ["scalar", "Scalar"], ["dict", "Dict"], ["list", "List"]], "create", self.createcombochanged).ac("createcombo") self.creatediv.a(self.createcombo) self.pastebutton = Button("Paste", self.pastebuttonpushed).ac("pastebutton") self.creatediv.a(self.pastebutton) self.childsdiv.a(self.creatediv) for child in self.childs: self.childsdiv.a(child) self.container = Div("container") self.container.a([self.itemdiv, self.childsdiv]) self.a(self.container) return self
def __init__(self, args={}): super().__init__("div") self.id = args.get("id", "doc") self.startpage = args.get("startpage", "contents") self.showcontentslink = args.get("showcontentslink", True) self.mdconv = __new__(showdown.Converter()) self.docdiv = Div("docdiv") self.srcdiv = Div("srcdiv") self.a(self.docdiv) getconn().sioreq({ "kind": "getdoc", "owner": self.id, "data": self.startpage, "switchtodoctab": False })
def build(self, text, seed): setseed(seed) self.contentdiv.x().pad(3) self.textarea = TextArea().w(1000).h(200) self.textarea.setText(text) self.controlpanel = Div() self.controlpanel.a(Button("Store", self.store)) if self.isadmin: self.contentdiv.a(self.textarea) self.contentdiv.a(self.controlpanel) self.rootnode = Forumnode( self, { "move": "startpos", "uci": None, "owner": "Wolfram_EP", "comment": "Forum game", "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "parent": None, "isadmin": self.isadmin }) self.contentdiv.a(self.rootnode) self.buildrec(self.rootnode, self.forumgame) #self.rootnode.e.scrollIntoView(True) self.parenttabpane.setscroll() self.contentdiv.sa("draggable", True).cm().ae("dragstart", self.dragstart)
def __init__(self, args = {}): super().__init__("div") self.controlheight = args.get("controlheight", 100) self.container = Div(["splitpane", "container"]) self.controlpanel = Div(["splitpane", "controlpanel"]) self.contentdiv = Div(["splitpane", "contentdiv"]) self.container.a([self.controlpanel, self.contentdiv]) self.contentelement = Div() self.minwidth = args.get("minwidth", 400) self.mincontentheight = args.get("mincontentheight", 200) self.resize(args.get("width", 600), args.get("height", 400)) self.fillwindow = args.get("fillwindow", False) if self.fillwindow: window.addEventListener("resize", self.resizetowindow) self.resizetowindow() self.a(self.container)
def drawmovearrow(self, move, args = {}): if move is None: return strokecolor = args.get("strokecolor", "#FFFF00") linewidth = args.get("linewidth", 0.2) * self.squaresize headwidth = args.get("headwidth", 0.2) * self.squaresize headheight = args.get("headheight", 0.2) * self.squaresize tomv = self.squarecoordsmiddlevect(self.flipawaresquare(move.tosq)) frommv = self.squarecoordsmiddlevect(self.flipawaresquare(move.fromsq)) if False: self.movecanvas.lineWidth(linewidth) self.movecanvas.strokeStyle(strokecolor) self.movecanvas.fillStyle(strokecolor) self.movecanvas.drawline(frommv, tomv) dv = Vect(headwidth, headheight) self.movecanvas.fillRect(tomv.m(dv), tomv.p(dv)) if not ( move.prompiece.isempty() ): pf = 4 dvp = Vect(linewidth * pf, linewidth * pf) move.prompiece.color = self.turn() ppdiv = Div().pa().cp().ac(getclassforpiece(move.prompiece, self.piecestyle)).w(linewidth * 2 * pf).h(linewidth * 2 * pf) ppdiv.pv(tomv.m(dvp)) self.piececanvashook.a(ppdiv) arrow = Arrow(frommv, tomv, { "linewidth": linewidth, "pointwidth": headheight * 4, "pointheight": headheight * 4, "color": strokecolor }) self.arrowdiv.a(arrow)
def buildconfigdiv(self): self.configdiv = Div() self.configdiv.a(Button("Serialize", self.serializeconfig)) self.configdiv.a(Button("Store cloud", self.storecloud)) self.configdiv.a(Button("Retrieve cloud", self.retrievecloud)) self.configschema = Schema(self.schemaconfig) self.configdiv.a(self.configschema)
def setmybots(self, obj): botprofiles = obj["mybots"] self.botresultdiv.x() __pragma__("jsiter") for id in botprofiles: botprofile = botprofiles[id] self.botresultdiv.a(Div().html("{} {}".format( botprofile["username"], cpick(botprofile["online"], "online", "offline"))).fs(25).pad(5)) self.botresultdiv.a(Div().html( "follow {} games {} last move {}".format( botprofile["nbFollowers"], botprofile["count"]["all"], botprofile["lastmoveago"])).fs(20).pad(3)) self.botresultdiv.a(Div().html("last players {}".format( botprofile["lastplayers"])).fs(20).pad(3)) __pragma__("nojsiter")
def __init__(self, key, displayname, element, clickedcallback): super().__init__("div") self.key = key self.displayname = displayname self.element = element self.clickedcallback = clickedcallback self.container = Div(["tab", "container", "noselect"]).html(displayname) self.a(self.container)
def build(self): self.x().ac("pgninfocontainer") self.tcdiv = Div().ac("pgninfotcdiv").html("{} {}".format(self.timecontrol, self.variant)) self.whitediv = Div().ac("pgninfoplayerdiv").html(self.playerlink(self.white)) self.whiteelodiv = Div().ac("pgninfoplayerelodiv").html("{} {}".format(self.whiteelo, self.whiteratingdiff)) if self.meblack(): self.whitediv.ac("pgninfotheyplayerdiv") self.blackdiv = Div().ac("pgninfoplayerdiv").html(self.playerlink(self.black)) self.blackelodiv = Div().ac("pgninfoplayerelodiv").html("{} {}".format(self.blackelo, self.blackratingdiff)) if self.mewhite(): self.blackdiv.ac("pgninfotheyplayerdiv") self.resultdiv = Div().ac("pgninforesultdiv").html(self.result) self.iddiv = Div().ac("pgninfoiddiv").html(self.id) self.iddiv.ae("mousedown", self.idclicked) mescore = self.mescore() if mescore == 1: self.ac("pgninfowhitewin") elif mescore == 0: self.ac("pgninfoblackwin") else: self.ac("pgninfodraw") self.a([self.tcdiv, self.whitediv, self.whiteelodiv, self.blackdiv, self.blackelodiv, self.resultdiv, self.iddiv]) if self.id == localStorage.getItem("pgninfo/idclicked"): self.bds("dashed").bdw("6").bdc("#00f") return self
def __init__(self, args = {}): super().__init__("div") self.container = Div("processinput") self.buttonlabel = args.get("buttonlabel", "Submit") self.entercallback = args.get("entercallback", None) self.textinput = TextInput().setentercallback(self.entercallback) self.submitbutton = Button(self.buttonlabel, self.onenter) self.container.a([self.textinput, self.submitbutton]) self.a(self.container)
def highlightsquare(self, sq, bc, op): if op == 0: return margin = self.squaresize * 0.1 hsize = self.squaresize - 2 * margin sqhdiv = self.sqhdivs[sq.hashkey()] if op > sqhdiv["cumop"]: sqhdiv["cumop"] = op sqhdiv["div"].x().a(Div().pa().t(margin).l(margin).w(hsize).h(hsize).bc(bc).op(sqhdiv["cumop"]))
def __init__(self): super().__init__("div") self.editdiv = SplitPane({"controlheight": 40}) self.pathlabel = Div("pathlabel") self.editdiv.controlpanel.a(self.pathlabel) self.reloadbutton = Button("Reload") self.savebutton = Button("Save") self.editdiv.controlpanel.a([self.reloadbutton, self.savebutton]) self.edittextarea = EditTextarea() self.editdiv.setcontentelement(self.edittextarea) self.a(self.editdiv)
def build(self): self.x() self.droparea = Div("fileuploaddroparea") self.form = Form().ac("fileuploadform") self.desc = P().ac("fileuploadp").html("Upload {}s with the file dialog or by dragging and dropping them onto the dashed region".format(self.acceptdisplay)) self.fileinput = FileInput().ac("fileuploadfileelem").setmultiple(self.multiple).setaccept(self.accept) self.fileinput.sa("id", "fileinputelement") self.fileinput.ae("change", self.fileinputchanged) self.button = Label().ac("fileuploadbutton").sa("for", "fileinputelement").html("Select some {}s".format(self.acceptdisplay)) self.form.a([self.desc, self.fileinput, self.button]) self.droparea.a(self.form) for eventname in ["dragenter", "dragover", "dragleave", "drop"]: self.droparea.ae(eventname, self.preventdefaults) for eventname in ["dragenter", "dragover"]: self.droparea.ae(eventname, self.highlight) for eventname in ["dragleave", "drop"]: self.droparea.ae(eventname, self.unhighlight) self.droparea.ae("drop", self.handledrop) self.info = Div("fileuploadinfo") self.infoitems = [] self.a([self.droparea, self.info])
def __init__(self, args): super().__init__("div") self.show = args.get("show", False) self.parent = args.get("parent", BasicBoard({})) self.store = args.get("store", "") self.color = args.get("color", WHITE) self.container = args.get("containerdiv", Div()) self.container.ac("noselect") self.piecesize = args.get("piecesize", self.parent.piecesize) self.muldivsize = int(self.piecesize / 2) self.a(self.container) self.setstore(self.store)
def build(self): self.root.innerHTML = "" self.buildconfigdiv() self.signupdiv = Div() if self.authenabled: self.buildsignupdiv() self.profiletab = Tab("profile", "Profile", self.signupdiv) self.mainelement = TabPane({ "id": "maintabpane", "fillwindow": True, "tabs": [ Tab("main", "Main", Div("contentplaceholder").html("Main.")), Tab("config", "Config", self.configdiv), Tab("upload", "Upload", FileUploader({"url": "/upload"})), Tab("log", "Log", Div("contentplaceholder").html("Log.")), self.profiletab, Tab("about", "About", Div("contentplaceholder").html("About.")) ], "selected": "upload" }) self.root.appendChild(self.mainelement.e)
def buildsignupdiv(self): self.signupdiv = Div() self.signupmaildiv = Div("signupmaildiv") self.emaillabel = Span().html("Email:") self.emailinput = TextInput().ac("profiletextinput").w(250) self.passwordlabel = Span().html("Password:"******"profiletextinput").w(100) self.signinbutton = Button("Sign in", self.signincallback) self.signoutbutton = Button("Sign out", self.signoutcallback) self.signupbutton = Button("Sign up", self.signupcallback) self.sendverificationbutton = Button("Send verification", self.sendverificationcallback) self.resetpasswordbutton = Button("Reset password", self.resetpasswordcallback) self.userinfodiv = Div("userinfodiv") self.signupmaildiv.a([self.emaillabel, self.emailinput, self.passwordlabel, self.passwordinput, self.signinbutton, self.signoutbutton, self.signupbutton, self.sendverificationbutton, self.resetpasswordbutton]) self.userdetailsdiv = Div("userdetailsdiv") self.displaynamelabel = Span().html("Display name:") self.displaynameinput = TextInput().ac("profiletextinput").w(250) self.photourllabel = Span().html("Photo url:") self.photourlinput = TextInput().ac("profiletextinput").w(250) self.updatedetailsbutton = Button("Update details", self.updatedetailscallback) self.userdetailsdiv.a([self.displaynamelabel, self.displaynameinput, self.photourllabel, self.photourlinput, self.updatedetailsbutton]) self.photodiv = Div("photodiv") self.signupdiv.a([self.signupmaildiv, self.userdetailsdiv, self.userinfodiv, self.photodiv]) self.firebaseuidiv = Div().sa("id", "firebaseuidiv") self.signupdiv.a(self.firebaseuidiv)
def authstatechanged(self, user): self.user = user self.passwordinput.setText("") if user: self.displayName = user.displayName self.email = user.email self.emailVerified = user.emailVerified self.photoURL = user.photoURL self.isAnonymous = user.isAnonymous self.uid = user.uid self.providerData = user.providerData print("user", self.displayName, self.email) print(self.providerData) self.nameinfodiv = Div().html("name : <span class='{}'>{}</span>".format(cpick(self.displayName, "uiinfo", "uiinfored"), getelse(self.displayName,"<NA>"))).pt(5) self.emailinfodiv = Div().html("email : <span class='{}'>{}</span>".format(cpick(self.email, "uiinfo", "uiinfored"), getelse(self.email, "<NA>"))) self.verifiedinfodiv = Div().html("status : <span class='{}'>{}</span>".format(cpick(self.userverified(), "uiinfo", "uiinfored"), self.userstatusverbal())) self.photourldiv = Div().html("photo url : <span class='{}'>{}</span>".format(cpick(self.photoURL, "uiinfo", "uiinfored"), getelse(self.photoURL,"<NA>"))) self.uidinfodiv = Div().html("uid : <span class='uiinfo'>{}</span>".format(self.uid)).pb(8) self.userinfodiv.x().a([self.nameinfodiv, self.emailinfodiv, self.verifiedinfodiv, self.photourldiv, self.uidinfodiv]) self.emailinput.setText(self.email) self.displaynameinput.setText(self.displayName) self.photourlinput.setText(self.photoURL) self.photodiv.x() if self.photoURL: self.photodiv.html("<img src='{}'></img>".format(self.photoURL)) else: print("no user") self.userinfodiv.x().a([ Div().html("Please sign up or sign in !"), Button("Sign in anonymously", self.signinanonymously()) ]) self.setprofiletab() self.userinfodiv.fs(cpick(self.user, 10, 14))
def __init__(self, args = {}): super().__init__("div") self.text = args.get("text", "") self.kind = args.get("kind", "normal") self.prompt = args.get("prompt", None) self.container = Div("logitem") self.container.ac(self.kind) self.promptspan = Span().ac("prompt") if self.prompt: self.promptspan.html(self.prompt) self.textspan = Span().html(escapeHTML(self.text)).ac(self.kind) self.container.a([self.promptspan, self.textspan]) self.a(self.container)
def buildsquares(self): self.container.x() self.sqdivs = {} self.sqhdivs = {} for sq in self.squarelist(): sqclass = cpick(self.islightsquare(sq), "boardsquarelight", "boardsquaredark") sqdiv = Div().ac(["boardsquare", sqclass]).w(self.squaresize).h(self.squaresize) sqhdiv = Div().pa().w(self.squaresize).h(self.squaresize) self.sqdivs[sq.hashkey()] = sqdiv self.sqhdivs[sq.hashkey()] = { "div": sqhdiv, "cumop": 0.0 } fasq = self.flipawaresquare(sq) sqdiv.pv(self.squarecoordsvect(fasq)) sqhdiv.pv(self.squarecoordsvect(fasq)) sqdiv.ae("dragover", self.piecedragoverfactory(sq)) sqdiv.ae("drop", self.piecedropfactory(sq)) sqhdiv.ae("dragover", self.piecedragoverfactory(sq)) sqhdiv.ae("drop", self.piecedropfactory(sq)) self.container.a([sqdiv, sqhdiv]) p = self.getpieceatsquare(sq) if p.ispiece(): pdiv = Div().ac("boardpiece").w(self.piecesize).h(self.piecesize).pv(self.piececoordsvect(fasq)) pdiv.ac(getclassforpiece(p, self.piecestyle)).sa("draggable", True) pdiv.ae("dragstart", self.piecedragstartfactory(sq, pdiv)) pdiv.ae("drag", self.piecedragfactory()) pdiv.ae("dragend", self.piecedragendfactory(sq, pdiv)) pdiv.ae("dragover", self.piecedragoverfactory(sq)) pdiv.ae("drop", self.piecedropfactory(sq)) pdiv.zi(10) if self.variantkey == "threeCheck": if ( p.kind == "k" ): mul = self.getthreelifesforcolor(p.color) lifesdiv = Div().pa().t(- self.squaresize / 10).l(self.squaresize / 2 + self.squaresize / 10).w(self.squaresize / 2).h(self.squaresize / 2) lifesdiv.ac("boardthreechecklifesdiv").fs(self.squaresize / 1.5).html("{}".format(mul)) lifesdiv.c(["#ff0", "#ff0"][p.color]) pdiv.a(lifesdiv) self.container.a(pdiv)
def build(self): self.configsplitpane = SplitPane({"controlheight": 50}) self.configdiv = Div("largesheet") self.configsplitpane.controlpanel.a([ Button("Serialize config", self.serializeconfig).ac("controlbutton"), Button("Serialize localstorage", self.serializelocalstorage).ac("controlbutton"), Button("Sync localstorage", self.synclocalstorage).ac("controlbutton") ]) self.configsplitpane.controlpanel.ac("subcontrolpanel") self.configschema = Schema(self.schemaconfig) self.configdiv.a(self.configschema) self.configsplitpane.setcontentelement(self.configdiv) self.x().a(self.configsplitpane)
def build(self): self.root.innerHTML = "" self.owners["config"] = self.config if self.dodirbrowser: self.maindirbrowser = DirBrowser({"id": "maindirbrowser"}) self.owners["maindirbrowser"] = self.maindirbrowser else: self.maindirbrowser = Div() if self.dodrive: self.drive = DirBrowser({ "id": "drive", "drive": True, "editclickedcallback": self.driveeditclickedcallback }) self.owners["drive"] = self.drive else: self.drive = Div() self.createbotdiv() if self.doboard: self.mainboard = Board({ "dobook": self.dobook, "dostoredanalysis": self.dostoredanalysis, "dostoredauto": self.dostoredauto, "dogames": self.dogames, "setposinfo": self.setposinfo, "dogamepreview": self.dogamepreview, "background": self.boardbackground, "autoanalysisdelay": self.autoanalysisdelay, "maxgames": self.maxgames, "gamesfilter": self.gamesfilter, "analysispvlength": self.analysispvlength }) self.mainboard.setusername(self.username, self.usertoken) self.mainboard.tabpane.controlpanel.ac("subcontrolpanel") self.owners["mainboard"] = self.mainboard else: self.mainboard = Div() if self.dodocs: self.doc = Doc() self.srcdiv = self.doc.srcdiv self.owners["doc"] = self.doc else: self.doc = Div() self.srcdiv = Div() if self.doabout: self.about = Doc({ "id": "about", "startpage": "about", "showcontentslink": False }) self.owners["about"] = self.about else: self.about = Div() if self.isadmin: self.processpane = ProcessPane( {"configsch": self.config.getpath("processes")}) self.processpane.processtabpane.controlpanel.ac("subcontrolpanel") else: self.processpane = Div("featureplaceholder").html( "Admin only feature.") self.forumgametab = Tab( "forumgame", "Forum game", Div("featureplaceholder").html("Forum game disabled.")) if self.doforumgame: self.forumgame = Forumgame() self.forumgame.mainboard = self.mainboard self.owners["forumgame"] = self.forumgame self.forumgametab = Tab("forumgame", "Forum game", self.forumgame) self.tabs = TabPane({ "id": "maintabpane", "fillwindow": True, "tabs": [ Tab("config", "Config", self.config), Tab("upload", "Upload", FileUploader({"url": "/upload"})), Tab("board", "Board", self.mainboard), self.forumgametab, Tab("process", "Process", self.processpane), Tab("dirbrowser", "Dirbrowser", self.maindirbrowser), Tab("drive", "Drive", self.drive), Tab("bots", "Bots", self.botdiv), Tab("doc", "Doc", self.doc), Tab("src", "Src", self.srcdiv), Tab("log", "Log", getconn().log), getconn().profiletab, Tab("about", "About", self.about) ], "selected": "drive" }) self.root.appendChild(self.tabs.e) qseltab = queryparams.get("tab", None) if qseltab: self.tabs.selectbykey(qseltab)
def createbotdiv(self): self.botdiv = Div() self.botresultdiv = Div() self.botdiv.a(Button("Request bots", self.requestbots).mar(10)) self.botdiv.a(Hlink("/bots", "Bots page")) self.botdiv.a(self.botresultdiv)
def build(self, gamesan = None): self.bestmoveuci = self.infoi["bestmoveuci"] self.bestmovesan = self.infoi["bestmovesan"] self.scorenumerical = self.infoi["scorenumerical"] self.pvsan = self.infoi["pvsan"] self.pvsans = self.pvsan.split(" ") if len(self.pvsans) > ( self.pvlength + 1 ): self.pvsans = self.pvsans[0:self.pvlength + 1] if len(self.pvsans) > 1: self.pvsans = self.pvsans[1:] self.showpv = " ".join(self.pvsans) self.pvpgn = self.infoi["pvpgn"] self.depth = self.infoi["depth"] self.nps = self.infoi["nps"] self.container = Div().ac("multipvinfocontainer") self.idiv = Div().ac("multipvinfoi").html("{}.".format(self.i)) self.bestmovesandiv = Div().ac("multipvinfobestmovesan").html(self.bestmovesan) if gamesan == self.bestmovesan: self.bestmovesandiv.bc("#fbf") self.bestmovesandiv.ae("mousedown", self.bestmovesanclickedfactory(self.bestmoveuci)) self.scorenumericaldiv = Div().ac("multipvinfoscorenumerical").html("{}".format(scoreverbal(self.effscore()))).cp() self.scorenumericaldiv.ae("mousedown", self.bestmovesanclickedfactory(self.bestmoveuci, True)) self.bonussliderdiv = Div().ac("multipvinfobonussliderdiv") self.bonusslider = Slider().setmin(-500).setmax(500).ac("multipvinfobonusslider").sv(self.scorebonus()) self.bonusslider.ae("change", self.bonussliderchanged) self.bonussliderdiv.a(self.bonusslider) self.depthdiv = Div().ac("multipvinfodepth").html("{}".format(self.depth)) self.miscdiv = Div().ac("multipvinfomisc").html("nps {}".format(self.nps)) self.traindiv = Div().ac("multipvinfomisc").w(100) metrainweight = self.infoi["metrainweight"] hasmetrain = False if not metrainweight: metrainweight = "0" opptrainweight = self.infoi["opptrainweight"] hasopptrain = False if not opptrainweight: opptrainweight = "0" try: if int(metrainweight) > 0: hasmetrain = True if int(opptrainweight) > 0: hasopptrain = True except: pass if hasmetrain and hasopptrain: self.trainbc = "#00f" elif hasmetrain: self.trainbc = "#0f0" elif hasopptrain: self.trainbc = "#f00" else: self.trainbc = "inherit" self.metrainweight = int(metrainweight) self.opptrainweight = int(opptrainweight) self.avgtrainweight = ( self.metrainweight + self.opptrainweight ) / 2.0 self.trainop = self.avgtrainweight / 10.0 self.metraincombo = ComboBox().setoptions(TRAIN_OPTIONS, metrainweight, self.traincombochanged) self.opptraincombo = ComboBox().setoptions(TRAIN_OPTIONS, opptrainweight, self.traincombochanged) self.traindiv.a([self.metraincombo, self.opptraincombo]) self.pvdiv = Div().ac("multipvinfopv").html(self.showpv).c("#070").fw("bold") self.container.a([self.idiv, self.bestmovesandiv, self.scorenumericaldiv, self.bonussliderdiv, self.traindiv, self.depthdiv, self.pvdiv]) self.container.bc(self.trainbc) self.bestmovesandiv.c(scorecolor(self.effscore())) self.scorenumericaldiv.c(scorecolor(self.effscore())) self.x().a(self.container)
def build(self): self.sectioncontainer = Div().ac("boardsectioncontainer").w(self.outerwidth) self.sectioncontainer.bci(self.background) self.outercontainer = Div().ac("boardoutercontainer").w(self.outerwidth).h(self.outerheight) self.outercontainer.bci(self.background) self.container = Div().ac("boardcontainer").w(self.width).h(self.height).t(self.margin).l(self.margin) self.container.bci(self.background) self.outercontainer.a(self.container) self.buildsquares() self.turndiv = Div().pa().w(self.turndivsize).h(self.turndivsize).bc(cpick(self.iswhitesturn(), "#fff", "#000")) if self.variantkey == "racingKings": self.turndiv.t(cpick(self.flip, 0, self.outerheight - self.turndivsize)) if xor(self.isblacksturn(), self.flip): self.turndiv.l(0) else: self.turndiv.l(self.outerwidth - self.turndivsize) else: self.turndiv.l(self.outerwidth - self.turndivsize).t(cpick(xor(self.isblacksturn(), self.flip), 0, self.outerheight - self.turndivsize)) self.outercontainer.a(self.turndiv) if self.promoting: self.buildprominput() self.container.ae("mousedown", self.promotecancelclick) self.fentext = TextInput({}).w(self.width).fs(10).setText(self.fen) self.fentext.changecallback = self.fentextchanged self.fendiv = Div().ac("boardfendiv").h(self.fendivheight).a(self.fentext) if self.variantkey == "crazyhouse": self.whitestorediv = Div().ac("boardstorediv").h(self.squaresize).w(self.outerwidth) self.whitestorediv.bci(self.background) self.blackstorediv = Div().ac("boardstorediv").h(self.squaresize).w(self.outerwidth) self.blackstorediv.bci(self.background) self.whitestore = PieceStore({ "show": self.show, "parent": self, "color": WHITE, "store": self.crazyfen, "containerdiv": self.whitestorediv }) self.blackstore = PieceStore({ "show": self.show, "parent": self, "color": BLACK, "store": self.crazyfen, "containerdiv": self.blackstorediv }) if self.flip: self.sectioncontainer.a([self.whitestorediv, self.outercontainer, self.blackstorediv]) else: self.sectioncontainer.a([self.blackstorediv, self.outercontainer, self.whitestorediv]) else: self.sectioncontainer.a([self.outercontainer]) if self.showfen: self.sectioncontainer.a(self.fendiv) self.x().a(self.sectioncontainer) self.movecanvas = Canvas(self.width, self.height).pa().t(0).l(0) self.movecanvashook = Div().pa().t(0).l(0).zi(5).op(0.5) self.piececanvashook = Div().pa().t(0).l(0).zi(11).op(0.5) self.arrowdiv = Div().pa() self.container.a([self.movecanvashook, self.arrowdiv, self.piececanvashook]) self.movecanvashook.a(self.movecanvas) self.buildgenmove() return self