Skip to content

Commit 442b3e8

Browse files
committed
Some new modifications, and start of implementing profile page system.
1 parent 5c436a4 commit 442b3e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4064
-225
lines changed

.idea/codeception.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.idea/deployment.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/phpspec.xml

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/symfony-blog.iml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/webServers.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/comment-requests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export default class CommentRequests {
6666
location.href = `/comment/${data.respondedComment}/replies#comment-${data.id}`;
6767
else {
6868
location.href = `/post/${data.postId}/#comment-${data.id}`; //location.href.split("#")[0] + `#comment-${data.id}`
69+
location.reload();
6970
}
7071
} else {
7172
Utilities.displayMessage(data.message, "danger");

assets/comments.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -443,20 +443,20 @@ if (!onHomePage) {
443443
}
444444
})
445445
}
446-
} else {
447-
for (let i = 0; i < commentFormButtons.length; i++) {
448-
commentFormButtons[i].addEventListener("click", function () {
449-
if (!onRepliesPage && i === 0) {
450-
CommentRequests.submit(commentEditors[i], null, false, this.getAttribute("data-post-id"));
451-
} else {
452-
if (commentBars[i].getAttribute("toBeEdited") !== "true")
453-
CommentRequests.submit(commentEditors[i], this.getAttribute("data-comment-id"));
454-
else
455-
CommentRequests.submit(commentEditors[i], this.getAttribute("data-comment-id"), true);
456-
}
446+
}
457447

458-
this.style.display = "none";
459-
})
460-
}
448+
for (let i = 0; i < commentFormButtons.length; i++) {
449+
commentFormButtons[i].addEventListener("click", function () {
450+
if (!onRepliesPage && i === 0) {
451+
CommentRequests.submit(commentEditors[i], null, false, this.getAttribute("data-post-id"));
452+
} else {
453+
if (commentBars[i].getAttribute("toBeEdited") !== "true")
454+
CommentRequests.submit(commentEditors[i], this.getAttribute("data-comment-id"));
455+
else
456+
CommentRequests.submit(commentEditors[i], this.getAttribute("data-comment-id"), true);
457+
}
458+
459+
this.style.display = "none";
460+
})
461461
}
462462

assets/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'froala-editor/css/froala_editor.pkgd.min.css';
66
import 'froala-editor/css/froala_style.min.css';
77
import dayjs from 'dayjs';
88
import relativeTime from 'dayjs/plugin/relativeTime';
9+
import "bootstrap";
910

1011
// Load your languages
1112
import 'froala-editor/js/languages/en_gb.js';
@@ -284,4 +285,4 @@ if (submitButton && createPostFormTitle && createPostFormTitle.innerText === 'Up
284285
if (postFormAudienceSelect.value.includes('friends_except') || postFormAudienceSelect.value.includes('specific_friends')) {
285286
postAudience.style.display = "block";
286287
}
287-
}
288+
}

assets/post-requests.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,30 @@ export default class PostRequests {
3737
})
3838
}
3939
}
40+
41+
static hide(post) {
42+
if (confirm("Do you want to hide this post?")) {
43+
return fetch(`/post/${post}/hide`, { method: "POST" })
44+
.then(response => response.json())
45+
.then(data => {
46+
return true
47+
})
48+
.catch(error => {
49+
console.log("Error: " + error);
50+
return false;
51+
})
52+
}
53+
}
54+
55+
static show(post) {
56+
return fetch(`/post/${post}/display`, { method: "POST" })
57+
.then(response => response.json())
58+
.then(data => {
59+
return data?.content;
60+
})
61+
.catch(error => {
62+
console.log("Error: " + error);
63+
return false;
64+
})
65+
}
4066
}

