forked from ayush-that/FinVeda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
finance.js
86 lines (73 loc) · 2.52 KB
/
finance.js
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
document.getElementById('postForm').addEventListener('submit', function (e) {
e.preventDefault();
const postContent = document.getElementById('postContent').value;
if (postContent.trim() === '') return;
const postContainer = document.getElementById('posts');
const newPost = document.createElement('div');
newPost.classList.add('post');
newPost.textContent = postContent;
postContainer.appendChild(newPost);
document.getElementById('postContent').value = ''; // Clear the textarea
});
// Array of video course data
const courses = [
{
title: "Introduction to Finance and Accounting",
url: "https://www.youtube.com/watch?v=kdd4SmNfZVk",
duration: "2:30 hours"
},
{
title: "Understanding Financial Statements",
url: "https://www.youtube.com/watch?v=7Y2nLfn1M2E",
duration: "1:45 hours"
},
{
title: "Basics of Investment",
url: "https://www.youtube.com/watch?v=RgT_KxfpItg",
duration: "1:20 hours"
},
{
title: "Personal Finance 101",
url: "https://www.youtube.com/watch?v=bk-x9LHzl90",
duration: "3:00 hours"
},
{
title: "Introduction to Corporate Finance",
url: "https://www.youtube.com/watch?v=SnfDF7fRIaM",
duration: "2:10 hours"
}
];
// Function to render video courses
function renderCourses() {
const videoCoursesContainer = document.getElementById("video-courses");
courses.forEach(course => {
const courseItem = document.createElement("div");
courseItem.className = "course-item";
const courseLink = document.createElement("a");
courseLink.className = "course-title";
courseLink.href = course.url;
courseLink.textContent = course.title;
courseLink.target = "_blank";
const courseDuration = document.createElement("span");
courseDuration.className = "course-duration";
courseDuration.textContent = course.duration;
courseItem.appendChild(courseLink);
courseItem.appendChild(courseDuration);
videoCoursesContainer.appendChild(courseItem);
});
}
// Show the button when the user scrolls down 100px from the top of the page
window.onscroll = function() {
const scrollToTopBtn = document.getElementById("scrollBtn");
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
};
// Smooth scroll to the top when the button is clicked
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Call the function to render courses on page load
window.onload = renderCourses;