diff --git a/lang/de/create_graph_by_incidence_matrix.php b/lang/de/create_graph_by_incidence_matrix.php index 7774135..3d3a22e 100644 --- a/lang/de/create_graph_by_incidence_matrix.php +++ b/lang/de/create_graph_by_incidence_matrix.php @@ -12,4 +12,5 @@ $g_lang["m_title"] = "Graph aus Inzidenzmatrix erstellen"; $g_lang["m_keyWords"] = "Graph online, Graph zeichnen, erstellen Sie ein Graph aus der Inzidenzmatrix, Inzidenzmatrix "; $g_lang["m_description"] = "Graph aus Inzidenzmatrix erstellen und Sehen Sie ein visuelles Ergebnis"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/de/create_graph_by_matrix.php b/lang/de/create_graph_by_matrix.php index dfd83fa..8607d98 100644 --- a/lang/de/create_graph_by_matrix.php +++ b/lang/de/create_graph_by_matrix.php @@ -15,4 +15,5 @@ $g_lang["separator"] = "Separator:"; $g_lang["separator_commo"] = "Komma"; $g_lang["separator_space"] = "Leerzeichen"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/lang/el/create_graph_by_incidence_matrix.php b/lang/el/create_graph_by_incidence_matrix.php index 820a1c2..53369b5 100644 --- a/lang/el/create_graph_by_incidence_matrix.php +++ b/lang/el/create_graph_by_incidence_matrix.php @@ -18,4 +18,5 @@ $g_lang["separator"] = "Διαχωριστής: "; $g_lang["separator_commo"] = "κόμμα"; $g_lang["separator_space"] = "κενό"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/el/create_graph_by_matrix.php b/lang/el/create_graph_by_matrix.php index f899411..d7c6505 100644 --- a/lang/el/create_graph_by_matrix.php +++ b/lang/el/create_graph_by_matrix.php @@ -19,4 +19,6 @@ $g_lang["separator"] = "Διαχωριστής: "; $g_lang["separator_commo"] = "κόμμα"; $g_lang["separator_space"] = "κενό"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/lang/en/create_graph_by_incidence_matrix.php b/lang/en/create_graph_by_incidence_matrix.php index 678ee48..100639a 100755 --- a/lang/en/create_graph_by_incidence_matrix.php +++ b/lang/en/create_graph_by_incidence_matrix.php @@ -14,4 +14,6 @@ $g_lang["m_title"] = "Creating graph from incidence matrix"; $g_lang["m_keyWords"] = "graph online, plot graph, creating graph from incidence matrix, incidence matrix"; $g_lang["m_description"] = "Creating graph from incidence matrix online and see visual result"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/en/create_graph_by_matrix.php b/lang/en/create_graph_by_matrix.php index d411356..b4ab11b 100755 --- a/lang/en/create_graph_by_matrix.php +++ b/lang/en/create_graph_by_matrix.php @@ -19,4 +19,5 @@ $g_lang["separator"] = "Separator: "; $g_lang["separator_commo"] = "comma"; $g_lang["separator_space"] = "space"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/lang/es/create_graph_by_matrix.php b/lang/es/create_graph_by_matrix.php index 059fea3..89759ee 100755 --- a/lang/es/create_graph_by_matrix.php +++ b/lang/es/create_graph_by_matrix.php @@ -20,4 +20,6 @@ $g_lang["separator"] = "Separador: "; $g_lang["separator_commo"] = "coma"; $g_lang["separator_space"] = "espacio"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/lang/fr/create_graph_by_incidence_matrix.php b/lang/fr/create_graph_by_incidence_matrix.php index 1adeba4..e25ea0e 100644 --- a/lang/fr/create_graph_by_incidence_matrix.php +++ b/lang/fr/create_graph_by_incidence_matrix.php @@ -13,4 +13,6 @@ $g_lang["m_title"] = "Création d'un graphique à partir de la matrice d'incidence"; $g_lang["m_keyWords"] = "graphique en ligne, graphique de tracé, création d'un graphique à partir d'une matrice d'incidence, matrice d'incidence"; $g_lang["m_description"] = "Créer un graphique à partir de la matrice d'incidence en ligne et voir le résultat visuel"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/fr/create_graph_by_matrix.php b/lang/fr/create_graph_by_matrix.php index db8d6ee..d57d381 100644 --- a/lang/fr/create_graph_by_matrix.php +++ b/lang/fr/create_graph_by_matrix.php @@ -16,4 +16,6 @@ $g_lang["separator"] = "Séparateur"; $g_lang["separator_commo"] = "virgule"; $g_lang["separator_space"] = "espace"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/nl/create_graph_by_incidence_matrix.php b/lang/nl/create_graph_by_incidence_matrix.php index 80839cd..7f57a0e 100644 --- a/lang/nl/create_graph_by_incidence_matrix.php +++ b/lang/nl/create_graph_by_incidence_matrix.php @@ -12,4 +12,6 @@ $g_lang["m_title"] = "Bezig met het creëren van een Graaf op basis van een incidentiematrix"; $g_lang["m_keyWords"] = "Graph Online, plot Graaf, Creëer graaf vanuit incidentiematrix, incidentiematrix"; $g_lang["m_description"] = "Creëer een graaf door middel van een incidentiematrix online en krijg het resultaat visueel"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/nl/create_graph_by_matrix.php b/lang/nl/create_graph_by_matrix.php index f76b0fa..6ad8393 100644 --- a/lang/nl/create_graph_by_matrix.php +++ b/lang/nl/create_graph_by_matrix.php @@ -15,4 +15,6 @@ $g_lang["separator"] = "Scheidingsteken"; $g_lang["separator_commo"] = "komma"; $g_lang["separator_space"] = "spatie"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/lang/pt/create_graph_by_incidence_matrix.php b/lang/pt/create_graph_by_incidence_matrix.php index e6b870d..5b7a76c 100644 --- a/lang/pt/create_graph_by_incidence_matrix.php +++ b/lang/pt/create_graph_by_incidence_matrix.php @@ -14,4 +14,5 @@ $g_lang["m_keyWords"] = "grafo onilne, plotar grafo, criar grafo a partir de uma matriz de incidência, matriz de incidência "; $g_lang["m_description"] = "Crie o grafo online a partir da matriz de incidência e veja o resultado"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/pt/create_graph_by_matrix.php b/lang/pt/create_graph_by_matrix.php index f2c7df4..aab309a 100644 --- a/lang/pt/create_graph_by_matrix.php +++ b/lang/pt/create_graph_by_matrix.php @@ -15,4 +15,6 @@ $g_lang["separator"] = "Separador:"; $g_lang["separator_commo"] = "vírgula"; $g_lang["separator_space"] = "espaço"; + + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/lang/ru/create_graph_by_incidence_matrix.php b/lang/ru/create_graph_by_incidence_matrix.php index 8beaaa9..9ddd0d3 100755 --- a/lang/ru/create_graph_by_incidence_matrix.php +++ b/lang/ru/create_graph_by_incidence_matrix.php @@ -16,4 +16,5 @@ $g_lang["add_edge_to_matrix"] = "Добавить дугу"; $g_lang["add_node_to_matrix"] = "Добавить вершину"; + $g_lang["use_ctrl_to_move_cells"] = "Используйте Ctrl + ← ↑ → ↓ клавиши для перемещения между ячейками."; ?> \ No newline at end of file diff --git a/lang/ru/create_graph_by_matrix.php b/lang/ru/create_graph_by_matrix.php index 7a3c77a..1013431 100755 --- a/lang/ru/create_graph_by_matrix.php +++ b/lang/ru/create_graph_by_matrix.php @@ -23,5 +23,5 @@ $g_lang["separator_commo"] = "запятая"; $g_lang["separator_space"] = "пробел"; - + $g_lang["use_ctrl_to_move_cells"] = "Используйте Ctrl + ← ↑ → ↓ клавиши для перемещения между ячейками."; ?> diff --git a/lang/sv/create_graph_by_incidence_matrix.php b/lang/sv/create_graph_by_incidence_matrix.php index c857e02..1d4e557 100644 --- a/lang/sv/create_graph_by_incidence_matrix.php +++ b/lang/sv/create_graph_by_incidence_matrix.php @@ -14,4 +14,5 @@ $g_lang["m_keyWords"] = "incidensmatris, graf, skapa en graf, skapa en graf online, använda insidensmatris"; $g_lang["m_description"] = "Skapa en graf med incidensmatris online"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> \ No newline at end of file diff --git a/lang/sv/create_graph_by_matrix.php b/lang/sv/create_graph_by_matrix.php index 0de3b39..3f18b92 100644 --- a/lang/sv/create_graph_by_matrix.php +++ b/lang/sv/create_graph_by_matrix.php @@ -17,4 +17,5 @@ $g_lang["separator_commo"] = "kommatecken"; $g_lang["separator_space"] = "utrymme"; + $g_lang["use_ctrl_to_move_cells"] = "Use Ctrl + ← ↑ → ↓ keys to move between cells."; ?> diff --git a/tpl/create_graph_by_incidence_matrix.php b/tpl/create_graph_by_incidence_matrix.php index 6c6b8db..c6e490e 100755 --- a/tpl/create_graph_by_incidence_matrix.php +++ b/tpl/create_graph_by_incidence_matrix.php @@ -8,6 +8,7 @@ // Current matrix size var g_MatrixWidth = 2; var g_MatrixHeight = 3; +var g_ctrlPressed = false; function PackMatrix() { @@ -17,7 +18,7 @@ function PackMatrix() { for (j = 0; j < g_MatrixWidth; j++) { - var element = document.getElementsByName("field" + i + j)[0]; + var element = document.getElementsByName("field" + i + "_" + j)[0]; matrix = matrix + (element.value.length > 0 ? element.value : "0") + ", "; } matrix = matrix + "\n"; @@ -25,9 +26,83 @@ function PackMatrix() return matrix; } -function CopyMatrixToTextInput() +function getCharCode(event) +{ + if (event.which == null) + { // IE + return event.keyCode; + } + + if (event.which != 0) + { // not IE + return event.which; + } + + return null; +} + +function getChar(event) +{ + var k = getCharCode(event) + return String.fromCharCode(k); +} + +function CopyMatrixToTextInput(event) { document.getElementById("IncidenceMatrixFieldPage").value = PackMatrix(); + // Move between cells. + if (event) + { + var key = getChar(event); + var code = getCharCode(event); + console.log(key + " code=" + code); + if (g_ctrlPressed) + { + var moveFocus = function(offsetX, offsetY) + { + var focused_element = document.activeElement; + + if (focused_element && focused_element.name.includes("field")) + { + var name = focused_element.name; + var coords = name.replace('field','').split("_"); + if (coords.length == 2) + { + var focusName = "field" + (parseInt(coords[0]) + offsetY) + "_" + (parseInt(coords[1]) + offsetX) + var element = document.getElementsByName(focusName)[0]; + if (element) + { + element.focus(); + } + } + } + } + switch (code) + { + case 38: // Up + { + moveFocus(0, -1); + break; + } + case 40: // Down + { + moveFocus(0, 1); + break; + } + case 37: // Left + { + moveFocus(-1, 0); + break; + } + case 39: // Right + { + moveFocus(1, 0); + break; + } + } + + } + } } function _ShowTextInput() @@ -88,7 +163,7 @@ function CopyMatrixToMatrixInput() { for (var j = 0; j < cols[0].length; j++) { - var element = document.getElementsByName("field" + i + j)[0]; + var element = document.getElementsByName("field" + i + "_" + j)[0]; element.value = cols[i][j]; } } @@ -104,9 +179,9 @@ function CreateInputElement(col, row) var input = document.createElement("input"); input.type = "text"; input.size = 3; - input.name = "field" + col + row; + input.name = "field" + col + "_" + row; input.value = 0; - input.onkeyup = function() {CopyMatrixToTextInput();}; + input.onkeyup = function(event) {CopyMatrixToTextInput(event);}; return input; } @@ -193,6 +268,15 @@ window.onload = function () CopyMatrixToMatrixInput(); + $(document).keydown(function(event) { + if (event.which == "17" || event.which == "91") + g_ctrlPressed = true; + }); + + $(document).keyup(function(event) { + if (event.which == "17" || event.which == "91") + g_ctrlPressed = false; + }); } @@ -228,16 +312,16 @@ window.onload = function ()
- - + +
- - + +
- - + +
@@ -248,6 +332,7 @@ window.onload = function () +

