-
Notifications
You must be signed in to change notification settings - Fork 32
Durga js variables #533
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
base: main
Are you sure you want to change the base?
Durga js variables #533
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
|
|
||
| * { | ||
| margin: 0; | ||
| padding: 0; | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| body { | ||
| font-family: Arial, sans-serif; | ||
| line-height: 1.6; | ||
| } | ||
|
|
||
| header { | ||
| background: #0d0a99; | ||
| color: #fff; | ||
| padding: 20px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| nav ul { | ||
| list-style: none; | ||
| display: flex; | ||
| justify-content: center; | ||
| gap: 20px; | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| nav a { | ||
| color: #fff; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| main { | ||
| display: flex; | ||
| padding: 20px; | ||
| gap: 20px; | ||
| } | ||
|
|
||
| article { | ||
| flex: 3; | ||
| background: #2c13a8; | ||
| color: #fff; | ||
| padding: 20px; | ||
| border-radius: 8px; | ||
| } | ||
|
|
||
| aside { | ||
| flex: 1; | ||
| background: #4d119b; | ||
| color: #fff; | ||
| padding: 20px; | ||
| border-radius: 8px; | ||
| } | ||
|
|
||
| footer { | ||
| background: #3f12ba; | ||
| color: #fff; | ||
| text-align: center; | ||
| padding: 15px; | ||
| margin-top: 20px; | ||
| bottom: auto; | ||
| } | ||
|
|
||
| @media (max-width: 768px) { | ||
| main { | ||
| flex-direction: column; | ||
| flex:1; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>CSS Animation & Media Queries</title> | ||
| <style> | ||
| body { | ||
| font-family: Arial, sans-serif; | ||
| margin: 0; | ||
| padding: 0; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| height: 100vh; | ||
| background: #f0f0f0; | ||
| } | ||
| .box { | ||
| width: 150px; | ||
| height: 150px; | ||
| background: #3498db; | ||
| border-radius: 10px; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| color: white; | ||
| font-weight: bold; | ||
| animation: bounce 2s infinite; | ||
| } | ||
| @keyframes bounce { | ||
| 0%, 100% { | ||
| transform: translateY(0); | ||
| } | ||
| 50% { | ||
| transform: translateY(-50px); | ||
| } | ||
| } | ||
| @media (max-width: 768px) { | ||
| .box { | ||
| width: 120px; | ||
| height: 120px; | ||
| font-size: 14px; | ||
| background: #e67e22; | ||
| } | ||
| } | ||
|
|
||
| @media (max-width: 480px) { | ||
| .box { | ||
| width: 90px; | ||
| height: 90px; | ||
| font-size: 12px; | ||
| background: #2ecc71; | ||
| } | ||
| } | ||
| </style> | ||
|
Comment on lines
+7
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CSS styles are defined within a |
||
| </head> | ||
| <body> | ||
| <div class="box">Hello Guys..!</div> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||
| <!DOCTYPE html> | ||||||
| <html lang="en"> | ||||||
| <head> | ||||||
| <meta charset="UTF-8"> | ||||||
| <title>Inline, Internal & External JS Execution Order</title> | ||||||
| </head> | ||||||
| <body onload="document.getElementById('inline').innerHTML = 'Hello from Inline JS!'"> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
|
||||||
| <h2>Execution Order Example</h2> | ||||||
| <p id="inline"></p> | ||||||
| <p id="internal"></p> | ||||||
| <p id="external"></p> | ||||||
|
|
||||||
| <script src="script.js"></script> | ||||||
|
|
||||||
|
|
||||||
| <script> | ||||||
| document.getElementById("internal").innnerHTML = "Hello from Internal JS!"; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a typo in
Suggested change
|
||||||
| </script> | ||||||
|
|
||||||
| </body> | ||||||
| </html> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
|
|
||
| document.getElementById("external").innerHTML = "Hello from External JS!"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| let output = ""; | ||
| output += "<b>Using var:</b><br>"; | ||
| var x = 10; | ||
| output += "Initial value: " + x + "<br>"; | ||
| var x = 20; | ||
| output += "After redeclaration: " + x + "<br>"; | ||
| x = 30; | ||
| output += "After reassignment: " + x + "<br><br>"; | ||
|
|
||
| output += "<b>Using let:</b><br>"; | ||
| let y = 10; | ||
| output += "Initial value: " + y + "<br>"; | ||
| try { | ||
| let y = 20; | ||
| output += "After redeclaration: " + y + "<br>"; | ||
| } catch (err) { | ||
| output += "Error on redeclaration: " + err.message + "<br>"; | ||
| } | ||
|
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
| y = 30; | ||
| output += "After reassignment: " + y + "<br><br>"; | ||
|
|
||
| output += "<b>Using const:</b><br>"; | ||
| const z = 10; | ||
| output += "Initial value: " + z + "<br>"; | ||
| try { | ||
| const z = 20; | ||
| output += "After redeclaration: " + z + "<br>"; | ||
| } catch (err) { | ||
| output += "Error on redeclaration: " + err.message + "<br>"; | ||
| } | ||
| try { | ||
| z = 30; | ||
| output += "After reassignment: " + z + "<br>"; | ||
| } catch (err) { | ||
| output += "Error on reassignment: " + err.message + "<br>"; | ||
| } | ||
|
|
||
| document.getElementById("output").innerHTML = output; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>var, let, const Example</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| <h2>Variable Declaration, Redeclaration & Reassignment</h2> | ||
|
|
||
| <div id="output"></div> | ||
|
|
||
| <script src="script.js"></script> | ||
|
|
||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| let output = ""; | ||
| let name = "Sai Durga"; | ||
| output += "Value: " + name + " — Type: " + typeof name + "<br>"; | ||
|
|
||
| let age = 22; | ||
| output += "Value: " + age + " — Type: " + typeof age + "<br>"; | ||
|
|
||
| let isStudent = true; | ||
| output += "Value: " + isStudent + " — Type: " + typeof isStudent + "<br>"; | ||
|
|
||
| let city; | ||
| output += "Value: " + city + " — Type: " + typeof city + "<br>"; | ||
|
|
||
| let car = null; | ||
| output += | ||
| "Value: " + | ||
| car + | ||
| " — Type: " + | ||
| typeof car + | ||
| " (note: null is a special case)<br>"; | ||
|
|
||
| let sym = Symbol("id"); | ||
| output += "Value: " + sym.toString() + " — Type: " + typeof sym + "<br>"; | ||
|
|
||
| let student = { name: "Sai", age: 25 }; | ||
| output += | ||
| "Value: " + JSON.stringify(student) + " — Type: " + typeof student + "<br>"; | ||
|
|
||
| document.getElementById("output").innerHTML = output; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>JavaScript Data Types</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| <h2>JavaScript Data Types and typeof</h2> | ||
|
|
||
| <div id="output"></div> | ||
|
|
||
| <script src="script.js"></script> | ||
|
|
||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>JavaScript Type Conversion</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| <h2>JavaScript Type Conversion Example</h2> | ||
| <div id="output"></div> | ||
|
|
||
| <script> | ||
| let output = ""; | ||
|
|
||
| let str = "123"; | ||
| let num = 42; | ||
| let bool = true; | ||
| let undef; | ||
| let nul = null; | ||
| let sym = Symbol("id"); | ||
| let obj = {name:"Sai"}; | ||
|
|
||
| function convertAndPrint(value, typeName) { | ||
|
|
||
| let displayValue = (typeof value === "symbol") ? value.toString() : value; | ||
| output += `<b>${typeName} (${displayValue})</b><br>`; | ||
|
|
||
| try { | ||
| let n = Number(value); | ||
| output += "Number(): " + n + "<br>"; | ||
| } catch(e) { | ||
| output += "Number(): Error - " + e.message + "<br>"; | ||
| } | ||
|
|
||
| try { | ||
| let s = String(value); | ||
| output += "String(): " + s + "<br>"; | ||
| } catch(e) { | ||
| output += "String(): Error - " + e.message + "<br>"; | ||
| } | ||
|
|
||
| try { | ||
| let b = Boolean(value); | ||
| output += "Boolean(): " + b + "<br><br>"; | ||
| } catch(e) { | ||
| output += "Boolean(): Error - " + e.message + "<br><br>"; | ||
| } | ||
| } | ||
| convertAndPrint(str, "String"); | ||
| convertAndPrint(num, "Number"); | ||
| convertAndPrint(bool, "Boolean"); | ||
| convertAndPrint(undef, "Undefined"); | ||
| convertAndPrint(nul, "Null"); | ||
| convertAndPrint(sym, "Symbol"); | ||
| convertAndPrint(obj, "Object"); | ||
|
|
||
| document.getElementById("output").innerHTML = output; | ||
| </script> | ||
|
Comment on lines
+12
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This HTML file contains a substantial amount of JavaScript. According to the best practices in the PR description, scripts should be in separate files to improve organization, maintainability, and enable caching. Please move this script to an external |
||
|
|
||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Type Coercion Example</title> | ||
| </head> | ||
| <body> | ||
|
|
||
| <h2>JavaScript Type Coercion (Addition)</h2> | ||
| <div id="output"></div> | ||
|
|
||
| <script> | ||
| let output = ""; | ||
|
|
||
| let str = "10"; | ||
| let num = 5; | ||
| let bool = true; | ||
| let undef; | ||
| let nul = null; | ||
| let obj = {name:"Sai"}; | ||
|
|
||
|
|
||
| function show(expr, result) { | ||
| output += expr + " → " + result + "<br>"; | ||
| } | ||
|
|
||
| show(`${num} + ${str}`, num + str); | ||
| show(`${num} + ${bool}`, num + bool); | ||
| show(`${num} + ${undef}`, num + undef); | ||
| show(`${num} + ${nul}`, num + nul); | ||
| show(`${num} + ${obj}`, num + obj); | ||
|
|
||
| show(`${str} + ${bool}`, str + bool); | ||
| show(`${str} + ${nul}`, str + nul); | ||
| show(`${bool} + ${nul}`, bool + nul); | ||
| show(`${bool} + ${str}`, bool + str); | ||
|
|
||
| document.getElementById("output").innerHTML = output; | ||
| </script> | ||
|
|
||
| </body> | ||
| </html> |
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.
The color
#0d0a99is hardcoded. For better maintainability and to ensure a consistent color scheme, it's recommended to define colors as CSS Custom Properties (variables) in a:rootselector. This practice should be applied to all hardcoded colors in the file (e.g., on lines 41, 49, 56).