snippet-command-kit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snippet_command_kit-0.1.0/PKG-INFO +10 -0
- snippet_command_kit-0.1.0/README.md +3 -0
- snippet_command_kit-0.1.0/pyproject.toml +28 -0
- snippet_command_kit-0.1.0/setup.cfg +4 -0
- snippet_command_kit-0.1.0/src/snippet_command_kit.egg-info/PKG-INFO +10 -0
- snippet_command_kit-0.1.0/src/snippet_command_kit.egg-info/SOURCES.txt +19 -0
- snippet_command_kit-0.1.0/src/snippet_command_kit.egg-info/dependency_links.txt +1 -0
- snippet_command_kit-0.1.0/src/snippet_command_kit.egg-info/entry_points.txt +11 -0
- snippet_command_kit-0.1.0/src/snippet_command_kit.egg-info/top_level.txt +1 -0
- snippet_command_kit-0.1.0/src/snippetkit/__init__.py +0 -0
- snippet_command_kit-0.1.0/src/snippetkit/cli.py +56 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p1.txt +74 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p10.txt +0 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p2.txt +120 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p3.txt +55 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p4.txt +165 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p5.txt +28 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p6.txt +0 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p7.txt +0 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p8.txt +0 -0
- snippet_command_kit-0.1.0/src/snippetkit/texts/p9.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: snippet-command-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A collection of useful Python code snippets
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# Snippet Command Kit
|
|
9
|
+
|
|
10
|
+
A Python package for printing code snippets using commands p1 through p10.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "snippet-command-kit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A collection of useful Python code snippets"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
p1 = "snippetkit.cli:p1"
|
|
14
|
+
p2 = "snippetkit.cli:p2"
|
|
15
|
+
p3 = "snippetkit.cli:p3"
|
|
16
|
+
p4 = "snippetkit.cli:p4"
|
|
17
|
+
p5 = "snippetkit.cli:p5"
|
|
18
|
+
p6 = "snippetkit.cli:p6"
|
|
19
|
+
p7 = "snippetkit.cli:p7"
|
|
20
|
+
p8 = "snippetkit.cli:p8"
|
|
21
|
+
p9 = "snippetkit.cli:p9"
|
|
22
|
+
p10 = "snippetkit.cli:p10"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.packages.find]
|
|
25
|
+
where = ["src"]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.package-data]
|
|
28
|
+
snippetkit = ["texts/*.txt"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: snippet-command-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A collection of useful Python code snippets
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# Snippet Command Kit
|
|
9
|
+
|
|
10
|
+
A Python package for printing code snippets using commands p1 through p10.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/snippet_command_kit.egg-info/PKG-INFO
|
|
4
|
+
src/snippet_command_kit.egg-info/SOURCES.txt
|
|
5
|
+
src/snippet_command_kit.egg-info/dependency_links.txt
|
|
6
|
+
src/snippet_command_kit.egg-info/entry_points.txt
|
|
7
|
+
src/snippet_command_kit.egg-info/top_level.txt
|
|
8
|
+
src/snippetkit/__init__.py
|
|
9
|
+
src/snippetkit/cli.py
|
|
10
|
+
src/snippetkit/texts/p1.txt
|
|
11
|
+
src/snippetkit/texts/p10.txt
|
|
12
|
+
src/snippetkit/texts/p2.txt
|
|
13
|
+
src/snippetkit/texts/p3.txt
|
|
14
|
+
src/snippetkit/texts/p4.txt
|
|
15
|
+
src/snippetkit/texts/p5.txt
|
|
16
|
+
src/snippetkit/texts/p6.txt
|
|
17
|
+
src/snippetkit/texts/p7.txt
|
|
18
|
+
src/snippetkit/texts/p8.txt
|
|
19
|
+
src/snippetkit/texts/p9.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
p1 = snippetkit.cli:p1
|
|
3
|
+
p10 = snippetkit.cli:p10
|
|
4
|
+
p2 = snippetkit.cli:p2
|
|
5
|
+
p3 = snippetkit.cli:p3
|
|
6
|
+
p4 = snippetkit.cli:p4
|
|
7
|
+
p5 = snippetkit.cli:p5
|
|
8
|
+
p6 = snippetkit.cli:p6
|
|
9
|
+
p7 = snippetkit.cli:p7
|
|
10
|
+
p8 = snippetkit.cli:p8
|
|
11
|
+
p9 = snippetkit.cli:p9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
snippetkit
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
TEXTS_DIR = Path(__file__).parent / "texts"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def print_text(number):
|
|
8
|
+
file_path = TEXTS_DIR / f"p{number}.txt"
|
|
9
|
+
|
|
10
|
+
if not file_path.exists():
|
|
11
|
+
print("Text not found!")
|
|
12
|
+
return
|
|
13
|
+
|
|
14
|
+
text = file_path.read_text(encoding="utf-8")
|
|
15
|
+
|
|
16
|
+
print(text)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def p1():
|
|
20
|
+
print_text(1)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def p2():
|
|
24
|
+
print_text(2)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def p3():
|
|
28
|
+
print_text(3)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def p4():
|
|
32
|
+
print_text(4)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def p5():
|
|
36
|
+
print_text(5)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def p6():
|
|
40
|
+
print_text(6)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def p7():
|
|
44
|
+
print_text(7)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def p8():
|
|
48
|
+
print_text(8)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def p9():
|
|
52
|
+
print_text(9)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def p10():
|
|
56
|
+
print_text(10)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<?xml-stylesheet type="text/css" href="style.css"?>
|
|
3
|
+
|
|
4
|
+
<college>
|
|
5
|
+
<h1>Annual Report</h1>
|
|
6
|
+
|
|
7
|
+
<student>
|
|
8
|
+
<usn>1BMCS064</usn>
|
|
9
|
+
<name>Deepika</name>
|
|
10
|
+
<clgname>BMSIT</clgname>
|
|
11
|
+
<prog>CSE</prog>
|
|
12
|
+
<yog>2024</yog>
|
|
13
|
+
<email>deepikah@gmail.com</email>
|
|
14
|
+
</student>
|
|
15
|
+
|
|
16
|
+
<student>
|
|
17
|
+
<usn>1BMCS074</usn>
|
|
18
|
+
<name>Devansh</name>
|
|
19
|
+
<clgname>BMSIT</clgname>
|
|
20
|
+
<prog>AIML</prog>
|
|
21
|
+
<yog>2025</yog>
|
|
22
|
+
<email>devansh@bmsit.in</email>
|
|
23
|
+
</student>
|
|
24
|
+
|
|
25
|
+
<student>
|
|
26
|
+
<usn>1BMCS104</usn>
|
|
27
|
+
<name>Sumit</name>
|
|
28
|
+
<clgname>BMSIT</clgname>
|
|
29
|
+
<prog>MECH</prog>
|
|
30
|
+
<yog>2023</yog>
|
|
31
|
+
<email>sumit@gmail.com</email>
|
|
32
|
+
</student>
|
|
33
|
+
|
|
34
|
+
</college>
|
|
35
|
+
|
|
36
|
+
college {
|
|
37
|
+
display: block;
|
|
38
|
+
font-family: Arial, sans-serif;
|
|
39
|
+
background-color: #f2f2f2;
|
|
40
|
+
padding: 20px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
student {
|
|
44
|
+
display: block;
|
|
45
|
+
background-color: white;
|
|
46
|
+
border: 2px solid #333;
|
|
47
|
+
margin: 15px;
|
|
48
|
+
padding: 15px;
|
|
49
|
+
width: 400px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
usn, name, clgname, prog, yog, email {
|
|
53
|
+
display: block;
|
|
54
|
+
margin: 8px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
usn {
|
|
58
|
+
font-weight: bold;
|
|
59
|
+
color: blue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
name {
|
|
63
|
+
font-size: 20px;
|
|
64
|
+
font-weight: bold;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
clgname {
|
|
68
|
+
color: green;
|
|
69
|
+
font-weight: bold;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
email {
|
|
73
|
+
color: purple;
|
|
74
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Simple Calculator</title>
|
|
5
|
+
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
font-family: Arial, sans-serif;
|
|
9
|
+
background-color: #f2f2f2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.calculator {
|
|
13
|
+
width: 300px;
|
|
14
|
+
margin: 80px auto;
|
|
15
|
+
padding: 20px;
|
|
16
|
+
background: white;
|
|
17
|
+
border: 2px solid black;
|
|
18
|
+
border-radius: 10px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
h2 {
|
|
22
|
+
text-align: center;
|
|
23
|
+
color: #333;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
input, select, button {
|
|
27
|
+
width: 90%;
|
|
28
|
+
padding: 10px;
|
|
29
|
+
margin: 8px;
|
|
30
|
+
font-size: 16px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#result {
|
|
34
|
+
margin-top: 15px;
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
color: blue;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
39
|
+
</head>
|
|
40
|
+
|
|
41
|
+
<body>
|
|
42
|
+
|
|
43
|
+
<div class="calculator">
|
|
44
|
+
|
|
45
|
+
<h2>Simple Calculator</h2>
|
|
46
|
+
|
|
47
|
+
<input type="number" id="num1"
|
|
48
|
+
placeholder="Enter first operand">
|
|
49
|
+
|
|
50
|
+
<select id="operator">
|
|
51
|
+
<option value="+">Addition (+)</option>
|
|
52
|
+
<option value="-">Subtraction (-)</option>
|
|
53
|
+
<option value="*">Multiplication (*)</option>
|
|
54
|
+
<option value="/">Division (/)</option>
|
|
55
|
+
</select>
|
|
56
|
+
|
|
57
|
+
<input type="number" id="num2"
|
|
58
|
+
placeholder="Enter second operand">
|
|
59
|
+
|
|
60
|
+
<button onclick="calculate()">Calculate</button>
|
|
61
|
+
|
|
62
|
+
<div id="result">Result:</div>
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<script>
|
|
67
|
+
function calculate() {
|
|
68
|
+
|
|
69
|
+
let num1 = parseFloat(
|
|
70
|
+
document.getElementById("num1").value
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
let num2 = parseFloat(
|
|
74
|
+
document.getElementById("num2").value
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
let op = document.getElementById("operator").value;
|
|
78
|
+
let result;
|
|
79
|
+
|
|
80
|
+
if (isNaN(num1) || isNaN(num2)) {
|
|
81
|
+
document.getElementById("result").innerHTML =
|
|
82
|
+
"Please enter valid numbers.";
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
switch (op) {
|
|
87
|
+
|
|
88
|
+
case "+":
|
|
89
|
+
result = num1 + num2;
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case "-":
|
|
93
|
+
result = num1 - num2;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case "*":
|
|
97
|
+
result = num1 * num2;
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case "/":
|
|
101
|
+
if (num2 === 0) {
|
|
102
|
+
document.getElementById("result").innerHTML =
|
|
103
|
+
"Cannot divide by zero.";
|
|
104
|
+
return;
|
|
105
|
+
} else {
|
|
106
|
+
result = num1 / num2;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
default:
|
|
111
|
+
result = "Invalid operator";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
document.getElementById("result").innerHTML =
|
|
115
|
+
"Result: " + result;
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
</body>
|
|
120
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>Text Growing and Shrinking</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<div id="text">Text to be transformed</div>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
let text = document.getElementById("text");
|
|
15
|
+
|
|
16
|
+
let growing = true;
|
|
17
|
+
let size = 5;
|
|
18
|
+
|
|
19
|
+
let timer = setInterval(function() {
|
|
20
|
+
|
|
21
|
+
if (growing) {
|
|
22
|
+
|
|
23
|
+
text.innerHTML = "Text Growing";
|
|
24
|
+
text.style.color = "red";
|
|
25
|
+
|
|
26
|
+
size += 0.5;
|
|
27
|
+
|
|
28
|
+
text.style.fontSize = size + "pt";
|
|
29
|
+
|
|
30
|
+
if (size >= 50) {
|
|
31
|
+
growing = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} else {
|
|
35
|
+
|
|
36
|
+
text.innerHTML = "Text Shrinking";
|
|
37
|
+
text.style.color = "blue";
|
|
38
|
+
|
|
39
|
+
size -= 0.5;
|
|
40
|
+
|
|
41
|
+
text.style.fontSize = size + "pt";
|
|
42
|
+
|
|
43
|
+
if (size <= 5) {
|
|
44
|
+
clearInterval(timer);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}, 100);
|
|
50
|
+
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
</body>
|
|
54
|
+
|
|
55
|
+
</html>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Registration Form</title>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: Arial, sans-serif;
|
|
11
|
+
background: #f0f4f8;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
min-height: 100vh;
|
|
16
|
+
margin: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.container {
|
|
20
|
+
background: white;
|
|
21
|
+
padding: 25px;
|
|
22
|
+
width: 320px;
|
|
23
|
+
border-radius: 10px;
|
|
24
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h2 {
|
|
28
|
+
text-align: center;
|
|
29
|
+
color: #2563eb;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
label {
|
|
33
|
+
display: block;
|
|
34
|
+
margin-top: 12px;
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
input {
|
|
39
|
+
width: 100%;
|
|
40
|
+
padding: 10px;
|
|
41
|
+
margin-top: 5px;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
border: 1px solid #ccc;
|
|
44
|
+
border-radius: 5px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
input:focus {
|
|
48
|
+
outline: none;
|
|
49
|
+
border-color: #2563eb;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
button {
|
|
53
|
+
width: 100%;
|
|
54
|
+
padding: 11px;
|
|
55
|
+
margin-top: 20px;
|
|
56
|
+
background: #2563eb;
|
|
57
|
+
color: white;
|
|
58
|
+
border: none;
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
font-size: 16px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
button:hover {
|
|
65
|
+
background: #1d4ed8;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#message {
|
|
69
|
+
margin-top: 15px;
|
|
70
|
+
text-align: center;
|
|
71
|
+
font-weight: bold;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
74
|
+
</head>
|
|
75
|
+
<body>
|
|
76
|
+
|
|
77
|
+
<div class="container">
|
|
78
|
+
<h2>Registration Form</h2>
|
|
79
|
+
|
|
80
|
+
<form id="registrationForm">
|
|
81
|
+
<label for="firstName">First Name</label>
|
|
82
|
+
<input type="text" id="firstName"
|
|
83
|
+
placeholder="Enter first name" required>
|
|
84
|
+
|
|
85
|
+
<label for="password">Password</label>
|
|
86
|
+
<input type="password" id="password"
|
|
87
|
+
placeholder="Enter password" required>
|
|
88
|
+
|
|
89
|
+
<label for="email">Email ID</label>
|
|
90
|
+
<input type="text" id="email"
|
|
91
|
+
placeholder="Enter email address" required>
|
|
92
|
+
|
|
93
|
+
<label for="phone">Phone Number</label>
|
|
94
|
+
<input type="tel" id="phone"
|
|
95
|
+
placeholder="Enter phone number" required>
|
|
96
|
+
|
|
97
|
+
<button type="submit">Register</button>
|
|
98
|
+
|
|
99
|
+
<p id="message" role="status" aria-live="polite"></p>
|
|
100
|
+
</form>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<script>
|
|
104
|
+
document.getElementById("registrationForm")
|
|
105
|
+
.addEventListener("submit", function(event) {
|
|
106
|
+
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
|
|
109
|
+
// Get input values
|
|
110
|
+
let name = document.getElementById("firstName").value.trim();
|
|
111
|
+
let password = document.getElementById("password").value;
|
|
112
|
+
let email = document.getElementById("email").value.trim();
|
|
113
|
+
let phone = document.getElementById("phone").value.trim();
|
|
114
|
+
let message = document.getElementById("message");
|
|
115
|
+
|
|
116
|
+
// A) First name: alphabets only, less than 6 characters
|
|
117
|
+
let namePattern = /^[A-Za-z]{1,5}$/;
|
|
118
|
+
|
|
119
|
+
if (!namePattern.test(name)) {
|
|
120
|
+
message.style.color = "red";
|
|
121
|
+
message.textContent =
|
|
122
|
+
"Name must contain only alphabets and be less than 6 characters.";
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// B) Password: minimum 6 characters
|
|
127
|
+
if (password.length < 6) {
|
|
128
|
+
message.style.color = "red";
|
|
129
|
+
message.textContent =
|
|
130
|
+
"Password must contain at least 6 characters.";
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// C) Email: standard email format
|
|
135
|
+
let emailPattern =
|
|
136
|
+
/^[A-Za-z0-9]+([._%+-][A-Za-z0-9]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
|
|
137
|
+
|
|
138
|
+
if (!emailPattern.test(email)) {
|
|
139
|
+
message.style.color = "red";
|
|
140
|
+
message.textContent =
|
|
141
|
+
"Please enter a valid email address.";
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// D) Phone: minimum 10 digits
|
|
146
|
+
// Allows spaces, +, -, and parentheses in phone numbers.
|
|
147
|
+
let phoneDigits = phone.replace(/\D/g, "");
|
|
148
|
+
|
|
149
|
+
if (phoneDigits.length < 10 ||
|
|
150
|
+
!/^[0-9+()\s-]+$/.test(phone)) {
|
|
151
|
+
message.style.color = "red";
|
|
152
|
+
message.textContent =
|
|
153
|
+
"Phone number must contain at least 10 digits.";
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// All validations passed
|
|
158
|
+
message.style.color = "green";
|
|
159
|
+
message.textContent =
|
|
160
|
+
"Registration successful!";
|
|
161
|
+
});
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
</body>
|
|
165
|
+
</html>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Visitor Counter</title>
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
|
|
8
|
+
<?php
|
|
9
|
+
$file = "counter.txt";
|
|
10
|
+
|
|
11
|
+
if (!file_exists($file)) {
|
|
12
|
+
file_put_contents($file, '0');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
$count = (int) file_get_contents($file);
|
|
16
|
+
$count++;
|
|
17
|
+
|
|
18
|
+
file_put_contents($file, $count);
|
|
19
|
+
|
|
20
|
+
echo "No. of visitors: " . $count;
|
|
21
|
+
|
|
22
|
+
if ($count == 50) {
|
|
23
|
+
echo "Limit reached";
|
|
24
|
+
}
|
|
25
|
+
?>
|
|
26
|
+
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|