Skip to content

Commit 70d4e90

Browse files
authored
Add files via upload
1 parent 65d8f0d commit 70d4e90

15 files changed

Lines changed: 499 additions & 0 deletions

File tree

audio_player/sample.mp3

208 KB
Binary file not shown.

audio_player/script.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(function() {
2+
'use strict';
3+
4+
// Constructor function for the AudioPlayer plugin
5+
function AudioPlayer(containerId, options) {
6+
// Store the audio player container
7+
this.container = document.getElementById(containerId);
8+
9+
// Set default options
10+
this.options = Object.assign({
11+
source: '', // URL to the audio file
12+
}, options);
13+
14+
// Initialize the audio player
15+
this.initAudioPlayer();
16+
}
17+
18+
AudioPlayer.prototype.initAudioPlayer = function() {
19+
// Create an audio element
20+
const audioElement = document.createElement('audio');
21+
audioElement.src = this.options.source;
22+
audioElement.controls = true;
23+
24+
// Append the audio element to the container
25+
this.container.appendChild(audioElement);
26+
};
27+
28+
// Export the AudioPlayer as a global function or as an ES module
29+
if (typeof window === 'object') {
30+
window.AudioPlayer = AudioPlayer;
31+
}
32+
if (typeof exports === 'object') {
33+
module.exports = AudioPlayer;
34+
}
35+
})();

audio_player/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Styling for the audio player container */
2+
.audio-player {
3+
max-width: 300px;
4+
margin: 20px auto;
5+
}

bottom_nav/script.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// BottomNavigation.js
2+
(function() {
3+
'use strict';
4+
5+
// Constructor function for the BottomNavigation plugin
6+
function BottomNavigation(navId) {
7+
// Store the bottom navigation element
8+
this.bottomNav = document.getElementById(navId);
9+
10+
// Initialize the bottom navigation
11+
this.initBottomNavigation();
12+
}
13+
14+
BottomNavigation.prototype.initBottomNavigation = function() {
15+
// Add click event listeners to navigation items
16+
const navItems = this.bottomNav.getElementsByClassName('nav-item');
17+
for (let i = 0; i < navItems.length; i++) {
18+
navItems[i].addEventListener('click', this.handleNavItemClick.bind(this));
19+
}
20+
};
21+
22+
BottomNavigation.prototype.handleNavItemClick = function(event) {
23+
// Remove the "active" class from all navigation items
24+
const navItems = this.bottomNav.getElementsByClassName('nav-item');
25+
for (let i = 0; i < navItems.length; i++) {
26+
navItems[i].classList.remove('active');
27+
}
28+
29+
// Add the "active" class to the clicked navigation item
30+
event.currentTarget.classList.add('active');
31+
};
32+
33+
// Export the BottomNavigation as a global function or as an ES module
34+
if (typeof window === 'object') {
35+
window.BottomNavigation = BottomNavigation;
36+
}
37+
if (typeof exports === 'object') {
38+
module.exports = BottomNavigation;
39+
}
40+
})();

bottom_nav/style.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* Reset some default styles */
2+
body, h1, h2, p {
3+
margin: 0;
4+
padding: 0;
5+
}
6+
7+
/* Apply styles to the bottom navigation and items */
8+
.bottom-navigation {
9+
display: flex;
10+
justify-content: space-around;
11+
align-items: center;
12+
background-color: #f0f0f0;
13+
position: fixed;
14+
bottom: 0;
15+
left: 0;
16+
width: 100%;
17+
height: 60px;
18+
box-shadow: 0px -2px 5px rgba(0, 0, 0, 0.1);
19+
z-index: 100;
20+
}
21+
22+
.nav-item {
23+
display: flex;
24+
flex-direction: column;
25+
align-items: center;
26+
text-decoration: none;
27+
color: #333;
28+
padding: 5px 0;
29+
transition: color 0.3s;
30+
}
31+
32+
.nav-item:hover {
33+
color: #007bff;
34+
}
35+
36+
.active {
37+
color: #007bff;
38+
}
39+
40+
/* Optional: Add a subtle animation effect */
41+
.nav-item .icon {
42+
font-size: 24px;
43+
margin-bottom: 5px;
44+
}
45+
46+
.nav-item .label {
47+
font-size: 12px;
48+
opacity: 0.8;
49+
transition: opacity 0.3s;
50+
}
51+
52+
.nav-item.active .label {
53+
opacity: 1;
54+
}

dragable/script.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
const draggableElements = document.querySelectorAll(".draggable");
3+
let activeElement = null;
4+
let startPosX = 0;
5+
let startPosY = 0;
6+
let offsetX = 0;
7+
let offsetY = 0;
8+
9+
draggableElements.forEach(function (element) {
10+
element.addEventListener("mousedown", function (event) {
11+
activeElement = element;
12+
startPosX = event.clientX;
13+
startPosY = event.clientY;
14+
offsetX = activeElement.getBoundingClientRect().left;
15+
offsetY = activeElement.getBoundingClientRect().top;
16+
activeElement.classList.add("dragging"); // Apply the dragging style
17+
});
18+
});
19+
20+
document.addEventListener("mousemove", function (event) {
21+
if (activeElement) {
22+
const deltaX = event.clientX - startPosX;
23+
const deltaY = event.clientY - startPosY;
24+
const newPosX = offsetX + deltaX;
25+
const newPosY = offsetY + deltaY;
26+
27+
activeElement.style.left = newPosX + "px";
28+
activeElement.style.top = newPosY + "px";
29+
}
30+
});
31+
32+
document.addEventListener("mouseup", function () {
33+
if (activeElement) {
34+
activeElement.classList.remove("dragging"); // Remove the dragging style
35+
activeElement = null;
36+
}
37+
});
38+
});

