mirror of
https://github.com/evennia/evennia.git
synced 2026-03-29 20:17:16 +02:00
Lint under_scores to CamelCase
This commit is contained in:
parent
068217f2ec
commit
a845bbf63d
5 changed files with 105 additions and 125 deletions
|
|
@ -66,8 +66,6 @@ let defaultin_plugin = (function () {
|
|||
e.which = 13;
|
||||
$("#inputfield").focus().trigger(e);
|
||||
});
|
||||
|
||||
console.log("DefaultIn initialized");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
let goldenlayout = (function () {
|
||||
|
||||
var myLayout;
|
||||
var known_types = ["all", "untagged"];
|
||||
var knownTypes = ["all", "untagged"];
|
||||
var untagged = [];
|
||||
|
||||
var newTabConfig = {
|
||||
|
|
@ -15,7 +15,7 @@ let goldenlayout = (function () {
|
|||
componentName: "evennia",
|
||||
componentState: {
|
||||
types: "all",
|
||||
update_method: "newlines",
|
||||
updateMethod: "newlines",
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -28,23 +28,26 @@ let goldenlayout = (function () {
|
|||
|
||||
// helper function: filter vals out of array
|
||||
function filter (vals, array) {
|
||||
let tmp = array.slice();
|
||||
for (let i=0; i<vals.length; i++) {
|
||||
let val = vals[i];
|
||||
while( tmp.indexOf(val) > -1 ) {
|
||||
tmp.splice( tmp.indexOf(val), 1 );
|
||||
}
|
||||
if( Array.isArray( vals ) && Array.isArray( array ) ) {
|
||||
let tmp = array.slice();
|
||||
vals.forEach( function (val) {
|
||||
while( tmp.indexOf(val) > -1 ) {
|
||||
tmp.splice( tmp.indexOf(val), 1 );
|
||||
}
|
||||
});
|
||||
return tmp;
|
||||
}
|
||||
return tmp;
|
||||
// pass along whatever we got, since our arguments aren't right.
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Calculate all known_types minus the "all" type,
|
||||
// Calculate all knownTypes 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"], knownTypes);
|
||||
// for each .content pane
|
||||
$(".content").each( function () {
|
||||
let types = $(this).attr("types");
|
||||
|
|
@ -65,7 +68,7 @@ let goldenlayout = (function () {
|
|||
|
||||
components.forEach( function (component) {
|
||||
let element = component.tab.header.parent.element[0];
|
||||
if( element == content && component.tab.isActive ) {
|
||||
if( (element === content) && (component.tab.isActive) ) {
|
||||
component.setTitle( title );
|
||||
}
|
||||
});
|
||||
|
|
@ -82,12 +85,11 @@ let goldenlayout = (function () {
|
|||
let checkboxes = $("#typelist :input");
|
||||
|
||||
let types = [];
|
||||
for (let i=0; i<checkboxes.length; i++ ) {
|
||||
let box = checkboxes[i];
|
||||
if( $(box).prop("checked") ) {
|
||||
types.push( $(box).val() );
|
||||
checkboxes.each( function (idx) {
|
||||
if( $(checkboxes[idx]).prop("checked") ) {
|
||||
types.push( $(checkboxes[idx]).val() );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
content.attr("types", types.join(" "));
|
||||
myLayout.emit("stateChanged");
|
||||
|
|
@ -103,7 +105,7 @@ let goldenlayout = (function () {
|
|||
let content = $("#updatelist").parent().find(".content");
|
||||
let value = $("input[name=upmethod]:checked").val();
|
||||
|
||||
content.attr("update_method", value );
|
||||
content.attr("updateMethod", value );
|
||||
myLayout.emit("stateChanged");
|
||||
$("#updatelist").remove();
|
||||
}
|
||||
|
|
@ -141,23 +143,22 @@ let goldenlayout = (function () {
|
|||
var onSelectTypesClicked = function (evnt) {
|
||||
let element = $(evnt.data.contentItem.element);
|
||||
let content = element.find(".content");
|
||||
let selected_types = content.attr("types");
|
||||
let selectedTypes = content.attr("types");
|
||||
let menu = $("<div id='typelist'>");
|
||||
let div = $("<div class='typelistsub'>");
|
||||
|
||||
if( selected_types ) {
|
||||
selected_types = selected_types.split(" ");
|
||||
if( selectedTypes ) {
|
||||
selectedTypes = selectedTypes.split(" ");
|
||||
}
|
||||
for (let i=0; i<known_types.length;i++) {
|
||||
let itype = known_types[i];
|
||||
knownTypes.forEach( function (itype) {
|
||||
let choice;
|
||||
if( selected_types && selected_types.includes(itype) ) {
|
||||
if( selectedTypes && selectedTypes.includes(itype) ) {
|
||||
choice = $("<label><input type='checkbox' value='"+itype+"' checked='checked'/>"+itype+"</label>");
|
||||
} else {
|
||||
choice = $("<label><input type='checkbox' value='"+itype+"'/>"+itype+"</label>");
|
||||
}
|
||||
choice.appendTo(div);
|
||||
}
|
||||
});
|
||||
div.appendTo(menu);
|
||||
|
||||
element.prepend(menu);
|
||||
|
|
@ -191,10 +192,10 @@ let 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 updateMethod = content.attr("updateMethod");
|
||||
let nlchecked = (updateMethod === "newlines") ? "checked='checked'" : "";
|
||||
let apchecked = (updateMethod === "append") ? "checked='checked'" : "";
|
||||
let rpchecked = (updateMethod === "replace") ? "checked='checked'" : "";
|
||||
|
||||
let menu = $("<div id='updatelist'>");
|
||||
let div = $("<div class='updatelistsub'>");
|
||||
|
|
@ -263,10 +264,10 @@ let goldenlayout = (function () {
|
|||
components.forEach( function (component) {
|
||||
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 textDiv = component.container.getElement().children(".content");
|
||||
let types = textDiv.attr("types");
|
||||
let updateMethod = textDiv.attr("updateMethod");
|
||||
component.container.extendState({ "types": types, "updateMethod": updateMethod });
|
||||
});
|
||||
|
||||
var state = JSON.stringify( myLayout.toConfig() );
|
||||
|
|
@ -301,7 +302,7 @@ let goldenlayout = (function () {
|
|||
tab.element.append( updateDropdownControl );
|
||||
tab.element.append( splitControl );
|
||||
|
||||
if( tab.contentItem.config.componentName == "Main" ) {
|
||||
if( tab.contentItem.config.componentName === "Main" ) {
|
||||
tab.element.prepend( $("#optionsbutton").clone(true).addClass("lm_title") );
|
||||
}
|
||||
|
||||
|
|
@ -333,10 +334,10 @@ let goldenlayout = (function () {
|
|||
components.forEach( function (component) {
|
||||
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");
|
||||
text_div.scrollTop( scrollHeight - clientHeight );
|
||||
let textDiv = component.container.getElement().children(".content");
|
||||
let scrollHeight = textDiv.prop("scrollHeight");
|
||||
let clientHeight = textDiv.prop("clientHeight");
|
||||
textDiv.scrollTop( scrollHeight - clientHeight );
|
||||
});
|
||||
myLayout.updateSize();
|
||||
}
|
||||
|
|
@ -344,30 +345,30 @@ let goldenlayout = (function () {
|
|||
|
||||
//
|
||||
//
|
||||
var routeMsg = function (text_div, txt, update_method) {
|
||||
if ( update_method == "replace" ) {
|
||||
text_div.html(txt);
|
||||
} else if ( update_method == "append" ) {
|
||||
text_div.append(txt);
|
||||
var routeMsg = function (textDiv, txt, updateMethod) {
|
||||
if ( updateMethod === "replace" ) {
|
||||
textDiv.html(txt);
|
||||
} else if ( updateMethod === "append" ) {
|
||||
textDiv.append(txt);
|
||||
} else { // line feed
|
||||
text_div.append("<div class='out'>" + txt + "</div>");
|
||||
textDiv.append("<div class='out'>" + txt + "</div>");
|
||||
}
|
||||
let scrollHeight = text_div.prop("scrollHeight");
|
||||
let clientHeight = text_div.prop("clientHeight");
|
||||
text_div.scrollTop( scrollHeight - clientHeight );
|
||||
let scrollHeight = textDiv.prop("scrollHeight");
|
||||
let clientHeight = textDiv.prop("clientHeight");
|
||||
textDiv.scrollTop( scrollHeight - clientHeight );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
var initComponent = function (div, container, state, default_types, update_method) {
|
||||
var initComponent = function (div, container, state, defaultTypes, updateMethod) {
|
||||
// set this container"s content div types attribute
|
||||
if( state ) {
|
||||
div.attr("types", state.types);
|
||||
div.attr("update_method", state.update_method);
|
||||
div.attr("updateMethod", state.updateMethod);
|
||||
} else {
|
||||
div.attr("types", default_types);
|
||||
div.attr("update_method", update_method);
|
||||
div.attr("types", defaultTypes);
|
||||
div.attr("updateMethod", updateMethod);
|
||||
}
|
||||
div.appendTo( container.getElement() );
|
||||
container.on("tab", onTabCreate);
|
||||
|
|
@ -399,41 +400,40 @@ let goldenlayout = (function () {
|
|||
|
||||
if ( kwargs && "type" in kwargs ) {
|
||||
msgtype = kwargs["type"];
|
||||
if ( ! known_types.includes(msgtype) ) {
|
||||
if ( ! knownTypes.includes(msgtype) ) {
|
||||
// this is a new output type that can be mapped to panes
|
||||
console.log("detected new output type: " + msgtype);
|
||||
known_types.push(msgtype);
|
||||
knownTypes.push(msgtype);
|
||||
untagged.push(msgtype);
|
||||
}
|
||||
}
|
||||
|
||||
let message_delivered = false;
|
||||
let messageDelivered = false;
|
||||
let components = myLayout.root.getItemsByType("component");
|
||||
|
||||
components.forEach( function (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 textDiv = component.container.getElement().children(".content");
|
||||
let attrTypes = textDiv.attr("types");
|
||||
let paneTypes = attrTypes ? attrTypes.split(" ") : [];
|
||||
let updateMethod = textDiv.attr("updateMethod");
|
||||
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") ) {
|
||||
routeMsg( text_div, txt, update_method );
|
||||
message_delivered = true;
|
||||
if( paneTypes.includes(msgtype) || paneTypes.includes("all") ) {
|
||||
routeMsg( textDiv, txt, updateMethod );
|
||||
messageDelivered = true;
|
||||
}
|
||||
|
||||
// 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 );
|
||||
message_delivered = true;
|
||||
if( paneTypes.includes("untagged") && untagged.includes(msgtype) ) {
|
||||
routeMsg( textDiv, txt, updateMethod );
|
||||
messageDelivered = true;
|
||||
}
|
||||
});
|
||||
|
||||
if ( message_delivered ) {
|
||||
if ( messageDelivered ) {
|
||||
return true;
|
||||
}
|
||||
// unhandled message
|
||||
|
|
@ -452,8 +452,6 @@ let goldenlayout = (function () {
|
|||
|
||||
// Set Save State callback
|
||||
myLayout.on( "stateChanged", onStateChanged );
|
||||
|
||||
console.log("Golden Layout Plugin Initialized.");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -514,8 +512,8 @@ let goldenlayout = (function () {
|
|||
postInit: postInit,
|
||||
onKeydown: onKeydown,
|
||||
onText: onText,
|
||||
getGL: function () { return myLayout },
|
||||
addKnownType: function (newtype) { known_types.push(newtype) },
|
||||
getGL: function () { return myLayout; },
|
||||
addKnownType: function (newtype) { knownTypes.push(newtype); },
|
||||
}
|
||||
})();
|
||||
}());
|
||||
window.plugin_handler.add("goldenlayout", goldenlayout);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ var goldenlayout_config = { // Global Variable used in goldenlayout.js init()
|
|||
tooltip: "Main - drag to desird position.",
|
||||
componentState: {
|
||||
types: "untagged",
|
||||
update_method: "newlines",
|
||||
updateMethod: "newlines",
|
||||
},
|
||||
}]
|
||||
}],
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
* Evennia Webclient Command History plugin
|
||||
*
|
||||
*/
|
||||
let history_plugin = (function () {
|
||||
let history = (function () {
|
||||
|
||||
// Manage history for input line
|
||||
var history_max = 21;
|
||||
var historyMax = 21;
|
||||
var history = new Array();
|
||||
var history_pos = 0;
|
||||
var historyPos = 0;
|
||||
|
||||
history[0] = ""; // the very latest input is empty for new entry.
|
||||
|
||||
|
|
@ -16,16 +16,16 @@ let history_plugin = (function () {
|
|||
// move back in the history
|
||||
var back = function () {
|
||||
// step backwards in history stack
|
||||
history_pos = Math.min(++history_pos, history.length - 1);
|
||||
return history[history.length - 1 - history_pos];
|
||||
historyPos = Math.min(++historyPos, history.length - 1);
|
||||
return history[history.length - 1 - historyPos];
|
||||
}
|
||||
|
||||
//
|
||||
// move forward in the history
|
||||
var fwd = function () {
|
||||
// step forwards in history stack
|
||||
history_pos = Math.max(--history_pos, 0);
|
||||
return history[history.length - 1 - history_pos];
|
||||
historyPos = Math.max(--historyPos, 0);
|
||||
return history[history.length - 1 - historyPos];
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -33,13 +33,13 @@ let history_plugin = (function () {
|
|||
var add = function (input) {
|
||||
// add a new entry to history, don't repeat latest
|
||||
if (input && input != history[history.length-2]) {
|
||||
if (history.length >= history_max) {
|
||||
if (history.length >= historyMax) {
|
||||
history.shift(); // kill oldest entry
|
||||
}
|
||||
history[history.length-1] = input;
|
||||
history[history.length] = "";
|
||||
}
|
||||
history_pos = 0;
|
||||
historyPos = 0;
|
||||
}
|
||||
|
||||
// Public
|
||||
|
|
@ -48,18 +48,18 @@ let history_plugin = (function () {
|
|||
// Handle up arrow and down arrow events.
|
||||
var onKeydown = function(event) {
|
||||
var code = event.which;
|
||||
var history_entry = null;
|
||||
var historyEntry = null;
|
||||
|
||||
// Only process up/down arrow if cursor is at the end of the line.
|
||||
if (code === 38 && event.shiftKey) { // Arrow up
|
||||
history_entry = back();
|
||||
historyEntry = back();
|
||||
}
|
||||
else if (code === 40 && event.shiftKey) { // Arrow down
|
||||
history_entry = fwd();
|
||||
historyEntry = fwd();
|
||||
}
|
||||
|
||||
// are we processing an up or down history event?
|
||||
if (history_entry !== null) {
|
||||
if (historyEntry !== 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");
|
||||
|
|
@ -67,7 +67,7 @@ let history_plugin = (function () {
|
|||
inputfield = $("#inputfield");
|
||||
}
|
||||
inputfield.val("");
|
||||
inputfield.blur().focus().val(history_entry);
|
||||
inputfield.blur().focus().val(historyEntry);
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -82,16 +82,10 @@ let history_plugin = (function () {
|
|||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// Init function
|
||||
var init = function () {
|
||||
console.log("History Plugin Initialized.");
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
init: function () {},
|
||||
onKeydown: onKeydown,
|
||||
onSend: onSend,
|
||||
}
|
||||
})()
|
||||
window.plugin_handler.add("history", history_plugin);
|
||||
}());
|
||||
window.plugin_handler.add("history", history);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
* REQUIRES: goldenlayout.js OR splithandler.js
|
||||
*/
|
||||
let hotbuttons = (function () {
|
||||
var dependencies_met = false;
|
||||
var dependenciesMet = false;
|
||||
|
||||
var num_buttons = 9;
|
||||
var command_cache = new Array;
|
||||
var numButtons = 9;
|
||||
var commandCache = new Array;
|
||||
|
||||
//
|
||||
// collect command text
|
||||
|
|
@ -40,7 +40,7 @@ let hotbuttons = (function () {
|
|||
// make sure text has something in it
|
||||
if( text && text.length ) {
|
||||
// cache the command text
|
||||
command_cache[n] = text;
|
||||
commandCache[n] = text;
|
||||
|
||||
// is there a space in the command, indicating "command argument" syntax?
|
||||
if( text.indexOf(" ") > 0 ) {
|
||||
|
|
@ -59,13 +59,13 @@ let hotbuttons = (function () {
|
|||
// change button text to "unassigned"
|
||||
$("#assign_button"+n).text( "unassigned" );
|
||||
// clear current command
|
||||
command_cache[n] = "unassigned";
|
||||
commandCache[n] = "unassigned";
|
||||
}
|
||||
|
||||
//
|
||||
// actually send the command associated with the button that is clicked
|
||||
var sendImmediate = function(n) {
|
||||
var text = command_cache[n];
|
||||
var text = commandCache[n];
|
||||
if( text.length ) {
|
||||
Evennia.msg("text", [text], {});
|
||||
}
|
||||
|
|
@ -75,7 +75,6 @@ let hotbuttons = (function () {
|
|||
// send, assign, or clear the button
|
||||
var hotButtonClicked = function(e) {
|
||||
var button = $("#assign_button"+e.data);
|
||||
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");
|
||||
|
|
@ -83,12 +82,12 @@ let hotbuttons = (function () {
|
|||
input = $("#inputfield");
|
||||
}
|
||||
assignButton( e.data, input.val() );
|
||||
Evennia.msg("webclient_options", [], { "HotButtons": command_cache });
|
||||
Evennia.msg("webclient_options", [], { "HotButtons": commandCache });
|
||||
} else {
|
||||
if( e.shiftKey ) {
|
||||
// Clear the button and send the full button state to the server using a Webclient_Options event
|
||||
clearButton(e.data);
|
||||
Evennia.msg("webclient_options", [], { "HotButtons": command_cache });
|
||||
Evennia.msg("webclient_options", [], { "HotButtons": commandCache });
|
||||
} else {
|
||||
sendImmediate(e.data);
|
||||
}
|
||||
|
|
@ -127,8 +126,8 @@ let hotbuttons = (function () {
|
|||
minSize: [150,20,50],
|
||||
});
|
||||
|
||||
for( var n=0; n<num_buttons; n++ ) {
|
||||
command_cache.push("unassigned");
|
||||
for( var n=0; n<numButtons; n++ ) {
|
||||
commandCache.push("unassigned");
|
||||
$("#assign_button"+n).click( n, hotButtonClicked );
|
||||
}
|
||||
}
|
||||
|
|
@ -140,14 +139,12 @@ let hotbuttons = (function () {
|
|||
var myLayout = window.plugins["goldenlayout"].getGL();
|
||||
|
||||
myLayout.registerComponent( "hotbuttons", function (container, componentState) {
|
||||
console.log("hotbuttons");
|
||||
|
||||
// build the buttons
|
||||
var div = $("<div class='input-group'>");
|
||||
|
||||
var len = command_cache.length;
|
||||
for( var x=len; x < len + num_buttons; x++ ) {
|
||||
command_cache.push("unassigned");
|
||||
var len = commandCache.length;
|
||||
for( var x=len; x < len + numButtons; x++ ) {
|
||||
commandCache.push("unassigned");
|
||||
|
||||
// initialize button command cache and onClick handler
|
||||
var button = $("<button class='btn' id='assign_button"+x+"' type='button' value='button"+x+"'>");
|
||||
|
|
@ -167,9 +164,9 @@ let 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"];
|
||||
$.each( button_options, function( key, value ) {
|
||||
if( dependenciesMet && kwargs["HotButtons"] ) {
|
||||
var buttonOptions = kwargs["HotButtons"];
|
||||
$.each( buttonOptions, function( key, value ) {
|
||||
assignButton(key, value);
|
||||
});
|
||||
}
|
||||
|
|
@ -182,7 +179,7 @@ let hotbuttons = (function () {
|
|||
// Are we using splithandler?
|
||||
if( window.plugins["splithandler"] ) {
|
||||
addButtonsUI();
|
||||
dependencies_met = true;
|
||||
dependenciesMet = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,14 +190,7 @@ let hotbuttons = (function () {
|
|||
// Are we using GoldenLayout?
|
||||
if( window.plugins["goldenlayout"] ) {
|
||||
buildComponent();
|
||||
dependencies_met = true;
|
||||
}
|
||||
|
||||
if( dependencies_met ) {
|
||||
console.log("HotButtons Plugin Initialized.");
|
||||
} else {
|
||||
console.log("HotButtons Plugin Dependencies Not Met!!");
|
||||
console.log("No splithandler.js or goldenlayout.js plugin found.");
|
||||
dependenciesMet = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue