Skip to content

Commit

Permalink
changed json structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JarUml committed Nov 21, 2023
1 parent f53f839 commit 94ff2fa
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 22 deletions.
20 changes: 10 additions & 10 deletions Frontend/algoverse/src/components/infoContainer/applications.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React from 'react';
import React from "react";
import "./Applications.css";
import { useSearchParams } from "react-router-dom";
import algorithmTexts from "./applicationsText.json"

import algorithmApplicationsTexts from "./applicationsText.json";

function Applications() {
const [searchParams] = useSearchParams();
const algorithm = searchParams.get("algorithm");


const applicationsText = algorithmTexts[algorithm] || "Default";

let applicationsText =
algorithmApplicationsTexts[algorithm]?.applications || "Default";

return (
<>
<div className='applicationsContainer'>
{applicationsText}
</div>
<div className="applicationsContainer">
<h1> PseudoCode </h1>
{applicationsText.map((step, index) => (
<p key={index}>{step}</p>
))}
</div>
</>
);
}

export default Applications;

Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
{
"Dijkstra": "This is the text content for Algorithm 1. It can be as long or as short as you need it to be.",
"BFS": "Text content for Algorithm 2 goes here. You can include detailed descriptions, instructions, or any other relevant information.",
"DFS": "Here's the text for Algorithm 3. Remember, you can customize this text to suit your application's needs.",
"AStar": "This is default text to be shown when no specific algorithm is selected or if the algorithm is not found in this list."
"Dijkstra": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"applications": [
"apple",
"banana",
"cherry"
]
},
"BFS": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"applications": [
"apple",
"banana",
"cherry"
]
},
"DFS": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"applications": [
"apple",
"banana",
"cherry"
]
},
"AStar": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"applications": [
"apple",
"banana",
"cherry"
]
},
"BubbleSort": {
"description": "A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.",
"steps": [
"apple",
"banana",
"cherry"
]
}

}

9 changes: 5 additions & 4 deletions Frontend/algoverse/src/components/infoContainer/pseudoCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import pseudoCodeTexts from "./pseudoCodeText.json";
function PseudoCode() {
const [searchParams] = useSearchParams();
const algorithm = searchParams.get("algorithm");


const pseudoCode = pseudoCodeTexts[algorithm] || "Default";

let pseudoCodeSteps = pseudoCodeTexts[algorithm]?.steps || "Default";

return (
<>
<div className='pseudoCodeContainer'>
{pseudoCode}
<h1> PseudoCode </h1>
{pseudoCodeSteps.map((step, index) => (
<p key={index}>{step}</p>
))}
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
{
"Dijkstra": "This is the text content for Algorithm 1. It can be as long or as short as you need it to be.",
"BFS": "Text content for Algorithm 2 goes here. You can include detailed descriptions, instructions, or any other relevant information.",
"DFS": "Here's the text for Algorithm 3. Remember, you can customize this text to suit your application's needs.",
"AStar": "This is default text to be shown when no specific algorithm is selected or if the algorithm is not found in this list."
"Dijkstra": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"steps": [
"apple",
"banana",
"cherry"
]
},
"BFS": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"steps": [
"apple",
"banana",
"cherry"
]
},
"DFS": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"steps": [
"apple",
"banana",
"cherry"
]
},
"AStar": {
"description": "Finds the shortest paths from a source to all vertices in the given graph",
"steps": [
"apple",
"banana",
"cherry"
]
},
"BubbleSort": {
"description": "A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.",
"steps": [
"apple",
"banana",
"cherry"
]
}

}

0 comments on commit 94ff2fa

Please sign in to comment.