-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
154 lines (136 loc) · 5.66 KB
/
index.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>محاسبه وام</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f3f4f6;
}
.calculator {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
.calculator h1 {
font-size: 1.5rem;
margin-bottom: 20px;
text-align: center;
}
.calculator label {
display: block;
margin-bottom: 8px;
font-weight: bold;
}
.calculator input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
.calculator button {
width: 100%;
padding: 10px;
background: #007bff;
color: white;
border: none;
border-radius: 5px;
font-size: 1rem;
cursor: pointer;
}
.calculator button:hover {
background: #0056b3;
}
.result {
margin-top: 20px;
padding: 10px;
background: #e6ffed;
border: 1px solid #34d399;
border-radius: 5px;
text-align: center;
}
</style>
</head>
<body>
<div class="calculator" id="mainMenu">
<h1>انتخاب نوع وام</h1>
<button onclick="showCalculator('bazari')">بازاری</button>
<button onclick="showCalculator('banki')">بانکی</button>
</div>
<div class="calculator" id="bazariCalculator" style="display: none;">
<h1>محاسبه وام بازاری</h1>
<label for="amount">مقدار مبلغ درخواستی (ریال):</label>
<input type="text" id="amount" placeholder="Enter loan amount" oninput="formatInput(this)">
<label for="installments">چند ماهه:</label>
<input type="number" id="installments" placeholder="Enter number of installments">
<label for="interestRate">نرخ سود (%) :</label>
<input type="number" id="interestRate" placeholder="Enter interest rate">
<button onclick="calculateBazariInstallment()">محاسبه اقساط</button>
<div id="bazariResult" class="result" style="display: none;"></div>
</div>
<div class="calculator" id="bankiCalculator" style="display: none;">
<h1>محاسبه وام بانکی</h1>
<label for="bankAmount">مقدار مبلغ درخواستی (ریال):</label>
<input type="text" id="bankAmount" placeholder="Enter loan amount" oninput="formatInput(this)">
<label for="totalMonths">تعداد ماه های کل اقساط:</label>
<input type="number" id="totalMonths" placeholder="Enter total months">
<label for="checkPeriod">چند ماه چند ماه میخواهید چک بدهید:</label>
<input type="number" id="checkPeriod" placeholder="Enter check period">
<label for="bankInterestRate">نرخ سود (%) :</label>
<input type="number" id="bankInterestRate" placeholder="Enter interest rate">
<button onclick="calculateBankiInstallment()">محاسبه اقساط</button>
<div id="bankiResult" class="result" style="display: none;"></div>
</div>
<script>
function formatNumber(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function formatInput(input) {
let value = input.value.replace(/,/g, '');
value = formatNumber(value);
input.value = value;
}
function showCalculator(type) {
document.getElementById('mainMenu').style.display = 'none';
document.getElementById('bazariCalculator').style.display = (type === 'bazari') ? 'block' : 'none';
document.getElementById('bankiCalculator').style.display = (type === 'banki') ? 'block' : 'none';
}
function calculateBazariInstallment() {
const amount = parseFloat(document.getElementById('amount').value.replace(/,/g, '')) || 0;
const installments = parseInt(document.getElementById('installments').value) || 1;
const interestRate = parseFloat(document.getElementById('interestRate').value) || 6.5;
const interest = (amount * interestRate * ((installments / 2) + 0.5)) / 100;
const totalPayable = amount + interest;
const monthlyInstallment = totalPayable / installments;
const resultDiv = document.getElementById('bazariResult');
resultDiv.style.display = 'block';
resultDiv.innerHTML = `<p>مبلغ هر قسط: <strong>${formatNumber(monthlyInstallment.toFixed(2))}</strong> ریال</p>`;
}
function calculateBankiInstallment() {
const amount = parseFloat(document.getElementById('bankAmount').value.replace(/,/g, '')) || 0;
const totalMonths = parseInt(document.getElementById('totalMonths').value) || 1;
const checkPeriod = parseInt(document.getElementById('checkPeriod').value) || 1;
const interestRate = parseFloat(document.getElementById('bankInterestRate').value) || 6.5;
const interest = (amount * interestRate * (totalMonths + checkPeriod)) / 2400;
const totalPayable = amount + interest;
const installmentCount = totalMonths / checkPeriod;
const installmentAmount = totalPayable / installmentCount;
const resultDiv = document.getElementById('bankiResult');
resultDiv.style.display = 'block';
resultDiv.innerHTML = `<p>مبلغ هر قسط: <strong>${formatNumber(installmentAmount.toFixed(2))}</strong> ریال</p>`;
}
</script>
</body>
</html>