Lint under_scores to CamelCase

This commit is contained in:
Brenden Tuck 2019-04-05 21:58:28 -04:00
parent 068217f2ec
commit a845bbf63d
5 changed files with 105 additions and 125 deletions

View file

@ -66,8 +66,6 @@ let defaultin_plugin = (function () {
e.which = 13; e.which = 13;
$("#inputfield").focus().trigger(e); $("#inputfield").focus().trigger(e);
}); });
console.log("DefaultIn initialized");
} }
return { return {

View file

@ -6,7 +6,7 @@
let goldenlayout = (function () { let goldenlayout = (function () {
var myLayout; var myLayout;
var known_types = ["all", "untagged"]; var knownTypes = ["all", "untagged"];
var untagged = []; var untagged = [];
var newTabConfig = { var newTabConfig = {
@ -15,7 +15,7 @@ let goldenlayout = (function () {
componentName: "evennia", componentName: "evennia",
componentState: { componentState: {
types: "all", types: "all",
update_method: "newlines", updateMethod: "newlines",
}, },
}; };
@ -28,23 +28,26 @@ let goldenlayout = (function () {
// helper function: filter vals out of array // helper function: filter vals out of array
function filter (vals, array) { function filter (vals, array) {
let tmp = array.slice(); if( Array.isArray( vals ) && Array.isArray( array ) ) {
for (let i=0; i<vals.length; i++) { let tmp = array.slice();
let val = vals[i]; vals.forEach( function (val) {
while( tmp.indexOf(val) > -1 ) { while( tmp.indexOf(val) > -1 ) {
tmp.splice( 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. // then filter out all types that have been mapped to a pane.
var calculateUntaggedTypes = function () { var calculateUntaggedTypes = function () {
// set initial untagged list // set initial untagged list
untagged = filter( ["all", "untagged"], known_types); untagged = filter( ["all", "untagged"], knownTypes);
// for each .content pane // for each .content pane
$(".content").each( function () { $(".content").each( function () {
let types = $(this).attr("types"); let types = $(this).attr("types");
@ -65,7 +68,7 @@ let goldenlayout = (function () {
components.forEach( function (component) { components.forEach( function (component) {
let element = component.tab.header.parent.element[0]; let element = component.tab.header.parent.element[0];
if( element == content && component.tab.isActive ) { if( (element === content) && (component.tab.isActive) ) {
component.setTitle( title ); component.setTitle( title );
} }
}); });
@ -82,12 +85,11 @@ let goldenlayout = (function () {
let checkboxes = $("#typelist :input"); let checkboxes = $("#typelist :input");
let types = []; let types = [];
for (let i=0; i<checkboxes.length; i++ ) { checkboxes.each( function (idx) {
let box = checkboxes[i]; if( $(checkboxes[idx]).prop("checked") ) {
if( $(box).prop("checked") ) { types.push( $(checkboxes[idx]).val() );
types.push( $(box).val() );
} }
} });
content.attr("types", types.join(" ")); content.attr("types", types.join(" "));
myLayout.emit("stateChanged"); myLayout.emit("stateChanged");
@ -103,7 +105,7 @@ let goldenlayout = (function () {
let content = $("#updatelist").parent().find(".content"); let content = $("#updatelist").parent().find(".content");
let value = $("input[name=upmethod]:checked").val(); let value = $("input[name=upmethod]:checked").val();
content.attr("update_method", value ); content.attr("updateMethod", value );
myLayout.emit("stateChanged"); myLayout.emit("stateChanged");
$("#updatelist").remove(); $("#updatelist").remove();
} }
@ -141,23 +143,22 @@ let goldenlayout = (function () {
var onSelectTypesClicked = function (evnt) { var onSelectTypesClicked = function (evnt) {
let element = $(evnt.data.contentItem.element); let element = $(evnt.data.contentItem.element);
let content = element.find(".content"); let content = element.find(".content");
let selected_types = content.attr("types"); let selectedTypes = content.attr("types");
let menu = $("<div id='typelist'>"); let menu = $("<div id='typelist'>");
let div = $("<div class='typelistsub'>"); let div = $("<div class='typelistsub'>");
if( selected_types ) { if( selectedTypes ) {
selected_types = selected_types.split(" "); selectedTypes = selectedTypes.split(" ");
} }
for (let i=0; i<known_types.length;i++) { knownTypes.forEach( function (itype) {
let itype = known_types[i];
let choice; 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>"); choice = $("<label><input type='checkbox' value='"+itype+"' checked='checked'/>"+itype+"</label>");
} else { } else {
choice = $("<label><input type='checkbox' value='"+itype+"'/>"+itype+"</label>"); choice = $("<label><input type='checkbox' value='"+itype+"'/>"+itype+"</label>");
} }
choice.appendTo(div); choice.appendTo(div);
} });
div.appendTo(menu); div.appendTo(menu);
element.prepend(menu); element.prepend(menu);
@ -191,10 +192,10 @@ let goldenlayout = (function () {
var onUpdateMethodClicked = function (evnt) { var onUpdateMethodClicked = function (evnt) {
let element = $(evnt.data.contentItem.element); let element = $(evnt.data.contentItem.element);
let content = element.find(".content"); let content = element.find(".content");
let update_method = content.attr("update_method"); let updateMethod = content.attr("updateMethod");
let nlchecked = (update_method == "newlines") ? "checked='checked'" : ""; let nlchecked = (updateMethod === "newlines") ? "checked='checked'" : "";
let apchecked = (update_method == "append") ? "checked='checked'" : ""; let apchecked = (updateMethod === "append") ? "checked='checked'" : "";
let rpchecked = (update_method == "replace") ? "checked='checked'" : ""; let rpchecked = (updateMethod === "replace") ? "checked='checked'" : "";
let menu = $("<div id='updatelist'>"); let menu = $("<div id='updatelist'>");
let div = $("<div class='updatelistsub'>"); let div = $("<div class='updatelistsub'>");
@ -263,10 +264,10 @@ let goldenlayout = (function () {
components.forEach( function (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 textDiv = component.container.getElement().children(".content");
let types = text_div.attr("types"); let types = textDiv.attr("types");
let update_method = text_div.attr("update_method"); let updateMethod = textDiv.attr("updateMethod");
component.container.extendState({ "types": types, "update_method": update_method }); component.container.extendState({ "types": types, "updateMethod": updateMethod });
}); });
var state = JSON.stringify( myLayout.toConfig() ); var state = JSON.stringify( myLayout.toConfig() );
@ -301,7 +302,7 @@ let goldenlayout = (function () {
tab.element.append( updateDropdownControl ); tab.element.append( updateDropdownControl );
tab.element.append( splitControl ); 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") ); tab.element.prepend( $("#optionsbutton").clone(true).addClass("lm_title") );
} }
@ -333,10 +334,10 @@ let goldenlayout = (function () {
components.forEach( function (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 textDiv = component.container.getElement().children(".content");
let scrollHeight = text_div.prop("scrollHeight"); let scrollHeight = textDiv.prop("scrollHeight");
let clientHeight = text_div.prop("clientHeight"); let clientHeight = textDiv.prop("clientHeight");
text_div.scrollTop( scrollHeight - clientHeight ); textDiv.scrollTop( scrollHeight - clientHeight );
}); });
myLayout.updateSize(); myLayout.updateSize();
} }
@ -344,30 +345,30 @@ let goldenlayout = (function () {
// //
// //
var routeMsg = function (text_div, txt, update_method) { var routeMsg = function (textDiv, txt, updateMethod) {
if ( update_method == "replace" ) { if ( updateMethod === "replace" ) {
text_div.html(txt); textDiv.html(txt);
} else if ( update_method == "append" ) { } else if ( updateMethod === "append" ) {
text_div.append(txt); textDiv.append(txt);
} else { // line feed } 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 scrollHeight = textDiv.prop("scrollHeight");
let clientHeight = text_div.prop("clientHeight"); let clientHeight = textDiv.prop("clientHeight");
text_div.scrollTop( scrollHeight - 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 // set this container"s content div types attribute
if( state ) { if( state ) {
div.attr("types", state.types); div.attr("types", state.types);
div.attr("update_method", state.update_method); div.attr("updateMethod", state.updateMethod);
} else { } else {
div.attr("types", default_types); div.attr("types", defaultTypes);
div.attr("update_method", update_method); div.attr("updateMethod", updateMethod);
} }
div.appendTo( container.getElement() ); div.appendTo( container.getElement() );
container.on("tab", onTabCreate); container.on("tab", onTabCreate);
@ -399,41 +400,40 @@ let goldenlayout = (function () {
if ( kwargs && "type" in kwargs ) { if ( kwargs && "type" in kwargs ) {
msgtype = kwargs["type"]; msgtype = kwargs["type"];
if ( ! known_types.includes(msgtype) ) { if ( ! knownTypes.includes(msgtype) ) {
// this is a new output type that can be mapped to panes // this is a new output type that can be mapped to panes
console.log("detected new output type: " + msgtype); knownTypes.push(msgtype);
known_types.push(msgtype);
untagged.push(msgtype); untagged.push(msgtype);
} }
} }
let message_delivered = false; let messageDelivered = false;
let components = myLayout.root.getItemsByType("component"); let components = myLayout.root.getItemsByType("component");
components.forEach( function (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 textDiv = component.container.getElement().children(".content");
let attr_types = text_div.attr("types"); let attrTypes = textDiv.attr("types");
let pane_types = attr_types ? attr_types.split(" ") : []; let paneTypes = attrTypes ? attrTypes.split(" ") : [];
let update_method = text_div.attr("update_method"); let updateMethod = textDiv.attr("updateMethod");
let txt = args[0]; let txt = args[0];
// is this message type listed in this pane"s types (or is this pane catching "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") ) { if( paneTypes.includes(msgtype) || paneTypes.includes("all") ) {
routeMsg( text_div, txt, update_method ); routeMsg( textDiv, txt, updateMethod );
message_delivered = true; messageDelivered = true;
} }
// is this pane catching "upmapped" messages? // is this pane catching "upmapped" messages?
// And is this message type listed in the untagged types array? // And is this message type listed in the untagged types array?
if( pane_types.includes("untagged") && untagged.includes(msgtype) ) { if( paneTypes.includes("untagged") && untagged.includes(msgtype) ) {
routeMsg( text_div, txt, update_method ); routeMsg( textDiv, txt, updateMethod );
message_delivered = true; messageDelivered = true;
} }
}); });
if ( message_delivered ) { if ( messageDelivered ) {
return true; return true;
} }
// unhandled message // unhandled message
@ -452,8 +452,6 @@ let goldenlayout = (function () {
// Set Save State callback // Set Save State callback
myLayout.on( "stateChanged", onStateChanged ); myLayout.on( "stateChanged", onStateChanged );
console.log("Golden Layout Plugin Initialized.");
} }
@ -514,8 +512,8 @@ let goldenlayout = (function () {
postInit: postInit, postInit: postInit,
onKeydown: onKeydown, onKeydown: onKeydown,
onText: onText, onText: onText,
getGL: function () { return myLayout }, getGL: function () { return myLayout; },
addKnownType: function (newtype) { known_types.push(newtype) }, addKnownType: function (newtype) { knownTypes.push(newtype); },
} }
})(); }());
window.plugin_handler.add("goldenlayout", goldenlayout); window.plugin_handler.add("goldenlayout", goldenlayout);

View file

@ -27,7 +27,7 @@ var goldenlayout_config = { // Global Variable used in goldenlayout.js init()
tooltip: "Main - drag to desird position.", tooltip: "Main - drag to desird position.",
componentState: { componentState: {
types: "untagged", types: "untagged",
update_method: "newlines", updateMethod: "newlines",
}, },
}] }]
}], }],

View file

@ -3,12 +3,12 @@
* Evennia Webclient Command History plugin * Evennia Webclient Command History plugin
* *
*/ */
let history_plugin = (function () { let history = (function () {
// Manage history for input line // Manage history for input line
var history_max = 21; var historyMax = 21;
var history = new Array(); var history = new Array();
var history_pos = 0; var historyPos = 0;
history[0] = ""; // the very latest input is empty for new entry. history[0] = ""; // the very latest input is empty for new entry.
@ -16,16 +16,16 @@ let history_plugin = (function () {
// move back in the history // move back in the history
var back = function () { var back = function () {
// step backwards in history stack // step backwards in history stack
history_pos = Math.min(++history_pos, history.length - 1); historyPos = Math.min(++historyPos, history.length - 1);
return history[history.length - 1 - history_pos]; return history[history.length - 1 - historyPos];
} }
// //
// move forward in the history // move forward in the history
var fwd = function () { var fwd = function () {
// step forwards in history stack // step forwards in history stack
history_pos = Math.max(--history_pos, 0); historyPos = Math.max(--historyPos, 0);
return history[history.length - 1 - history_pos]; return history[history.length - 1 - historyPos];
} }
// //
@ -33,13 +33,13 @@ let history_plugin = (function () {
var add = function (input) { var add = function (input) {
// add a new entry to history, don't repeat latest // add a new entry to history, don't repeat latest
if (input && input != history[history.length-2]) { if (input && input != history[history.length-2]) {
if (history.length >= history_max) { if (history.length >= historyMax) {
history.shift(); // kill oldest entry history.shift(); // kill oldest entry
} }
history[history.length-1] = input; history[history.length-1] = input;
history[history.length] = ""; history[history.length] = "";
} }
history_pos = 0; historyPos = 0;
} }
// Public // Public
@ -48,18 +48,18 @@ let history_plugin = (function () {
// Handle up arrow and down arrow events. // Handle up arrow and down arrow events.
var onKeydown = function(event) { var onKeydown = function(event) {
var code = event.which; 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. // Only process up/down arrow if cursor is at the end of the line.
if (code === 38 && event.shiftKey) { // Arrow up if (code === 38 && event.shiftKey) { // Arrow up
history_entry = back(); historyEntry = back();
} }
else if (code === 40 && event.shiftKey) { // Arrow down else if (code === 40 && event.shiftKey) { // Arrow down
history_entry = fwd(); historyEntry = fwd();
} }
// are we processing an up or down history event? // 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 // Doing a history navigation; replace the text in the input and
// move the cursor to the end of the new value // move the cursor to the end of the new value
var inputfield = $(".inputfield:focus"); var inputfield = $(".inputfield:focus");
@ -67,7 +67,7 @@ let history_plugin = (function () {
inputfield = $("#inputfield"); inputfield = $("#inputfield");
} }
inputfield.val(""); inputfield.val("");
inputfield.blur().focus().val(history_entry); inputfield.blur().focus().val(historyEntry);
event.preventDefault(); event.preventDefault();
return true; return true;
} }
@ -82,16 +82,10 @@ let history_plugin = (function () {
return null; return null;
} }
//
// Init function
var init = function () {
console.log("History Plugin Initialized.");
}
return { return {
init: init, init: function () {},
onKeydown: onKeydown, onKeydown: onKeydown,
onSend: onSend, onSend: onSend,
} }
})() }());
window.plugin_handler.add("history", history_plugin); window.plugin_handler.add("history", history);

View file

@ -29,10 +29,10 @@
* REQUIRES: goldenlayout.js OR splithandler.js * REQUIRES: goldenlayout.js OR splithandler.js
*/ */
let hotbuttons = (function () { let hotbuttons = (function () {
var dependencies_met = false; var dependenciesMet = false;
var num_buttons = 9; var numButtons = 9;
var command_cache = new Array; var commandCache = new Array;
// //
// collect command text // collect command text
@ -40,7 +40,7 @@ let hotbuttons = (function () {
// make sure text has something in it // make sure text has something in it
if( text && text.length ) { if( text && text.length ) {
// cache the command text // cache the command text
command_cache[n] = text; commandCache[n] = text;
// is there a space in the command, indicating "command argument" syntax? // is there a space in the command, indicating "command argument" syntax?
if( text.indexOf(" ") > 0 ) { if( text.indexOf(" ") > 0 ) {
@ -59,13 +59,13 @@ let hotbuttons = (function () {
// change button text to "unassigned" // change button text to "unassigned"
$("#assign_button"+n).text( "unassigned" ); $("#assign_button"+n).text( "unassigned" );
// clear current command // clear current command
command_cache[n] = "unassigned"; commandCache[n] = "unassigned";
} }
// //
// actually send the command associated with the button that is clicked // actually send the command associated with the button that is clicked
var sendImmediate = function(n) { var sendImmediate = function(n) {
var text = command_cache[n]; var text = commandCache[n];
if( text.length ) { if( text.length ) {
Evennia.msg("text", [text], {}); Evennia.msg("text", [text], {});
} }
@ -75,7 +75,6 @@ let hotbuttons = (function () {
// send, assign, or clear the button // send, assign, or clear the button
var hotButtonClicked = function(e) { var hotButtonClicked = function(e) {
var button = $("#assign_button"+e.data); var button = $("#assign_button"+e.data);
console.log("button " + e.data + " clicked");
if( button.text() == "unassigned" ) { if( button.text() == "unassigned" ) {
// Assign the button and send the full button state to the server using a Webclient_Options event // 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");
@ -83,12 +82,12 @@ let hotbuttons = (function () {
input = $("#inputfield"); input = $("#inputfield");
} }
assignButton( e.data, input.val() ); assignButton( e.data, input.val() );
Evennia.msg("webclient_options", [], { "HotButtons": command_cache }); Evennia.msg("webclient_options", [], { "HotButtons": commandCache });
} else { } else {
if( e.shiftKey ) { if( e.shiftKey ) {
// Clear the button and send the full button state to the server using a Webclient_Options event // Clear the button and send the full button state to the server using a Webclient_Options event
clearButton(e.data); clearButton(e.data);
Evennia.msg("webclient_options", [], { "HotButtons": command_cache }); Evennia.msg("webclient_options", [], { "HotButtons": commandCache });
} else { } else {
sendImmediate(e.data); sendImmediate(e.data);
} }
@ -127,8 +126,8 @@ let hotbuttons = (function () {
minSize: [150,20,50], minSize: [150,20,50],
}); });
for( var n=0; n<num_buttons; n++ ) { for( var n=0; n<numButtons; n++ ) {
command_cache.push("unassigned"); commandCache.push("unassigned");
$("#assign_button"+n).click( n, hotButtonClicked ); $("#assign_button"+n).click( n, hotButtonClicked );
} }
} }
@ -140,14 +139,12 @@ let hotbuttons = (function () {
var myLayout = window.plugins["goldenlayout"].getGL(); var myLayout = window.plugins["goldenlayout"].getGL();
myLayout.registerComponent( "hotbuttons", function (container, componentState) { myLayout.registerComponent( "hotbuttons", function (container, componentState) {
console.log("hotbuttons");
// build the buttons // build the buttons
var div = $("<div class='input-group'>"); var div = $("<div class='input-group'>");
var len = command_cache.length; var len = commandCache.length;
for( var x=len; x < len + num_buttons; x++ ) { for( var x=len; x < len + numButtons; x++ ) {
command_cache.push("unassigned"); commandCache.push("unassigned");
// initialize button command cache and onClick handler // initialize button command cache and onClick handler
var button = $("<button class='btn' id='assign_button"+x+"' type='button' value='button"+x+"'>"); 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 // Handle the HotButtons part of a Webclient_Options event
var onGotOptions = function(args, kwargs) { var onGotOptions = function(args, kwargs) {
if( dependencies_met && kwargs["HotButtons"] ) { if( dependenciesMet && kwargs["HotButtons"] ) {
var button_options = kwargs["HotButtons"]; var buttonOptions = kwargs["HotButtons"];
$.each( button_options, function( key, value ) { $.each( buttonOptions, function( key, value ) {
assignButton(key, value); assignButton(key, value);
}); });
} }
@ -182,7 +179,7 @@ let hotbuttons = (function () {
// Are we using splithandler? // Are we using splithandler?
if( window.plugins["splithandler"] ) { if( window.plugins["splithandler"] ) {
addButtonsUI(); addButtonsUI();
dependencies_met = true; dependenciesMet = true;
} }
} }
@ -193,14 +190,7 @@ let hotbuttons = (function () {
// Are we using GoldenLayout? // Are we using GoldenLayout?
if( window.plugins["goldenlayout"] ) { if( window.plugins["goldenlayout"] ) {
buildComponent(); buildComponent();
dependencies_met = true; dependenciesMet = 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.");
} }
} }