Updates
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,5 +1,5 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
/wwwroot/scripts/js/external/* linguist-vendored
|
||||
/wwwroot/scripts/external/* linguist-vendored
|
||||
/wwwroot/stylesheets/css/* linguist-vendored
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<Content Include="xslt\orderHtmltoXML.xslt" />
|
||||
<Content Include="xslt\htmlToEscPos.xslt" />
|
||||
<Content Include=".gitignore" />
|
||||
<Folder Include="wwwroot\scripts\js" />
|
||||
<Folder Include="wwwroot\styles\css" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
let showLoginBox = () => showVirtualNumpad('Enter Login Code', 6, true, false, false, authenticate);
|
||||
let authenticate = (input) => {
|
||||
let login = ajaxSync('/ajax/authenticateClerk', input);
|
||||
if (login === 'success') {
|
||||
location.assign('/floorplan');
|
||||
}
|
||||
else
|
||||
showLoginBox();
|
||||
};
|
||||
$(() => {
|
||||
showLoginBox();
|
||||
});
|
||||
//# sourceMappingURL=dredgepos.authenticate.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"dredgepos.authenticate.js","sourceRoot":"","sources":["../ts/dredgepos.authenticate.ts"],"names":[],"mappings":"AAAA,IAAI,YAAY,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAA;AAEnG,IAAK,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE;IACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA;IACtD,IAAG,KAAK,KAAK,SAAS,EAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;KAChC;;QAEG,YAAY,EAAE,CAAA;AACtB,CAAC,CAAA;AAED,CAAC,CAAC,GAAG,EAAE;IACH,YAAY,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
|
||||
@@ -1,150 +0,0 @@
|
||||
let Application = {
|
||||
keyboard: null,
|
||||
mode: [],
|
||||
languageVars: {}
|
||||
};
|
||||
/** Parses a language variable. */
|
||||
let lang = (key, replacements) => {
|
||||
let finalValue = Application.languageVars[key] || '';
|
||||
if (!replacements)
|
||||
return finalValue;
|
||||
if (typeof replacements === 'string')
|
||||
replacements = [replacements];
|
||||
replacements.forEach((replacement, index) => {
|
||||
let correctIndex = index + 1;
|
||||
finalValue = finalValue.replace(`[${correctIndex}]`, replacement);
|
||||
});
|
||||
return finalValue;
|
||||
};
|
||||
/** Check if a variable is defined */
|
||||
let defined = (variable) => {
|
||||
return typeof variable !== 'undefined';
|
||||
};
|
||||
/** Call an Ajax function asynchronously */
|
||||
let ajax = (endpoint, data, method = 'POST', successFunction, errorFunction, beforeFunction) => {
|
||||
data = (data == null) ? data : JSON.stringify(data);
|
||||
return $.ajax({
|
||||
url: endpoint,
|
||||
method: method,
|
||||
data: data,
|
||||
success: (response) => {
|
||||
if (successFunction && response.status == 'success')
|
||||
successFunction(JSON.parse(response.data));
|
||||
else if (errorFunction && response.status != 'success') {
|
||||
errorFunction(JSON.parse(response.data));
|
||||
}
|
||||
},
|
||||
error: (error) => console.log(error.statusCode),
|
||||
beforeSend: beforeFunction
|
||||
});
|
||||
};
|
||||
/*
|
||||
For the flow of the app, synchronous is commonly preferred
|
||||
though trying to keep its usage as low as possible.
|
||||
*/
|
||||
let ajaxSync = (endpoint, data, method = 'POST') => {
|
||||
let response = JSON.parse($.ajax({
|
||||
url: endpoint,
|
||||
method: method,
|
||||
data: JSON.stringify(data),
|
||||
async: false,
|
||||
}).responseText);
|
||||
if (response.data) {
|
||||
response.data = JSON.parse(response.data);
|
||||
return response.data;
|
||||
}
|
||||
return response;
|
||||
};
|
||||
/* Redirect to a specific URL */
|
||||
let redirect = (url) => location.assign(url);
|
||||
const resize = () => {
|
||||
$('#pageContainer').height(window.innerHeight + "px");
|
||||
};
|
||||
let setupCore = (languageVars) => {
|
||||
Application.languageVars = languageVars;
|
||||
const doc = $(document);
|
||||
doc.on('click', '#alertNo, #alertOk', hideAlerts);
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
setElementVisibilityByMode();
|
||||
};
|
||||
// @ts-ignore
|
||||
let posAlert = (message, title = 'Message') => {
|
||||
let alertBox = $('#alert');
|
||||
alertBox.css('display', 'flex');
|
||||
alertBox.data('value', '');
|
||||
$('#alertHeading').text(title);
|
||||
$('#alertMessage').text(message);
|
||||
$('#alertOk').css('display', 'flex');
|
||||
$('#alertYes').css('display', 'none');
|
||||
$('#alertNo').css('display', 'none');
|
||||
};
|
||||
let confirmation = (message, data, title = 'Confirm', submitFunction = (data) => { hideAlerts(); }) => {
|
||||
let alert = $('#alert');
|
||||
$(document).on('click', '#alert #alertYes', () => {
|
||||
hideAlerts();
|
||||
submitFunction(data);
|
||||
$(document).off('click', '#alert #alertYes');
|
||||
});
|
||||
alert.css('display', 'flex');
|
||||
$('#alertHeading').html(title);
|
||||
$('#alertMessage').html(message);
|
||||
$('#alertOk').css('display', 'none');
|
||||
$('#alertYes').css('display', 'flex');
|
||||
$('#alertNo').css('display', 'flex');
|
||||
};
|
||||
let hideAlerts = () => $('#alert').hide();
|
||||
let turnOnMode = (mode) => {
|
||||
Application.mode.push(mode);
|
||||
setElementVisibilityByMode();
|
||||
};
|
||||
let turnOffMode = (mode) => {
|
||||
Application.mode = Application.mode.filter((value) => value != mode);
|
||||
setElementVisibilityByMode();
|
||||
};
|
||||
let toggleMode = (mode) => {
|
||||
if (!isInMode(mode))
|
||||
turnOnMode(mode);
|
||||
else
|
||||
turnOffMode(mode);
|
||||
};
|
||||
let clearModes = () => { Application.mode = []; };
|
||||
let isInMode = (mode) => Application.mode.includes(mode);
|
||||
let setElementVisibilityByMode = () => {
|
||||
const mode = Application.mode;
|
||||
const elements = $('[data-visible-in-mode]');
|
||||
elements.each((index, elem) => {
|
||||
let element = $(elem);
|
||||
let visibleInModes = element.data('visible-in-mode');
|
||||
let showElement = visibleInModes.every(visibleMode => {
|
||||
return mode.includes(visibleMode);
|
||||
});
|
||||
if (element.hasClass('useVisibility')) {
|
||||
if (showElement) {
|
||||
element.css('visibility', 'visible');
|
||||
}
|
||||
else
|
||||
element.css('visibility', 'hidden');
|
||||
}
|
||||
else
|
||||
element.toggle(showElement);
|
||||
});
|
||||
const invisibleElements = $('[data-invisible-in-mode]');
|
||||
invisibleElements.each((index, elem) => {
|
||||
let element = $(elem);
|
||||
let inVisibleInModes = element.data('invisible-in-mode');
|
||||
let hideElement = inVisibleInModes.some(invisibleMode => {
|
||||
return mode.includes(invisibleMode);
|
||||
});
|
||||
element.toggle(!hideElement);
|
||||
});
|
||||
$('[data-active-in-mode]').each((index, elem) => {
|
||||
const button = $(elem);
|
||||
const activeInMode = button.data('active-in-mode');
|
||||
mode.includes(activeInMode)
|
||||
? button.addClass('active')
|
||||
: button.removeClass('active');
|
||||
});
|
||||
};
|
||||
$(() => ajax('/ajax/languageVars', null, 'GET', setupCore, null, null));
|
||||
//# sourceMappingURL=dredgepos.core.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,645 +0,0 @@
|
||||
/// <reference path="./typings/konva.d.ts" />
|
||||
const Floorplan = {
|
||||
rooms: [],
|
||||
tables: [],
|
||||
decorations: [],
|
||||
reservations: [],
|
||||
activeTableNumbers: [],
|
||||
stage: null,
|
||||
transformer: null,
|
||||
tableLayer: null,
|
||||
selectedTableNumber: 0,
|
||||
currentRoom: null,
|
||||
roomToLoad: null,
|
||||
visualScale: 1,
|
||||
visualScaleBasis: 1280,
|
||||
floorplanDiv: null,
|
||||
selectedDecorationId: 0
|
||||
};
|
||||
$(() => ajax('/ajax/getFloorplanData/1', null, 'get', setupFloorplan, null, null));
|
||||
const setupFloorplanEvents = () => {
|
||||
const doc = $(document);
|
||||
doc.on('click', '.roomButton', roomButtonClicked);
|
||||
doc.on('click', '.editModeButton', editModeButtonClicked);
|
||||
doc.on('click', '.changeShapeButton', changeTableShape);
|
||||
doc.on('click', '.addTableButton', showAddTablePopup);
|
||||
doc.on('click', '.deleteTableButton', confirmDeleteTable);
|
||||
doc.on('click', '.addDecoration', showDecorator);
|
||||
doc.on('click', '.deleteDecoration', deleteDecoration);
|
||||
doc.on('click', '.decoratorItem', addDecoration);
|
||||
doc.on('click', '.mergeButton', toggleMergeMode);
|
||||
doc.on('click', '.unmergeButton', unmergeTable);
|
||||
doc.on('click', '.transferTableButton', toggleTransferMode);
|
||||
doc.on('click', '.reserveTableButton', reserveTable);
|
||||
doc.on('click', '.unreserveTableButton', unreserveTable);
|
||||
};
|
||||
const roomButtonClicked = (e) => {
|
||||
const button = $(e.target);
|
||||
const roomId = button.data('value');
|
||||
loadRoom(getRoomById(roomId));
|
||||
};
|
||||
const editModeButtonClicked = (e) => {
|
||||
const button = $(e.target);
|
||||
button.toggleClass('active');
|
||||
toggleMode('edit');
|
||||
if (isInMode('edit')) {
|
||||
Floorplan.stage.find('Group, Image').forEach(table => table.draggable(true));
|
||||
if (isInMode('tableSelected')) {
|
||||
const selectedTableShape = getTableShapeFromTableNumber(Floorplan.selectedTableNumber);
|
||||
selectTable(selectedTableShape);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setTransformerNodes([]);
|
||||
Floorplan.stage.find('Group, Image').forEach(table => table.draggable(false));
|
||||
}
|
||||
};
|
||||
const setupFloorplan = (floorplanData) => {
|
||||
Floorplan.tables = floorplanData.tables;
|
||||
Floorplan.activeTableNumbers = floorplanData.activeTableNumbers;
|
||||
Floorplan.rooms = floorplanData.rooms;
|
||||
Floorplan.decorations = floorplanData.decorations;
|
||||
Floorplan.reservations = floorplanData.reservations;
|
||||
getDimensions();
|
||||
setupFloorplanEvents();
|
||||
loadRoom(Floorplan.rooms[0]);
|
||||
};
|
||||
const loadRoom = (roomToLoad) => {
|
||||
setRoomBackground(roomToLoad);
|
||||
setupKonva();
|
||||
$('.roomButton').removeClass('active');
|
||||
let button = $(`.roomButton[data-value=${roomToLoad.id}]`);
|
||||
button.addClass('active');
|
||||
const tablesInRoom = Floorplan.tables.filter(table => table.room_id == roomToLoad.id);
|
||||
const decorationsInRoom = Floorplan.decorations.filter(decoration => decoration.decoration_room == roomToLoad.id);
|
||||
decorationsInRoom.forEach(decoration => createDecorationShape(decoration, false));
|
||||
tablesInRoom.forEach(createTableShape);
|
||||
if (!isInMode('transfer')) {
|
||||
deselectTables();
|
||||
}
|
||||
Floorplan.currentRoom = roomToLoad;
|
||||
};
|
||||
const getRoomById = (roomId) => {
|
||||
return Floorplan.rooms.find((room) => room.id == roomId);
|
||||
};
|
||||
const tableIsOpen = (table) => Floorplan.activeTableNumbers.includes(table.table_number);
|
||||
const createTableShape = (table) => {
|
||||
const draggable = isInMode('edit');
|
||||
const tableGroup = new Konva.Group({
|
||||
x: table.pos_x * Floorplan.visualScale,
|
||||
y: table.pos_y * Floorplan.visualScale,
|
||||
draggable: draggable,
|
||||
listening: true,
|
||||
id: table.table_number.toString()
|
||||
});
|
||||
const fillColor = tableIsOpen(table)
|
||||
? 'lightblue'
|
||||
: table.status == 2
|
||||
? 'lightgreen'
|
||||
: 'gray';
|
||||
let tableShape;
|
||||
switch (table.shape) {
|
||||
case "circle": // fall-through
|
||||
case "ellipse": // fall-through
|
||||
case "longellipse":
|
||||
tableShape = new Konva.Ellipse({
|
||||
x: 0,
|
||||
y: 0,
|
||||
radiusX: table.width * 0.5 * Floorplan.visualScale,
|
||||
radiusY: table.height * 0.5 * Floorplan.visualScale,
|
||||
rotation: table.rotation,
|
||||
fill: fillColor,
|
||||
stroke: "black",
|
||||
strokeWidth: 4,
|
||||
draggable: false,
|
||||
listening: true
|
||||
});
|
||||
break;
|
||||
default:
|
||||
tableShape = new Konva.Rect({
|
||||
x: 0,
|
||||
y: 0,
|
||||
offsetX: table.width * 0.5 * Floorplan.visualScale,
|
||||
offsetY: table.height * 0.5 * Floorplan.visualScale,
|
||||
width: table.width * Floorplan.visualScale,
|
||||
height: table.height * Floorplan.visualScale,
|
||||
rotation: table.rotation,
|
||||
fill: fillColor,
|
||||
stroke: "black",
|
||||
strokeWidth: 4,
|
||||
draggable: false,
|
||||
listening: true
|
||||
});
|
||||
break;
|
||||
}
|
||||
const label = new Konva.Text({
|
||||
x: table.width * -0.5 * Floorplan.visualScale,
|
||||
y: table.height * -0.5 * Floorplan.visualScale,
|
||||
width: table.width * Floorplan.visualScale,
|
||||
height: table.height * Floorplan.visualScale,
|
||||
text: table.table_number.toString(),
|
||||
fontSize: 40 * Floorplan.visualScale,
|
||||
fill: "black",
|
||||
align: "center",
|
||||
verticalAlign: "middle",
|
||||
draggable: false,
|
||||
listening: false
|
||||
});
|
||||
tableGroup.add(tableShape, label);
|
||||
setupTableEvents(tableGroup);
|
||||
Floorplan.tableLayer.add(tableGroup);
|
||||
return tableGroup;
|
||||
};
|
||||
const setupTableEvents = (tableGroup) => {
|
||||
const tableShape = getTableShapeFromGroup(tableGroup);
|
||||
tableGroup.on('click', tableClicked);
|
||||
tableGroup.on('tap', tableClicked);
|
||||
tableGroup.on('dragend', tableGroupTransformed);
|
||||
tableShape.on('transformend', tableShapeTransformed);
|
||||
};
|
||||
const getTableShapeFromGroup = (group) => group.getChildren()[0];
|
||||
const getTableGroupFromShape = (shape) => shape.parent;
|
||||
const tableGroupTransformed = (e) => {
|
||||
saveTableTransformation(e.target);
|
||||
};
|
||||
const tableShapeTransformed = (e) => {
|
||||
let shape = e.target;
|
||||
let group = getTableGroupFromShape(shape);
|
||||
saveTableTransformation(group);
|
||||
};
|
||||
const saveTableTransformation = (tableGroup) => {
|
||||
const originalTable = getTableDataFromGroup(tableGroup);
|
||||
const tableShape = getTableShapeFromGroup(tableGroup);
|
||||
const newTableInfo = {
|
||||
table_number: originalTable.table_number,
|
||||
previous_state: originalTable.previous_state,
|
||||
merged_children: originalTable.merged_children,
|
||||
id: originalTable.id,
|
||||
width: Math.round(tableShape.scaleX() * tableShape.width() / Floorplan.visualScale),
|
||||
height: Math.round(tableShape.scaleY() * tableShape.height() / Floorplan.visualScale),
|
||||
pos_x: Math.round(tableGroup.x() / Floorplan.visualScale),
|
||||
pos_y: Math.round(tableGroup.y() / Floorplan.visualScale),
|
||||
rotation: Math.round(tableShape.rotation()),
|
||||
room_id: originalTable.room_id,
|
||||
status: originalTable.status,
|
||||
venue_id: originalTable.venue_id,
|
||||
shape: originalTable.shape,
|
||||
default_covers: originalTable.default_covers,
|
||||
};
|
||||
saveTable(newTableInfo);
|
||||
redrawTable(tableGroup);
|
||||
};
|
||||
const saveTable = (tableToUpdate) => {
|
||||
const tables = Floorplan
|
||||
.tables
|
||||
.filter(table => {
|
||||
return table.id != tableToUpdate.id;
|
||||
});
|
||||
tables.push(tableToUpdate);
|
||||
Floorplan.tables = tables;
|
||||
ajax("/ajax/transformTable", tableToUpdate, 'post', null, null, null);
|
||||
};
|
||||
const setTransformerNodes = (nodes) => {
|
||||
Floorplan.transformer.moveToTop();
|
||||
if (nodes.length < 1)
|
||||
Floorplan.transformer.moveToBottom();
|
||||
Floorplan.transformer.nodes(nodes);
|
||||
};
|
||||
const getTableDataFromTableNumber = (tableNumber) => {
|
||||
return Floorplan.tables.filter(table => table.table_number == tableNumber)[0];
|
||||
};
|
||||
const getTableDataFromGroup = (tableGroup) => {
|
||||
const tableNumber = tableGroup.attrs.id;
|
||||
return Floorplan.tables.find(table => tableNumber == table.table_number);
|
||||
};
|
||||
const getTableDataFromShape = (tableShape) => getTableDataFromGroup(tableShape.parent);
|
||||
const getTableShapeFromTableNumber = (tableNumber) => {
|
||||
const tableGroup = Floorplan.stage.find('Group').find((group) => {
|
||||
return group.attrs.id == tableNumber;
|
||||
});
|
||||
return tableGroup.getChildren()[0];
|
||||
};
|
||||
const getTableGroupFromTableNumber = (tableNumber) => {
|
||||
const tableShape = getTableShapeFromTableNumber(tableNumber);
|
||||
return getTableGroupFromShape(tableShape);
|
||||
};
|
||||
const setReservationStatus = (table) => {
|
||||
const reservationText = $('.reservationStatus');
|
||||
const tableShape = getTableShapeFromTableNumber(table.table_number);
|
||||
reservationText.text('');
|
||||
if (table.status == 2) {
|
||||
tableShape.fill('lightgreen');
|
||||
const reservations = Floorplan.reservations.filter(reservation => reservation.reservation_table_id == table.id);
|
||||
if (reservations.length) {
|
||||
turnOnMode('reservedTableSelected');
|
||||
reservationText.text(lang('reserved'));
|
||||
let reservation = reservations[0];
|
||||
if (reservation.reservation_name != '') {
|
||||
reservationText.text(lang('reserved_for', reservation.reservation_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
let fillColor = tableIsOpen(table) ? 'lightblue' : 'gray';
|
||||
tableShape.fill(fillColor);
|
||||
turnOffMode('reservedTableSelected');
|
||||
}
|
||||
};
|
||||
const reserveTable = () => {
|
||||
showVirtualNumpad(lang('how_many_covers'), 2, false, false, true, createEmptyReservation);
|
||||
};
|
||||
const createEmptyReservation = (covers) => {
|
||||
const newReservation = {
|
||||
id: 0,
|
||||
reservation_covers: covers,
|
||||
reservation_created_at: 0,
|
||||
reservation_table_id: getSelectedTableData().id,
|
||||
reservation_name: '',
|
||||
reservation_time: 0,
|
||||
};
|
||||
ajax('/ajax/newEmptyReservation', newReservation, 'post', emptyReservationCreated, null, null);
|
||||
};
|
||||
const emptyReservationCreated = (reservation) => {
|
||||
Floorplan.reservations.push(reservation);
|
||||
const selectedTable = getSelectedTableData();
|
||||
selectedTable.status = 2;
|
||||
selectedTable.default_covers = reservation.reservation_covers;
|
||||
updateTableData(selectedTable);
|
||||
updateCoverText(selectedTable);
|
||||
setReservationStatus(getSelectedTableData());
|
||||
showVirtualKeyboard(lang('confirm_reservation_name'), 32, false, addReservationName);
|
||||
};
|
||||
const addReservationName = (name) => {
|
||||
hideVirtualKeyboard();
|
||||
const reservation = Floorplan.reservations.filter(reservation => reservation.reservation_table_id == getSelectedTableData().id)[0];
|
||||
reservation.reservation_name = name;
|
||||
ajax('/ajax/updateReservation', reservation, 'post', reservationNameAdded, null, null);
|
||||
};
|
||||
const reservationNameAdded = (updatedReservation) => {
|
||||
console.log(updatedReservation);
|
||||
Floorplan.reservations = Floorplan.reservations.filter(reservation => reservation.id != updatedReservation.id);
|
||||
Floorplan.reservations.push(updatedReservation);
|
||||
setReservationStatus(getSelectedTableData());
|
||||
};
|
||||
const getReservationsOnTable = (table) => Floorplan.reservations.filter(reservation => reservation.reservation_table_id == table.id);
|
||||
const updateTableData = (tableToRemove) => {
|
||||
Floorplan.tables = Floorplan.tables.filter(table => table.id != tableToRemove.id);
|
||||
Floorplan.tables.push(tableToRemove);
|
||||
};
|
||||
const unreserveTable = () => {
|
||||
const selectedTable = getSelectedTableData();
|
||||
selectedTable.status = 0;
|
||||
ajax('/ajax/unreserveTable', selectedTable, 'post', tableUnreserved, null, null);
|
||||
};
|
||||
const tableUnreserved = (table) => {
|
||||
Floorplan.reservations = Floorplan.reservations.filter(reservation => reservation.reservation_table_id != table.id);
|
||||
updateTableData(table);
|
||||
setReservationStatus(table);
|
||||
};
|
||||
const getSelectedTableData = () => getTableDataFromTableNumber(Floorplan.selectedTableNumber);
|
||||
const deselectTables = () => {
|
||||
Floorplan.stage.find('Rect, Ellipse').forEach((shape, index) => {
|
||||
shape.stroke('black');
|
||||
});
|
||||
Floorplan.selectedDecorationId = 0;
|
||||
Floorplan.selectedTableNumber = 0;
|
||||
turnOffMode('tableSelected');
|
||||
turnOffMode('activeTableSelected');
|
||||
turnOffMode('decorationSelected');
|
||||
turnOffMode('merge');
|
||||
turnOffMode('transfer');
|
||||
setTransformerNodes([]);
|
||||
};
|
||||
const selectTable = (tableShape) => {
|
||||
tableShape.stroke('yellow');
|
||||
const table = getTableDataFromShape(tableShape);
|
||||
Floorplan.selectedTableNumber = table.table_number;
|
||||
if (isInMode('edit')) {
|
||||
setTransformerNodes([tableShape]);
|
||||
}
|
||||
if (tableIsOpen(table)) {
|
||||
turnOnMode('activeTableSelected');
|
||||
}
|
||||
$('.reservationStatus').html('<b>' + lang('active_table', table.table_number.toString() + '</b>'));
|
||||
updateCoverText(table);
|
||||
$('.selectedTableNumber').text(lang('active_table', table.table_number.toString()));
|
||||
setReservationStatus(table);
|
||||
const unmergeVisibility = table.merged_children ? 'visible' : 'hidden';
|
||||
$('.unmergeButton').css('visibility', unmergeVisibility);
|
||||
turnOnMode('tableSelected');
|
||||
};
|
||||
const updateCoverText = (table) => $('.selectedTableCovers').text(lang('covers', table.default_covers.toString()));
|
||||
const tableClicked = (event) => {
|
||||
let tableShape = getTableShapeFromGroup(event.currentTarget);
|
||||
const table = getTableDataFromShape(tableShape);
|
||||
if (isInMode('merge')) {
|
||||
mergeTables(getTableDataFromTableNumber(Floorplan.selectedTableNumber), table);
|
||||
return;
|
||||
}
|
||||
if (isInMode('transfer')) {
|
||||
transferTables(getTableDataFromTableNumber(Floorplan.selectedTableNumber), table);
|
||||
}
|
||||
const selectedTableNumber = Floorplan.selectedTableNumber;
|
||||
deselectTables();
|
||||
if (selectedTableNumber != table.table_number) {
|
||||
selectTable(tableShape);
|
||||
}
|
||||
};
|
||||
const createDecorationShape = (decoration, select) => {
|
||||
const draggable = isInMode('edit');
|
||||
const decorationShape = new Image();
|
||||
decorationShape.onload = () => {
|
||||
const decorationImage = new Konva.Image({
|
||||
id: decoration.id.toString(),
|
||||
x: decoration.decoration_pos_x * Floorplan.visualScale,
|
||||
y: decoration.decoration_pos_y * Floorplan.visualScale,
|
||||
image: decorationShape,
|
||||
offsetX: decoration.decoration_width * 0.5 * Floorplan.visualScale,
|
||||
offsetY: decoration.decoration_height * 0.5 * Floorplan.visualScale,
|
||||
rotation: decoration.decoration_rotation,
|
||||
width: decoration.decoration_width * Floorplan.visualScale,
|
||||
height: decoration.decoration_height * Floorplan.visualScale,
|
||||
draggable: draggable,
|
||||
});
|
||||
// add the shape to the layer
|
||||
Floorplan.tableLayer.add(decorationImage);
|
||||
Floorplan.tableLayer.draw();
|
||||
decorationImage.moveToBottom();
|
||||
setupDecorationEvents(decorationImage);
|
||||
if (select) {
|
||||
decorationImage.moveToTop();
|
||||
selectDecorationShape(decorationImage);
|
||||
}
|
||||
};
|
||||
decorationShape.src = 'images/decorations/' + decoration.decoration_image;
|
||||
};
|
||||
const setupDecorationEvents = (decorationShape) => {
|
||||
decorationShape.on('click', decorationClicked);
|
||||
decorationShape.on('tap', decorationClicked);
|
||||
decorationShape.on('transformend', decorationTransformed);
|
||||
decorationShape.on('dragend', decorationTransformed);
|
||||
};
|
||||
const decorationClicked = (event) => {
|
||||
let decorationShape = event.target;
|
||||
if (isInMode('edit')) {
|
||||
turnOffMode('tableSelected');
|
||||
if ((Floorplan.transformer.nodes().length > 0 && Floorplan.transformer.nodes()[0] != decorationShape) || Floorplan.transformer.nodes().length == 0) {
|
||||
selectDecorationShape(decorationShape);
|
||||
}
|
||||
else {
|
||||
deselectTables();
|
||||
decorationShape.moveToBottom();
|
||||
}
|
||||
}
|
||||
};
|
||||
const selectDecorationShape = (decorationShape) => {
|
||||
deselectTables();
|
||||
Floorplan.transformer.nodes([decorationShape]);
|
||||
Floorplan.selectedDecorationId = Number(decorationShape.id());
|
||||
decorationShape.moveToTop();
|
||||
Floorplan.transformer.moveToTop();
|
||||
turnOnMode('decorationSelected');
|
||||
};
|
||||
const getDecorationDataById = (id) => {
|
||||
return Floorplan.decorations.find(decoration => id == decoration.id);
|
||||
};
|
||||
const decorationTransformed = (event) => {
|
||||
let decorationShape = event.currentTarget;
|
||||
const oldDecorationData = getDecorationDataById(Number(decorationShape.id()));
|
||||
const newDecoration = {
|
||||
id: oldDecorationData.id,
|
||||
decoration_room: oldDecorationData.decoration_room,
|
||||
decoration_pos_x: Math.round(decorationShape.x() / Floorplan.visualScale),
|
||||
decoration_pos_y: Math.round(decorationShape.y() / Floorplan.visualScale),
|
||||
decoration_rotation: Math.round(decorationShape.rotation()),
|
||||
decoration_width: Math.round((decorationShape.scaleX() * decorationShape.width()) / Floorplan.visualScale),
|
||||
decoration_height: Math.round((decorationShape.scaleY() * decorationShape.height()) / Floorplan.visualScale),
|
||||
decoration_image: oldDecorationData.decoration_image,
|
||||
};
|
||||
saveDecoration(newDecoration);
|
||||
};
|
||||
const saveDecoration = (decorationToUpdate) => {
|
||||
const decorations = Floorplan
|
||||
.decorations
|
||||
.filter(decoration => {
|
||||
return decoration.id != decorationToUpdate.id;
|
||||
});
|
||||
decorations.push(decorationToUpdate);
|
||||
Floorplan.decorations = decorations;
|
||||
ajax("/ajax/updateDecoration", decorationToUpdate, 'post', null, null, null);
|
||||
};
|
||||
const showDecorator = () => $('#decorator').css('display', 'flex');
|
||||
const hideDecorator = () => $('#decorator').css('display', 'flex').hide();
|
||||
const addDecoration = (e) => {
|
||||
const button = $(e.currentTarget);
|
||||
const newDecoration = {
|
||||
id: 0,
|
||||
decoration_room: Floorplan.currentRoom.id,
|
||||
decoration_pos_x: Floorplan.visualScaleBasis / 2,
|
||||
decoration_pos_y: Floorplan.visualScaleBasis / 2,
|
||||
decoration_rotation: 0,
|
||||
decoration_width: 200,
|
||||
decoration_height: 200,
|
||||
decoration_image: button.data('image')
|
||||
};
|
||||
ajax('/ajax/addDecoration', newDecoration, 'post', decorationAdded, null, null);
|
||||
};
|
||||
const decorationAdded = (decoration) => {
|
||||
Floorplan.decorations.push(decoration);
|
||||
createDecorationShape(decoration, true);
|
||||
hideDecorator();
|
||||
};
|
||||
const deleteDecoration = () => ajax('/ajax/deleteDecoration', getDecorationDataById(Floorplan.selectedDecorationId), 'post', decorationDeleted, null, null);
|
||||
const decorationDeleted = (deletedDecoration) => {
|
||||
Floorplan.decorations = Floorplan.decorations.filter(decoration => decoration.id != deletedDecoration.id);
|
||||
const decorationShape = Floorplan.stage.findOne(`#${deletedDecoration.id}`);
|
||||
decorationShape.destroy();
|
||||
deselectTables();
|
||||
};
|
||||
const setRoomBackground = (roomToLoad) => {
|
||||
const width = Floorplan.floorplanDiv.width();
|
||||
const height = Floorplan.floorplanDiv.height();
|
||||
Floorplan.floorplanDiv.css("background-image", `url(images/rooms/${roomToLoad.background_image})`);
|
||||
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`);
|
||||
};
|
||||
const setupKonva = () => {
|
||||
const dimensions = getDimensions();
|
||||
if (Floorplan.stage !== null)
|
||||
Floorplan.stage.destroy();
|
||||
Floorplan.stage = new Konva.Stage({
|
||||
container: 'floorplanCanvas',
|
||||
width: dimensions.width,
|
||||
height: dimensions.height,
|
||||
});
|
||||
Floorplan.stage.on('click', e => {
|
||||
if (e.target == Floorplan.stage) {
|
||||
deselectTables();
|
||||
}
|
||||
});
|
||||
Floorplan.transformer = new Konva.Transformer({
|
||||
rotationSnaps: [0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 225, 270, -15, -30, -45, -60, -75, -90, -105, -120, -135, -150, -165, -180, -225, -270, 360, -360],
|
||||
anchorSize: 30 * Floorplan.visualScale,
|
||||
ignoreStroke: true,
|
||||
centeredScaling: true,
|
||||
anchorCornerRadius: 10,
|
||||
});
|
||||
Floorplan.tableLayer = new Konva.Layer();
|
||||
Floorplan.tableLayer.add(Floorplan.transformer);
|
||||
Floorplan.stage.add(Floorplan.tableLayer);
|
||||
};
|
||||
const resetKonva = setupKonva;
|
||||
const changeTableShape = () => {
|
||||
if (!Floorplan.selectedTableNumber)
|
||||
return;
|
||||
const table = getTableDataFromTableNumber(Floorplan.selectedTableNumber);
|
||||
const tableGroup = getTableGroupFromTableNumber(table.table_number);
|
||||
const order = ['square', 'rect', 'longrect', 'diamond', 'circle', 'ellipse', 'longellipse'];
|
||||
if (order.indexOf(table.shape) === -1)
|
||||
table.shape = 'square';
|
||||
const currentIndex = order.indexOf(table.shape);
|
||||
let nextIndex = currentIndex + 1;
|
||||
if (nextIndex > (order.length) - 1)
|
||||
nextIndex = 0;
|
||||
table.shape = order[nextIndex];
|
||||
switch (table.shape) {
|
||||
case 'square':
|
||||
case 'circle':
|
||||
// noinspection JSSuspiciousNameCombination
|
||||
table.height = table.width;
|
||||
table.rotation = 0;
|
||||
break;
|
||||
case 'diamond':
|
||||
// noinspection JSSuspiciousNameCombination
|
||||
table.height = table.width;
|
||||
table.rotation = 45;
|
||||
break;
|
||||
case 'rect':
|
||||
case 'ellipse':
|
||||
table.height = table.width * 2;
|
||||
table.rotation = 0;
|
||||
break;
|
||||
case 'longrect':
|
||||
case 'longellipse':
|
||||
table.rotation = 90;
|
||||
break;
|
||||
}
|
||||
saveTable(table);
|
||||
deselectTables();
|
||||
redrawTable(tableGroup);
|
||||
};
|
||||
const redrawTable = (tableGroup) => {
|
||||
deselectTables();
|
||||
const draggable = tableGroup.draggable();
|
||||
const table = getTableDataFromGroup(tableGroup);
|
||||
tableGroup.destroy();
|
||||
const newTableGroup = createTableShape(table);
|
||||
const newTableShape = getTableShapeFromTableNumber(table.table_number);
|
||||
selectTable(newTableShape);
|
||||
newTableGroup.draggable(draggable);
|
||||
};
|
||||
const showAddTablePopup = () => showVirtualNumpad(lang('new_table_number'), 4, false, false, true, addTable);
|
||||
const addTable = (tableNumber) => {
|
||||
const newTable = {
|
||||
id: 0,
|
||||
table_number: tableNumber,
|
||||
room_id: Floorplan.currentRoom.id,
|
||||
default_covers: 2,
|
||||
width: 200,
|
||||
height: 200,
|
||||
rotation: 0,
|
||||
pos_x: Floorplan.visualScaleBasis / 2,
|
||||
pos_y: Floorplan.visualScaleBasis / 2,
|
||||
shape: 'square',
|
||||
merged_children: '',
|
||||
previous_state: '',
|
||||
status: 0,
|
||||
venue_id: 1
|
||||
};
|
||||
ajax('/ajax/createTable', newTable, 'post', tableAdded, tableNotAdded, null);
|
||||
};
|
||||
const tableAdded = (table) => {
|
||||
deselectTables();
|
||||
const newTableGroup = createTableShape(table);
|
||||
Floorplan.tables.push(table);
|
||||
selectTable(getTableShapeFromGroup(newTableGroup));
|
||||
};
|
||||
const tableNotAdded = (response) => {
|
||||
posAlert(response);
|
||||
};
|
||||
const confirmDeleteTable = () => confirmation(lang('confirm_delete_table', Floorplan.selectedTableNumber.toString()), Floorplan.selectedTableNumber, 'Confirm', deleteTable);
|
||||
const deleteTable = (tableNumber) => {
|
||||
if (!tableNumber)
|
||||
return false;
|
||||
const tableToDelete = getTableDataFromTableNumber(tableNumber);
|
||||
if (tableIsOpen(tableToDelete)) {
|
||||
posAlert(lang('error_delete_existing_table'));
|
||||
return false;
|
||||
}
|
||||
ajax(`/ajax/deleteTable`, tableToDelete, 'post', tableDeleted, null, null);
|
||||
};
|
||||
const tableDeleted = (deletedTable) => {
|
||||
Floorplan.tables = Floorplan.tables.filter(table => table.table_number != deletedTable.table_number);
|
||||
const tableGroup = getTableGroupFromTableNumber(deletedTable.table_number);
|
||||
deselectTables();
|
||||
tableGroup.destroy();
|
||||
};
|
||||
const toggleMergeMode = () => toggleMode('merge');
|
||||
const mergeTables = (table1, table2) => {
|
||||
toggleMergeMode();
|
||||
if (table1.table_number == table2.table_number) {
|
||||
posAlert(lang('error_self_merge'));
|
||||
return false;
|
||||
}
|
||||
ajax('/ajax/mergeTables', [table1, table2], 'post', tablesMerged, null, null);
|
||||
};
|
||||
const tablesMerged = (tables) => {
|
||||
tableDeleted(tables['child']);
|
||||
tableDeleted(tables['parent']);
|
||||
tableAdded(tables['merged']);
|
||||
deselectTables();
|
||||
const tableGroup = getTableGroupFromTableNumber(tables['merged'].table_number);
|
||||
selectTable(getTableShapeFromGroup(tableGroup));
|
||||
tableGroup.draggable(true);
|
||||
};
|
||||
const unmergeTable = () => ajax(`/ajax/unmergeTable/${Floorplan.selectedTableNumber}`, null, 'get', tablesUnmerged, null, null);
|
||||
const tablesUnmerged = (tables) => {
|
||||
const parentTable = tables['parent'];
|
||||
const childTable = tables['child'];
|
||||
tableDeleted(parentTable);
|
||||
tableAdded(parentTable);
|
||||
tableAdded(childTable);
|
||||
deselectTables();
|
||||
};
|
||||
const toggleTransferMode = () => toggleMode('transfer');
|
||||
const transferTables = (origin, destination) => {
|
||||
if (origin.table_number == destination.table_number) {
|
||||
posAlert(lang('transfer_self_error'));
|
||||
return;
|
||||
}
|
||||
ajax(`/ajax/transferTable/${origin.table_number}/${destination.table_number}`, null, 'get', tableTransferred, null, null);
|
||||
};
|
||||
const tableTransferred = (tables) => {
|
||||
const origin = tables['origin'];
|
||||
const destination = tables['destination'];
|
||||
Floorplan.activeTableNumbers = Floorplan.activeTableNumbers.filter(tableNumber => tableNumber != origin.table_number);
|
||||
Floorplan.activeTableNumbers.push(destination.table_number);
|
||||
if (Floorplan.currentRoom.id == origin.room_id) {
|
||||
redrawTable(getTableGroupFromTableNumber(origin.table_number));
|
||||
}
|
||||
redrawTable(getTableGroupFromTableNumber(destination.table_number));
|
||||
};
|
||||
const getDimensions = () => {
|
||||
Floorplan.floorplanDiv = $('#floorplanCanvas');
|
||||
const parentDiv = $('#floorplanCenterColumn .middleCell');
|
||||
const outerWidth = parentDiv.outerWidth();
|
||||
const outerHeight = parentDiv.outerHeight();
|
||||
if (outerWidth >= outerHeight) {
|
||||
Floorplan.floorplanDiv.css('height', '100%');
|
||||
}
|
||||
else {
|
||||
Floorplan.floorplanDiv.css('width', '100%');
|
||||
}
|
||||
Floorplan.visualScale = Floorplan.floorplanDiv.width() / Floorplan.visualScaleBasis;
|
||||
return { width: Floorplan.floorplanDiv.width(), height: Floorplan.floorplanDiv.height() };
|
||||
};
|
||||
//# sourceMappingURL=dredgepos.floorplan.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,224 +0,0 @@
|
||||
let showVirtualNumpad = (heading, maxlength = 4, isPassword, allowDecimals = true, allowClose = true, submitFunction) => {
|
||||
let numpad = $('#virtualNumpad');
|
||||
let inputBox = $('#virtualNumpadInput');
|
||||
let closeKeyboardButton = $('.closeKeyboards');
|
||||
numpad.css('display', 'flex');
|
||||
let showCloseButton = allowClose ? 'flex' : 'none';
|
||||
closeKeyboardButton.css('display', showCloseButton);
|
||||
$('#virtualNumpadHeading').html(heading);
|
||||
/*
|
||||
The numpad always submits to a function.
|
||||
If a function isn't specified, it will submit
|
||||
to the same function that called it
|
||||
*/
|
||||
numpad.data('value', '');
|
||||
inputBox.text('');
|
||||
numpad.data('maxlength', maxlength);
|
||||
numpad.data('submitfunction', submitFunction);
|
||||
numpad.data('password', isPassword);
|
||||
numpad.data('allowdecimals', allowDecimals);
|
||||
$(document).off('keyup');
|
||||
$(document).on('keyup', e => {
|
||||
let key = e.key;
|
||||
switch (key) {
|
||||
case 'Backspace':
|
||||
case 'Delete':
|
||||
key = 'clear';
|
||||
break;
|
||||
case 'Enter':
|
||||
key = 'submit';
|
||||
break;
|
||||
}
|
||||
virtualNumpadInput(key);
|
||||
});
|
||||
};
|
||||
let hideVirtualKeyboard = () => {
|
||||
let keyboard = $('#virtualKeyboard');
|
||||
keyboard.hide();
|
||||
$('#virtualKeyboardHeading').html('');
|
||||
$(document).unbind('keyup');
|
||||
};
|
||||
let hideVirtualNumpad = () => {
|
||||
let numpad = $('#virtualNumpad');
|
||||
numpad.css('display', 'none');
|
||||
$('#virtualNumpadHeading').html('');
|
||||
$(document).unbind('keyup');
|
||||
};
|
||||
let virtualNumpadInput = (input) => {
|
||||
let inputBox = $('#virtualNumpadInput');
|
||||
let numpad = $('#virtualNumpad');
|
||||
let maxlength = numpad.data('maxlength');
|
||||
let allowDecimals = numpad.data('allowdecimals');
|
||||
let submitFunction = numpad.data('submitfunction');
|
||||
let allowedValues = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'submit', 'clear'];
|
||||
let currentValue = numpad.data('value').toString();
|
||||
if (allowDecimals)
|
||||
allowedValues.push('.', ',');
|
||||
let validInput = allowedValues.includes(input);
|
||||
//If the input is a valid number, decimal point or command.
|
||||
if (validInput) {
|
||||
switch (input) {
|
||||
case 'submit':
|
||||
hideVirtualNumpad();
|
||||
let numpadValue = numpad.data('value').length > 0 ? numpad.data('value') : "0";
|
||||
submitFunction(numpadValue);
|
||||
break;
|
||||
case 'clear':
|
||||
clearNumpadInput();
|
||||
break;
|
||||
default:
|
||||
let newText = currentValue + input;
|
||||
let isPassword = numpad.data('password');
|
||||
let length = input.length + inputBox.text().length;
|
||||
if (length <= maxlength) {
|
||||
inputBox.append(isPassword ? '*' : input);
|
||||
numpad.data('value', newText);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let clearNumpadInput = () => {
|
||||
$('#virtualNumpadInput').text("");
|
||||
$('#virtualNumpad').data('value', '');
|
||||
};
|
||||
let setupVirtualNumpad = () => {
|
||||
$(document).on('click', '.virtualNumpadButton', e => {
|
||||
virtualNumpadInput($(e.target).data('value').toString());
|
||||
});
|
||||
$('.closeKeyboards').on('click', () => {
|
||||
hideVirtualKeyboard();
|
||||
hideVirtualNumpad();
|
||||
});
|
||||
};
|
||||
let setupVirtualKeyboard = (keyboardLayouts) => {
|
||||
Application.keyboard = {
|
||||
capsLock: false,
|
||||
shift: false,
|
||||
layouts: keyboardLayouts,
|
||||
currentLayout: 'default',
|
||||
};
|
||||
$(document).on('click', '.virtualKeyboardButton', e => {
|
||||
virtualKeyboardInput($(e.target).data('value'));
|
||||
});
|
||||
$(document).on('click', '.forceFocus', (e) => {
|
||||
$('#virtualKeyboardInput').trigger('focus');
|
||||
});
|
||||
setKeyboardLayout('default');
|
||||
};
|
||||
let showVirtualKeyboard = (heading, maxlength = 32, isPassword = false, submitFunction = () => { hideVirtualKeyboard(); }) => {
|
||||
let keyboard = $('#virtualKeyboard');
|
||||
let inputBox = $('#virtualKeyboardInput');
|
||||
keyboard.css('display', 'flex');
|
||||
$('#virtualKeyboardHeading').html(heading);
|
||||
$('.forceFocus').trigger('click');
|
||||
keyboard.data('value', '');
|
||||
inputBox.val('');
|
||||
keyboard.data('maxlength', maxlength);
|
||||
keyboard.data('password', isPassword);
|
||||
keyboard.data('submitfunction', submitFunction);
|
||||
inputBox.attr('autofocus', 'autofocus');
|
||||
inputBox.trigger('focus');
|
||||
inputBox.trigger('click');
|
||||
inputBox.trigger('select');
|
||||
$(document).on('keyup', e => {
|
||||
let key = e.key;
|
||||
if (key == 'Enter' && inputBox.val().toString().length > 0) {
|
||||
key = 'submit';
|
||||
virtualKeyboardInput(key);
|
||||
}
|
||||
});
|
||||
};
|
||||
let virtualKeyboardInput = (input) => {
|
||||
let inputBox = $('#virtualKeyboardInput');
|
||||
let keyboard = $('#virtualKeyboard');
|
||||
let maxlength = keyboard.data('maxlength');
|
||||
let isPassword = keyboard.data('password');
|
||||
let length = input.length + inputBox.text().length;
|
||||
switch (input.toLowerCase()) {
|
||||
case 'backspace':
|
||||
case 'delete':
|
||||
let newText = inputBox.text().slice(0, -1);
|
||||
inputBox.val(newText);
|
||||
keyboard.data('value', newText);
|
||||
break;
|
||||
case 'submit':
|
||||
hideVirtualKeyboard();
|
||||
let submitFunction = keyboard.data('submitfunction');
|
||||
submitFunction(inputBox.val());
|
||||
break;
|
||||
case 'shift':
|
||||
if (Application.keyboard.capsLock)
|
||||
break;
|
||||
Application.keyboard.shift = !Application.keyboard.shift;
|
||||
Application.keyboard.capsLock = false;
|
||||
setKeyboardLayout('default', Application.keyboard.shift ? 'shift' : '');
|
||||
break;
|
||||
case 'capslock':
|
||||
Application.keyboard.shift = false;
|
||||
Application.keyboard.capsLock = !Application.keyboard.capsLock;
|
||||
let capsLockButton = $('[data-value="capslock"]');
|
||||
capsLockButton.toggleClass('active');
|
||||
setKeyboardLayout('default', Application.keyboard.capsLock ? 'shift' : '');
|
||||
break;
|
||||
case 'space':
|
||||
input = ' ';
|
||||
break;
|
||||
}
|
||||
//Stops keys such as F5 being pressed.
|
||||
if (input.length == 1) {
|
||||
if (Application.keyboard.shift || Application.keyboard.capsLock) {
|
||||
input = input.toUpperCase();
|
||||
//If shift, reload lowercase
|
||||
if (Application.keyboard.shift) {
|
||||
Application.keyboard.shift = false;
|
||||
setKeyboardLayout('default');
|
||||
}
|
||||
}
|
||||
let newText = inputBox.val() + input;
|
||||
keyboard.data('value', newText);
|
||||
inputBox.val(newText);
|
||||
}
|
||||
};
|
||||
let setKeyboardLayout = (layout, modifier = '') => {
|
||||
if (modifier != '')
|
||||
modifier = `_${modifier}`;
|
||||
Application.keyboard.currentLayout = layout;
|
||||
let layoutToLoad = Application.keyboard.layouts[layout];
|
||||
$('.virtualKeyboardRow').each((index, row) => {
|
||||
/*
|
||||
We start at 1 instead of 0. Makes it easier for non-programmers
|
||||
and translators making their own language packs
|
||||
*/
|
||||
index = index + 1;
|
||||
// @ts-ignore
|
||||
let currentRow = layoutToLoad[`row${index}${modifier}`];
|
||||
$(row).children('a').each((keyIndex, button) => {
|
||||
let key = $(button);
|
||||
let keyValue = currentRow[keyIndex];
|
||||
/*
|
||||
KeyText is the text that appears
|
||||
in the button. KeyData is the value
|
||||
submitted when the button is pressed.
|
||||
*/
|
||||
let keyText = keyValue;
|
||||
let keyData = keyValue;
|
||||
key.addClass('posButton');
|
||||
key.addClass('virtualKeyboardButton');
|
||||
let pattern = new RegExp(/\[([^)]+)\]/);
|
||||
let matches = keyValue.match(pattern);
|
||||
if (matches) {
|
||||
keyText = keyValue.replace(pattern, '');
|
||||
keyData = matches[1];
|
||||
}
|
||||
key.html(keyText);
|
||||
//Use attr() as some keys have CSS dependent on data-value
|
||||
key.attr('data-value', keyData);
|
||||
key.data('value', keyData);
|
||||
});
|
||||
});
|
||||
};
|
||||
$(() => {
|
||||
setupVirtualNumpad();
|
||||
ajax('/ajax/getKeyboardLayout/english', null, 'get', setupVirtualKeyboard, null, null);
|
||||
});
|
||||
//# sourceMappingURL=keyboards.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
//# sourceMappingURL=test.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["../ts/test.ts"],"names":[],"mappings":""}
|
||||
@@ -1 +0,0 @@
|
||||
//# sourceMappingURL=types.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":""}
|
||||
Reference in New Issue
Block a user