HarbourSOFT-LAB
commited on
Update index.html
Browse files- index.html +96 -23
index.html
CHANGED
|
@@ -1,29 +1,102 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
-
|
| 4 |
<head>
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</head>
|
| 11 |
-
|
| 12 |
<body>
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
</
|
| 23 |
-
<
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
|
|
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Phishing Email Detection</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
padding: 20px;
|
| 11 |
+
}
|
| 12 |
+
textarea {
|
| 13 |
+
width: 100%;
|
| 14 |
+
height: 200px;
|
| 15 |
+
margin-bottom: 20px;
|
| 16 |
+
}
|
| 17 |
+
button {
|
| 18 |
+
padding: 10px 20px;
|
| 19 |
+
background-color: #4CAF50;
|
| 20 |
+
color: white;
|
| 21 |
+
border: none;
|
| 22 |
+
cursor: pointer;
|
| 23 |
+
}
|
| 24 |
+
#result {
|
| 25 |
+
margin-top: 20px;
|
| 26 |
+
padding: 10px;
|
| 27 |
+
background-color: #f4f4f4;
|
| 28 |
+
}
|
| 29 |
+
#loading-message {
|
| 30 |
+
margin-top: 20px;
|
| 31 |
+
color: blue;
|
| 32 |
+
}
|
| 33 |
+
</style>
|
| 34 |
</head>
|
|
|
|
| 35 |
<body>
|
| 36 |
+
<h1>Phishing Email Detection</h1>
|
| 37 |
+
<p>Would you like to load the phishing detection model?</p>
|
| 38 |
+
<button id="load-model-btn">Yes, Load Model</button>
|
| 39 |
+
<button id="cancel-load-btn" style="display: none;">Cancel</button>
|
| 40 |
+
|
| 41 |
+
<div id="loading-message" style="display: none;">Loading model, please wait...</div>
|
| 42 |
+
|
| 43 |
+
<div id="email-input-section" style="display: none;">
|
| 44 |
+
<textarea id="email-input" placeholder="Paste email content here..."></textarea><br>
|
| 45 |
+
<button id="detect-btn">Detect Phishing</button>
|
| 46 |
+
<div id="result"></div>
|
| 47 |
+
</div>
|
| 48 |
+
|
| 49 |
+
<script type="module">
|
| 50 |
+
// Import transformers.js directly from the CDN
|
| 51 |
+
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@latest/dist/transformers.min.js";
|
| 52 |
+
|
| 53 |
+
const modelPath = "https://huggingface.co/aaazKI/phishing-email-detection-distilbert_v2.4.1-ONNX/resolve/main/model.onnx";
|
| 54 |
+
let model;
|
| 55 |
|
| 56 |
+
const loadModelBtn = document.getElementById("load-model-btn");
|
| 57 |
+
const cancelLoadBtn = document.getElementById("cancel-load-btn");
|
| 58 |
+
const emailInputSection = document.getElementById("email-input-section");
|
| 59 |
+
const loadingMessage = document.getElementById("loading-message");
|
| 60 |
+
const resultDiv = document.getElementById("result");
|
| 61 |
+
const detectBtn = document.getElementById("detect-btn");
|
| 62 |
+
|
| 63 |
+
loadModelBtn.addEventListener("click", async () => {
|
| 64 |
+
// Hide buttons and show loading message
|
| 65 |
+
loadModelBtn.style.display = "none";
|
| 66 |
+
cancelLoadBtn.style.display = "inline-block";
|
| 67 |
+
loadingMessage.style.display = "block";
|
| 68 |
+
|
| 69 |
+
// Load the model asynchronously
|
| 70 |
+
try {
|
| 71 |
+
model = await pipeline("text-classification", modelPath);
|
| 72 |
+
loadingMessage.style.display = "none";
|
| 73 |
+
emailInputSection.style.display = "block"; // Show input section once model is loaded
|
| 74 |
+
} catch (error) {
|
| 75 |
+
loadingMessage.innerText = "Error loading the model. Please try again.";
|
| 76 |
+
}
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
cancelLoadBtn.addEventListener("click", () => {
|
| 80 |
+
// Reset the UI if the user cancels loading
|
| 81 |
+
loadModelBtn.style.display = "inline-block";
|
| 82 |
+
cancelLoadBtn.style.display = "none";
|
| 83 |
+
loadingMessage.style.display = "none";
|
| 84 |
+
});
|
| 85 |
+
|
| 86 |
+
detectBtn.addEventListener("click", async () => {
|
| 87 |
+
const emailText = document.getElementById("email-input").value;
|
| 88 |
+
if (!emailText.trim()) {
|
| 89 |
+
resultDiv.innerText = "Please enter some text to classify.";
|
| 90 |
+
return;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// Run inference using the model
|
| 94 |
+
const result = await model(emailText);
|
| 95 |
+
|
| 96 |
+
// Display the result
|
| 97 |
+
const prediction = result[0].label;
|
| 98 |
+
resultDiv.innerText = `Prediction: ${prediction}`;
|
| 99 |
+
});
|
| 100 |
+
</script>
|
| 101 |
+
</body>
|
| 102 |
+
</html>
|