-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollab.html
More file actions
293 lines (250 loc) · 10.8 KB
/
Copy pathcollab.html
File metadata and controls
293 lines (250 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Find Collaborators - Script2Cinema</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<style>
:root{ --primary:#ff9800; --dark:#0d1b2a; --bg:#010409; --card:#0d1117; --text:#f0f6fc; --muted:#8b949e; --border:#30363d; }
*{margin:0;padding:0;box-sizing:border-box}
body{ font-family:Poppins,sans-serif; background:url('bc 1.jpg') center/cover fixed no-repeat; color:var(--text); }
/* TOAST NOTIFICATION STYLES */
#toast {
visibility: hidden;
min-width: 250px;
background-color: #28a745;
color: #fff;
text-align: center;
border-radius: 8px;
padding: 16px;
position: fixed;
z-index: 1000;
left: 50%;
bottom: 30px;
transform: translateX(-50%);
font-size: 1rem;
box-shadow: 0px 4px 15px rgba(0,0,0,0.5);
opacity: 0;
transition: opacity 0.5s, bottom 0.5s;
}
#toast.show {
visibility: visible;
opacity: 1;
bottom: 50px;
}
header{ display:flex; justify-content:space-between; align-items:center; padding:1rem 2rem; background:var(--dark); border-bottom:1px solid var(--border); }
.logo{color:var(--primary);font-size:1.5rem;font-weight:700;text-decoration:none}
.nav-links{display:flex;gap:1.2rem;list-style:none}
.nav-links a{ color:var(--text); text-decoration:none; padding:.45rem .75rem; border-radius:6px; }
.nav-links a.active,.nav-links a:hover{ background:var(--primary); color:#000; }
.user-actions{display:flex;gap:1rem;align-items:center}
.logout-btn{ background:none; border:1px solid var(--border); color:var(--text); padding:.4rem .9rem; border-radius:6px; cursor:pointer; }
.container{max-width:1280px;margin:2rem auto;padding:0 2rem}
.page-header h1{font-size:2.2rem}
.filters{display:flex;gap:1rem;margin:2rem 0}
.search{ flex:1; padding:.8rem 1rem; background:var(--card); border:1px solid var(--border); color:var(--text); border-radius:6px; }
.select{ padding:.8rem 1rem; background:var(--card); border:1px solid var(--border); color:var(--text); border-radius:6px; }
.grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:1.5rem; }
/* CARD LINK WRAPPER */
.card-link { text-decoration: none; color: inherit; display: block; }
.card{ background:rgba(13,17,23,.9); border:1px solid var(--border); border-radius:10px; padding:1.4rem; display:flex; flex-direction:column; justify-content:space-between; transition:.25s; height: 100%; }
.card:hover{ border-color:var(--primary); transform:translateY(-4px); }
.card-header{ display:flex; gap:1rem; align-items:center; }
.avatar{ width:52px; height:52px; border-radius:50%; object-fit:cover; background:#1f2937; display:flex; align-items:center; justify-content:center; }
.tag{ background:var(--primary); color:#000; font-size:.75rem; padding:.25rem .7rem; border-radius:20px; margin:.2rem; display:inline-block; }
.bio{ font-size:.9rem; color:var(--muted); margin-top:1rem; border-top:1px solid var(--border); padding-top:.8rem; }
.btn{ margin-top:1rem; width:100%; padding:.7rem; border-radius:6px; border:none; font-weight:600; cursor:pointer; }
.connect{background:#007bff;color:#fff}
.pending{background:#6c757d;color:#fff;cursor:not-allowed}
.connected{background:var(--primary);color:#000}
</style>
</head>
<body>
<header>
<a class="logo" href="dash.html">Script2Cinema</a>
<ul class="nav-links">
<li><a href="dash.html"><i class="fas fa-tachometer-alt"></i> Dashboard</a></li>
<li><a href="project.html"><i class="fas fa-folder"></i> Projects</a></li>
<li><a href="collab.html" class="active"><i class="fas fa-users"></i> Collaborators</a></li>
<li><a href="message.html"><i class="fas fa-envelope"></i> Message</a></li>
<li><a href="profile.html"><i class="fas fa-user-circle"></i> Profile</a></li>
</ul>
<div class="user-actions">
<span id="welcome">Welcome</span>
<button class="logout-btn" id="logout">Logout</button>
</div>
</header>
<main class="container">
<div class="page-header">
<h1>Find Collaborators</h1>
<p>Connect with filmmakers and creatives.</p>
</div>
<div class="filters">
<input class="search" id="search" placeholder="Search by name">
<select class="select" id="role">
<option value="">All Roles</option>
<option>Director</option>
<option>Writer</option>
<option>Editor</option>
<option>Cinematographer</option>
<option>Producer</option>
<option>Executive Producer</option>
<option>Assistant Director</option>
<option>Casting Director</option>
<option>VFX Artist</option>
<option>Musician</option>
<option>Choreographer</option>
<option>Action Director</option>
<option>Make-up Team</option>
<option>Costume Designer</option>
<option>Lyricist</option>
<option>Other</option>
</select>
</div>
<div class="grid" id="grid"></div>
</main>
<div id="toast"><i class="fas fa-check-circle"></i> Request Sent Successfully!</div>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-firestore.js"></script>
<script>
// ---------- FIREBASE INIT ----------
const firebaseConfig = {
apiKey: "AIzaSyAJzGN3RURMAvSSk2OkxTj9I6JMsyrdVEc",
authDomain: "script2cinema-86afa.firebaseapp.com",
projectId: "script2cinema-86afa",
storageBucket: "script2cinema-86afa.appspot.com",
messagingSenderId: "709129400285",
appId: "1:709129400285:web:8e32274e9c605ffc7ed034"
};
if (!firebase.apps.length) firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const db = firebase.firestore();
// ---------- STATE ----------
let me = null;
let users = [];
let connections = {};
// ---------- AUTH ----------
auth.onAuthStateChanged(async user => {
if (!user) return location.href = "login.html";
const snap = await db.collection("users").doc(user.uid).get();
me = { uid: user.uid, ...snap.data() };
document.getElementById("welcome").textContent = `Welcome, ${me.name}`;
listenConnections();
loadUsers();
document.getElementById("logout").onclick =
() => auth.signOut().then(() => location.href = "login.html");
});
function listenConnections() {
db.collection("connections")
.where("participants", "array-contains", me.uid)
.onSnapshot(snapshot => {
connections = {};
snapshot.forEach(doc => {
const d = doc.data();
const other = d.participants.find(id => id !== me.uid);
if(other) connections[other] = d.status;
});
render();
});
}
async function loadUsers() {
const snap = await db.collection("users").get();
users = [];
snap.forEach(d => {
if (d.id !== me.uid) users.push({ uid: d.id, ...d.data() });
});
render();
}
// ---------- TOAST HELPER ----------
function showToast(message) {
const t = document.getElementById("toast");
t.innerHTML = `<i class="fas fa-check-circle"></i> ${message}`;
t.className = "show";
setTimeout(() => { t.className = t.className.replace("show", ""); }, 3000);
}
// ---------- SEND CONNECTION REQUEST ----------
window.sendRequest = async (targetUid) => {
const btn = document.getElementById(`btn-${targetUid}`);
if(btn) { btn.disabled = true; btn.innerText = "Sending..."; }
const connId = [me.uid, targetUid].sort().join("_");
try {
const targetSnap = await db.collection("users").doc(targetUid).get();
const targetName = targetSnap.exists ? targetSnap.data().name : "User";
await db.collection("connections").doc(connId).set({
participants: [me.uid, targetUid],
requesterId: me.uid,
requesterName: me.name,
receiverId: targetUid,
receiverName: targetName,
status: "pending",
timestamp: firebase.firestore.FieldValue.serverTimestamp()
}, { merge: true });
showToast("Request sent successfully!"); // <-- TRIGGER TOAST
} catch (error) {
console.error(error);
alert("Error: " + error.message);
if(btn) { btn.disabled = false; btn.innerText = "Connect"; }
}
}
window.openChat = (uid) => {
location.href = `message.html?chatWith=${uid}`;
}
function render() {
const grid = document.getElementById("grid");
const filter = document.getElementById("search").value.toLowerCase();
grid.innerHTML = "";
users.forEach(u => {
if(filter && !u.name.toLowerCase().includes(filter)) return;
const status = connections[u.uid];
let btn = "";
if (status === "pending") {
// NOTE: Added event.preventDefault() to stop profile click
btn = `<button class="btn pending" disabled style="background:#6c757d; cursor: not-allowed;" onclick="event.preventDefault()">
<i class="fas fa-clock"></i> Request Sent
</button>`;
}
else if (status === "accepted") {
// NOTE: Added event.preventDefault() to stop profile click
btn = `<button class="btn connected" onclick="event.preventDefault(); openChat('${u.uid}')" style="background:#28a745; color:white;">
<i class="fas fa-comments"></i> Message
</button>`;
}
else {
// NOTE: Added event.preventDefault() to stop profile click
btn = `<button id="btn-${u.uid}" class="btn connect" onclick="event.preventDefault(); sendRequest('${u.uid}')" style="background:#007bff; color:white;">
<i class="fas fa-user-plus"></i> Connect
</button>`;
}
const roles = u.roles || [];
const roleTags = roles.map(r => `<span class="tag">${r}</span>`).join("");
// --- CARD WITH LINK WRAPPER ---
grid.innerHTML += `
<a href="profile.html?id=${u.uid}" target="_blank" class="card-link">
<div class="card">
<div class="card-header">
${u.profilePictureUrl
? `<img src="${u.profilePictureUrl}" class="avatar">`
: `<div class="avatar">${u.name[0]}</div>`}
<div>
<h3 style="margin-bottom:0.2rem">${u.name}</h3>
<small style="color:#8b949e">Filmmaker</small>
</div>
</div>
<div class="bio">
${u.aboutMe ? u.aboutMe.substring(0, 100) + (u.aboutMe.length>100?"...":"") : "No bio available."}
</div>
<div style="margin: 1rem 0;">
${roleTags}
</div>
${btn}
</div>
</a>`;
});
}
document.getElementById("search").addEventListener("keyup", render);
</script>
</body>
</html>