assets/posts.js

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function reactToPost(id, reaction = "like") {
6565

6666
// Definition of the necessary variables of the HTML Elements
6767
const postMenus = document.querySelectorAll(".post-menu"),
68+
postsContents = document.querySelectorAll(".post-block .fr-view"),
6869
postMenuBlocks = document.querySelectorAll(".post-menu-block"),
6970
postMenuButtons = document.querySelectorAll(".post-menu-button"),
7071
seeHistoryButtons = document.querySelectorAll(".see-history"),
@@ -78,8 +79,6 @@ const postMenus = document.querySelectorAll(".post-menu"),
7879
selectedFilters = document.querySelectorAll(".selected-filter"),
7980
filtersContainers = document.querySelectorAll(".filters"),
8081
allFilters = document.querySelectorAll(".filter"),
81-
commentInputs = document.querySelectorAll(".comment-input"),
82-
commentFormButtons = document.querySelectorAll('.comment-bar form svg'),
8382
storiesSection = document.querySelector(".stories-section"),
8483
postReactsNumbers = document.querySelectorAll(".post-reacts-number"),
8584
postReactionsContainerBlocks = document.querySelectorAll(".post-reactions-container-block"),
@@ -91,7 +90,16 @@ const postMenus = document.querySelectorAll(".post-menu"),
9190
createCommentBar = document.getElementById("create-comment-bar"),
9291
reportPostButtons = document.querySelectorAll(".report-post"),
9392
snoozeUserButtons = document.querySelectorAll(".snooze"),
94-
blockUserButtons = document.querySelectorAll(".post-menu-action.block");
93+
blockUserButtons = document.querySelectorAll(".post-menu-action.block"),
94+
unBlockUserButtons = document.querySelectorAll(".post-menu-action.unblock"),
95+
hidePostButtons = document.querySelectorAll(".hide-post"),
96+
showPostButtons = document.querySelectorAll(".show-post"),
97+
commentsBlocks = document.querySelectorAll(".comments"),
98+
iframeCodeButtons = document.querySelectorAll(".iframe-code-button"),
99+
iframeInputs = document.querySelectorAll(".iframe-input"),
100+
iframeContainerCloseButtons = document.querySelectorAll(".iframe-container-close"),
101+
iframeContainerBlocks = document.querySelectorAll(".iframe-container-block"),
102+
embedPostButtons = document.querySelectorAll(".embed-post");
95103

96104
const url = new URL(location.href);
97105
const queryParams = new URLSearchParams(location.search),
@@ -102,6 +110,12 @@ if (storiesSection) {
102110
for (const selectedFilter of selectedFilters) {
103111
selectedFilter.style.display = "none";
104112
}
113+
} else {
114+
// Setting the title of the page to the title of the post content
115+
const title = Utilities.getPostTitle();
116+
if (title) {
117+
document.title = `Nexus | ${title}`;
118+
}
105119
}
106120

107121
let allLikeNumbers = [],
@@ -190,7 +204,7 @@ for (let i = 0; i < postMenus.length; i++) {
190204
dislikeButtons[i].style.color = 'inherit';
191205
}
192206
}
193-
})
207+
});
194208

195209
dislikeButtons[i].addEventListener('click', async function (evt) {
196210
evt.preventDefault();
@@ -215,7 +229,7 @@ for (let i = 0; i < postMenus.length; i++) {
215229
likeButtons[i].style.color = 'inherit';
216230
}
217231
}
218-
})
232+
});
219233

220234
shareButtons[i].addEventListener("click", function (evt) {
221235
evt.preventDefault();
@@ -235,7 +249,7 @@ for (let i = 0; i < postMenus.length; i++) {
235249
alert("Successful shared article")
236250
})
237251
.catch(err => console.log("Couldn't share the post"));
238-
})
252+
});
239253

