feat(app): create pairing page with dynamic IMDb search and FastAPI send
- Render Section 1 containing captured magnet link with clear and edit controls - Implement Section 2 with dynamic character-input IMDb search (250ms debounce) - Display top 5 matches with posters, titles, years, IMDb IDs, and cast info - Lock both sections upon selection and reveal prominent SEND button - Dispatch download payload to FastAPI backend with live status feedback
This commit is contained in:
1 parent
6bb6b3a1ea
commit
b734b8d414
3 files changed
+1149
No files matched your search
@@ -0,0 +1,579 @@
|
|||||||
|
/* app.css - Styling for Magnetflix POC */
|
||||||
|
:root {
|
||||||
|
--bg-color: #0e0e11;
|
||||||
|
--card-bg: #18181c;
|
||||||
|
--card-border: #27272e;
|
||||||
|
--text-main: #f4f4f5;
|
||||||
|
--text-muted: #a1a1aa;
|
||||||
|
--primary-red: #e50914;
|
||||||
|
--primary-red-hover: #f6121d;
|
||||||
|
--accent-gold: #f5c518;
|
||||||
|
--accent-green: #22c55e;
|
||||||
|
--accent-blue: #3b82f6;
|
||||||
|
--focus-ring: rgba(229, 9, 20, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
color: var(--text-main);
|
||||||
|
line-height: 1.5;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 40px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 680px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
.app-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
border-bottom: 1px solid var(--card-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-icon {
|
||||||
|
font-size: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-title {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: var(--primary-red);
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-badges {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-subtle {
|
||||||
|
background-color: #27272e;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-api {
|
||||||
|
background-color: rgba(59, 130, 246, 0.15);
|
||||||
|
color: #60a5fa;
|
||||||
|
border: 1px solid rgba(59, 130, 246, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-locked {
|
||||||
|
background-color: rgba(245, 197, 24, 0.15);
|
||||||
|
color: var(--accent-gold);
|
||||||
|
border: 1px solid rgba(245, 197, 24, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main Cards */
|
||||||
|
.app-main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--card-border);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 24px;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
||||||
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card.is-fixed {
|
||||||
|
border-color: #3f3f46;
|
||||||
|
background: #141417;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-number {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
background-color: #27272e;
|
||||||
|
color: var(--text-main);
|
||||||
|
border-radius: 50%;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card.is-fixed .section-number {
|
||||||
|
background-color: var(--accent-gold);
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header h2 {
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Groups & Inputs */
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-with-icon {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-with-icon input,
|
||||||
|
.search-input-wrapper input {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #101013;
|
||||||
|
border: 1px solid #3f3f46;
|
||||||
|
color: #ffffff;
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
outline: none;
|
||||||
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-with-icon input:focus,
|
||||||
|
.search-input-wrapper input:focus {
|
||||||
|
border-color: var(--primary-red);
|
||||||
|
box-shadow: 0 0 0 3px var(--focus-ring);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-with-icon input[readonly] {
|
||||||
|
background-color: #0b0b0e;
|
||||||
|
border-color: #27272e;
|
||||||
|
color: #a1a1aa;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-icon {
|
||||||
|
position: absolute;
|
||||||
|
right: 12px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: #71717a;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-icon:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-hint {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-hint code {
|
||||||
|
background-color: #27272e;
|
||||||
|
padding: 2px 5px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search Wrapper & Spinner */
|
||||||
|
.search-input-wrapper {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
position: absolute;
|
||||||
|
left: 14px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #71717a;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input-wrapper input {
|
||||||
|
padding-left: 42px;
|
||||||
|
padding-right: 42px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
position: absolute;
|
||||||
|
right: 14px;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border: 2px solid #3f3f46;
|
||||||
|
border-top-color: var(--primary-red);
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.6s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Results Container */
|
||||||
|
.results-container {
|
||||||
|
margin-top: 14px;
|
||||||
|
background: #121215;
|
||||||
|
border: 1px solid #2e2e36;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-header {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: #71717a;
|
||||||
|
background: #18181d;
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-bottom: 1px solid #27272e;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-list {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-bottom: 1px solid #1f1f24;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-item:hover {
|
||||||
|
background-color: #202027;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-poster-wrap {
|
||||||
|
width: 44px;
|
||||||
|
height: 60px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #27272e;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-poster {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-poster-fallback {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-title-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-title {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #ffffff;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-year {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-meta-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta-tag {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imdb-tag {
|
||||||
|
background-color: rgba(245, 197, 24, 0.15);
|
||||||
|
color: var(--accent-gold);
|
||||||
|
border: 1px solid rgba(245, 197, 24, 0.3);
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-tag {
|
||||||
|
background: #27272e;
|
||||||
|
color: #d4d4d8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-tag {
|
||||||
|
background: #202027;
|
||||||
|
color: #a1a1aa;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-stars {
|
||||||
|
font-size: 11px;
|
||||||
|
color: #71717a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-select-action {
|
||||||
|
color: var(--primary-red);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s, transform 0.15s;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-item:hover .result-select-action {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-results {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding: 14px;
|
||||||
|
background: #18181c;
|
||||||
|
border: 1px dashed #3f3f46;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #a1a1aa;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Selected Movie Card (Fixed State) */
|
||||||
|
.selected-movie-card {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
background: #111114;
|
||||||
|
border: 1px solid #323238;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-poster {
|
||||||
|
width: 60px;
|
||||||
|
height: 84px;
|
||||||
|
border-radius: 6px;
|
||||||
|
object-fit: cover;
|
||||||
|
background: #27272e;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #ffffff;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-meta {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-stars {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button styles */
|
||||||
|
.btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 18px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
transition: background-color 0.15s, transform 0.1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sm {
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background: #27272e;
|
||||||
|
color: #d4d4d8;
|
||||||
|
border: 1px solid #3f3f46;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover {
|
||||||
|
background: #3f3f46;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Action Section & Send Button */
|
||||||
|
.section-action {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
animation: fadeIn 0.3s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; transform: translateY(8px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-send {
|
||||||
|
background: var(--primary-red);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
padding: 14px 28px;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 4px 18px rgba(229, 9, 20, 0.4);
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-send:hover {
|
||||||
|
background: var(--primary-red-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-send:active {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-send:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Response Box */
|
||||||
|
.response-box {
|
||||||
|
background: #161619;
|
||||||
|
border: 1px solid #27272e;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 16px;
|
||||||
|
animation: fadeIn 0.2s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.response-box.success {
|
||||||
|
border-color: rgba(34, 197, 94, 0.4);
|
||||||
|
background: rgba(34, 197, 94, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.response-box.error {
|
||||||
|
border-color: rgba(239, 68, 68, 0.4);
|
||||||
|
background: rgba(239, 68, 68, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.response-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.response-box.success .response-title {
|
||||||
|
color: var(--accent-green);
|
||||||
|
}
|
||||||
|
|
||||||
|
.response-box.error .response-title {
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.response-body {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
background: #0f0f12;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: #d4d4d8;
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Magnetflix - Pair Magnet & IMDb Movie</title>
|
||||||
|
<link rel="stylesheet" href="app.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="app-container">
|
||||||
|
<!-- Header -->
|
||||||
|
<header class="app-header">
|
||||||
|
<div class="brand">
|
||||||
|
<span class="brand-icon">🧲</span>
|
||||||
|
<h1 class="brand-title">Magnetflix</h1>
|
||||||
|
</div>
|
||||||
|
<div class="header-badges">
|
||||||
|
<span class="badge badge-subtle">Proof of Concept</span>
|
||||||
|
<span class="badge badge-api">FastAPI :8000</span>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="app-main">
|
||||||
|
<!-- Section 1: Magnet Link -->
|
||||||
|
<section class="card section-magnet" id="section-magnet">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-title-wrap">
|
||||||
|
<span class="section-number">1</span>
|
||||||
|
<h2>Captured Magnet Link</h2>
|
||||||
|
</div>
|
||||||
|
<span id="magnet-lock-badge" class="badge badge-locked hidden">🔒 Fixed</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="input-with-icon">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="magnet-input"
|
||||||
|
name="magnet"
|
||||||
|
placeholder="Waiting for magnet link or paste here (e.g. magnet:?xt=urn:btih:...)"
|
||||||
|
spellcheck="false"
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
|
<button type="button" id="btn-clear-magnet" class="btn-icon" title="Clear input">✕</button>
|
||||||
|
</div>
|
||||||
|
<div class="field-hint" id="magnet-hint">
|
||||||
|
Ensure the magnet link starts with <code>magnet:?xt=urn:...</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Section 2: Movie Search -->
|
||||||
|
<section class="card section-movie" id="section-movie">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-title-wrap">
|
||||||
|
<span class="section-number">2</span>
|
||||||
|
<h2>Movie</h2>
|
||||||
|
</div>
|
||||||
|
<span id="movie-lock-badge" class="badge badge-locked hidden">🔒 Fixed</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Movie Input & Results Container (Visible when not fixed) -->
|
||||||
|
<div id="movie-search-container">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="search-input-wrapper">
|
||||||
|
<span class="search-icon">🔍</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="movie"
|
||||||
|
id="movie-input"
|
||||||
|
placeholder="Search title, year, IMDb ID (e.g. 'perfect blue 1997', 'black swan', 'tt0156887')..."
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
|
<div id="search-spinner" class="spinner hidden"></div>
|
||||||
|
</div>
|
||||||
|
<div class="field-hint">
|
||||||
|
Dynamic search triggers on each character input, showing top 5 IMDb matches.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Dynamic Results List (Top 5 matches) -->
|
||||||
|
<div id="results-container" class="results-container hidden">
|
||||||
|
<div class="results-header">Top 5 IMDb Matches</div>
|
||||||
|
<ul id="results-list" class="results-list"></ul>
|
||||||
|
</div>
|
||||||
|
<div id="no-results" class="no-results hidden">
|
||||||
|
No matching titles found. Try adjusting title, year, or IMDb ID.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Fixed / Selected Movie Card (Visible when movie is selected) -->
|
||||||
|
<div id="selected-movie-container" class="selected-movie-container hidden">
|
||||||
|
<div class="selected-movie-card">
|
||||||
|
<img id="selected-poster" src="" alt="Movie Poster" class="selected-poster" />
|
||||||
|
<div class="selected-info">
|
||||||
|
<h3 id="selected-title" class="selected-title"></h3>
|
||||||
|
<div class="selected-meta">
|
||||||
|
<span id="selected-year" class="meta-tag year-tag"></span>
|
||||||
|
<span id="selected-imdbid" class="meta-tag imdb-tag"></span>
|
||||||
|
<span id="selected-type" class="meta-tag type-tag"></span>
|
||||||
|
</div>
|
||||||
|
<p id="selected-stars" class="selected-stars"></p>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="btn-change-movie" class="btn btn-secondary btn-sm" title="Pick another movie">
|
||||||
|
Change
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Action Section: Appears when both sections are fixed -->
|
||||||
|
<section id="section-action" class="section-action hidden">
|
||||||
|
<button type="button" id="btn-send" class="btn btn-send">
|
||||||
|
<span class="btn-send-icon">🚀</span>
|
||||||
|
<span class="btn-send-text">SEND</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Response Alert Box -->
|
||||||
|
<div id="response-box" class="response-box hidden">
|
||||||
|
<div class="response-header">
|
||||||
|
<span id="response-icon" class="response-icon"></span>
|
||||||
|
<span id="response-title" class="response-title"></span>
|
||||||
|
</div>
|
||||||
|
<pre id="response-body" class="response-body"></pre>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="app.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,438 @@
|
|||||||
|
// app.js - Logic for Magnetflix Page
|
||||||
|
const browserAPI = window.browser || window.chrome;
|
||||||
|
|
||||||
|
// State
|
||||||
|
let selectedMovie = null;
|
||||||
|
let searchDebounceTimer = null;
|
||||||
|
let currentSearchAbortController = null;
|
||||||
|
|
||||||
|
// DOM Elements
|
||||||
|
const magnetInput = document.getElementById("magnet-input");
|
||||||
|
const btnClearMagnet = document.getElementById("btn-clear-magnet");
|
||||||
|
const magnetLockBadge = document.getElementById("magnet-lock-badge");
|
||||||
|
const sectionMagnet = document.getElementById("section-magnet");
|
||||||
|
|
||||||
|
const movieInput = document.getElementById("movie-input");
|
||||||
|
const searchSpinner = document.getElementById("search-spinner");
|
||||||
|
const movieLockBadge = document.getElementById("movie-lock-badge");
|
||||||
|
const sectionMovie = document.getElementById("section-movie");
|
||||||
|
const movieSearchContainer = document.getElementById("movie-search-container");
|
||||||
|
const resultsContainer = document.getElementById("results-container");
|
||||||
|
const resultsList = document.getElementById("results-list");
|
||||||
|
const noResults = document.getElementById("no-results");
|
||||||
|
|
||||||
|
const selectedMovieContainer = document.getElementById("selected-movie-container");
|
||||||
|
const selectedPoster = document.getElementById("selected-poster");
|
||||||
|
const selectedTitle = document.getElementById("selected-title");
|
||||||
|
const selectedYear = document.getElementById("selected-year");
|
||||||
|
const selectedImdbId = document.getElementById("selected-imdbid");
|
||||||
|
const selectedType = document.getElementById("selected-type");
|
||||||
|
const selectedStars = document.getElementById("selected-stars");
|
||||||
|
const btnChangeMovie = document.getElementById("btn-change-movie");
|
||||||
|
|
||||||
|
const sectionAction = document.getElementById("section-action");
|
||||||
|
const btnSend = document.getElementById("btn-send");
|
||||||
|
const responseBox = document.getElementById("response-box");
|
||||||
|
const responseIcon = document.getElementById("response-icon");
|
||||||
|
const responseTitle = document.getElementById("response-title");
|
||||||
|
const responseBody = document.getElementById("response-body");
|
||||||
|
|
||||||
|
// Initialize on page load
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
initMagnetField();
|
||||||
|
initMovieSearch();
|
||||||
|
initActions();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 1. Magnet Link Initialization
|
||||||
|
function initMagnetField() {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const magnetParam = urlParams.get("magnet");
|
||||||
|
|
||||||
|
if (magnetParam) {
|
||||||
|
magnetInput.value = magnetParam;
|
||||||
|
} else if (browserAPI && browserAPI.storage && browserAPI.storage.local) {
|
||||||
|
browserAPI.storage.local.get(["lastMagnet"], (res) => {
|
||||||
|
if (res && res.lastMagnet) {
|
||||||
|
magnetInput.value = res.lastMagnet;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
btnClearMagnet.addEventListener("click", () => {
|
||||||
|
if (!magnetInput.readOnly) {
|
||||||
|
magnetInput.value = "";
|
||||||
|
magnetInput.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Dynamic Movie Search
|
||||||
|
function initMovieSearch() {
|
||||||
|
movieInput.addEventListener("input", (e) => {
|
||||||
|
const query = e.target.value.trim();
|
||||||
|
|
||||||
|
if (searchDebounceTimer) {
|
||||||
|
clearTimeout(searchDebounceTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
|
resultsContainer.classList.add("hidden");
|
||||||
|
noResults.classList.add("hidden");
|
||||||
|
searchSpinner.classList.add("hidden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debounce search by 250ms for responsive typing
|
||||||
|
searchSpinner.classList.remove("hidden");
|
||||||
|
searchDebounceTimer = setTimeout(async () => {
|
||||||
|
await performMovieSearch(query);
|
||||||
|
}, 250);
|
||||||
|
});
|
||||||
|
|
||||||
|
btnChangeMovie.addEventListener("click", () => {
|
||||||
|
unlockSections();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search IMDb suggestion API
|
||||||
|
async function performMovieSearch(query) {
|
||||||
|
if (currentSearchAbortController) {
|
||||||
|
currentSearchAbortController.abort();
|
||||||
|
}
|
||||||
|
currentSearchAbortController = new AbortController();
|
||||||
|
const { signal } = currentSearchAbortController;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const results = await searchIMDb(query, signal);
|
||||||
|
searchSpinner.classList.add("hidden");
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
resultsList.innerHTML = "";
|
||||||
|
resultsContainer.classList.add("hidden");
|
||||||
|
noResults.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
noResults.classList.add("hidden");
|
||||||
|
renderSearchResults(results);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (err.name !== "AbortError") {
|
||||||
|
console.error("IMDb Search Error:", err);
|
||||||
|
searchSpinner.classList.add("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query IMDb Suggestion APIs with multi-strategy fallback
|
||||||
|
async function searchIMDb(query, signal) {
|
||||||
|
const cleanQ = query.trim();
|
||||||
|
if (!cleanQ) return [];
|
||||||
|
|
||||||
|
const isTtId = /^tt\d+$/i.test(cleanQ);
|
||||||
|
const endpoints = [];
|
||||||
|
|
||||||
|
const firstChar = cleanQ.charAt(0).toLowerCase();
|
||||||
|
endpoints.push(`https://v3.sg.media-imdb.com/suggestion/x/${encodeURIComponent(cleanQ.toLowerCase())}.json`);
|
||||||
|
endpoints.push(`https://v3.sg.media-imdb.com/suggestion/${firstChar}/${encodeURIComponent(cleanQ.toLowerCase().replace(/\s+/g, "_"))}.json`);
|
||||||
|
|
||||||
|
if (isTtId) {
|
||||||
|
const digits = cleanQ.slice(2);
|
||||||
|
// Standard IMDb 7-digit zero-padding
|
||||||
|
if (digits.length < 7) {
|
||||||
|
const paddedId = "tt" + digits.padStart(7, "0");
|
||||||
|
endpoints.push(`https://v3.sg.media-imdb.com/suggestion/t/${encodeURIComponent(paddedId)}.json`);
|
||||||
|
endpoints.push(`https://v3.sg.media-imdb.com/suggestion/x/${encodeURIComponent(paddedId)}.json`);
|
||||||
|
} else {
|
||||||
|
endpoints.push(`https://v3.sg.media-imdb.com/suggestion/t/${encodeURIComponent(cleanQ)}.json`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const seen = new Set();
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
for (const url of endpoints) {
|
||||||
|
try {
|
||||||
|
const resp = await fetch(url, { signal, headers: { "Accept": "application/json" } });
|
||||||
|
if (!resp.ok) continue;
|
||||||
|
const data = await resp.json();
|
||||||
|
|
||||||
|
if (Array.isArray(data.d)) {
|
||||||
|
for (const item of data.d) {
|
||||||
|
// Accept feature films, movies, series, or video titles
|
||||||
|
if (item.id && !seen.has(item.id)) {
|
||||||
|
seen.add(item.id);
|
||||||
|
results.push({
|
||||||
|
id: item.id,
|
||||||
|
title: item.l || item.id,
|
||||||
|
year: item.y || item.tl || "N/A",
|
||||||
|
type: item.q || item.qid || "Movie",
|
||||||
|
stars: item.s || "",
|
||||||
|
imageUrl: item.i ? item.i.imageUrl : null
|
||||||
|
});
|
||||||
|
if (results.length >= 5) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (e.name === "AbortError") throw e;
|
||||||
|
}
|
||||||
|
if (results.length >= 5) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return results.slice(0, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render the 5 matching results
|
||||||
|
function renderSearchResults(results) {
|
||||||
|
resultsList.innerHTML = "";
|
||||||
|
|
||||||
|
results.forEach((movie) => {
|
||||||
|
const li = document.createElement("li");
|
||||||
|
li.className = "result-item";
|
||||||
|
|
||||||
|
const posterWrap = document.createElement("div");
|
||||||
|
posterWrap.className = "result-poster-wrap";
|
||||||
|
|
||||||
|
if (movie.imageUrl) {
|
||||||
|
const img = document.createElement("img");
|
||||||
|
img.src = movie.imageUrl;
|
||||||
|
img.alt = movie.title;
|
||||||
|
img.className = "result-poster";
|
||||||
|
img.loading = "lazy";
|
||||||
|
img.onerror = () => {
|
||||||
|
posterWrap.innerHTML = '<span class="result-poster-fallback">🎬</span>';
|
||||||
|
};
|
||||||
|
posterWrap.appendChild(img);
|
||||||
|
} else {
|
||||||
|
posterWrap.innerHTML = '<span class="result-poster-fallback">🎬</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = document.createElement("div");
|
||||||
|
content.className = "result-content";
|
||||||
|
|
||||||
|
const titleRow = document.createElement("div");
|
||||||
|
titleRow.className = "result-title-row";
|
||||||
|
const titleSpan = document.createElement("span");
|
||||||
|
titleSpan.className = "result-title";
|
||||||
|
titleSpan.textContent = movie.title;
|
||||||
|
titleRow.appendChild(titleSpan);
|
||||||
|
|
||||||
|
if (movie.year) {
|
||||||
|
const yearSpan = document.createElement("span");
|
||||||
|
yearSpan.className = "result-year";
|
||||||
|
yearSpan.textContent = `(${movie.year})`;
|
||||||
|
titleRow.appendChild(yearSpan);
|
||||||
|
}
|
||||||
|
|
||||||
|
const metaRow = document.createElement("div");
|
||||||
|
metaRow.className = "result-meta-row";
|
||||||
|
const imdbSpan = document.createElement("span");
|
||||||
|
imdbSpan.className = "meta-tag imdb-tag";
|
||||||
|
imdbSpan.textContent = movie.id;
|
||||||
|
|
||||||
|
const typeSpan = document.createElement("span");
|
||||||
|
typeSpan.className = "meta-tag type-tag";
|
||||||
|
typeSpan.textContent = movie.type;
|
||||||
|
|
||||||
|
metaRow.appendChild(imdbSpan);
|
||||||
|
metaRow.appendChild(typeSpan);
|
||||||
|
|
||||||
|
content.appendChild(titleRow);
|
||||||
|
content.appendChild(metaRow);
|
||||||
|
|
||||||
|
if (movie.stars) {
|
||||||
|
const stars = document.createElement("div");
|
||||||
|
stars.className = "result-stars";
|
||||||
|
stars.textContent = movie.stars;
|
||||||
|
content.appendChild(stars);
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectAction = document.createElement("div");
|
||||||
|
selectAction.className = "result-select-action";
|
||||||
|
selectAction.innerHTML = "Select →";
|
||||||
|
|
||||||
|
li.appendChild(posterWrap);
|
||||||
|
li.appendChild(content);
|
||||||
|
li.appendChild(selectAction);
|
||||||
|
|
||||||
|
li.addEventListener("click", () => {
|
||||||
|
selectMovie(movie);
|
||||||
|
});
|
||||||
|
|
||||||
|
resultsList.appendChild(li);
|
||||||
|
});
|
||||||
|
|
||||||
|
resultsContainer.classList.remove("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Selection & Fixing State
|
||||||
|
function selectMovie(movie) {
|
||||||
|
selectedMovie = movie;
|
||||||
|
|
||||||
|
// Lock Section 1 (Magnet Link)
|
||||||
|
magnetInput.readOnly = true;
|
||||||
|
sectionMagnet.classList.add("is-fixed");
|
||||||
|
magnetLockBadge.classList.remove("hidden");
|
||||||
|
|
||||||
|
// Lock Section 2 (Movie)
|
||||||
|
sectionMovie.classList.add("is-fixed");
|
||||||
|
movieLockBadge.classList.remove("hidden");
|
||||||
|
movieSearchContainer.classList.add("hidden");
|
||||||
|
|
||||||
|
// Display selected movie details
|
||||||
|
selectedTitle.textContent = movie.title;
|
||||||
|
selectedYear.textContent = movie.year ? `Year: ${movie.year}` : "";
|
||||||
|
selectedImdbId.textContent = movie.id;
|
||||||
|
selectedType.textContent = movie.type || "Movie";
|
||||||
|
selectedStars.textContent = movie.stars ? `Cast: ${movie.stars}` : "";
|
||||||
|
|
||||||
|
if (movie.imageUrl) {
|
||||||
|
selectedPoster.src = movie.imageUrl;
|
||||||
|
selectedPoster.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
selectedPoster.classList.add("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedMovieContainer.classList.remove("hidden");
|
||||||
|
|
||||||
|
// Show Section Action & SEND Button
|
||||||
|
sectionAction.classList.remove("hidden");
|
||||||
|
hideResponseBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock sections if user wants to change movie
|
||||||
|
function unlockSections() {
|
||||||
|
selectedMovie = null;
|
||||||
|
|
||||||
|
magnetInput.readOnly = false;
|
||||||
|
sectionMagnet.classList.remove("is-fixed");
|
||||||
|
magnetLockBadge.classList.add("hidden");
|
||||||
|
|
||||||
|
sectionMovie.classList.remove("is-fixed");
|
||||||
|
movieLockBadge.classList.add("hidden");
|
||||||
|
selectedMovieContainer.classList.add("hidden");
|
||||||
|
movieSearchContainer.classList.remove("hidden");
|
||||||
|
|
||||||
|
sectionAction.classList.add("hidden");
|
||||||
|
hideResponseBox();
|
||||||
|
|
||||||
|
movieInput.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. FastAPI SEND Action
|
||||||
|
function initActions() {
|
||||||
|
btnSend.addEventListener("click", async () => {
|
||||||
|
const magnetValue = magnetInput.value.trim();
|
||||||
|
|
||||||
|
if (!magnetValue) {
|
||||||
|
showResponse(false, "Missing Magnet Link", "Please provide a valid magnet link before sending.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedMovie || !selectedMovie.id) {
|
||||||
|
showResponse(false, "No Movie Selected", "Please select a movie from the IMDb results.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare payload
|
||||||
|
const payload = {
|
||||||
|
magnet: magnetValue,
|
||||||
|
imdbid: selectedMovie.id
|
||||||
|
};
|
||||||
|
|
||||||
|
// Button loading state
|
||||||
|
btnSend.disabled = true;
|
||||||
|
btnSend.querySelector(".btn-send-text").textContent = "SENDING TO FASTAPI...";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Send directly to FastAPI endpoint
|
||||||
|
const response = await fetch("http://localhost:8000/download", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json().catch(() => ({}));
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
showResponse(
|
||||||
|
true,
|
||||||
|
"Download Triggered Successfully!",
|
||||||
|
JSON.stringify(data, null, 2)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const errorDetail = data.detail
|
||||||
|
? (typeof data.detail === "object" ? JSON.stringify(data.detail, null, 2) : data.detail)
|
||||||
|
: response.statusText;
|
||||||
|
showResponse(
|
||||||
|
false,
|
||||||
|
`FastAPI Returned Error ${response.status}`,
|
||||||
|
errorDetail || "Unknown error from server."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// If direct fetch fails (e.g. server down or CORS), try background script
|
||||||
|
if (browserAPI && browserAPI.runtime && browserAPI.runtime.sendMessage) {
|
||||||
|
browserAPI.runtime.sendMessage(
|
||||||
|
{
|
||||||
|
action: "send_download",
|
||||||
|
magnet: payload.magnet,
|
||||||
|
imdbid: payload.imdbid
|
||||||
|
},
|
||||||
|
(bgRes) => {
|
||||||
|
if (bgRes && bgRes.success) {
|
||||||
|
showResponse(
|
||||||
|
true,
|
||||||
|
"Download Triggered Successfully! (via Background)",
|
||||||
|
JSON.stringify(bgRes.data, null, 2)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const msg = bgRes ? bgRes.error : err.message;
|
||||||
|
showResponse(
|
||||||
|
false,
|
||||||
|
"Connection to FastAPI Failed",
|
||||||
|
`${msg}\n\nMake sure your FastAPI server is running on http://localhost:8000:\ncd dummy_api && uvicorn dummy_api.main:app --port 8000`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showResponse(
|
||||||
|
false,
|
||||||
|
"Connection to FastAPI Failed",
|
||||||
|
`${err.message}\n\nMake sure your FastAPI server is running on http://localhost:8000:\ncd dummy_api && uvicorn dummy_api.main:app --port 8000`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
btnSend.disabled = false;
|
||||||
|
btnSend.querySelector(".btn-send-text").textContent = "SEND";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showResponse(isSuccess, title, body) {
|
||||||
|
responseBox.classList.remove("hidden", "success", "error");
|
||||||
|
responseBox.classList.add(isSuccess ? "success" : "error");
|
||||||
|
|
||||||
|
responseIcon.textContent = isSuccess ? "✅" : "⚠️";
|
||||||
|
responseTitle.textContent = title;
|
||||||
|
responseBody.textContent = body;
|
||||||
|
responseBox.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideResponseBox() {
|
||||||
|
responseBox.classList.add("hidden");
|
||||||
|
responseBody.textContent = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeHTML(str) {
|
||||||
|
if (!str) return "";
|
||||||
|
return String(str)
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, """)
|
||||||
|
.replace(/'/g, "'");
|
||||||
|
}
|
||||||
Reference in new issue
Block a user