dragable/style.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.draggable {
2+
position: absolute;
3+
cursor: grab; /* Set cursor to indicate the element is draggable */
4+
user-select: none; /* Prevent text selection while dragging */
5+
width: 200px;
6+
height: 100px;
7+
background-color: lightblue;
8+
border: 1px solid blue;
9+
text-align: center;
10+
line-height: 100px;
11+
}
12+
13+
.draggable.dragging {
14+
cursor: grabbing; /* Set cursor when the element is being dragged */
15+
}

drawer/script.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(function() {
2+
'use strict';
3+
4+
// Constructor function for the Drawer plugin
5+
function Drawer(drawerId, openButtonId) {
6+
// Store the drawer and open button elements
7+
this.drawer = document.getElementById(drawerId);
8+
this.openButton = document.getElementById(openButtonId);
9+
10+
// Initialize the drawer
11+
this.initDrawer();
12+
}
13+
14+
Drawer.prototype.initDrawer = function() {
15+
// Add click event listener to the open button
16+
this.openButton.addEventListener('click', this.toggleDrawer.bind(this));
17+
18+
// Add a click event listener to the document to close the drawer when clicking outside
19+
document.addEventListener('click', this.closeDrawerOutside.bind(this));
20+
};
21+
22+
Drawer.prototype.toggleDrawer = function(event) {
23+
// Prevent the default behavior of the button click
24+
event.preventDefault();
25+
// Toggle the "open" class to show/hide the drawer
26+
this.drawer.classList.toggle('open');
27+
};
28+
29+
Drawer.prototype.closeDrawerOutside = function(event) {
30+
// Check if the clicked element is not inside the drawer or the open button
31+
if (!this.drawer.contains(event.target) && event.target !== this.openButton) {
32+
// Close the drawer
33+
this.drawer.classList.remove('open');
34+
}
35+
};
36+
37+
// Export the Drawer as a global function or as an ES module
38+
if (typeof window === 'object') {
39+
window.Drawer = Drawer;
40+
}
41+
if (typeof exports === 'object') {
42+
module.exports = Drawer;
43+
}
44+
})();

drawer/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Styles for the drawer and its content */
2+
.drawer {
3+
position: fixed;
4+
top: 0;
5+
right: -300px; /* Start hidden outside the viewport */
6+
width: 300px;
7+
height: 100%;
8+
background-color: #f0f0f0;
9+
overflow-x: hidden;
10+
transition: right 0.3s ease-in-out;
11+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
12+
}
13+
14+
.drawer.open {
15+
right: 0; /* Slide in from the right when open */
16+
}
17+
18+
.drawer-content {
19+
padding: 20px;
20+
}
21+
22+
/* Button to open the drawer */
23+
#openDrawerButton {
24+
position: absolute;
25+
top: 10px;
26+
right: 10px;
27+
}

google_map_widget/script.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// GoogleMapsWidget.js
2+
3+
(function() {
4+
'use strict';
5+
6+
// Constructor function for the GoogleMapsWidget
7+
function GoogleMapsWidget(elementId, options) {
8+
// Store the target element where the map will be embedded
9+
this.element = document.getElementById(elementId);
10+
11+
// Set default options
12+
this.options = Object.assign({
13+
apiKey: '',
14+
center: { lat: 37.7749, lng: -122.4194 }, // Default to San Francisco
15+
zoom: 10
16+
}, options);
17+
18+
// Initialize the map
19+
this.initMap();
20+
}
21+
22+
GoogleMapsWidget.prototype.initMap = function() {
23+
// Create a new Google Map instance
24+
this.map = new google.maps.Map(this.element, {
25+
center: this.options.center,
26+
zoom: this.options.zoom
27+
});
28+
};
29+
30+
// Public method to change the map center
31+
GoogleMapsWidget.prototype.setCenter = function(center) {
32+
if (center && center.lat && center.lng) {
33+
this.map.setCenter(center);
34+
}
35+
};
36+
37+
// Public method to change the map zoom level
38+
GoogleMapsWidget.prototype.setZoom = function(zoom) {
39+
if (zoom) {
40+
this.map.setZoom(zoom);
41+
}
42+
};
43+
44+
// Export the GoogleMapsWidget as a global function or as an ES module
45+
if (typeof window === 'object') {
46+
window.GoogleMapsWidget = GoogleMapsWidget;
47+
}
48+
if (typeof exports === 'object') {
49+
module.exports = GoogleMapsWidget;
50+
}
51+
})();

0 commit comments

Comments
 (0)