');
+ button.on('click', function () { onNewRegexRow(formdiv) });
+ formdiv.append(button);
+
+ // display the existing spawnmap
+ for( var id in spawnmap ) {
+ var div = $("
");
+ displayRow(formdiv, div, spawnmap[id]["r"], spawnmap[id]["t"] );
+ }
+
+ parentdiv.append('
Message Routing:
');
+ parentdiv.append(formdiv);
+ }
+
+ //
+ // onText -- catch Text before it is routed by the goldenlayout router
+ // then test our list of regexes on the given text to see if it matches.
+ // If it does, rewrite the Text Type to be our tag value instead.
+ //
+ var onText = function (args, kwargs) {
+ var div = $("
" + args[0] + "
");
+ var txt = div.text();
+ for( var id in spawnmap ) {
+ var regex = spawnmap[id]["r"];
+ if ( txt.match(regex) != null ) {
+ kwargs['type'] = spawnmap[id]["t"];
+ }
+ }
+ return false;
+ }
+
+
+ //
+ // OnKeydown -- if the Options window is open, capture focus
+ //
+ var onKeydown = function(evnt) {
+ return ignoreDefaultKeydown;
+ }
+
+
+ //
+ // init
+ //
+ var init = function () {
+ var ls_spawnmap = localStorage.getItem( "evenniaMessageRoutingSavedState" );
+ if( ls_spawnmap ) {
+ spawnmap = JSON.parse(ls_spawnmap);
+ for( var id in spawnmap ) {
+ window.plugins["goldenlayout"].addKnownType( spawnmap[id]["t"] );
+ }
+ }
+
+ console.log('Client-Side Message Routing plugin initialized');
+ }
+
+ return {
+ init: init,
+ onOptionsUI: onOptionsUI,
+ onText: onText,
+ onKeydown: onKeydown,
+ }
+})();
+window.plugin_handler.add("spawns", spawns);
diff --git a/evennia/web/webclient/static/webclient/js/plugins/options2.js b/evennia/web/webclient/static/webclient/js/plugins/options2.js
new file mode 100644
index 0000000000..eb3bc31bc2
--- /dev/null
+++ b/evennia/web/webclient/static/webclient/js/plugins/options2.js
@@ -0,0 +1,184 @@
+/*
+ * Options 2.0
+ * REQUIRES: goldenlayout.js
+ */
+let options2 = (function () {
+
+ var options_container = null ;
+
+ //
+ // When the user changes a setting from the interface
+ var onOptionCheckboxChanged = function (evnt) {
+ var name = $(evnt.target).data("setting");
+ var value = $(evnt.target).is(":checked");
+ options[name] = value;
+ Evennia.msg("webclient_options", [], options);
+ }
+
+ //
+ // Callback to display our basic OptionsUI
+ var onOptionsUI = function (parentdiv) {
+ var checked;
+
+ checked = options["gagprompt"] ? "checked='checked'" : "";
+ var gagprompt = $( [ "
"
+ ].join("") );
+
+ checked = options["notification_popup"] ? "checked='checked'" : "";
+ var notifypopup = $( [ "
"
+ ].join("") );
+
+ checked = options["notification_sound"] ? "checked='checked'" : "";
+ var notifysound = $( [ "
"
+ ].join("") );
+
+ gagprompt.on("change", onOptionCheckboxChanged);
+ notifypopup.on("change", onOptionCheckboxChanged);
+ notifysound.on("change", onOptionCheckboxChanged);
+
+ parentdiv.append(gagprompt);
+ parentdiv.append(notifypopup);
+ parentdiv.append(notifysound);
+ }
+
+
+ //
+ // Create and register the "options" golden-layout component
+ var createOptionsComponent = function () {
+ var myLayout = window.plugins["goldenlayout"].getGL();
+
+ myLayout.registerComponent( "options", function (container, componentState) {
+ var plugins = window.plugins;
+ options_container = container.getElement();
+
+ // build the buttons
+ var div = $("
");
+
+ for( let plugin in plugins ) {
+ if( "onOptionsUI" in plugins[plugin] ) {
+ var card = $("
");
+ var body = $("
");
+
+ plugins[plugin].onOptionsUI( body );
+
+ card.append(body);
+ card.appendTo( div );
+ }
+ }
+
+ div.appendTo( options_container );
+ });
+ }
+
+
+ // handler for the "Options" button
+ var onOpenCloseOptions = function () {
+ var optionsComponent = {
+ title: "Options",
+ type: "component",
+ componentName: "options",
+ componentState: {
+ },
+ };
+
+ // Create a new GoldenLayout tab filled with the optionsComponent above
+ var myLayout = window.plugins["goldenlayout"].getGL();
+ if( ! options_container ) {
+ // open new optionsComponent
+ var main = myLayout.root.getItemsByType("stack")[0].getActiveContentItem();
+
+ myLayout.on( "tabCreated", function( tab ) {
+ if( tab.contentItem.componentName == "options" ) {
+ tab
+ .closeElement
+ .off("click")
+ .click( function () {
+ options_container = null;
+ tab.contentItem.remove();
+ });
+ options_container = tab.contentItem;
+ }
+ });
+ main.parent.addChild( optionsComponent );
+ } else {
+ options_container.remove();
+ options_container = null;
+ }
+ }
+
+ // Public
+
+ //
+ // Called when options settings are sent from server
+ var onGotOptions = function (args, kwargs) {
+ var addKnownType = window.plugins["goldenlayout"].addKnownType;
+
+ $.each(kwargs, function(key, value) {
+ options[key] = value;
+
+ // for "available_server_tags", addKnownType for each value ["tag1", "tag2", ... ]
+ if( (key === "available_server_tags") && addKnownType ) {
+ $.each( value, addKnownType );
+ }
+ });
+ }
+
+ //
+ // Called when the user logged in
+ var onLoggedIn = function (args, kwargs) {
+ Evennia.msg("webclient_options", [], {});
+ }
+
+ //
+ // Display a "prompt" command from the server
+ var onPrompt = function (args, kwargs) {
+ // display the prompt in the output window if gagging is disabled
+ if( options["gagprompt"] == false ) {
+ plugin_handler.onText(args, kwargs);
+ }
+
+ // don't claim this Prompt as completed.
+ return false;
+ }
+
+ //
+ //
+ var init = function() {
+ var optionsbutton = $("");
+ $("#toolbar").append( optionsbutton );
+ options["gagprompt"] = true;
+ options["notification_popup"] = true;
+ options["notification_sound"] = true;
+ }
+
+ //
+ //
+ var postInit = function() {
+ // Are we using GoldenLayout?
+ if( window.plugins["goldenlayout"] ) {
+ createOptionsComponent();
+
+ $("#optionsbutton").bind("click", onOpenCloseOptions);
+ }
+ console.log("Options 2.0 Loaded");
+ }
+
+ return {
+ init: init,
+ postInit: postInit,
+ onGotOptions: onGotOptions,
+ onLoggedIn: onLoggedIn,
+ onOptionsUI: onOptionsUI,
+ onPrompt: onPrompt,
+ }
+})();
+window.plugin_handler.add("options2", options2);
diff --git a/evennia/web/webclient/templates/webclient/base.html b/evennia/web/webclient/templates/webclient/base.html
index 399389f15e..46353b18ad 100644
--- a/evennia/web/webclient/templates/webclient/base.html
+++ b/evennia/web/webclient/templates/webclient/base.html
@@ -76,9 +76,16 @@ JQuery available.
{% block guilib_import %}
+
-
+
+
+
+
+