').append(
- $('| ', {
- class: ['text-right', Util.config.helpClass, config.connectionInfoTableCellMassTotalTooltipClass].join(' '),
- html: ''
- }),
- $(' | ', {
- text: scopeLabel.charAt(0).toUpperCase() + scopeLabel.slice(1)
- }),
- $(' | ', {
- class: ['text-right', config.connectionInfoTableCellConnectionClass].join(' ')
- }).append(
- $('', {
- class: MapUtil.getConnectionFakeClassesByTypes(connectionData.type).join(' ')
- })
- )
- ),
- $(' ').append(
- $('| ', {
- class: ['text-right', Util.config.helpClass].join(' '),
- html: '',
- title: 'initial mass. From signature table'
- }).attr('data-toggle', 'tooltip'),
- $(' | ', {
- text: 'Total mass'
- }),
- $(' | ', {
- class: ['text-right', 'txt-color', config.connectionInfoTableCellMassTotalClass].join(' ')
- })
- ),
- $(' | ', {
- class: config.connectionInfoTableRowMassLogClass
- }).append(
- $('| ', {
- class: ['text-right', Util.config.helpClass].join(' '),
- title: 'recorded total jump mass'
- }).attr('data-toggle', 'tooltip').append(
- $('', {
- class: [
- 'fas', 'fa-fw', 'fa-question-circle'
- ].join(' ')
- }),
- $('', {
- class: [
- 'fas', 'fa-fw', 'fa-adjust',
- 'txt-color', 'txt-color-warning',
- 'hidden'
- ].join(' ')
- }),
- $('', {
- class: [
- 'far', 'fa-fw', 'fa-circle',
- 'txt-color', 'txt-color-danger',
- 'hidden'
- ].join(' ')
- })
- ),
- $(' | ', {
- text: 'Logged mass'
- }),
- $(' | ', {
- class: ['text-right', config.connectionInfoTableCellMassLogClass].join(' ')
- })
- ),
- $(' | ', {
- class: config.connectionInfoTableRowMassShipClass
- }).append(
- $('| ', {
- class: ['text-right', Util.config.helpClass].join(' '),
- title: 'current ship mass'
- }).attr('data-toggle', 'tooltip').append(
- $('', {
- class: ['fas', 'fa-fw', 'fa-question-circle'].join(' ')
- }),
- $('', {
- class: [
- 'fas', 'fa-fw', 'fa-exclamation-triangle',
- 'txt-color', 'txt-color-danger',
- 'hidden'
- ].join(' ')
- })
- ),
- $(' | ', {
- class: ['pf-table-cell-ellipses-auto'].join(' '),
- text: 'Ship mass'
- }),
- $(' | ', {
- class: ['text-right', 'txt-color', config.connectionInfoTableCellMassShipClass].join(' ')
- })
- ),
- $(' | ').append(
- $('| ', {
- class: ['text-right', Util.config.helpClass].join(' '),
- html: '',
- title: 'max. mass left'
- }).attr('data-toggle', 'tooltip'),
- $(' | ', {
- text: 'Mass left'
- }),
- $(' | ', {
- class: ['text-right', 'txt-color', config.connectionInfoTableCellMassLeftClass].join(' ')
- })
- )
- )
- ).on('pf:updateInfoTable', function(e, data){
- // update information table -------------------------------------------------------
- let tableElement = $(this);
- let connectionData = tableElement.data('connectionData');
- if(connectionData){
- if(connectionData.scope === 'wh'){
- // update signature information -------------------------------------------
- let sourceLabelElement = tableElement.find('.' + config.connectionInfoTableLabelSourceClass);
- let targetLabelElement = tableElement.find('.' + config.connectionInfoTableLabelTargetClass);
-
- // get related jsPlumb connection
- let connection = $().getConnectionById(data.mapId, data.connectionId);
- let signatureTypeNames = MapUtil.getConnectionDataFromSignatures(connection, connectionData);
-
- let sourceLabel = signatureTypeNames.sourceLabels;
- let targetLabel = signatureTypeNames.targetLabels;
- sourceLabelElement.html(MapUtil.getEndpointOverlayContent(sourceLabel));
- targetLabelElement.html(MapUtil.getEndpointOverlayContent(targetLabel));
-
- // remove K162
- sourceLabel = sourceLabel.diff(['K162']);
- targetLabel = targetLabel.diff(['K162']);
-
- // get static wormhole data by endpoint Labels
- let wormholeName = '';
- let wormholeData = null;
- if(sourceLabel.length === 1 && targetLabel.length === 0){
- wormholeName = sourceLabel[0];
- }else if(sourceLabel.length === 0 && targetLabel.length === 1){
- wormholeName = targetLabel[0];
- }
-
- if(
- wormholeName &&
- Init.wormholes.hasOwnProperty(wormholeName)
- ){
- wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
- wormholeData.class = Util.getSecurityClassForSystem(wormholeData.security);
-
- // init wormhole tooltip ----------------------------------------------
- let massTotalTooltipCell = tableElement.find('.' + config.connectionInfoTableCellMassTotalTooltipClass);
- massTotalTooltipCell.addWormholeInfoTooltip(wormholeData);
- }
-
- // all required data is set -> re-calculate rows
- tableElement.data('wormholeData', wormholeData);
- tableElement.trigger('pf:calcInfoTable');
- }
-
- }
- }).on('pf:calcInfoTable', function(e){
- // re-calculate information table from .data() cell values ------------------------
- let tableElement = $(this);
- let connectionData = tableElement.data('connectionData');
- let massChartCell = tableElement.find('[data-percent]');
-
- let wormholeData = tableElement.data('wormholeData');
- let shipData = null;
- let shipName = '';
- let showShip = Boolean(tableElement.data('showShip'));
- let massLogRow = tableElement.find('.' + config.connectionInfoTableRowMassLogClass);
- let massShipRow = tableElement.find('.' + config.connectionInfoTableRowMassShipClass);
-
- // icons
- let massLogTooltipIcon = massLogRow.find('i.fa-question-circle');
- let massLogStage2Icon = massLogRow.find('i.fa-adjust');
- let massLogStage3Icon = massLogRow.find('i.fa-circle');
-
- let massShipTooltipIcon = massShipRow.find('i.fa-question-circle');
- let massShipWarningIcon = massShipRow.find('i.fa-exclamation-triangle');
-
- // table cells
- let connectionCell = tableElement.find('.' + config.connectionInfoTableCellConnectionClass);
- let massTotalCell = tableElement.find('.' + config.connectionInfoTableCellMassTotalClass);
- let massLogCell = tableElement.find('.' + config.connectionInfoTableCellMassLogClass);
- let massShipCell = tableElement.find('.' + config.connectionInfoTableCellMassShipClass);
- let massLeftCell = tableElement.find('.' + config.connectionInfoTableCellMassLeftClass);
- let massTotal = null; // initial connection mass
- let massReduction = 0; // default reduction (e.g. reduced, crit) in percent
- let massLog = massLogCell.data('mass'); // recorded mass
- let massLogTotal = massLog; // recorded mass + current ship
- let massIndividual = null; // mass mass per jump
- let massShip = 0; // current ship
- let massIndividualError = false;
-
- // get wormhole data from signature binding ---------------------------------------
- if(wormholeData){
- massTotal = parseInt(wormholeData.massTotal);
- massIndividual = parseInt(wormholeData.massIndividual);
- }
-
- // get connection type (show fake connection div) ---------------------------------
- connectionCell.find('div').removeClass().addClass(MapUtil.getConnectionFakeClassesByTypes(connectionData.type).join(' '));
-
- // get wormhole status ------------------------------------------------------------
- if(connectionData.type.indexOf('wh_critical') !== -1){
- massReduction = 90;
- massLogTooltipIcon.toggleClass('hidden', true);
- massLogStage2Icon.toggleClass('hidden', true);
- massLogStage3Icon.toggleClass('hidden', false);
- massLogStage3Icon.parent().attr('title', 'stage 3 (critical)').tooltip('fixTitle');
- }else if(connectionData.type.indexOf('wh_reduced') !== -1){
- massReduction = 50;
- massLogTooltipIcon.toggleClass('hidden', true);
- massLogStage2Icon.toggleClass('hidden', false);
- massLogStage3Icon.toggleClass('hidden', true);
- massLogStage3Icon.parent().attr('title', 'stage 2 (reduced)').tooltip('fixTitle');
- }else{
- massLogTooltipIcon.toggleClass('hidden', false);
- massLogStage2Icon.toggleClass('hidden', true);
- massLogStage3Icon.toggleClass('hidden', true);
- massLogStage3Icon.parent().attr('title', 'recorded total jump mass').tooltip('fixTitle');
- }
-
- if(massReduction){
- let massLogReduction = massTotal / 100 * massReduction;
- if(massLogReduction > massLog){
- massLog = massLogTotal = massLogReduction;
- }
- }
-
- // get current ship data ----------------------------------------------------------
- massShipCell.parent().toggle(showShip);
- if(showShip){
- shipData = $('.' + config.headUserShipClass).data('shipData');
- if(shipData){
- if(shipData.mass){
- massShip = parseInt(shipData.mass);
-
- // check individual mass jump
- if(massIndividual){
- massIndividualError = massShip > massIndividual;
- }
- }
- if(shipData.typeId && shipData.typeName){
- shipName = shipData.typeName;
- }
- }
- }
-
- // update ship mass and "individual mass" cells ----------------------------------
- massShipTooltipIcon.toggleClass('hidden', massIndividualError);
- massShipWarningIcon.toggleClass('hidden', !massIndividualError);
- let shipMassTooltip = 'current ship mass ' + (shipName ? '"' + shipName + '"' : '');
- if(massIndividualError){
- shipMassTooltip = '"' + shipName + '" exceeds max jump mass for this connection: ' + Util.formatMassValue(massIndividual);
- }else{
- // current ship mass check is OK -> add to massLogTotal
- massLogTotal += massShip;
- }
- massShipTooltipIcon.parent().attr('title', shipMassTooltip).tooltip('fixTitle');
-
- // current ship mass --------------------------------------------------------------
- massShipCell.html( function(){
- let cell = $(this);
- let value = ' ';
- let error = false;
- let textLineThrough = false;
- if(massShip > 0){
- value += Util.formatMassValue(massShip);
- if(massIndividualError){
- error = textLineThrough = true;
- value = ' ' + value;
- }else{
- value = '-' + value;
- }
- }else{
- error = true;
- value = 'undefined';
- }
-
- // change cell style
- cell.toggleClass('txt-color-red', error)
- .toggleClass('txt-color-warning', !error)
- .toggleClass('pf-font-line-through', textLineThrough);
-
- return value;
- });
-
- // calculate mass left ------------------------------------------------------------
- let massLeft = massTotal - massLogTotal;
- massLeft = (massLeft < 0) ? 0 : massLeft;
- let massPercentLog = (massTotal > 0) ? Math.floor((100 / massTotal) * massLogTotal) : 0;
-
- // update easyPieChart and tooltip ------------------------------------------------
- let massPercentLeft = (100 - massPercentLog <= 0) ? 0 : '< ' + (100 - massPercentLog);
- massChartCell.data('easyPieChart').enableAnimation().update(massPercentLog * -1);
- massChartCell.attr('title', massPercentLeft + '% mass left').tooltip('fixTitle');
-
- // update mass cells --------------------------------------------------------------
- massTotalCell.html(massTotal > 0 ? Util.formatMassValue(massTotal) : 'undefined')
- .toggleClass('txt-color-red', massTotal <= 0);
- massLogCell.html('- ' + Util.formatMassValue(massLog));
- massLeftCell.html(
- massLeft > 0 ?
- '~ ' + Util.formatMassValue(massLeft) :
- (massLeft === 0 && massTotal) ?
- 'will collapse' : 'undefined')
- .toggleClass('txt-color-red', massLeft <= 0)
- .toggleClass('txt-color-success', massLeft > 0);
- })
- );
-
- element.find('[data-toggle="tooltip"]').tooltip({
- container: 'body'
- });
-
- return element;
- };
-
- /**
- * get HTML id by connectionId
- * @param connectionId
- * @returns {string}
- */
- let getConnectionElementId = (connectionId) => {
- return config.connectionInfoPanelId + connectionId;
- };
-
- /**
- * get all visible connection panel elements
- * @param moduleElement
- * @returns {*|T|{}}
- */
- let getConnectionElements = (moduleElement) => {
- return moduleElement.find('.' + config.connectionInfoPanelClass).not('#' + getConnectionElementId(0));
- };
-
- /**
- * request connection log data
- * @param requestData
- * @param context
- * @param callback
- */
- let requestConnectionLogData = (requestData, context, callback) => {
- // show loading animation
- for(let connectionId of requestData.connectionIds){
- context.moduleElement.find('#' + getConnectionElementId(connectionId) + ' table').showLoadingAnimation();
- }
-
- $.ajax({
- type: 'POST',
- url: Init.path.getMapConnectionData,
- data: requestData,
- dataType: 'json',
- context: context
- }).done(function(connectionsData){
- // enrich connectionData with "logs" data (if available) and other "missing" data
- for(let i = 0; i < this.connectionsData.length; i++){
- for(let connectionData of connectionsData) {
- if(this.connectionsData[i].id === connectionData.id){
- // copy some missing data
- this.connectionsData[i].created = connectionData.created;
- // check for mass logs and copy data
- if(connectionData.logs && connectionData.logs.length){
- this.connectionsData[i].logs = connectionData.logs;
- }
- // check for signatures and copy data
- if(connectionData.signatures && connectionData.signatures.length){
- this.connectionsData[i].signatures = connectionData.signatures;
- }
- break;
- }
- }
- }
-
- callback(this.moduleElement, this.connectionsData);
- }).always(function(){
- // hide loading animation
- for(let contextData of this.connectionsData){
- context.moduleElement.find('#' + getConnectionElementId(contextData.id) + ' table').hideLoadingAnimation();
- }
- });
- };
-
- /**
- * @see requestConnectionLogData
- * @param moduleElement
- * @param mapId
- * @param connectionsData
- */
- let getConnectionsLogData = (moduleElement, mapId, connectionsData) => {
- let connectionIds = [];
- for(let connectionData of connectionsData) {
- connectionIds.push(connectionData.id);
- }
-
- let requestData = {
- mapId: mapId,
- connectionIds: connectionIds,
- addData : ['signatures', 'logs'],
- // filterData : ['logs'] // do not exclude connections with NO "logs" -> sig data will be used as well
- };
-
- let contextData = {
- moduleElement: moduleElement,
- connectionsData: connectionsData
- };
-
- requestConnectionLogData(requestData, contextData, addConnectionsData);
- };
-
- /**
- * replace/insert dataTables log data
- * @param moduleElement
- * @param connectionsData
- */
- let addConnectionsData = (moduleElement, connectionsData) => {
-
- let getRowIndexesByData = (dataTable, colName, value) => {
- return dataTable.rows().eq(0).filter((rowIdx) => {
- return (dataTable.cell(rowIdx, colName + ':name' ).data() === value);
- });
- };
-
- for(let connectionData of connectionsData) {
- // find related dom element for current connection
- let connectionElement = moduleElement.find('#' + getConnectionElementId(connectionData.id));
- if(connectionElement.length){
- // attach connectionData to connection information for later use ------------------
- let connectionInfoElement = connectionElement.find('.' + config.moduleTableClass);
- connectionInfoElement.data('connectionData', connectionData);
-
- // update dataTable ---------------------------------------------------------------
- let dataTable = connectionElement.find('.dataTable').dataTable().api();
-
- if(connectionData.logs && connectionData.logs.length > 0){
- for(let i = 0; i < connectionData.logs.length; i++){
- let rowData = connectionData.logs[i];
- let row = null;
- let animationStatus = null;
- let indexes = getRowIndexesByData(dataTable, 'index', rowData.id);
- if(indexes.length === 0){
- // row not found -> add new row
- row = dataTable.row.add( rowData );
- animationStatus = 'added';
- }
- /* else{
- // we DON´t expect changes -> no row update)
- // update row with FIRST index
- //row = dataTable.row( parseInt(indexes[0]) );
- // update row data
- //row.data(connectionData.logs[i]);
- //animationStatus = 'changed';
- } */
-
- if(
- animationStatus !== null &&
- row.length > 0
- ){
- row.nodes().to$().data('animationStatus', animationStatus);
- }
- }
- }else{
- // clear table or leave empty
- dataTable.clear();
- }
-
- // redraw dataTable
- dataTable.draw(false);
- }
- }
- };
-
- /**
- *
- * @param moduleElement
- * @param mapId
- * @param connectionData
- */
- let updateConnectionPanel = (moduleElement, mapId, connectionData) => {
- let rowElement = moduleElement.find('.row');
- let connectionElement = rowElement.find('#' + getConnectionElementId(connectionData.id));
-
- if( !connectionElement.length ){
- connectionElement = getConnectionElement(mapId, connectionData.id);
- connectionElement.append(getInformationElement(connectionData));
-
- let table = $('', {
- class: ['compact', 'stripe', 'order-column', 'row-border', 'nowrap', config.connectionInfoTableClass].join(' ')
- }).append(' | | | | | ');
- connectionElement.append(table);
-
- // init empty table
- let logTable = table.DataTable({
- pageLength: 8,
- paging: true,
- pagingType: 'simple',
- lengthChange: false,
- ordering: true,
- order: [[ 4, 'desc' ]],
- info: true,
- searching: false,
- hover: false,
- autoWidth: false,
- // rowId: 'systemTo',
- language: {
- emptyTable: 'No jumps recorded',
- info: '_START_ to _END_ of _MAX_',
- infoEmpty: ''
- },
- columnDefs: [
- {
- targets: 0,
- name: 'index',
- title: '',
- orderable: false,
- searchable: false,
- width: 20,
- class: 'text-center',
- data: 'id'
- },{
- targets: 1,
- title: '',
- width: 26,
- orderable: false,
- className: [Util.config.helpDefaultClass, 'text-center', config.tableCellImageClass].join(' '),
- data: 'ship',
- render: {
- _: function(data, type, row){
- let value = data.typeId;
- if(type === 'display'){
- value = ' ';
- }
- return value;
- }
- },
- createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
- $(cell).find('img').tooltip();
- }
- },{
- targets: 2,
- title: '',
- width: 26,
- orderable: false,
- className: [Util.config.helpDefaultClass, 'text-center', config.tableCellImageClass].join(' '),
- data: 'created.character',
- render: {
- _: function(data, type, row){
- let value = data.name;
- if(type === 'display'){
- value = ' ';
- }
- return value;
- }
- },
- createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
- $(cell).find('img').tooltip();
- }
- },{
- targets: 3,
- title: 'mass',
- className: ['text-right'].join(' ') ,
- data: 'ship.mass',
- render: {
- _: function(data, type, row){
- let value = data;
- if(type === 'display'){
- value = Util.formatMassValue(value);
- }
- return value;
- }
- }
- },{
- targets: 4,
- title: 'log',
- width: 55,
- className: ['text-right', config.tableCellCounterClass].join(' '),
- data: 'created.created',
- createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
- $(cell).initTimestampCounter('d');
- }
- }
- ],
- drawCallback: function(settings){
- let animationRows = this.api().rows().nodes().to$().filter(function(a,b ) {
- return (
- $(this).data('animationStatus') ||
- $(this).data('animationTimer')
- );
- });
-
- for(let i = 0; i < animationRows.length; i++){
- $(animationRows[i]).pulseTableRow($(animationRows[i]).data('animationStatus'));
- $(animationRows[i]).removeData('animationStatus');
- }
-
- },
- footerCallback: function ( row, data, start, end, display ) {
-
- let api = this.api();
- let sumColumnIndexes = [3];
-
- // column data for "sum" columns over this page
- let pageTotalColumns = api
- .columns( sumColumnIndexes, { page: 'all'} )
- .data();
-
- // sum columns for "total" sum
- pageTotalColumns.each((colData, index) => {
- pageTotalColumns[index] = colData.reduce((a, b) => {
- return parseInt(a) + parseInt(b);
- }, 0);
- });
-
- $(sumColumnIndexes).each((index, value) => {
- $( api.column( value ).footer() ).text( Util.formatMassValue(pageTotalColumns[index]) );
-
- // save mass for further reCalculation of "info" table
- connectionElement.find('.' + config.connectionInfoTableCellMassLogClass).data('mass', pageTotalColumns[index]);
- });
-
- // calculate "info" table -----------------------------------------------------
- connectionElement.find('.' + config.moduleTableClass).trigger('pf:updateInfoTable', connectionElement.data());
- }
- });
-
- // find position to insert
- connectionElement.insertBefore(rowElement.find('#' + getConnectionElementId(0)));
-
- logTable.on('order.dt search.dt', function(){
- let pageInfo = logTable.page.info();
- logTable.column(0, {search:'applied', order:'applied'}).nodes().each((cell, i) => {
- let content = (pageInfo.recordsTotal - i) + '. ';
- $(cell).html(content);
- });
- });
-
- logTable.on('destroy.dt', function(){
- $(this).destroyTimestampCounter();
- });
- }
- };
-
- /**
- * remove connection Panel from moduleElement
- * @param connectionElement
- */
- let removeConnectionPanel = (connectionElement) => {
- connectionElement = $(connectionElement);
- if(connectionElement.length){
- // destroy dataTable (and remove table from DOM)
- let logTable = connectionElement.find('.' + config.connectionInfoTableClass);
- logTable.dataTable().api().destroy(true);
- // remove belonging connectionElement
- connectionElement.remove();
- }
- };
-
- /**
- * get connections from ModuleElement
- * -> validate with current map data
- * @param moduleElement
- * @param mapId
- * @returns {{connectionsDataUpdate: Array, connectionsDataRemove: Array}}
- */
- let getConnectionsDataFromModule = (moduleElement, mapId) => {
- let activeMap = Util.getMapModule().getActiveMap();
- let mapData = activeMap.getMapDataFromClient({forceData: true});
- let connectionsData = {
- connectionsDataUpdate: [],
- connectionsDataRemove: [],
- };
-
- if(mapData !== false){
- getConnectionElements(moduleElement).each((i, connectionElement) => {
- let removeConnectionPanel = true;
- let connectionData = {id: $(connectionElement).data('connectionId') };
-
- let connection = $().getConnectionById(mapId, connectionData.id);
- if(connection){
- let connectionDataTemp = MapUtil.getDataByConnection(connection);
- if(connectionDataTemp.id > 0){
- // connection still on map - OK
- removeConnectionPanel = false;
- connectionData = connectionDataTemp;
- }
- }
-
- if(removeConnectionPanel){
- connectionsData.connectionsDataRemove.push(connectionData);
- }else{
- connectionsData.connectionsDataUpdate.push(connectionData);
- }
- });
- }
-
- return connectionsData;
- };
-
- /**
- * update/init multiple connection panels at once
- * @param moduleElement
- * @param mapId
- * @param connectionsDataUpdate
- * @param connectionsDataRemove
- */
- let updateConnectionPanels = (moduleElement, mapId, connectionsDataUpdate, connectionsDataRemove) => {
- for(let connectionData of connectionsDataRemove){
- let connectionElement = moduleElement.find('#' + getConnectionElementId(connectionData.id));
- removeConnectionPanel(connectionElement);
- }
-
- for(let connectionData of connectionsDataUpdate){
- updateConnectionPanel(moduleElement, mapId, connectionData);
- }
-
- // request connectionsLogData for each updated connection
- if(connectionsDataUpdate.length){
- getConnectionsLogData(moduleElement, mapId, connectionsDataUpdate);
- }
-
- // remove module if no connection panel left
- // --> all connection deselected on map
- let connectionElements = getConnectionElements(moduleElement);
- if(connectionElements.length === 0){
- MapUtil.getTabContentElementByMapElement(moduleElement).trigger('pf:removeConnectionModules');
- }
-
- // hide "control" panel when multiple connection
- moduleElement.find('#' + getConnectionElementId(0)).toggle(connectionElements.length < 2);
- };
-
- /**
- * set module observer
- * @param moduleElement
- * @param mapId
- */
- let setModuleObserver = (moduleElement, mapId) => {
- $(document).off('pf:updateConnectionInfoModule').on('pf:updateConnectionInfoModule', function(e, data){
- updateConnectionPanels(
- moduleElement,
- data.mapId,
- MapUtil.getDataByConnections(data.connectionsUpdate),
- MapUtil.getDataByConnections(data.connectionsRemove)
- );
- });
-
- $(document).off('pf:activeShip').on('pf:activeShip', function(e){
- moduleElement.find('.' + config.connectionInfoPanelClass).each((i, connectionElement) => {
- $(connectionElement).find('.' + config.moduleTableClass).each((i, tableElement) => {
- $(tableElement).trigger('pf:calcInfoTable');
- });
- });
- });
-
- // init toggle active ship ----------------------------------------------------------------
- moduleElement.find('.' + config.moduleHeadlineIconCurrentMassClass).on('click', function(e){
- let currentMassIcon = $(this).toggleClass('active');
- moduleElement.find('.' + config.connectionInfoPanelClass).each((i, connectionElement) => {
- $(connectionElement).find('.' + config.moduleTableClass).each((i, tableElement) => {
- $(tableElement).data('showShip', currentMassIcon.hasClass('active')).trigger('pf:calcInfoTable');
- });
- });
- });
-
- // init refresh connections ---------------------------------------------------------------
- moduleElement.find('.' + config.moduleHeadlineIconRefreshClass).on('click', function(e){
- refreshConnectionPanels(moduleElement, mapId);
- });
- };
-
- /**
- * refresh all connection panels in a module
- * @param moduleElement
- * @param mapId
- */
- let refreshConnectionPanels = (moduleElement, mapId) => {
- let connectionsData = getConnectionsDataFromModule(moduleElement, mapId);
- updateConnectionPanels(moduleElement, mapId, connectionsData.connectionsDataUpdate, connectionsData.connectionsDataRemove);
- };
-
- /**
- * before module destroy callback
- * @param moduleElement
- */
- let beforeDestroy = (moduleElement) => {
- getConnectionElements(moduleElement).each((i, connectionElement) => {
- removeConnectionPanel(connectionElement);
- });
- };
-
- /**
- * init callback
- * @param moduleElement
- * @param mapId
- * @param connectionData
- */
- let initModule = (moduleElement, mapId, connectionData) => {
- setModuleObserver(moduleElement, mapId);
- };
-
- /**
- * get module element
- * @param parentElement
- * @param mapId
- * @param connections
- * @returns {*|jQuery|HTMLElement}
- */
- let getModule = (parentElement, mapId, connections) => {
- // create new module container
- let moduleElement = $('').append(
- $(' ', {
- class: config.moduleHeadClass
- }).append(
- $(' ', {
- class: config.moduleHandlerClass
- }),
- $('', {
- text: 'Connection'
- }),
- getHeadlineToolbar()
- )
- );
-
- let rowElement = $('', {
- class: 'row'
- });
-
- moduleElement.append(rowElement);
-
- rowElement.append(getInfoPanelControl(mapId));
-
- updateConnectionPanels(moduleElement, mapId, MapUtil.getDataByConnections(connections), []);
-
- return moduleElement;
- };
-
- return {
- config: config,
- getModule: getModule,
- initModule: initModule,
- beforeDestroy: beforeDestroy
- };
-});
\ No newline at end of file
diff --git a/public/js/v1.4.1/app/ui/form_element.js b/public/js/v1.4.1/app/ui/form_element.js
index 54c82ba9..e37cf9b8 100644
--- a/public/js/v1.4.1/app/ui/form_element.js
+++ b/public/js/v1.4.1/app/ui/form_element.js
@@ -461,7 +461,7 @@ define([
* @param term search term
*/
function sortResultData (data, term){
- let levenshtein = function (a,b){
+ let levenshtein = (a,b) => {
let matrix = new Array(a.length+1);
for(let i = 0; i < matrix.length; i++){
matrix[i] = new Array(b.length+1).fill(0);
@@ -480,7 +480,7 @@ define([
matrix[ai][bi] = Math.min(
matrix[ai-1][bi]+1,
matrix[ai][bi-1]+1,
- matrix[ai-1][bi-1]+(a[ai-1] == b[bi-1] ? 0 : 1)
+ matrix[ai-1][bi-1]+(a[ai-1] === b[bi-1] ? 0 : 1)
);
}
}
@@ -488,7 +488,7 @@ define([
return matrix[a.length][b.length];
};
- data.sort(function(a,b){
+ data.sort((a,b) => {
let levA = levenshtein(term, a.name.toLowerCase());
let levB = levenshtein(term, b.name.toLowerCase());
return levA === levB ? 0 : (levA > levB ? 1 : -1);
@@ -531,6 +531,7 @@ define([
for(let category in result){
// skip custom functions in case result = [] (array functions)
if(result.hasOwnProperty(category)){
+ // sort results (optional)
sortResultData(result[category], page.term);
data.results.push({
text: category,
diff --git a/public/js/v1.4.1/app/ui/module/system_signature.js b/public/js/v1.4.1/app/ui/module/system_signature.js
index b7fb2f8f..f3979aed 100644
--- a/public/js/v1.4.1/app/ui/module/system_signature.js
+++ b/public/js/v1.4.1/app/ui/module/system_signature.js
@@ -1220,7 +1220,7 @@ define([
searchable: true,
title: 'id',
type: 'string',
- width: 15,
+ width: 12,
class: [config.tableCellFocusClass, config.sigTableEditSigNameInput].join(' '),
data: 'name',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
diff --git a/public/js/v1.4.1/app/ui/module/system_signature_new.js b/public/js/v1.4.1/app/ui/module/system_signature_new.js
deleted file mode 100644
index ef192dd4..00000000
--- a/public/js/v1.4.1/app/ui/module/system_signature_new.js
+++ /dev/null
@@ -1,2461 +0,0 @@
-/**
- * System signature module
- */
-
-define([
- 'jquery',
- 'app/init',
- 'app/util',
- 'bootbox',
- 'app/counter',
- 'app/map/map',
- 'app/map/util',
- 'app/ui/form_element'
-], ($, Init, Util, bootbox, Counter, Map, MapUtil, FormElement) => {
- 'use strict';
-
- let config = {
- // module info
- modulePosition: 4,
- moduleName: 'systemSignature',
- moduleHeadClass: 'pf-module-head', // class for module header
- moduleHandlerClass: 'pf-module-handler-drag', // class for "drag" handler
-
- // system signature module
- moduleTypeClass: 'pf-system-signature-module', // class for this module
-
- // headline toolbar
- moduleHeadlineIconClass: 'pf-module-icon-button', // class for toolbar icons in the head
- moduleHeadlineIconAddClass: 'pf-module-icon-button-add', // class for "add signature" icon
- moduleHeadlineIconReaderClass: 'pf-module-icon-button-reader', // class for "signature reader" icon
- moduleHeadlineIconLazyClass: 'pf-module-icon-button-lazy', // class for "lazy delete" toggle icon
- moduleHeadlineProgressBarClass: 'pf-system-progress-scanned', // class for signature progress bar
-
- // tables
- tableToolsActionClass: 'pf-table-tools-action', // class for "new signature" table (hidden)
-
- // table toolbar
- sigTableClearButtonClass: 'pf-sig-table-clear-button', // class for "clear" signatures button
-
- // signature table
- sigTableId: 'pf-sig-table-', // Table id prefix
- sigTableClass: 'pf-sig-table', // Table class for all Signature Tables
- sigTablePrimaryClass: 'pf-sig-table-primary', // class for primary sig table
- sigTableSecondaryClass: 'pf-sig-table-secondary', // class for secondary sig table
- sigTableRowIdPrefix: 'pf-sig-row_', // id prefix for table rows
-
- sigTableEditSigNameInput: 'pf-sig-table-edit-name-input', // class for editable fields (sig name)
-
- tableCellConnectionClass: 'pf-table-connection-cell', // class for "connection" cells
- tableCellFocusClass: 'pf-table-focus-cell', // class for "tab-able" cells. enable focus()
- tableCellCounterClass: 'pf-table-counter-cell', // class for "counter" cells
- tableCellActionClass: 'pf-table-action-cell', // class for "action" cells
-
- // xEditable
- editableNameInputClass: 'pf-editable-name', // class for "name" input
- editableDescriptionInputClass: 'pf-editable-description', // class for "description" textarea
- editableUnknownInputClass: 'pf-editable-unknown', // class for input fields (e.g. checkboxes) with "unknown" status
-
- signatureGroupsLabels: Util.getSignatureGroupOptions('label'),
- signatureGroupsNames: Util.getSignatureGroupOptions('name')
- };
-
- let lockedTables = {}; // locked tables (e.g. disable cops&paste, disable table update)
-
- let sigNameCache = {}; // cache signature names
-
- let validSignatureNames = [ // allowed signature type/names
- 'Cosmic Anomaly',
- 'Cosmic Signature',
- 'Kosmische Anomalie',
- 'Kosmische Signatur',
- 'Anomalie cosmique',
- 'Signature cosmique',
- 'Космическая аномалия', // == "Cosmic Anomaly"
- 'Источники сигналов' // == "Cosmic Signature"
- ];
-
- let emptySignatureData = {
- id: 0,
- name: '',
- groupId: 0,
- typeId: 0
- };
-
- let editableDefaults = { // xEditable default options for signature fields
- url: Init.path.saveSignatureData,
- dataType: 'json',
- container: 'body',
- highlight: false, // i use a custom implementation. xEditable uses inline styles for bg color animation -> does not work properly on datatables "sort" cols
- error: function(jqXHR, newValue){
- let reason = '';
- let status = 'Error';
- if(jqXHR.statusText){
- reason = jqXHR.statusText;
- }else if(jqXHR.name){
- // validation error new sig (new row data save function)
- reason = jqXHR.name;
- // re-open "name" fields (its a collection of fields but we need "id" field)
- jqXHR.name.field.$element.editable('show');
- }else{
- reason = jqXHR.responseJSON.text;
- status = jqXHR.status;
- }
-
- Util.showNotify({title: status + ': save signature', text: reason, type: 'error'});
- $(document).setProgramStatus('problem');
- return reason;
- }
- };
-
- /**
- * get custom "metaData" from dataTables API
- * @param tableApi
- * @returns {*}
- */
- let getTableMetaData = tableApi => {
- let data = null;
- if(tableApi){
- data = tableApi.init().pfMeta;
- }
- return data;
- };
-
- /**
- * lock signature tableApi and lockType
- * @param tableApi
- * @param lockType
- */
- let lockTable = (tableApi, lockType = 'update') => {
- let metaData = getTableMetaData(tableApi);
- if(metaData.systemId){
- if( !lockedTables.hasOwnProperty(metaData.systemId) ){
- lockedTables[metaData.systemId] = {};
- }
- lockedTables[metaData.systemId][lockType] = true;
- }else{
- console.warn('metaData.systemId required in lockTable()', metaData.systemId);
- }
- };
-
- /**
- * check whether a signature tableApi is locked by lockType
- * @param tableApi
- * @param lockType
- * @returns {boolean}
- */
- let isLockedTable = (tableApi, lockType = 'update') => {
- let locked = false;
- if(tableApi){
- let metaData = getTableMetaData(tableApi);
- if(metaData.systemId){
- if(
- lockedTables.hasOwnProperty(metaData.systemId) &&
- lockedTables[metaData.systemId].hasOwnProperty(lockType)
- ){
- locked = true;
- }
- }else{
- console.warn('metaData.systemId required in isLockedTable()', metaData.systemId);
- }
- }
-
- return locked;
- };
-
- /**
- * unlock signature tableApi and lockType
- * @param tableApi
- * @param lockType
- */
- let unlockTable = (tableApi, lockType = 'update') => {
- if(tableApi){
- let metaData = getTableMetaData(tableApi);
- if(isLockedTable(tableApi, lockType)){
- delete lockedTables[metaData.systemId][lockType];
- }
- if(
- lockedTables.hasOwnProperty(metaData.systemId) &&
- !Object.getOwnPropertyNames(lockedTables[metaData.systemId]).length
- ){
- delete lockedTables[metaData.systemId];
- }
- }
- };
-
- /**
- * get dataTable id
- * @param mapId
- * @param systemId
- * @param tableType
- * @returns {string}
- */
- let getTableId = (mapId, systemId, tableType) => config.sigTableId + [mapId, systemId, tableType].join('-');
-
- /**
- * get a dataTableApi instance from global cache
- * @param mapId
- * @param systemId
- * @param tableType
- * @returns {*}
- */
- let getDataTableInstance = (mapId, systemId, tableType) => {
- let instance = null;
- let table = $.fn.dataTable.tables({ visible: false, api: true }).table('#' + getTableId(mapId, systemId, tableType));
- if(table.node()){
- instance = table;
- }
- return instance;
- };
-
- /**
- * Update/set tooltip for an element
- * @param element
- * @param title
- */
- let updateTooltip = (element, title) => {
- $(element).attr('data-container', 'body')
- .attr('title', title.toUpperCase())
- .tooltip('fixTitle').tooltip('setContent');
- };
-
- /**
- * sum up all options in nested (or not nested) object of objects
- * -> e.g.
- * {
- * first: {
- * count = [4, 2, 1]
- * test = { ... }
- * },
- * second: {
- * count = [12, 13]
- * test = { ... }
- * }
- * }
- * -> getOptionsCount('count', obj) => 5;
- * @param key
- * @param obj
- * @returns {number}
- */
- let getOptionsCount = (key, obj) => {
- let sum = 0;
- for(let entry of obj){
- if(entry.hasOwnProperty(key)){
- sum += entry[key].length;
- }else{
- sum++;
- }
- }
- return sum;
- };
-
- /**
- * get possible frig holes that could spawn in a system
- * filtered by "systemTypeId"
- * @param systemTypeId
- * @returns {{}}
- */
- let getFrigateHolesBySystem = systemTypeId => {
- let signatureNames = {};
- if(Init.frigateWormholes[systemTypeId]){
- signatureNames = Init.frigateWormholes[systemTypeId];
- }
- return signatureNames;
- };
-
- /**
- * get all signature types that can exist for a given system
- * -> result is partially cached
- * @param systemData
- * @param systemTypeId
- * @param areaId
- * @param groupId
- * @returns {Array}
- */
- let getAllSignatureNames = (systemData, systemTypeId, areaId, groupId) => {
- systemTypeId = parseInt(systemTypeId || 0);
- areaId = parseInt(areaId || 0);
- groupId = parseInt(groupId || 0);
- let newSelectOptions = [];
- let newSelectOptionsCount = 0;
-
- if(!systemTypeId || !areaId || !groupId){
- return newSelectOptions;
- }
-
- let cacheKey = [systemTypeId, areaId, groupId].join('_');
-
- // check for cached signature names
- if(sigNameCache.hasOwnProperty( cacheKey )){
- // cached signatures do not include static WHs!
- // -> ".slice(0)" creates copy
- newSelectOptions = sigNameCache[cacheKey].slice(0);
- newSelectOptionsCount = getOptionsCount('children', newSelectOptions);
- }else{
- // get new Options ----------
- // get all possible "static" signature names by the selected groupId
- let tempSelectOptions = Util.getAllSignatureNames(systemTypeId, areaId, groupId);
-
- // format options into array with objects advantages: keep order, add more options (whs), use optgroup
- if(tempSelectOptions){
- let fixSelectOptions = [];
- for(let key in tempSelectOptions){
- if (
- key > 0 &&
- tempSelectOptions.hasOwnProperty(key)
- ){
- newSelectOptionsCount++;
- fixSelectOptions.push({value: newSelectOptionsCount, text: tempSelectOptions[key]});
- }
- }
-
- if(newSelectOptionsCount > 0){
- if(groupId === 5){
- // "wormhole" selected => multiple | |