-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
239 lines (226 loc) · 10.1 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="طلا، محاسبه قیمت طلا، محاسبه قیمت آنلاین طلا، ماشین حساب طلا">
<meta name="keywords" content="طلا، محاسبه قیمت طلا، محاسبه قیمت آنلاین طلا، ماشین حساب طلا">
<meta name="author" content="https://github.com/IAliReza">
<meta name="generator" content="0.2">
<title>ماشین حساب طلا</title>
<link rel="stylesheet" href="assets/css/bootstrap.rtl.min.css"/>
<link rel="stylesheet" href="assets/css/custom.css"/>
<link rel="stylesheet" href="assets/css/font-face.css"/>
<link rel="icon" sizes="32x32" type="image/png" href="assets/img/32.png">
<link rel="manifest" href="manifest.webmanifest">
<meta name="theme-color" content="#cdb398">
</head>
<body class="bg-light">
<div class="container">
<header class="py-3 mb-3 border-bottom">
<div class="container-fluid d-grid gap-3 align-items-center" style="grid-template-columns: 1fr 2fr;">
<div class="dropdown">
<a href="#"
class="d-flex align-items-center col-lg-4 mb-2 mb-lg-0 link-body-emphasis text-decoration-none dropdown-toggle"
data-bs-toggle="dropdown" aria-expanded="false">
منو
</a>
<ul class="dropdown-menu text-small shadow" style="">
<li>
<a class="dropdown-item" href="index.html">خانه</a>
</li>
<li>
<a class="dropdown-item" href="mz.html">مظنه</a>
</li>
<li>
<a class="dropdown-item" href="oz.html">اونس</a>
</li>
<li>
<a class="dropdown-item" href="bubble.html">حباب</a>
</li>
<li>
<a class="dropdown-item" href="https://AliRezaMohammadiDoost.Ir" target="_blank">تماسبا ما</a>
</li>
<li>
<a class="dropdown-item" href="https://github.com/ialireza/gold-calculator" target="_blank">
منبع و توضیحات
</a>
</li>
</ul>
</div>
</div>
</header>
<div class="row">
<div class="col-lg-6 mt-5">
<h5>جزئیات کالا</h5>
<div class="col-12">
<label for="price" class="form-label">
نرخ طلا
<i class="bi bi-arrow-down"></i>
</label>
<div class="input-group mb-3">
<input type="text" class="form-control form_input" id="price" dir="ltr" required
onkeyup="priceSeparator(this.value,this);"
onfocus="priceSeparator(this.value,this);">
<span class="input-group-text text-bg-warning">تومان</span>
</div>
<div class="invalid-feedback">
Valid first name is required.
</div>
</div>
<div class="col-12">
<label for="constructionFee" class="form-label">
اجرت ساخت
<i class="bi bi-arrow-down"></i>
</label>
<div class="input-group mb-3">
<input type="text" class="form-control form_input" id="constructionFee" dir="ltr" required>
<span class="input-group-text text-bg-warning">تومان یا درصد</span>
</div>
<div class="invalid-feedback">
Valid last name is required.
</div>
</div>
<div class="col-12">
<label for="constructionFeeType" class="form-label">
اجرت ساخت (تومان یا درصد)
<i class="bi bi-arrow-down"></i>
</label>
<div class="input-group mb-3">
<select name="constructionFeeType" class="form-control form_input" id="constructionFeeType">
<option value="2">درصد</option>
<option value="1">مبلغ ثابت تومان</option>
</select>
<span class="input-group-text text-bg-warning">نوع اجرت</span>
</div>
<div class="invalid-feedback">
Valid last name is required.
</div>
</div>
<div class="col-12">
<label for="taxation" class="form-label">
ارزش افزوده
<i class="bi bi-arrow-down"></i>
</label>
<div class="input-group mb-3">
<input type="text" class="form-control form_input" id="taxation"
placeholder="پیشفرض ۹ درصد میباشد."
value="9" dir="ltr" required>
<span class="input-group-text text-bg-warning">درصد</span>
</div>
<div class="invalid-feedback">
Valid first name is required.
</div>
</div>
<div class="col-12">
<label for="profitOfTheSeller" class="form-label">
سود فروشنده(درصد)
<i class="bi bi-arrow-down"></i>
</label>
<div class="input-group mb-3">
<input type="text" class="form-control form_input" id="profitOfTheSeller"
dir="ltr" placeholder="پیشفرض ۷ درصد میباشد." value="7" required>
<span class="input-group-text text-bg-warning">سود فروشنده</span>
</div>
<div class="invalid-feedback">
Valid first name is required.
</div>
</div>
<div class="col-12">
<label for="weight" class="form-label">
وزن
<i class="bi bi-arrow-down"></i>
</label>
<div class="input-group mb-3">
<input type="text" class="form-control form_input" id="weight" dir="ltr" required>
<span class="input-group-text text-bg-warning">گرم</span>
</div>
<div class="invalid-feedback">
Valid last name is required.
</div>
</div>
</div>
<div class="col-lg-6 mt-5">
<h5>جزئیات سفارش</h5>
<div class="table-responsive text-center">
<table class="table table-bordered">
<thead>
<tr>
<th style="width: 35%">نوع</th>
<th>مبلغ</th>
</tr>
</thead>
<tbody>
<tr>
<td>اجرت ساخت</td>
<td id="cf-text"></td>
</tr>
<tr>
<td>سود فروشنده</td>
<td id="ps-text"></td>
</tr>
<tr>
<td>مالیات</td>
<td id="tx-text"></td>
</tr>
<tr>
<td>جمع کل</td>
<td id="result-text"></td>
</tr>
</tbody>
</table>
</div>
<button class="w-100 btn btn-lg btn-custom" type="submit" id="submit">محاسبه قیمت</button>
</div>
</div>
</div>
<script src="assets/js/jquery-3.6.0.min.js"></script>
<script src="assets/js/bootstrap.bundle.min.js"></script>
<script>
$(function () {
$('#submit').click(function () {
const price = parseInt($('#price').val().replaceAll(',', ''));
const taxation = parseInt($('#taxation').val());
let constructionFee = parseFloat($('#constructionFee').val());
const constructionFeeType = parseInt($('#constructionFeeType').val());
const weight = parseFloat($('#weight').val());
if (constructionFeeType == 2) {
constructionFee = ((price * constructionFee) / 100);
}
let profitOfTheSeller = parseFloat($('#profitOfTheSeller').val());
profitOfTheSeller = ((price + constructionFee) * profitOfTheSeller) / 100;
separateNum(Math.floor(constructionFee * weight), '#cf-text');
separateNum(Math.floor(profitOfTheSeller * weight), '#ps-text');
separateNum(Math.floor((((constructionFee + profitOfTheSeller) * taxation) / 100) * weight), '#tx-text');
const result = ((((((constructionFee + profitOfTheSeller) * taxation) / 100) + (constructionFee + profitOfTheSeller)) + price) * weight);
separateNum(Math.floor(result), '#result-text');
});
});
function separateNum(value, target) {
let nStr = value + '';
nStr = nStr.replace(/\,/g, "");
let x = nStr.split('.');
let x1 = x[0];
let x2 = x.length > 1 ? '.' + x[1] : '';
let rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
if (x1 + x2 != 'NaN') {
$(target).html(x1 + x2);
// $('#result').html(x1 + x2);
}
}
function priceSeparator(price, input) {
const regex = /(\d+)(\d{3})/;
price = price.replace(/\,/g, '');
price = price.split('.')[0];
while (regex.test(price)) {
price = price.replace(regex, '$1' + ',' + '$2');
}
input.value = price;
}
</script>
<script src="sw.js"></script>
</body>
</html>