// Copyright Epic Games, Inc. All Rights Reserved. "use strict"; import { WidgetHost } from "../util/widgets.js" //////////////////////////////////////////////////////////////////////////////// export class PageBase extends WidgetHost { constructor(parent, params) { super(parent) this._params = params; } set_title(name) { var value = document.title; if (name.length && value.length) name = value + " - " + name; document.title = name; } get_param(name, fallback=undefined) { var ret = this._params.get(name); if (ret != undefined) return ret; if (fallback != undefined) this.set_param(name, fallback); return fallback; } set_param(name, value, update=true) { this._params.set(name, value); if (!update) return value; const url = new URL(window.location); for (var [key, xfer] of this._params) url.searchParams.set(key, xfer); history.replaceState(null, "", url); return value; } reload() { window.location.reload(); } } //////////////////////////////////////////////////////////////////////////////// export class ZenPage extends PageBase { constructor(parent, ...args) { super(parent, ...args); super.set_title("zen"); this.add_branding(parent); this.generate_crumbs(); } add_branding(parent) { var root = parent.tag().id("branding"); const zen_store = root.tag("pre").id("logo").text( "_________ _______ __\n" + "\\____ /___ ___ / ___// |__ ___ ______ ____\n" + " / __/ __ \\ / \\ \\___ \\\\_ __// \\\\_ \\/ __ \\\n" + " / \\ __// | \\/ \\| | ( - )| |\\/\\ __/\n" + "/______/\\___/\\__|__/\\______/|__| \\___/ |__| \\___|" ); zen_store.tag().id("go_home").on_click(() => window.location.search = ""); root.tag("img").attr("src", "favicon.ico").id("ue_logo"); /* _________ _______ __ \____ /___ ___ / ___// |__ ___ ______ ____ / __/ __ \ / \ \___ \\_ __// \\_ \/ __ \ / \ __// | \/ \| | ( - )| |\/\ __/ /______/\___/\__|__/\______/|__| \___/ |__| \___| */ } set_title(...args) { super.set_title(...args); } generate_crumbs() { const auto_name = this.get_param("page") || "start"; if (auto_name == "start") return; const crumbs = this.tag().id("crumbs"); const new_crumb = function(name, search=undefined) { crumbs.tag(); var crumb = crumbs.tag().text(name); if (search != undefined) crumb.on_click((x) => window.location.search = x, search); }; new_crumb("home", ""); var project = this.get_param("project"); if (project != undefined) { var oplog = this.get_param("oplog"); if (oplog != undefined) { new_crumb("project", `?page=project&project=${project}`); if (this.get_param("opkey")) new_crumb("oplog", `?page=oplog&project=${project}&oplog=${oplog}`); } } new_crumb(auto_name.toLowerCase()); } }