mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 17:26:32 +01:00
Lint fixes
This commit is contained in:
parent
7d433b67ec
commit
9ffbb72d8c
4 changed files with 221 additions and 219 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Evennia Webclient default 'send-text-on-enter-key' IO plugin
|
||||
* Evennia Webclient default "send-text-on-enter-key" IO plugin
|
||||
*
|
||||
*/
|
||||
let defaultin_plugin = (function () {
|
||||
|
|
@ -32,7 +32,7 @@ let defaultin_plugin = (function () {
|
|||
for (var i = 0; i < lines.length; i++) {
|
||||
plugin_handler.onSend( lines[i].trim() );
|
||||
}
|
||||
inputfield.val(''); // Clear this inputfield
|
||||
inputfield.val(""); // Clear this inputfield
|
||||
event.preventDefault();
|
||||
}
|
||||
inputfield.blur();
|
||||
|
|
@ -44,7 +44,7 @@ let defaultin_plugin = (function () {
|
|||
if( inputfield.length < 1 ) {
|
||||
// Nope, focus the last .inputfield found in the DOM (or #inputfield)
|
||||
// :last only matters if multi-input plugins are in use
|
||||
inputfield = $(".inputfield:last")
|
||||
inputfield = $(".inputfield:last");
|
||||
inputfield.focus();
|
||||
if( inputfield.length < 1 ) { // non-goldenlayout backwards compatibility
|
||||
$("#inputfield").focus();
|
||||
|
|
@ -67,7 +67,7 @@ let defaultin_plugin = (function () {
|
|||
$("#inputfield").focus().trigger(e);
|
||||
});
|
||||
|
||||
console.log('DefaultIn initialized');
|
||||
console.log("DefaultIn initialized");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -75,4 +75,4 @@ let defaultin_plugin = (function () {
|
|||
onKeydown: onKeydown,
|
||||
}
|
||||
})();
|
||||
plugin_handler.add('defaultin', defaultin_plugin);
|
||||
window.plugin_handler.add("defaultin", defaultin_plugin);
|
||||
|
|
|
|||
|
|
@ -3,64 +3,64 @@
|
|||
* Golden Layout plugin
|
||||
*
|
||||
*/
|
||||
plugin_handler.add('goldenlayout', (function () {
|
||||
let goldenlayout = (function () {
|
||||
|
||||
var myLayout;
|
||||
var input_component = null;
|
||||
var known_types = ['all', 'untagged'];
|
||||
var known_types = ["all", "untagged"];
|
||||
var untagged = [];
|
||||
|
||||
var config = {
|
||||
content: [{
|
||||
type: 'column',
|
||||
type: "column",
|
||||
content: [{
|
||||
type: 'row',
|
||||
type: "row",
|
||||
content: [{
|
||||
type: 'column',
|
||||
type: "column",
|
||||
content: [{
|
||||
type: 'component',
|
||||
componentName: 'Main',
|
||||
type: "component",
|
||||
componentName: "Main",
|
||||
isClosable: false,
|
||||
tooltip: 'Main - drag to desird position.',
|
||||
tooltip: "Main - drag to desird position.",
|
||||
componentState: {
|
||||
types: 'untagged',
|
||||
update_method: 'newlines',
|
||||
types: "untagged",
|
||||
update_method: "newlines",
|
||||
},
|
||||
}]
|
||||
}],
|
||||
}, {
|
||||
type: 'component',
|
||||
componentName: 'input',
|
||||
id: 'inputComponent',
|
||||
type: "component",
|
||||
componentName: "input",
|
||||
id: "inputComponent",
|
||||
height: 12,
|
||||
tooltip: 'Input - The last input in the layout is always the default.',
|
||||
tooltip: "Input - The last input in the layout is always the default.",
|
||||
}, {
|
||||
type: 'component',
|
||||
componentName: 'input',
|
||||
id: 'inputComponent',
|
||||
type: "component",
|
||||
componentName: "input",
|
||||
id: "inputComponent",
|
||||
height: 12,
|
||||
isClosable: false,
|
||||
tooltip: 'Input - The last input in the layout is always the default.',
|
||||
tooltip: "Input - The last input in the layout is always the default.",
|
||||
}]
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
var newTabConfig = {
|
||||
title: 'Untitled',
|
||||
type: 'component',
|
||||
componentName: 'evennia',
|
||||
title: "Untitled",
|
||||
type: "component",
|
||||
componentName: "evennia",
|
||||
componentState: {
|
||||
types: 'all',
|
||||
update_method: 'newlines',
|
||||
types: "all",
|
||||
update_method: "newlines",
|
||||
},
|
||||
};
|
||||
|
||||
var newInputConfig = {
|
||||
title: 'input',
|
||||
type: 'component',
|
||||
componentName: 'input',
|
||||
id: 'inputComponent',
|
||||
title: "input",
|
||||
type: "component",
|
||||
componentName: "input",
|
||||
id: "inputComponent",
|
||||
};
|
||||
|
||||
// helper function: filter vals out of array
|
||||
|
|
@ -77,16 +77,16 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
|
||||
|
||||
//
|
||||
// Calculate all known_types minus the 'all' type,
|
||||
// Calculate all known_types minus the "all" type,
|
||||
// then filter out all types that have been mapped to a pane.
|
||||
var calculateUntaggedTypes = function () {
|
||||
// set initial untagged list
|
||||
untagged = filter( ['all', 'untagged'], known_types);
|
||||
untagged = filter( ["all", "untagged"], known_types);
|
||||
// for each .content pane
|
||||
$('.content').each( function () {
|
||||
let types = $(this).attr('types');
|
||||
$(".content").each( function () {
|
||||
let types = $(this).attr("types");
|
||||
if ( typeof types !== "undefined" ) {
|
||||
untagged = filter( types.split(' '), untagged );
|
||||
untagged = filter( types.split(" "), untagged );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -95,10 +95,10 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var closeRenameDropdown = function () {
|
||||
let content = $('#renamebox').parent().parent().parent().parent()[0];
|
||||
let title = $('#renameboxin').val();
|
||||
let content = $("#renamebox").parent().parent().parent().parent()[0];
|
||||
let title = $("#renameboxin").val();
|
||||
|
||||
let components = myLayout.root.getItemsByType('component');
|
||||
let components = myLayout.root.getItemsByType("component");
|
||||
|
||||
components.forEach( function (component) {
|
||||
let element = component.tab.header.parent.element[0];
|
||||
|
|
@ -107,8 +107,8 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
}
|
||||
});
|
||||
|
||||
myLayout.emit('stateChanged');
|
||||
$('#renamebox').remove();
|
||||
myLayout.emit("stateChanged");
|
||||
$("#renamebox").remove();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -116,22 +116,22 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
// Handle the renameDropdown
|
||||
var renameDropdown = function (evnt) {
|
||||
let element = $(evnt.data.contentItem.element);
|
||||
let content = element.find('.content');
|
||||
let content = element.find(".content");
|
||||
let title = evnt.data.contentItem.config.title;
|
||||
let renamebox = document.getElementById('renamebox');
|
||||
let renamebox = document.getElementById("renamebox");
|
||||
|
||||
// check that no other dropdown is open
|
||||
if( document.getElementById('typelist') ) {
|
||||
if( document.getElementById("typelist") ) {
|
||||
closeTypelistDropdown();
|
||||
}
|
||||
|
||||
if( document.getElementById('updatelist') ) {
|
||||
if( document.getElementById("updatelist") ) {
|
||||
closeUpdatelistDropdown();
|
||||
}
|
||||
|
||||
if( !renamebox ) {
|
||||
renamebox = $('<div id="renamebox">');
|
||||
renamebox.append('<input type="textbox" id="renameboxin" value="'+title+'">');
|
||||
renamebox = $("<div id='renamebox'>");
|
||||
renamebox.append("<input type='textbox' id='renameboxin' value='"+title+"'>");
|
||||
renamebox.insertBefore( content );
|
||||
} else {
|
||||
closeRenameDropdown();
|
||||
|
|
@ -142,22 +142,22 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var closeTypelistDropdown = function () {
|
||||
let content = $('#typelist').parent().find('.content');
|
||||
let checkboxes = $('#typelist :input');
|
||||
let content = $("#typelist").parent().find(".content");
|
||||
let checkboxes = $("#typelist :input");
|
||||
|
||||
let types = [];
|
||||
for (let i=0; i<checkboxes.length; i++ ) {
|
||||
let box = checkboxes[i];
|
||||
if( $(box).prop('checked') ) {
|
||||
if( $(box).prop("checked") ) {
|
||||
types.push( $(box).val() );
|
||||
}
|
||||
}
|
||||
|
||||
content.attr('types', types.join(' '));
|
||||
myLayout.emit('stateChanged');
|
||||
content.attr("types", types.join(" "));
|
||||
myLayout.emit("stateChanged");
|
||||
|
||||
calculateUntaggedTypes();
|
||||
$('#typelist').remove();
|
||||
$("#typelist").remove();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -165,21 +165,21 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
var onSelectTypesClicked = function (evnt) {
|
||||
let element = $(evnt.data.contentItem.element);
|
||||
let content = element.find('.content');
|
||||
let selected_types = content.attr('types');
|
||||
let menu = $('<div id="typelist">');
|
||||
let div = $('<div class="typelistsub">');
|
||||
let content = element.find(".content");
|
||||
let selected_types = content.attr("types");
|
||||
let menu = $("<div id='typelist'>");
|
||||
let div = $("<div class='typelistsub'>");
|
||||
|
||||
if( selected_types ) {
|
||||
selected_types = selected_types.split(' ');
|
||||
selected_types = selected_types.split(" ");
|
||||
}
|
||||
for (let i=0; i<known_types.length;i++) {
|
||||
let type = known_types[i];
|
||||
let itype = known_types[i];
|
||||
let choice;
|
||||
if( selected_types && selected_types.includes(type) ) {
|
||||
choice = $('<label><input type="checkbox" value="'+type+'" checked="checked"/>'+type+'</label>');
|
||||
if( selected_types && selected_types.includes(itype) ) {
|
||||
choice = $("<label><input type='checkbox' value='"+itype+"' checked='checked'/>"+itype+"</label>");
|
||||
} else {
|
||||
choice = $('<label><input type="checkbox" value="'+type+'"/>'+type+'</label>');
|
||||
choice = $("<label><input type='checkbox' value='"+itype+"'/>"+itype+"</label>");
|
||||
}
|
||||
choice.appendTo(div);
|
||||
}
|
||||
|
|
@ -192,14 +192,14 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
// Handle the typeDropdown
|
||||
var typeDropdown = function (evnt) {
|
||||
let typelist = document.getElementById('typelist');
|
||||
let typelist = document.getElementById("typelist");
|
||||
|
||||
// check that no other dropdown is open
|
||||
if( document.getElementById('renamebox') ) {
|
||||
if( document.getElementById("renamebox") ) {
|
||||
closeRenameDropdown();
|
||||
}
|
||||
|
||||
if( document.getElementById('updatelist') ) {
|
||||
if( document.getElementById("updatelist") ) {
|
||||
closeUpdatelistDropdown();
|
||||
}
|
||||
|
||||
|
|
@ -214,12 +214,12 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var closeUpdatelistDropdown = function () {
|
||||
let content = $('#updatelist').parent().find('.content');
|
||||
let value = $('input[name=upmethod]:checked').val();
|
||||
let content = $("#updatelist").parent().find(".content");
|
||||
let value = $("input[name=upmethod]:checked").val();
|
||||
|
||||
content.attr('update_method', value );
|
||||
myLayout.emit('stateChanged');
|
||||
$('#updatelist').remove();
|
||||
content.attr("update_method", value );
|
||||
myLayout.emit("stateChanged");
|
||||
$("#updatelist").remove();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -227,18 +227,18 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
var onUpdateMethodClicked = function (evnt) {
|
||||
let element = $(evnt.data.contentItem.element);
|
||||
let content = element.find('.content');
|
||||
let update_method = content.attr('update_method');
|
||||
let nlchecked = (update_method == 'newlines') ? 'checked="checked"' : '';
|
||||
let apchecked = (update_method == 'append') ? 'checked="checked"' : '';
|
||||
let rpchecked = (update_method == 'replace') ? 'checked="checked"' : '';
|
||||
let content = element.find(".content");
|
||||
let update_method = content.attr("update_method");
|
||||
let nlchecked = (update_method == "newlines") ? "checked="checked"" : "";
|
||||
let apchecked = (update_method == "append") ? "checked="checked"" : "";
|
||||
let rpchecked = (update_method == "replace") ? "checked="checked"" : "";
|
||||
|
||||
let menu = $('<div id="updatelist">');
|
||||
let div = $('<div class="updatelistsub">');
|
||||
let menu = $("<div id='updatelist'>");
|
||||
let div = $("<div class='updatelistsub'>");
|
||||
|
||||
let newlines = $('<label><input type="radio" name="upmethod" value="newlines" '+nlchecked+'/>Newlines</label>');
|
||||
let append = $('<label><input type="radio" name="upmethod" value="append" '+apchecked+'/>Append</label>');
|
||||
let replace = $('<label><input type="radio" name="upmethod" value="replace" '+rpchecked+'/>Replace</label>');
|
||||
let newlines = $("<label><input type='radio' name='upmethod' value='newlines' "+nlchecked+"/>Newlines</label>");
|
||||
let append = $("<label><input type='radio' name='upmethod' value='append' "+apchecked+"/>Append</label>");
|
||||
let replace = $("<label><input type='radio' name='upmethod' value='replace' "+rpchecked+"/>Replace</label>");
|
||||
|
||||
newlines.appendTo(div);
|
||||
append.appendTo(div);
|
||||
|
|
@ -253,14 +253,14 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
// Handle the updateDropdown
|
||||
var updateDropdown = function (evnt) {
|
||||
let updatelist = document.getElementById('updatelist');
|
||||
let updatelist = document.getElementById("updatelist");
|
||||
|
||||
// check that no other dropdown is open
|
||||
if( document.getElementById('renamebox') ) {
|
||||
if( document.getElementById("renamebox") ) {
|
||||
closeRenameDropdown();
|
||||
}
|
||||
|
||||
if( document.getElementById('typelist') ) {
|
||||
if( document.getElementById("typelist") ) {
|
||||
closeTypelistDropdown();
|
||||
}
|
||||
|
||||
|
|
@ -275,9 +275,9 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var onActiveTabChange = function (tab) {
|
||||
let renamebox = document.getElementById('renamebox');
|
||||
let typelist = document.getElementById('typelist');
|
||||
let updatelist = document.getElementById('updatelist');
|
||||
let renamebox = document.getElementById("renamebox");
|
||||
let typelist = document.getElementById("typelist");
|
||||
let updatelist = document.getElementById("updatelist");
|
||||
|
||||
if( renamebox ) {
|
||||
closeRenameDropdown();
|
||||
|
|
@ -296,18 +296,18 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
// Save the GoldenLayout state to localstorage whenever it changes.
|
||||
var onStateChanged = function () {
|
||||
let components = myLayout.root.getItemsByType('component');
|
||||
let components = myLayout.root.getItemsByType("component");
|
||||
components.forEach( function (component) {
|
||||
if( component.hasId('inputComponent') ) { return; } // ignore input components
|
||||
if( component.hasId("inputComponent") ) { return; } // ignore input components
|
||||
|
||||
let text_div = component.container.getElement().children('.content');
|
||||
let types = text_div.attr('types');
|
||||
let update_method = text_div.attr('update_method');
|
||||
component.container.extendState({ 'types': types, 'update_method': update_method });
|
||||
let text_div = component.container.getElement().children(".content");
|
||||
let types = text_div.attr("types");
|
||||
let update_method = text_div.attr("update_method");
|
||||
component.container.extendState({ "types": types, "update_method": update_method });
|
||||
});
|
||||
|
||||
var state = JSON.stringify( myLayout.toConfig() );
|
||||
localStorage.setItem( 'evenniaGoldenLayoutSavedState', state );
|
||||
localStorage.setItem( "evenniaGoldenLayoutSavedState", state );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -315,10 +315,10 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
var onTabCreate = function (tab) {
|
||||
//HTML for the typeDropdown
|
||||
let renameDropdownControl = $('<span class="lm_title" style="font-size: 1em;width: 1.5em;">\u2B57</span>');
|
||||
let typeDropdownControl = $('<span class="lm_title" style="font-size: 1.5em;width: 1em;">⮛</span>');
|
||||
let updateDropdownControl = $('<span class="lm_title" style="font-size: 1.5em;width: 1em;">⮛</span>');
|
||||
let splitControl = $('<span class="lm_title" style="font-size: 2em;width: 1em;">+</span>');
|
||||
let renameDropdownControl = $("<span class='lm_title' style='font-size: 1em;width: 1.5em;'>\u2B57</span>");
|
||||
let typeDropdownControl = $("<span class='lm_title' style='font-size: 1.5em;width: 1em;'>⮛</span>");
|
||||
let updateDropdownControl = $("<span class='lm_title' style='font-size: 1.5em;width: 1em;'>⮛</span>");
|
||||
let splitControl = $("<span class='lm_title' style='font-size: 2em;width: 1em;'>+</span>");
|
||||
|
||||
// track dropdowns when the associated control is clicked
|
||||
renameDropdownControl.click( tab, renameDropdown );
|
||||
|
|
@ -339,10 +339,10 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
tab.element.append( splitControl );
|
||||
|
||||
if( tab.contentItem.config.componentName == "Main" ) {
|
||||
tab.element.prepend( $('#optionsbutton').clone(true).addClass('lm_title') );
|
||||
tab.element.prepend( $("#optionsbutton").clone(true).addClass("lm_title") );
|
||||
}
|
||||
|
||||
tab.header.parent.on( 'activeContentItemChanged', onActiveTabChange );
|
||||
tab.header.parent.on( "activeContentItemChanged", onActiveTabChange );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
var onInputCreate = function (tab) {
|
||||
//HTML for the typeDropdown
|
||||
let splitControl = $('<span class="lm_title" style="font-size: 2em;width: 1em;">+</span>');
|
||||
let splitControl = $("<span class='lm_title' style='font-size: 2em;width: 1em;'>+</span>");
|
||||
|
||||
// track adding a new tab
|
||||
splitControl.click( tab, function (evnt) {
|
||||
|
|
@ -360,19 +360,19 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
// Add the typeDropdown to the header
|
||||
tab.element.append( splitControl );
|
||||
|
||||
tab.header.parent.on( 'activeContentItemChanged', onActiveTabChange );
|
||||
tab.header.parent.on( "activeContentItemChanged", onActiveTabChange );
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
var scrollAll = function () {
|
||||
let components = myLayout.root.getItemsByType('component');
|
||||
let components = myLayout.root.getItemsByType("component");
|
||||
components.forEach( function (component) {
|
||||
if( component.hasId('inputComponent') ) { return; } // ignore input components
|
||||
if( component.hasId("inputComponent") ) { return; } // ignore input components
|
||||
|
||||
let text_div = component.container.getElement().children('.content');
|
||||
let scrollHeight = text_div.prop('scrollHeight');
|
||||
let clientHeight = text_div.prop('clientHeight');
|
||||
let text_div = component.container.getElement().children(".content");
|
||||
let scrollHeight = text_div.prop("scrollHeight");
|
||||
let clientHeight = text_div.prop("clientHeight");
|
||||
text_div.scrollTop( scrollHeight - clientHeight );
|
||||
});
|
||||
myLayout.updateSize();
|
||||
|
|
@ -382,15 +382,15 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var routeMsg = function (text_div, txt, update_method) {
|
||||
if ( update_method == 'replace' ) {
|
||||
if ( update_method == "replace" ) {
|
||||
text_div.html(txt)
|
||||
} else if ( update_method == 'append' ) {
|
||||
} else if ( update_method == "append" ) {
|
||||
text_div.append(txt);
|
||||
} else { // line feed
|
||||
text_div.append('<div class="out">' + txt + '</div>');
|
||||
text_div.append("<div class='out'>" + txt + "</div>");
|
||||
}
|
||||
let scrollHeight = text_div.prop('scrollHeight');
|
||||
let clientHeight = text_div.prop('clientHeight');
|
||||
let scrollHeight = text_div.prop("scrollHeight");
|
||||
let clientHeight = text_div.prop("clientHeight");
|
||||
text_div.scrollTop( scrollHeight - clientHeight );
|
||||
}
|
||||
|
||||
|
|
@ -398,16 +398,16 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var initComponent = function (div, container, state, default_types, update_method) {
|
||||
// set this container's content div types attribute
|
||||
// set this container"s content div types attribute
|
||||
if( state ) {
|
||||
div.attr('types', state.types);
|
||||
div.attr('update_method', state.update_method);
|
||||
div.attr("types", state.types);
|
||||
div.attr("update_method", state.update_method);
|
||||
} else {
|
||||
div.attr('types', default_types);
|
||||
div.attr('update_method', update_method);
|
||||
div.attr("types", default_types);
|
||||
div.attr("update_method", update_method);
|
||||
}
|
||||
div.appendTo( container.getElement() );
|
||||
container.on('tab', onTabCreate);
|
||||
container.on("tab", onTabCreate);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -419,7 +419,7 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var onKeydown = function(evnt) {
|
||||
var renamebox = document.getElementById('renamebox');
|
||||
var renamebox = document.getElementById("renamebox");
|
||||
if( renamebox ) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -430,39 +430,39 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
//
|
||||
//
|
||||
var onText = function (args, kwargs) {
|
||||
// If the message is not itself tagged, we'll assume it
|
||||
// should go into any panes with 'all' and 'untagged' set
|
||||
var msgtype = 'untagged';
|
||||
// If the message is not itself tagged, we"ll assume it
|
||||
// should go into any panes with "all" and "untagged" set
|
||||
var msgtype = "untagged";
|
||||
|
||||
if ( kwargs && 'type' in kwargs ) {
|
||||
msgtype = kwargs['type'];
|
||||
if ( kwargs && "type" in kwargs ) {
|
||||
msgtype = kwargs["type"];
|
||||
if ( ! known_types.includes(msgtype) ) {
|
||||
// this is a new output type that can be mapped to panes
|
||||
console.log('detected new output type: ' + msgtype)
|
||||
console.log("detected new output type: " + msgtype)
|
||||
known_types.push(msgtype);
|
||||
untagged.push(msgtype);
|
||||
}
|
||||
}
|
||||
|
||||
let message_delivered = false;
|
||||
let components = myLayout.root.getItemsByType('component');
|
||||
let components = myLayout.root.getItemsByType("component");
|
||||
|
||||
components.forEach( function (component) {
|
||||
if( component.hasId('inputComponent') ) { return; } // ignore the input component
|
||||
if( component.hasId("inputComponent") ) { return; } // ignore the input component
|
||||
|
||||
let text_div = component.container.getElement().children('.content');
|
||||
let attr_types = text_div.attr('types');
|
||||
let pane_types = attr_types ? attr_types.split(' ') : [];
|
||||
let update_method = text_div.attr('update_method');
|
||||
let text_div = component.container.getElement().children(".content");
|
||||
let attr_types = text_div.attr("types");
|
||||
let pane_types = attr_types ? attr_types.split(" ") : [];
|
||||
let update_method = text_div.attr("update_method");
|
||||
let txt = args[0];
|
||||
|
||||
// is this message type listed in this pane's types (or is this pane catching 'all')
|
||||
if( pane_types.includes(msgtype) || pane_types.includes('all') ) {
|
||||
// is this message type listed in this pane"s types (or is this pane catching "all")
|
||||
if( pane_types.includes(msgtype) || pane_types.includes("all") ) {
|
||||
routeMsg( text_div, txt, update_method );
|
||||
message_delivered = true;
|
||||
}
|
||||
|
||||
// is this pane catching 'upmapped' messages?
|
||||
// is this pane catching "upmapped" messages?
|
||||
// And is this message type listed in the untagged types array?
|
||||
if( pane_types.includes("untagged") && untagged.includes(msgtype) ) {
|
||||
routeMsg( text_div, txt, update_method );
|
||||
|
|
@ -488,9 +488,9 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
$(window).bind("resize", scrollAll);
|
||||
|
||||
// Set Save State callback
|
||||
myLayout.on( 'stateChanged', onStateChanged );
|
||||
myLayout.on( "stateChanged", onStateChanged );
|
||||
|
||||
console.log('Golden Layout Plugin Initialized.');
|
||||
console.log("Golden Layout Plugin Initialized.");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -498,8 +498,8 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
// required Init me
|
||||
var init = function (options) {
|
||||
// Set up our GoldenLayout instance built off of the default main-sub div
|
||||
var savedState = localStorage.getItem( 'evenniaGoldenLayoutSavedState' );
|
||||
var mainsub = document.getElementById('main-sub');
|
||||
var savedState = localStorage.getItem( "evenniaGoldenLayoutSavedState" );
|
||||
var mainsub = document.getElementById("main-sub");
|
||||
|
||||
if( savedState !== null ) {
|
||||
config = JSON.parse( savedState );
|
||||
|
|
@ -507,40 +507,40 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
|
||||
myLayout = new GoldenLayout( config, mainsub );
|
||||
|
||||
$('#inputcontrol').remove(); // remove the cluttered, HTML-defined input divs
|
||||
$("#inputcontrol").remove(); // remove the cluttered, HTML-defined input divs
|
||||
|
||||
// register our component and replace the default messagewindow with the Main component
|
||||
myLayout.registerComponent( 'Main', function (container, componentState) {
|
||||
let main = $('#messagewindow').addClass('content');
|
||||
initComponent(main, container, componentState, 'untagged', 'newlines' );
|
||||
myLayout.registerComponent( "Main", function (container, componentState) {
|
||||
let main = $("#messagewindow").addClass("content");
|
||||
initComponent(main, container, componentState, "untagged", "newlines" );
|
||||
});
|
||||
|
||||
// register our new input component
|
||||
myLayout.registerComponent( 'input', function (container, componentState) {
|
||||
var inputfield = $('<textarea type="text" class="inputfield form-control"></textarea>');
|
||||
var button = $('<button type="button" class="inputsend">></button>');
|
||||
myLayout.registerComponent( "input", function (container, componentState) {
|
||||
var inputfield = $("<textarea type='text' class='inputfield form-control'></textarea>");
|
||||
var button = $("<button type='button' class='inputsend'>></button>");
|
||||
|
||||
$('<div class="inputwrap">')
|
||||
$("<div class='inputwrap'>")
|
||||
.append( button )
|
||||
.append( inputfield )
|
||||
.appendTo( container.getElement() );
|
||||
|
||||
button.bind('click', function (evnt) {
|
||||
button.bind("click", function (evnt) {
|
||||
// focus our textarea
|
||||
$( $(evnt.target).siblings('.inputfield')[0] ).focus();
|
||||
$( $(evnt.target).siblings(".inputfield")[0] ).focus();
|
||||
// fake a carriage return event
|
||||
var e = $.Event('keydown');
|
||||
var e = $.Event("keydown");
|
||||
e.which = 13;
|
||||
$( $(evnt.target).siblings('.inputfield')[0] ).trigger(e);
|
||||
$( $(evnt.target).siblings(".inputfield")[0] ).trigger(e);
|
||||
});
|
||||
|
||||
container.on('tab', onInputCreate);
|
||||
container.on("tab", onInputCreate);
|
||||
});
|
||||
|
||||
myLayout.registerComponent( 'evennia', function (container, componentState) {
|
||||
let div = $('<div class="content"></div>');
|
||||
initComponent(div, container, componentState, 'all', 'newlines');
|
||||
container.on('destroy', calculateUntaggedTypes);
|
||||
myLayout.registerComponent( "evennia", function (container, componentState) {
|
||||
let div = $("<div class='content'></div>");
|
||||
initComponent(div, container, componentState, "all", "newlines");
|
||||
container.on("destroy", calculateUntaggedTypes);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -555,4 +555,5 @@ plugin_handler.add('goldenlayout', (function () {
|
|||
setConfig: function (newconfig) { config = newconfig },
|
||||
addKnownType: function (newtype) { known_types.push(newtype) },
|
||||
}
|
||||
})());
|
||||
})();
|
||||
window.plugin_handler.add("goldenlayout", goldenlayout);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ let history_plugin = (function () {
|
|||
var history = new Array();
|
||||
var history_pos = 0;
|
||||
|
||||
history[0] = ''; // the very latest input is empty for new entry.
|
||||
history[0] = ""; // the very latest input is empty for new entry.
|
||||
|
||||
//
|
||||
// move back in the history
|
||||
|
|
@ -37,7 +37,7 @@ let history_plugin = (function () {
|
|||
history.shift(); // kill oldest entry
|
||||
}
|
||||
history[history.length-1] = input;
|
||||
history[history.length] = '';
|
||||
history[history.length] = "";
|
||||
}
|
||||
history_pos = 0;
|
||||
}
|
||||
|
|
@ -62,11 +62,11 @@ let history_plugin = (function () {
|
|||
if (history_entry !== null) {
|
||||
// Doing a history navigation; replace the text in the input and
|
||||
// move the cursor to the end of the new value
|
||||
var inputfield = $('.inputfield:focus');
|
||||
var inputfield = $(".inputfield:focus");
|
||||
if( inputfield.length < 1 ) { // pre-goldenlayout backwards compatibility
|
||||
inputfield = $('#inputfield');
|
||||
inputfield = $("#inputfield");
|
||||
}
|
||||
inputfield.val('');
|
||||
inputfield.val("");
|
||||
inputfield.blur().focus().val(history_entry);
|
||||
event.preventDefault();
|
||||
return true;
|
||||
|
|
@ -85,7 +85,7 @@ let history_plugin = (function () {
|
|||
//
|
||||
// Init function
|
||||
var init = function () {
|
||||
console.log('History Plugin Initialized.');
|
||||
console.log("History Plugin Initialized.");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -94,4 +94,4 @@ let history_plugin = (function () {
|
|||
onSend: onSend,
|
||||
}
|
||||
})()
|
||||
plugin_handler.add('history', history_plugin);
|
||||
plugin_handler.add("history", history_plugin);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Assignable 'hot-buttons' Plugin
|
||||
* Assignable "hot-buttons" Plugin
|
||||
*
|
||||
* This adds a bar of 9 buttons that can be shift-click assigned whatever is in the textinput buffer, so you can simply
|
||||
* click the button again and have it execute those commands, instead of having to type it all out again and again.
|
||||
|
|
@ -18,10 +18,10 @@
|
|||
* <script src={% static "webclient/js/plugins/hotbuttons.js" %} language="javascript" type="text/javascript"></script>
|
||||
* after the other <script></script> plugin tags.
|
||||
*
|
||||
* Run: evennia collectstatic (say 'yes' to the overwrite prompt)
|
||||
* Run: evennia collectstatic (say "yes" to the overwrite prompt)
|
||||
* Start Evennia
|
||||
*/
|
||||
plugin_handler.add('hotbuttons', (function () {
|
||||
let hotbuttons = (function () {
|
||||
var dependencies_met = true; // To start, assume either splithandler or goldenlayout plugin is enabled.
|
||||
|
||||
var num_buttons = 9;
|
||||
|
|
@ -29,41 +29,41 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
|
||||
var hotButtonConfig = {
|
||||
content: [{
|
||||
type: 'column',
|
||||
type: "column",
|
||||
content: [{
|
||||
type: 'row',
|
||||
type: "row",
|
||||
content: [{
|
||||
type: 'column',
|
||||
type: "column",
|
||||
content: [{
|
||||
type: 'component',
|
||||
componentName: 'Main',
|
||||
type: "component",
|
||||
componentName: "Main",
|
||||
isClosable: false,
|
||||
tooltip: 'Main - drag to desird position.',
|
||||
tooltip: "Main - drag to desird position.",
|
||||
componentState: {
|
||||
types: 'untagged',
|
||||
update_method: 'newlines',
|
||||
types: "untagged",
|
||||
update_method: "newlines",
|
||||
},
|
||||
}]
|
||||
}],
|
||||
}, {
|
||||
type: 'component',
|
||||
componentName: 'hotbuttons',
|
||||
id: 'inputComponent',
|
||||
type: "component",
|
||||
componentName: "hotbuttons",
|
||||
id: "inputComponent",
|
||||
height: 12,
|
||||
tooltip: 'Input - The last input in the layout is always the default.',
|
||||
tooltip: "Input - The last input in the layout is always the default.",
|
||||
}, {
|
||||
type: 'component',
|
||||
componentName: 'input',
|
||||
id: 'inputComponent',
|
||||
type: "component",
|
||||
componentName: "input",
|
||||
id: "inputComponent",
|
||||
height: 12,
|
||||
tooltip: 'Input - The last input in the layout is always the default.',
|
||||
tooltip: "Input - The last input in the layout is always the default.",
|
||||
}, {
|
||||
type: 'component',
|
||||
componentName: 'input',
|
||||
id: 'inputComponent',
|
||||
type: "component",
|
||||
componentName: "input",
|
||||
id: "inputComponent",
|
||||
height: 12,
|
||||
isClosable: false,
|
||||
tooltip: 'Input - The last input in the layout is always the default.',
|
||||
tooltip: "Input - The last input in the layout is always the default.",
|
||||
}]
|
||||
}]
|
||||
};
|
||||
|
|
@ -72,29 +72,29 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
// Add Buttons UI for SplitHandler
|
||||
var addButtonsUI = function () {
|
||||
var buttons = $( [
|
||||
'<div id="buttons" class="split split-vertical">',
|
||||
' <div id="buttonsform">',
|
||||
' <div id="buttonscontrol" class="input-group">',
|
||||
' <button class="btn" id="assign_button0" type="button" value="button0">unassigned</button>',
|
||||
' <button class="btn" id="assign_button1" type="button" value="button1">unassigned</button>',
|
||||
' <button class="btn" id="assign_button2" type="button" value="button2">unassigned</button>',
|
||||
' <button class="btn" id="assign_button3" type="button" value="button3">unassigned</button>',
|
||||
' <button class="btn" id="assign_button4" type="button" value="button4">unassigned</button>',
|
||||
' <button class="btn" id="assign_button5" type="button" value="button5">unassigned</button>',
|
||||
' <button class="btn" id="assign_button6" type="button" value="button6">unassigned</button>',
|
||||
' <button class="btn" id="assign_button7" type="button" value="button7">unassigned</button>',
|
||||
' <button class="btn" id="assign_button8" type="button" value="button8">unassigned</button>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
'</div>',
|
||||
"<div id='buttons' class='split split-vertical'>",
|
||||
" <div id='buttonsform'>",
|
||||
" <div id='buttonscontrol' class='input-group'>",
|
||||
" <button class='btn' id='assign_button0' type='button' value='button0'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button1' type='button' value='button1'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button2' type='button' value='button2'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button3' type='button' value='button3'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button4' type='button' value='button4'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button5' type='button' value='button5'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button6' type='button' value='button6'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button7' type='button' value='button7'>unassigned</button>",
|
||||
" <button class='btn' id='assign_button8' type='button' value='button8'>unassigned</button>",
|
||||
" </div>",
|
||||
" </div>",
|
||||
"</div>",
|
||||
].join("\n") );
|
||||
|
||||
// Add buttons in front of the existing #inputform
|
||||
$('#input').prev().replaceWith(buttons);
|
||||
$("#input").prev().replaceWith(buttons);
|
||||
|
||||
Split(['#main','#buttons','#input'], {
|
||||
Split(["#main","#buttons","#input"], {
|
||||
sizes: [85,5,10],
|
||||
direction: 'vertical',
|
||||
direction: "vertical",
|
||||
gutterSize: 4,
|
||||
minSize: [150,20,50],
|
||||
});
|
||||
|
|
@ -150,9 +150,9 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
console.log("button " + e.data + " clicked");
|
||||
if( button.text() == "unassigned" ) {
|
||||
// Assign the button and send the full button state to the server using a Webclient_Options event
|
||||
var input = $('.inputfield:last');
|
||||
var input = $(".inputfield:last");
|
||||
if( input.length < 1 ) {
|
||||
input = $('#inputfield');
|
||||
input = $("#inputfield");
|
||||
}
|
||||
assignButton( e.data, input.val() );
|
||||
Evennia.msg("webclient_options", [], { "HotButtons": command_cache });
|
||||
|
|
@ -171,20 +171,20 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
//
|
||||
// Create and register the hotbuttons golden-layout component
|
||||
var buildComponent = function () {
|
||||
var myLayout = plugins['goldenlayout'].getGL();
|
||||
var myLayout = plugins["goldenlayout"].getGL();
|
||||
|
||||
myLayout.registerComponent( 'hotbuttons', function (container, componentState) {
|
||||
console.log('hotbuttons');
|
||||
myLayout.registerComponent( "hotbuttons", function (container, componentState) {
|
||||
console.log("hotbuttons");
|
||||
|
||||
// build the buttons
|
||||
var div = $('<div class="input-group">');
|
||||
var div = $("<div class='input-group'>");
|
||||
|
||||
var len = command_cache.length;
|
||||
for( var x=len; x < len + num_buttons; x++ ) {
|
||||
command_cache.push("unassigned");
|
||||
|
||||
// initialize button command cache and onClick handler
|
||||
button = $('<button class="btn" id="assign_button'+x+'" type="button" value="button'+x+'">');
|
||||
button = $("<button class='btn' id='assign_button"+x+"' type='button' value='button"+x+"'>");
|
||||
button.html("unassigned");
|
||||
button.click( x, hotButtonClicked );
|
||||
|
||||
|
|
@ -201,8 +201,8 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
//
|
||||
// Handle the HotButtons part of a Webclient_Options event
|
||||
var onGotOptions = function(args, kwargs) {
|
||||
if( dependencies_met && kwargs['HotButtons'] ) {
|
||||
var button_options = kwargs['HotButtons'];
|
||||
if( dependencies_met && kwargs["HotButtons"] ) {
|
||||
var button_options = kwargs["HotButtons"];
|
||||
$.each( button_options, function( key, value ) {
|
||||
assignButton(key, value);
|
||||
});
|
||||
|
|
@ -214,15 +214,15 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
// Initialize me
|
||||
var init = function() {
|
||||
// Are we using GoldenLayout?
|
||||
if( plugins['goldenlayout'] ) {
|
||||
// update goldenlayout's global config
|
||||
plugins['goldenlayout'].setConfig( hotButtonConfig );
|
||||
if( plugins["goldenlayout"] ) {
|
||||
// update goldenlayout"s global config
|
||||
plugins["goldenlayout"].setConfig( hotButtonConfig );
|
||||
// wait for postInit() to create the required component
|
||||
dependencies_met = true;
|
||||
}
|
||||
|
||||
// Are we using splithandler?
|
||||
if( plugins['splithandler'] ) {
|
||||
if( plugins["splithandler"] ) {
|
||||
addButtonsUI();
|
||||
dependencies_met = true;
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
//
|
||||
var postInit = function() {
|
||||
if( dependencies_met ) {
|
||||
if( plugins['goldenlayout'] ) {
|
||||
if( plugins["goldenlayout"] ) {
|
||||
buildComponent();
|
||||
}
|
||||
|
||||
|
|
@ -248,4 +248,5 @@ plugin_handler.add('hotbuttons', (function () {
|
|||
postInit: postInit,
|
||||
onGotOptions: onGotOptions,
|
||||
}
|
||||
})());
|
||||
})();
|
||||
window.plugin_handler.add("hotbuttons", hotbuttons);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue