Create basic Netflix clone website

#16
by smolSWE - opened
Files changed (3) hide show
  1. index.html +53 -34
  2. script.js +17 -82
  3. style.css +120 -41
index.html CHANGED
@@ -1,45 +1,64 @@
1
-
2
  <!DOCTYPE html>
3
- <html lang="en">
4
  <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Calculator with Graph</title>
8
  <link rel="stylesheet" href="style.css">
9
- <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10
  </head>
11
  <body>
12
- <div class="calculator">
13
- <input type="text" id="display" readonly>
14
- <div class="buttons">
15
- <button onclick="clearDisplay()">C</button>
16
- <button onclick="deleteLast()">DEL</button>
17
- <button onclick="appendValue('%')">%</button>
18
- <button onclick="appendValue('/')">/</button>
19
- <button onclick="appendValue('7')">7</button>
20
- <button onclick="appendValue('8')">8</button>
21
- <button onclick="appendValue('9')">9</button>
22
- <button onclick="appendValue('*')">*</button>
23
- <button onclick="appendValue('4')">4</button>
24
- <button onclick="appendValue('5')">5</button>
25
- <button onclick="appendValue('6')">6</button>
26
- <button onclick="appendValue('-')">-</button>
27
- <button onclick="appendValue('1')">1</button>
28
- <button onclick="appendValue('2')">2</button>
29
- <button onclick="appendValue('3')">3</button>
30
- <button onclick="appendValue('+')">+</button>
31
- <button onclick="appendValue('0')">0</button>
32
- <button onclick="appendValue('.')">.</button>
33
- <button onclick="calculate()">=</button>
34
  </div>
35
- </div>
36
 
37
- <div class="graph-container">
38
- <input type="text" id="equation" placeholder="Enter equation (e.g., x^2)">
39
- <button onclick="plotGraph()">Plot Graph</button>
40
- <canvas id="myChart"></canvas>
41
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
 
 
 
 
 
 
 
43
  <script src="script.js"></script>
44
  </body>
45
  </html>
 
 
1
  <!DOCTYPE html>
2
+ <html>
3
  <head>
4
+ <title>Netflix Clone</title>
 
 
5
  <link rel="stylesheet" href="style.css">
 
6
  </head>
7
  <body>
8
+ <nav class="navbar">
9
+ <div class="navbar-logo">
10
+ <img src="https://upload.wikimedia.org/wikipedia/commons/0/08/Netflix_2015_logo.svg" alt="Netflix Logo">
11
+ </div>
12
+ <ul class="navbar-menu">
13
+ <li><a href="#">Home</a></li>
14
+ <li><a href="#">TV Shows</a></li>
15
+ <li><a href="#">Movies</a></li>
16
+ <li><a href="#">My List</a></li>
17
+ </ul>
18
+ </nav>
19
+
20
+ <section class="hero">
21
+ <div class="hero-content">
22
+ <h1>Movie Title</h1>
23
+ <p>A brief description of the movie.</p>
24
+ <div class="hero-buttons">
25
+ <button>Play</button>
26
+ <button>More Info</button>
27
+ </div>
 
 
28
  </div>
29
+ </section>
30
 
31
+ <main class="container">
32
+ <div class="movie-row">
33
+ <h2>Trending Now</h2>
34
+ <div class="movie-posters">
35
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
36
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
37
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
38
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
39
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
40
+ </div>
41
+ </div>
42
+
43
+ <div class="movie-row">
44
+ <h2>Top Picks for You</h2>
45
+ <div class="movie-posters">
46
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
47
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
48
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
49
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
50
+ <img src="https://via.placeholder.com/150x200" alt="Movie Poster">
51
+ </div>
52
+ </div>
53
+ </main>
54
 
55
+ <footer class="footer">
56
+ <p>&copy; 2024 Netflix Clone</p>
57
+ <ul>
58
+ <li><a href="#">Terms of Use</a></li>
59
+ <li><a href="#">Privacy Policy</a></li>
60
+ </ul>
61
+ </footer>
62
  <script src="script.js"></script>
63
  </body>
64
  </html>
script.js CHANGED
@@ -1,87 +1,22 @@
1
 
