Skip to content

Commit

Permalink
Add basic form validation. Increase link thickness
Browse files Browse the repository at this point in the history
  • Loading branch information
sruti committed Feb 14, 2019
1 parent 763ab6f commit 418f87b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
17 changes: 9 additions & 8 deletions frontend/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async function displayGraph() {
dataState = await getData();
Graph.graphData(JSON.parse(JSON.stringify(dataState)))
.nodeLabel("name")
.linkWidth(0.5)
.onNodeHover(node => graphElem.style.cursor = node ? "pointer" : null)
.onNodeClick(node => {
// Aim at node from outside it
Expand Down Expand Up @@ -60,20 +61,20 @@ function onModalSubmitClick(event, form) {
const modal = document.getElementById("modal-idea-new");
modal.style.display = "none";

const ideaName = form["idea-name"];
const ideaTags = form["tags"];
const ideaDescription = form["description"];
const creatorName = form["creator-name"];
const ideaName = form["idea-name"].value;
const ideaTags = form["tags"].value;
const ideaDescription = form["description"].value ? form["description"].value : " ";
const creatorName = form["creator-name"].value ? form["creator-name"].value : " ";

const id = dataState.nodes.length;
const newTags = new Set(ideaTags.value.split(",").map(tag => tag.trim().toLowerCase()));
const newTags = new Set(ideaTags.split(",").map(tag => tag.trim().toLowerCase()));

const newIdea = {
id: id.toString(),
name: ideaName.value,
name: ideaName,
tags: Array.from(newTags),
creator: creatorName.value,
description: ideaDescription.value,
creator: creatorName,
description: ideaDescription,
};
const newLinks = matchTags(newIdea, dataState.nodes)

Expand Down
9 changes: 4 additions & 5 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<button class="button-modal-close" onclick="onModalCloseClick(this)">X</button>
<form id="form-idea-new" onsubmit="onModalSubmitClick(event, this)">
Idea Name:<br>
<input type="text" name="idea-name">
<input type="text" name="idea-name" required>
<br><br>
Description:<br>
Short Description:<br>
<textarea type="text" name="description"></textarea>
<br><br>
Topics (comma separated):<br>
<input type="text" name="tags">
<input type="text" name="tags" required>
<br><br>
Your Name:<br>
<input type="text" name="creator-name">
Expand All @@ -35,5 +35,4 @@

<script src="api.js"></script>
<script src="graph.js"></script>
</body>

</body>

0 comments on commit 418f87b

Please sign in to comment.