Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion jdk_21_maven/cs/web/triangle-spa/pom.xml
Original file line number Diff line number Diff line change
@@ -1 +1,58 @@
TODO replace me
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>trianglespa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TriangleSPA</name>
<description>TriangleSPA</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.trianglespa;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import static org.springframework.boot.SpringApplication.*;

@SpringBootApplication
public class TriangleSPAApplication {
public static void main(String[] args) {
run(TriangleSPAApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Triangle Classifier</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>

<h1>Triangle Classifier SPA</h1>

<form id="triangleForm">
<label for="a">Side A:</label>
<input type="number" id="a" name="a" required><br>
<label for="b">Side B:</label>
<input type="number" id="b" name="b" required><br>
<label for="c">Side C:</label>
<input type="number" id="c" name="c" required><br>
<button type="submit">Classify</button>
</form>

<div class="result" id="result"></div>

<script src="script.js"></script>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function classifyTriangle(a, b, c) {
a = Number(a);
b = Number(b);
c = Number(c);

if (a <= 0 || b <= 0 || c <= 0 || a + b <= c || a + c <= b || b + c <= a) {
return "Not a triangle";
} else if (a === b && b === c) {
return "Equilateral triangle";
} else if (a === b || b === c || a === c) {
return "Isosceles triangle";
} else {
return "Scalene triangle";
}
}

document.getElementById("triangleForm").addEventListener("submit", function (event) {
event.preventDefault();
const a = document.getElementById("a").value;
const b = document.getElementById("b").value;
const c = document.getElementById("c").value;

const result = classifyTriangle(a, b, c);
document.getElementById("result").textContent = `Result: ${result}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a SPA, we still need to simulate different pages. so, address bar in the browser need to be programmatically updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I will updated it accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arcuri82

I’ve implemented the changes accordingly.

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
body {
font-family: Arial, sans-serif;
padding: 30px;
background-color: #f9f9f9;
}
h1 {
color: #333;
}
form {
margin-bottom: 20px;
}
label {
margin-right: 10px;
}
input {
margin-bottom: 10px;
padding: 5px;
width: 60px;
}
button {
padding: 6px 12px;
cursor: pointer;
}
.result {
margin-top: 20px;
font-weight: bold;
color: #00529B;
}