Skip to content

Commit

Permalink
remove unlimited option and switch output count to range input
Browse files Browse the repository at this point in the history
  • Loading branch information
seramo committed Sep 20, 2024
1 parent 8456f71 commit ca9e4ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
14 changes: 7 additions & 7 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ function toggleInputFields() {
}
}

function updateOutputCountValue() {
const rangeValue = document.getElementById('outputCount').value;
document.getElementById('outputCountValue').textContent = rangeValue;
}

function isValidCIDR(cidr) {
return /^(\d{1,3}\.){3}\d{1,3}\/\d{1,2}$/.test(cidr) || /^[0-9a-fA-F:]+\/\d{1,3}$/.test(cidr);
}
Expand Down Expand Up @@ -145,17 +150,12 @@ function modifyConfigsFromCIDR() {
const [ip, range] = ipaddr.parseCIDR(ipRange.trim());
const ipType = ip.kind();

if (outputCount === 'unlimited' && ipType === 'ipv6') {
showWarning('تعداد خروجی بدون محدودیت فقط برای رنج آی پی های ورژن 4 قابل استفاده است.');
return;
}

let currentIp = ip;
while (currentIp.match(ipaddr.parseCIDR(ipRange.trim())) && (outputCount === 'unlimited' || count < parseInt(outputCount))) {
while (currentIp.match(ipaddr.parseCIDR(ipRange.trim())) && count < parseInt(outputCount)) {
generatedOutput += replaceIPInConfig(inputConfig, currentIp);
count++;

if (outputCount !== 'unlimited' && count >= parseInt(outputCount)) {
if (count >= parseInt(outputCount)) {
break;
}

Expand Down
15 changes: 5 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,11 @@
<button onclick="loadIPRanges('gcore')" class="badge bg-gcore border-0 me-1">جی‌کور</button>
<button onclick="loadIPRanges('fastly')" class="badge bg-fastly border-0 me-1">فستلی</button>
<textarea id="ipRange" class="form-control" rows="4" placeholder="هر رنج آی پی در یک خط" dir="ltr"></textarea>
</div>

<label for="outputCount" class="form-label mt-3">تعداد خروجی‌ها</label>
<select id="outputCount" class="form-control">
<option value="10000">10000</option>
<option value="20000">20000</option>
<option value="30000">30000</option>
<option value="40000">40000</option>
<option value="50000">50000</option>
<option value="unlimited">بدون محدودیت</option>
</select>
<div class="col-12">
<label for="outputCount" class="form-label mt-3">تعداد خروجی‌ها: <span id="outputCountValue">5000</span></label>
<input type="range" class="form-range" min="1000" max="50000" step="1000" id="outputCount" value="5000" oninput="updateOutputCountValue()">
</div>

<div class="col-12 mt-3" id="listFields" style="display: none;">
Expand All @@ -76,6 +71,6 @@
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ipaddr.js/2.0.1/ipaddr.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/base64.min.js"></script>
<script src="assets/js/script.js?v=1.0.2"></script>
<script src="assets/js/script.js?v=1.0.3"></script>
</body>
</html>

0 comments on commit ca9e4ae

Please sign in to comment.