240254
reportPostButtons[i].addEventListener("click", async function () {
241255
await PostRequests.report(postMenus[i].getAttribute("data-post-id"));
@@ -245,6 +259,55 @@ for (let i = 0; i < postMenus.length; i++) {
245259
await UserRequests.snooze(postMenus[i].getAttribute("data-user-id"));
246260
});
247261

262+
blockUserButtons[i].addEventListener("click", async function () {
263+
await UserRequests.block(postMenus[i].getAttribute("data-user-id"));
264+
});
265+
266+
unBlockUserButtons[i].addEventListener("click", async function () {
267+
await UserRequests.unblock(postMenus[i].getAttribute("data-user-id"));
268+
});
269+
270+
hidePostButtons[i].addEventListener("click", async function () {
271+
let result = await PostRequests.hide(postMenus[i].getAttribute("data-post-id"));
272+
if (result) {
273+
postsContents[i].innerHTML = "<p>This post has been hidden</p>";
274+
}
275+
276+
showPostButtons[i].style.display = "flex";
277+
this.style.display = "none";
278+
commentsBlocks[i].style.display = "none";
279+
});
280+
281+
showPostButtons[i].addEventListener("click", async function () {
282+
let result = await PostRequests.show(postMenus[i].getAttribute("data-post-id"));
283+
if (result) {
284+
postsContents[i].innerHTML = result;
285+
}
286+
287+
hidePostButtons[i].style.display = "flex";
288+
this.style.display = "none";
289+
commentsBlocks[i].style.display = "block";
290+
});
291+
292+
iframeCodeButtons[i].addEventListener("click", function (evt) {
293+
evt.preventDefault();
294+
navigator.clipboard.writeText(iframeInputs[i].value)
295+
.then(() => {
296+
alert('Code copied to clipboard!');
297+
}).catch(err => {
298+
alert('Failed to copy code');
299+
})
300+
;
301+
});
302+
303+
iframeContainerCloseButtons[i].addEventListener("click", function () {
304+
iframeContainerBlocks[i].style.display = "none";
305+
});
306+
307+
embedPostButtons[i].addEventListener("click", function () {
308+
iframeContainerBlocks[i].style.display = "flex";
309+
})
310+
248311
selectedFilters[i].addEventListener("click", function () {
249312
filtersContainers[i].style.display = getComputedStyle(filtersContainers[i]).display === "flex" ? "none" : "flex";
250313
})

assets/profile.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import "./styles/profile.css";
2+
3+
const profileNavBarActions = document.querySelectorAll('.profile-nav-bar-actions>.profile-nav-bar-action'),
4+
profileNavBarDropdownTrigger = document.querySelector(".profile-nav-bar-dropdown-trigger"),
5+
profileNavBarDropdown = document.querySelector(".profile-nav-bar-dropdown-menu"),
6+
profileNavBarDropdownChevronUp = document.querySelector(".profile-nav-bar-dropdown-trigger .chevron-up"),
7+
profileNavBarDropdownChevronDown = document.querySelector(".profile-nav-bar-dropdown-trigger .chevron-down"),
8+
profileOptionsBlock = document.querySelector('.profile-options-container-block'),
9+
profileOptionsBlockTrigger = document.querySelector('.supplementary-actions-button'),
10+
profileOptionsBlockClose = document.querySelector('.profile-options-container-close');
11+
12+
profileNavBarDropdownTrigger.addEventListener("click", function () {
13+
if (getComputedStyle(profileNavBarDropdown).display === "none") {
14+
profileNavBarDropdown.style.display = "block";
15+
profileNavBarDropdownChevronUp.style.display = "block";
16+
profileNavBarDropdownChevronDown.style.display = "none";
17+
} else {
18+
profileNavBarDropdown.style.display = "none";
19+
profileNavBarDropdownChevronUp.style.display = "none";
20+
profileNavBarDropdownChevronDown.style.display = "block";
21+
}
22+
})
23+
24+
profileOptionsBlockTrigger.addEventListener('click', function () {
25+
profileOptionsBlock.style.display = 'flex';
26+
})
27+
28+
profileOptionsBlockClose.addEventListener('click', function () {
29+
profileOptionsBlock.style.display = 'none';
30+
})
31+
32+
const url = new URL(window.location.href);
33+
const urlParts = (url.host + url.pathname).split("/");
34+
if (urlParts[2] !== "") {
35+
const profileAction = document.querySelector(`.profile-nav-bar-action.${urlParts[2]}`);
36+
if (profileAction) {
37+
console.log(profileAction);
38+
await onVisible(profileAction, () => {
39+
profileNavBarDropdownTrigger.classList.remove('active');
40+
profileAction.classList.add('active')
41+
});
42+
await notVisible(profileAction, () => {
43+
profileAction.classList.remove('active');
44+
profileNavBarDropdownTrigger.classList.add('active');
45+
});
46+
}
47+
} else
48+
profileNavBarActions[0].classList.add('active');
49+
50+
function onVisible(element, callback) {
51+
new IntersectionObserver((entries, observer) => {
52+
entries.forEach(entry => {
53+
if(entry.intersectionRatio > 0) {
54+
callback(element);
55+
// observer.disconnect();
56+
}
57+
});
58+
}).observe(element);
59+
if(!callback) return new Promise(r => callback=r);
60+
}
61+
62+
function notVisible(element, callback) {
63+
new IntersectionObserver((entries, observer) => {
64+
entries.forEach(entry => {
65+
if(entry.intersectionRatio <= 0) {
66+
callback(element);
67+
// observer.disconnect();
68+
}
69+
});
70+
}).observe(element);
71+
if(!callback) return new Promise(r => callback=r);
72+
}

assets/styles/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
body {
4545
background-color: var(--principal-background);
46-
font-family: SFProDisplay-Regular, serif;
46+
font-family: SFProDisplay-Regular, serif;
4747
display: flex;
4848
align-content: center;
4949
box-sizing: unset;

0 commit comments

Comments
 (0)