diff --git a/i/css/home.css b/i/css/home.css index 73076a3..93ec6d2 100755 --- a/i/css/home.css +++ b/i/css/home.css @@ -387,4 +387,16 @@ .small-bottom-marging { margin-bottom: 4px; +} + +.small-top-marging +{ + margin-top: 4px; +} + +.categoryButton { + width: 100%; + text-align: left; + border: none; + border-radius: 0px } \ No newline at end of file diff --git a/lang/bg/home.php b/lang/bg/home.php index 52ddf6b..8b1ee83 100644 --- a/lang/bg/home.php +++ b/lang/bg/home.php @@ -272,4 +272,7 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang['find_all_paths_from_vertex'] = "Намерете всички най-кратки пътища от връх"; $g_lang['distance_from'] = "Разстояние от "; $g_lang['path_to'] = "Път до "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/ch/home.php b/lang/ch/home.php index 69c144d..431cd0b 100644 --- a/lang/ch/home.php +++ b/lang/ch/home.php @@ -272,4 +272,7 @@ $g_lang['find_all_paths_from_vertex'] = "从一个顶点找所有最短路"; $g_lang['distance_from'] = "距离从"; $g_lang['path_to'] = "路线至 "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/de/home.php b/lang/de/home.php index 8460deb..1512ac6 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -235,4 +235,7 @@ $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/el/home.php b/lang/el/home.php index 88a454d..1545bf1 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -273,4 +273,7 @@ $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/en/home.php b/lang/en/home.php index 7c67671..9c70965 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -272,4 +272,7 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/es/home.php b/lang/es/home.php index ee9b581..60ab5f0 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -271,5 +271,8 @@ Tenemos traducciones en griego 🇬🇷. diff --git a/lang/fr/home.php b/lang/fr/home.php index 4e815fd..ca90014 100644 --- a/lang/fr/home.php +++ b/lang/fr/home.php @@ -239,5 +239,8 @@ // FindShortPatchsFromOne.js $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; - $g_lang['path_to'] = "Path to "; + $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/nl/home.php b/lang/nl/home.php index 82a2ab0..6b75f77 100644 --- a/lang/nl/home.php +++ b/lang/nl/home.php @@ -236,5 +236,8 @@ // FindShortPatchsFromOne.js $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; - $g_lang['path_to'] = "Path to "; + $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/pt/home.php b/lang/pt/home.php index 0c77568..726093e 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -237,5 +237,8 @@ // FindShortPatchsFromOne.js $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; - $g_lang['path_to'] = "Path to "; + $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/lang/ru/home.php b/lang/ru/home.php index 58e271a..3d655fd 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -273,4 +273,8 @@ $g_lang['find_all_paths_from_vertex'] = "Найти все кратчайшие пути от вершины"; $g_lang['distance_from'] = "Расстояние от "; $g_lang['path_to'] = "Путь до "; + + $g_lang['search_pathes'] = "Поиск путей"; + $g_lang['other_algorithms'] = "Другие алгоритмы"; + ?> diff --git a/lang/sv/home.php b/lang/sv/home.php index 2b59752..5bb7cc0 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -233,5 +233,8 @@ // FindShortPatchsFromOne.js $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; $g_lang['distance_from'] = "Distance from "; - $g_lang['path_to'] = "Path to "; + $g_lang['path_to'] = "Path to "; + + $g_lang['search_pathes'] = "Search paths"; + $g_lang['other_algorithms'] = "Other algorithms"; ?> diff --git a/script/Algorithms.js b/script/Algorithms.js index bfa6828..2d6cb42 100644 --- a/script/Algorithms.js +++ b/script/Algorithms.js @@ -141,6 +141,11 @@ BaseAlgorithm.prototype.IsSupportMultiGraph = function() return false; } +BaseAlgorithm.prototype.getCategory = function() +{ + return 0; +} + /** * Default handler. * Select using mouse, drag. diff --git a/script/Appilcation.js b/script/Appilcation.js index 182e5a7..b390520 100644 --- a/script/Appilcation.js +++ b/script/Appilcation.js @@ -1295,6 +1295,7 @@ Application.prototype.getAlgorithmNames = function() obj.name = oneFactory.getName(g_language); obj.id = oneFactory.getId(); obj.priority = oneFactory.getPriority(); + obj.category = oneFactory.getCategory(); res.push(obj); } diff --git a/script/main.js b/script/main.js index df2f028..374d6ca 100644 --- a/script/main.js +++ b/script/main.js @@ -1,7 +1,7 @@ var SiteDir = ""; var DisableEmscripted = false; -var algorithmsVersion = 1; +var algorithmsVersion = 2; var application = new Application(document, window); @@ -111,8 +111,8 @@ function createAlgorithmMenu() { algorithm = algorithms[i]; - var list = document.getElementById("algorithmList"); - var item = list.lastElementChild; + var list = document.getElementById("algorithmCategoryElements" + algorithm.category); + var item = document.getElementById("algTopic" + algorithm.category); var clone = item.cloneNode(true); var button = clone.getElementsByTagName("button")[0]; var textSpan = button.getElementsByTagName("span")[1]; @@ -122,8 +122,9 @@ function createAlgorithmMenu() buttonsList.push(algorithm.id); - button.onclick = function () + button.onclick = function (e) { + e["closeThisMenu"] = true; userAction(this.id); restButtons (this.id); application.SetHandlerMode(this.id); @@ -144,7 +145,7 @@ function createAlgorithmMenu() $(data.object).show(); }); - list.appendChild(clone); + list.insertBefore(clone, document.getElementById("insert" + algorithm.category)); index++; } @@ -643,7 +644,6 @@ function postLoadPage() }); } - // Get algorithms list and load it. $.get( "/" + SiteDir + "cgi-bin/getPluginsList.php", function( data ) @@ -675,6 +675,48 @@ function postLoadPage() devTools.style.left = 0; resizeCanvas(); application.onPostLoadEvent(); + + $(function() { + $('#algorithmList').on('click', function(event) { + if (!event.originalEvent.closeThisMenu) { + event.stopPropagation(); + } + }); + $(window).on('click', function() { + $('#algorithmList').slideUp(); + }); + }); + + + let showHideCategory = function(button, elementsListName){ + let width = $( button ).width(); + let elementsList = $(elementsListName); + var hideMark = button.querySelector('span[name="hideMark"]') + var showMark = button.querySelector('span[name="showMark"]') + if (elementsList.is(":visible")) { + elementsList.hide(); + $(hideMark).show(); + $(showMark).hide(); + } else { + elementsList.show(); + $(hideMark).hide(); + $(showMark).show(); + } + $( button ).width(width); + + userAction("algCategory_" + elementsListName); + } + + $(document.getElementById("algorithmCategoryBtn1").querySelector('span[name="hideMark"]')).hide(); + $(document.getElementById("algorithmCategoryBtn0").querySelector('span[name="hideMark"]')).hide(); + + $('#algorithmCategoryBtn1').click(function(){ + showHideCategory(this, "#algorithmCategoryElements1"); + }); + + $('#algorithmCategoryBtn0').click(function(){ + showHideCategory(this, "#algorithmCategoryElements0"); + }); } //window.onload = function () diff --git a/script/plugins/BFS.js b/script/plugins/BFS.js index 09aa276..e1b2379 100755 --- a/script/plugins/BFS.js +++ b/script/plugins/BFS.js @@ -29,6 +29,11 @@ BFSAlgorithm.prototype.getMessage = function(local) return this.message; } +BFSAlgorithm.prototype.getCategory = function() +{ + return 1; +} + BFSAlgorithm.prototype.result = function(resultCallback) { var result = {}; diff --git a/script/plugins/DFS.js b/script/plugins/DFS.js index fefd5cc..1767011 100755 --- a/script/plugins/DFS.js +++ b/script/plugins/DFS.js @@ -70,6 +70,11 @@ DFSAlgorithm.prototype.getPriority = function() return -9.5; } +DFSAlgorithm.prototype.getCategory = function() +{ + return 1; +} + DFSAlgorithm.prototype.step = function() { for (var i = this.visited.length - 1; i >= 0; i--) diff --git a/script/plugins/EulerianLoop.js b/script/plugins/EulerianLoop.js index ef77e15..137d5a2 100755 --- a/script/plugins/EulerianLoop.js +++ b/script/plugins/EulerianLoop.js @@ -30,6 +30,11 @@ FindEulerianLoop.prototype.getMessage = function(local) return this.message; } +FindEulerianLoop.prototype.getCategory = function() +{ + return 1; +} + FindEulerianLoop.prototype.result = function(resultCallback) { this.outResultCallback = function (result ) { resultCallback(result); }; diff --git a/script/plugins/EulerianPath.js b/script/plugins/EulerianPath.js index cfde08a..1d733ab 100755 --- a/script/plugins/EulerianPath.js +++ b/script/plugins/EulerianPath.js @@ -30,6 +30,11 @@ FindEulerianPath.prototype.getMessage = function(local) return this.message; } +FindEulerianPath.prototype.getCategory = function() +{ + return 1; +} + FindEulerianPath.prototype.result = function(resultCallback) { this.outResultCallback = function (result ) { resultCallback(result); }; diff --git a/script/plugins/FindAllPatches.js b/script/plugins/FindAllPatches.js index b56741d..97c993b 100644 --- a/script/plugins/FindAllPatches.js +++ b/script/plugins/FindAllPatches.js @@ -40,6 +40,11 @@ FindAllPathes.prototype.getMessage = function(local) return this.message; } +FindAllPathes.prototype.getCategory = function() +{ + return 1; +} + FindAllPathes.prototype.result = function(resultCallback) { if (this.firstObject && this.secondObject) diff --git a/script/plugins/FindShortPatchsFromOne.js b/script/plugins/FindShortPatchsFromOne.js index c7e73e6..6f725c1 100644 --- a/script/plugins/FindShortPatchsFromOne.js +++ b/script/plugins/FindShortPatchsFromOne.js @@ -40,6 +40,11 @@ FindShortPatchsFromOne.prototype.getMessage = function(local) return this.message; } +FindShortPatchsFromOne.prototype.getCategory = function() +{ + return 1; +} + FindShortPatchsFromOne.prototype.result = function(resultCallback) { if (this.firstObject) diff --git a/script/plugins/Floid.js b/script/plugins/Floid.js index 8c4d651..4846146 100755 --- a/script/plugins/Floid.js +++ b/script/plugins/Floid.js @@ -39,6 +39,11 @@ FloidAlgorithm.prototype.getMessage = function(local) return this.message; } +FloidAlgorithm.prototype.getCategory = function() +{ + return 1; +} + FloidAlgorithm.prototype.result = function(resultCallback) { var result = {}; diff --git a/script/plugins/HamiltonianLoop.js b/script/plugins/HamiltonianLoop.js index a697562..390d5b3 100755 --- a/script/plugins/HamiltonianLoop.js +++ b/script/plugins/HamiltonianLoop.js @@ -30,6 +30,11 @@ FindHamiltonianLoop.prototype.getMessage = function(local) return this.message; } +FindHamiltonianLoop.prototype.getCategory = function() +{ + return 1; +} + FindHamiltonianLoop.prototype.result = function(resultCallback) { this.outResultCallback = function (result ) { resultCallback(result); }; diff --git a/script/plugins/HamiltonianPath.js b/script/plugins/HamiltonianPath.js index d583354..7a4c373 100755 --- a/script/plugins/HamiltonianPath.js +++ b/script/plugins/HamiltonianPath.js @@ -30,6 +30,11 @@ FindHamiltonianPath.prototype.getMessage = function(local) return this.message; } +FindHamiltonianPath.prototype.getCategory = function() +{ + return 1; +} + FindHamiltonianPath.prototype.result = function(resultCallback) { this.outResultCallback = function (result ) { resultCallback(result); }; diff --git a/script/plugins/ShortestPath.js b/script/plugins/ShortestPath.js index 5337fb9..99dcb37 100755 --- a/script/plugins/ShortestPath.js +++ b/script/plugins/ShortestPath.js @@ -37,6 +37,11 @@ FindShortPathNew.prototype.getMessage = function(local) return this.message; } +FindShortPathNew.prototype.getCategory = function() +{ + return 1; +} + FindShortPathNew.prototype.result = function(resultCallback) { if (this.firstObject && this.secondObject) diff --git a/tpl/home.php b/tpl/home.php index 8ee4efb..bf08f76 100755 --- a/tpl/home.php +++ b/tpl/home.php @@ -10,7 +10,7 @@ - + @@ -109,17 +109,31 @@ - -