function boot() { CTX.init(); route(); } function GET(param) { param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]" + param + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results === null) return null; else return decodeURIComponent(results[1]); } function escAttr(string) { if (string) { return string.replace(/"/g, """) } return ""; } function setTitle(title) { document.getElementsByTagName("title")[0].innerHTML = title + " — Mobilistache"; } function isHandle(handle) { if (typeof handle !== "string") { return false; } if (!handle.startsWith("@")) { return false; } return handle.split("@").length >= 3; } function splitHandle(handle) { if (!isHandle(handle)) { return null; } var parts = handle.split("@"); if (parts.length < 3) { return null; } var host = parts[parts.length -1]; var name = parts.slice(1, -1).join("@"); return ({host: host, name: name}); } function getHandle(host, name) { return "@" + name + "@" + host; } function getGroupUrl(handle) { return "./index.html?page=group&handle=" + encodeURIComponent(handle); } function getEventUrl(host, eventUuid) { return "./index.html?page=event&host=" + encodeURIComponent(host) + "&event=" + encodeURIComponent(eventUuid); } function getAddEventUrl(group) { return ("index.html?page=add-event&group=" + encodeURIComponent(group.getUsername())); } function replaceContent(parentElement, contentElement) { while (parentElement.hasChildNodes()) { parentElement.removeChild(firstChild); } parentElement.appendChild(contentElement); } class Widget { root; /** * Add this widget as a child of the given element. * @param element The element to add the widget to. */ showIn(element) { element.appendChild(this.root); } /** * Add this widget in place of the given element. * @param element The element to merge the widget into. * All attributes of the element are discarded. */ mergeInto(element) { element.parentNode.replaceChild(this.root, element); } }