-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Realtime Notification option on home page #88
Open
Shalinis19137
wants to merge
1
commit into
Harshdev098:main
Choose a base branch
from
Shalinis19137:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+108
β2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Real-Time Notifications</title> | ||
<link rel="stylesheet" href="notify.css"> <!-- Link to CSS file --> | ||
</head> | ||
<body> | ||
<div class="notification-container"> | ||
<h2>Notifications</h2> | ||
<div id="notifications"></div> | ||
<button id="clear-notifications">Clear Notifications</button> | ||
</div> | ||
|
||
<script src="notify.js"></script> <!-- Link to JavaScript file --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #d4edda; /* Light green background color */ | ||
margin: 0; | ||
padding: 20px; | ||
} | ||
|
||
.notification-container { | ||
max-width: 600px; | ||
margin: auto; | ||
background: #fff; /* White background for notification box */ | ||
border-radius: 8px; | ||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
padding: 20px; | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
} | ||
|
||
.notification { | ||
padding: 10px; | ||
border-bottom: 1px solid #e0e0e0; | ||
position: relative; | ||
} | ||
|
||
.notification:last-child { | ||
border-bottom: none; | ||
} | ||
|
||
.notification p { | ||
margin: 0; | ||
} | ||
|
||
.notification-time { | ||
font-size: 0.8em; | ||
color: #999; | ||
position: absolute; | ||
right: 10px; | ||
top: 10px; | ||
} | ||
|
||
button { | ||
margin-top: 20px; | ||
padding: 10px 20px; | ||
background-color: #007bff; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background-color: #0056b3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// script.js | ||
|
||
// Sample notification data | ||
const notifications = [ | ||
{ message: "New research paper on AI published.", time: new Date().toLocaleTimeString() }, | ||
{ message: "New comment on your research article.", time: new Date().toLocaleTimeString() }, | ||
{ message: "Your research submission has been reviewed.", time: new Date().toLocaleTimeString() } | ||
]; | ||
|
||
// Function to display notifications | ||
function displayNotification(notification) { | ||
const notificationsContainer = document.getElementById('notifications'); | ||
const notificationDiv = document.createElement('div'); | ||
notificationDiv.classList.add('notification'); | ||
notificationDiv.innerHTML = ` | ||
<p>${notification.message}</p> | ||
<span class="notification-time">${notification.time}</span> | ||
`; | ||
notificationsContainer.prepend(notificationDiv); // Add new notifications to the top | ||
} | ||
|
||
// Simulate receiving notifications every 5 seconds | ||
setInterval(() => { | ||
const randomIndex = Math.floor(Math.random() * notifications.length); | ||
displayNotification(notifications[randomIndex]); | ||
}, 5000); | ||
|
||
// Clear notifications | ||
document.getElementById('clear-notifications').addEventListener('click', () => { | ||
const notificationsContainer = document.getElementById('notifications'); | ||
notificationsContainer.innerHTML = ''; // Clear all notifications | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the changes made is possibly good but the notification data(message) are fetched from the node server, we will add this functionality, just remove the sample notification data we will change the logic of
displayNotification
function from the API endpoint. But yah if you want to change this logic to fetch the the notifications from our node server you can work on it