2
- let display = document.getElementById('display');
3
- let chart;
4
-
5
- function appendValue(value) {
6
- display.value += value;
7
- }
8
-
9
- function clearDisplay() {
10
- display.value = '';
11
- }
12
-
13
- function calculate() {
14
- try {
15
- let expression = display.value;
16
- let result = evaluateExpression(expression);
17
- display.value = result;
18
- } catch (error) {
19
- display.value = 'Error';
20
- }
21
- }
22
-
23
- function evaluateExpression(expression) {
24
- // Basic implementation, more robust parsing needed for complex expressions
25
- expression = expression.replace(/[^-()\d/*+.]/g, ''); // Remove invalid characters
26
- expression = expression.replace(/(\d+\.\d+)/g, parseFloat); // clean floats
27
- expression = expression.replace(/(\d+)/g, parseInt); // clean integers
28
- try {
29
- return new Function('return ' + expression)();
30
- } catch (e) {
31
- return 'Error';
32
- }
33
  }
34
 
35
-
36
- function deleteLast() {
37
- display.value = display.value.slice(0, -1);
38
  }
39
 
40
- function plotGraph() {
41
- const equation = document.getElementById('equation').value;
42
- const xValues = [];
43
- const yValues = [];
44
-
45
- for (let x = -10; x <= 10; x += 0.5) {
46
- xValues.push(x);
47
- try {
48
- // Replace x in the equation and evaluate
49
- let y = evaluateExpression(equation.replace(/x/g, x));
50
- yValues.push(y);
51
- } catch (error) {
52
- alert("Invalid equation!");
53
- return;
54
- }
55
- }
56
-
57
- // Destroy previous chart if it exists
58
- if (chart) {
59
- chart.destroy();
60
- }
61
-
62
- const ctx = document.getElementById('myChart').getContext('2d');
63
- chart = new Chart(ctx, {
64
- type: 'line',
65
- data: {
66
- labels: xValues,
67
- datasets: [{
68
- label: equation,
69
- data: yValues,
70
- borderColor: 'blue',
71
- fill: false
72
- }]
73
- },
74
- options: {
75
- scales: {
76
- x: {
77
- type: 'linear',
78
- position: 'bottom'
79
- },
80
- y: {
81
- type: 'linear',
82
- position: 'left'
83
- }
84
- }
85
- }
86
- });
87
- }
 
1
 
2
+ // Function to display a movie trailer (placeholder)
3
+ function showTrailer() {
4
+ alert('Trailer is not available yet.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
6
 
7
+ // Function to add a movie to My List (placeholder)
8
+ function addToMyList() {
9
+ alert('Added to My List!');
10
  }
11
 
12
+ // Add event listeners to movie posters
13
+ const moviePosters = document.querySelectorAll('.movie-posters img');
14
+ moviePosters.forEach(poster => {
15
+ poster.addEventListener('click', showTrailer);
16
+ });
17
+
18
+ // Add event listener to the "More Info" button (placeholder)
19
+ const moreInfoButton = document.querySelector('.hero-buttons button:last-child');
20
+ moreInfoButton.addEventListener('click', () => {
21
+ alert('More info about the movie will be displayed here.');
22
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
style.css CHANGED
@@ -1,64 +1,143 @@
1
 
2
- .calculator {
3
- width: 300px;
4
- margin: 50px auto;
5
- background-color: #333;
6
- border-radius: 10px;
7
- overflow: hidden;
8
  }
9
 
10
- .calculator input {
11
- width: 100%;
12
- padding: 20px;
13
- font-size: 24px;
14
- border: none;
15
- background-color: #222;
16
- color: white;
17
- text-align: right;
18
- white-space: nowrap;
19
- overflow-x: auto;
20
  }
21
 
22
- .calculator .buttons {
23
- display: grid;
24
- grid-template-columns: repeat(4, 1fr);
25
  }
26
 
27
- .calculator button {
28
- padding: 20px;
29
- font-size: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  border: none;
31
- background-color: #444;
32
- color: white;
 
33
  cursor: pointer;
34
- transition: background-color 0.3s ease;
35
  }
36
 
37
- .calculator button:hover {
38
- background-color: #555;
39
  }
40
 
41
- .calculator button:active {
42
- background-color: #666;
43
  }
44
 
45
- .calculator .buttons button:nth-child(4n) {
46
- background-color: #f0a040;
 
47
  }
48
 
49
- .calculator .buttons button:nth-child(4n):hover {
50
- background-color: #f2b96e;
 
 
51
  }
52
 
53
- .graph-container {
54
- width: 600px;
55
- margin: 20px auto;
56
  text-align: center;
57
  }
58
 
59
- #equation {
60
- padding: 10px;
61
- font-size: 16px;
62
- width: 400px;
63
- margin-bottom: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
 
1
 
2
+ body {
3
+ font-family: sans-serif;
4
+ background-color: #000;
5
+ color: #fff;
6
+ margin: 0;
 
7
  }
8
 
9
+ .navbar {
10
+ background-color: #000;
11
+ padding: 10px 20px;
12
+ display: flex;
13
+ justify-content: space-between;
14
+ align-items: center;
 
 
 
 
15
  }
16
 
17
+ .navbar-logo img {
18
+ width: 100px;
 
19
  }
20
 
21
+ .navbar-menu {
22
+ list-style: none;
23
+ display: flex;
24
+ padding: 0;
25
+ }
26
+
27
+ .navbar-menu li {
28
+ margin-left: 20px;
29
+ }
30
+
31
+ .navbar-menu li a {
32
+ color: #fff;
33
+ text-decoration: none;
34
+ }
35
+
36
+ .hero {
37
+ background-image: url('https://via.placeholder.com/1920x1080');
38
+ background-size: cover;
39
+ background-position: center;
40
+ height: 500px;
41
+ display: flex;
42
+ align-items: center;
43
+ padding: 0 20px;
44
+ }
45
+
46
+ .hero-content {
47
+ max-width: 600px;
48
+ }
49
+
50
+ .hero-content h1 {
51
+ font-size: 3em;
52
+ margin-bottom: 20px;
53
+ }
54
+
55
+ .hero-content p {
56
+ font-size: 1.2em;
57
+ margin-bottom: 30px;
58
+ }
59
+
60
+ .hero-buttons button {
61
+ background-color: rgba(0, 0, 0, 0.5);
62
+ color: #fff;
63
  border: none;
64
+ padding: 10px 20px;
65
+ margin-right: 10px;
66
+ font-size: 1.1em;
67
  cursor: pointer;
 
68
  }
69
 
70
+ .container {
71
+ padding: 20px;
72
  }
73
 
74
+ .movie-row {
75
+ margin-bottom: 30px;
76
  }
77
 
78
+ .movie-posters {
79
+ display: flex;
80
+ overflow-x: auto;
81
  }
82
 
83
+ .movie-posters img {
84
+ margin-right: 10px;
85
+ width: 150px;
86
+ height: 200px;
87
  }
88
 
89
+ .footer {
90
+ background-color: #222;
91
+ padding: 20px;
92
  text-align: center;
93
  }
94
 
95
+ .footer ul {
96
+ list-style: none;
97
+ padding: 0;
98
+ display: flex;
99
+ justify-content: center;
100
+ }
101
+
102
+ .footer li {
103
+ margin: 0 10px;
104
+ }
105
+
106
+ .footer li a {
107
+ color: #fff;
108
+ text-decoration: none;
109
+ }
110
+
111
+ /* Responsive Design */
112
+ @media (max-width: 768px) {
113
+ .navbar {
114
+ flex-direction: column;
115
+ align-items: flex-start;
116
+ }
117
+
118
+ .navbar-menu {
119
+ margin-top: 10px;
120
+ flex-direction: column;
121
+ }
122
+
123
+ .navbar-menu li {
124
+ margin-left: 0;
125
+ margin-bottom: 10px;
126
+ }
127
+
128
+ .hero {
129
+ height: 400px;
130
+ }
131
+
132
+ .hero-content {
133
+ max-width: 100%;
134
+ }
135
+
136
+ .hero-content h1 {
137
+ font-size: 2em;
138
+ }
139
+
140
+ .hero-content p {
141
+ font-size: 1em;
142
+ }
143
  }