diff --git a/tpl/create_graph_by_matrix.php b/tpl/create_graph_by_matrix.php index 1ff208a..e108d96 100755 --- a/tpl/create_graph_by_matrix.php +++ b/tpl/create_graph_by_matrix.php @@ -8,6 +8,7 @@ // Current matrix size var g_MatrixSize = 3; +var g_ctrlPressed = false; function PackMatrix() { @@ -17,7 +18,7 @@ function PackMatrix() { for (j = 0; j < g_MatrixSize; j++) { - var element = document.getElementsByName("field" + i + j)[0]; + var element = document.getElementsByName("field" + i + "_" + j)[0]; matrix = matrix + (element.value.length > 0 ? element.value : "0") + ", "; } matrix = matrix + "\n"; @@ -25,9 +26,84 @@ function PackMatrix() return matrix; } -function CopyMatrixToTextInput() +function getCharCode(event) +{ + if (event.which == null) + { // IE + return event.keyCode; + } + + if (event.which != 0) + { // все кроме IE + return event.which; // остальные + } + + return null; // спец. символ +} + +function getChar(event) +{ + var k = getCharCode(event) + return String.fromCharCode(k); // остальные +} + +function CopyMatrixToTextInput(event) { document.getElementById("AdjacencyMatrixFieldPage").value = PackMatrix(); + + // Move between cells. + if (event) + { + var key = getChar(event); + var code = getCharCode(event); + console.log(key + " code=" + code); + if (g_ctrlPressed) + { + var moveFocus = function(offsetX, offsetY) + { + var focused_element = document.activeElement; + + if (focused_element && focused_element.name.includes("field")) + { + var name = focused_element.name; + var coords = name.replace('field','').split("_"); + if (coords.length == 2) + { + var focusName = "field" + (parseInt(coords[0]) + offsetY) + "_" + (parseInt(coords[1]) + offsetX) + var element = document.getElementsByName(focusName)[0]; + if (element) + { + element.focus(); + } + } + } + } + switch (code) + { + case 38: // Up + { + moveFocus(0, -1); + break; + } + case 40: // Down + { + moveFocus(0, 1); + break; + } + case 37: // Left + { + moveFocus(-1, 0); + break; + } + case 39: // Right + { + moveFocus(1, 0); + break; + } + } + + } + } } function _ShowTextInput() @@ -62,15 +138,12 @@ function ShowMatrixInput() document.getElementById("showText").className = "btn btn-default"; } - - function CopyMatrixToMatrixInput() { var graph = new Graph(); var colsObj = {}; - var rowsObj = {}; - + var rowsObj = {}; if (graph.TestAdjacencyMatrix($( "#AdjacencyMatrixFieldPage" ).val(), rowsObj, colsObj)) { @@ -86,7 +159,7 @@ function CopyMatrixToMatrixInput() { for (var j = 0; j < rows.length; j++) { - var element = document.getElementsByName("field" + i + j)[0]; + var element = document.getElementsByName("field" + i + "_"+ j)[0]; element.value = cols[i][j]; } } @@ -102,9 +175,9 @@ function CreateInputElement(col, row) var input = document.createElement("input"); input.type = "text"; input.size = 3; - input.name = "field" + col + row; + input.name = "field" + col + "_" + row; input.value = 0; - input.onkeyup = function() {CopyMatrixToTextInput();}; + input.onkeyup = function(event) {CopyMatrixToTextInput(event);}; return input; } @@ -194,6 +267,16 @@ window.onload = function () }); CopyMatrixToMatrixInput(); + + $(document).keydown(function(event) { + if (event.which == "17" || event.which == "91") + g_ctrlPressed = true; + }); + + $(document).keyup(function(event) { + if (event.which == "17" || event.which == "91") + g_ctrlPressed = false; + }); } @@ -232,19 +315,19 @@ window.onload = function ()
- - - + + +
- - - + + +
- - - + + +
@@ -252,6 +335,7 @@ window.onload = function () +

@@ -300,7 +384,6 @@ window.onload = function ()
- 🤑 Поддержать проект деньгами 🤑