Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions # Code Citations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Code Citations

## License: unknown
https://github.com/lilyball/textmate-bundles/tree/1016d113200d99ea6cec3217ec193a3a42a804ac/Bundles/SSH-Config.tmbundle/Syntaxes/SSH-Config.tmLanguage

```
[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]
```


## License: GPL_3_0
https://github.com/puzzle/cryptopus/tree/f2149de2c518f07598860ae897db44739ad341af/frontend/app/components/admin/setting-multiselect-with-create.js

```
9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]
```


## License: unknown
https://github.com/balepc/ip_geolocation/tree/f3ac8d8cb7eb302f625f65e97f817985e5759431/lib/models/ip_geolocation.rb

```
= /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4]
```


## License: unknown
https://github.com/kof/sharedjs/tree/3599e808ad4afca303756fd90023cf8d5fe254ec/src/validate.methods.js

```
01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
```


## License: unknown
https://github.com/ThanhTrungGVC/Magento/tree/a4ece2d52844ed6c457980af8a61c005f69088fc/lib/web/mage/validation.js

```
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][
```

61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,64 @@ For the Badge:
[![forthebadge](https://forthebadge.com/images/badges/uses-html.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/uses-js.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/uses-css.svg)](https://forthebadge.com)

# AI-Powered Online Toolbox

This toolbox provides various tools enhanced by Artificial Intelligence for networking, IP-related tasks, and password management.

## Tools

### What's My IP Address
Displays your current IP address.

- **Usage:** Click the "Check" button to fetch and display your IP address.

### IP Lookup / Geolocation
Looks up the geolocation of a given IP address.

- **Usage:** Enter an IP address in the input field and click the "Lookup" button to fetch and display the geolocation information.

### Internet Speed Test
Tests your internet speed.

- **Usage:** Click the "Run Test" button to measure and display your download speed.

### Ping
Pings a given URL to measure the response time.

- **Usage:** Enter a URL in the input field and click the "Ping" button to measure and display the ping time.

### Password Generator
Generates a random secure password.

- **Usage:** Click the "Generate" button to create and display a random password.

### Password Strength Checker
Checks the strength of a given password.

- **Usage:** Enter a password in the input field and click the "Check" button to evaluate and display the password strength.

### Password Breach Checker
Checks if a given password has been breached using the HaveIBeenPwned API.

- **Usage:** Enter a password in the input field and click the "Check" button to check and display if the password has been breached.

## Debug Logging

A new debug logging function `logDebug` has been added to log debug messages to the console.

- **Usage:** Import the `logDebug` function from `utils.js` and call it with a message to log.

```javascript
import { logDebug } from './utils.js';
logDebug('This is a debug message');
```

## Error Handling
If an error occurs during any operation, an error message will be displayed.

## Styling
The tools are styled using the `styles.css` file.

## Scripts
The functionality of the tools is implemented in the `main.js` file.
4 changes: 4 additions & 0 deletions api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Ensure that 'serverApi' is not declared multiple times
const serverApi = {
// Object implementation
};
3 changes: 3 additions & 0 deletions block-css-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const BLOCK_CSS_VALUE = {
// Object implementation
};
4 changes: 4 additions & 0 deletions block-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Ensure that 'BLOCK_TYPES' is not declared multiple times
const BLOCK_TYPES = {
// Object implementation
};
4 changes: 4 additions & 0 deletions browser-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Ensure that 'BrowserInfo' is not declared multiple times
const BrowserInfo = {
// Object implementation
};
3 changes: 3 additions & 0 deletions debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const debug = (message) => {
console.log(message);
};
1 change: 1 addition & 0 deletions dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const Dialog = {}; // ...existing code...
10 changes: 10 additions & 0 deletions getMyIP.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
async function getMyIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
console.error('Error fetching IP:', error);
throw error;
}
}
4 changes: 4 additions & 0 deletions helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Ensure that 'guidSeed' is not declared multiple times
const guidSeed = {
// Object implementation
};
3 changes: 3 additions & 0 deletions icon-badge-periods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const ICON_BADGE_PERIODS = {
// Object implementation
};
62 changes: 57 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI-Powered Toolbox</title>
<link rel="stylesheet" href="styles.css">
<script src="getMyIP.js"></script>
<script src="script.js"></script>
</head>
<body>
<header>
Expand All @@ -15,32 +17,82 @@ <h1>AI-Powered Online Toolbox</h1>
<section id="tools">
<div>
<h2>What's My IP Address</h2>
<button onclick="getMyIP()">Check</button>
<button id="lookup-ip-btn" onclick="fetchIP()">Check</button>
<p id="my-ip">Your IP will appear here.</p>
<p id="ipDisplay"></p>
</div>
<div>
<h2>IP Lookup / Geolocation</h2>
<input type="text" id="ip-input" placeholder="Enter an IP address">
<button onclick="lookupIP()">Lookup</button>
<button id="lookup-ip-btn" onclick="lookupIP()">Lookup</button>
<p id="ip-info">Results will appear here.</p>
</div>
<div>
<h2>Internet Speed Test</h2>
<button onclick="runSpeedTest()">Run Test</button>
<button id="speed-test-btn">Run Test</button>
<p id="speed-results">Speed test results will appear here.</p>
</div>
<div>
<h2>Ping</h2>
<input type="text" id="ping-url" placeholder="Enter URL">
<button onclick="ping()">Ping</button>
<button id="ping-btn">Ping</button>
<p id="ping-results">Ping results will appear here.</p>
</div>
<div>
<h2>Password Generator</h2>
<button id="generate-password-btn">Generate</button>
<p id="generated-password">Generated password will appear here.</p>
</div>
<div>
<h2>Password Strength Checker</h2>
<input type="text" id="password-input" placeholder="Enter password">
<button id="check-password-strength-btn">Check</button>
<p id="password-strength">Strength will appear here.</p>
</div>
<div>
<h2>Password Breach Checker</h2>
<input type="password" id="breach-input" placeholder="Enter password">
<button id="check-password-breach-btn">Check</button>
<p id="password-breach">Breach status will appear here.</p>
</div>
</section>
<div id="error-message" style="display:none;"></div>
</main>
<footer>
<p>&copy; 2025 AI Toolbox</p>
</footer>
<script src="scripts.js"></script>
<script src="main.js"></script>
<script src="script.js"></script>
<script>
async function fetchIP() {
try {
const ip = await getMyIP();
document.getElementById('ipDisplay').innerText = `Your IP: ${ip}`;
} catch (error) {
document.getElementById('ipDisplay').innerText = 'Error fetching IP.';
}
}

async function getMyIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
throw new Error('Unable to fetch IP address');
}
}

async function lookupIP() {
const ip = document.getElementById('ip-input').value;
try {
const response = await fetch(`https://ipapi.co/${ip}/json/`);
const data = await response.json();
document.getElementById('ip-info').innerText = JSON.stringify(data, null, 2);
} catch (error) {
document.getElementById('ip-info').innerText = 'Error fetching IP information.';
}
}
</script>
</body>
</html>
43 changes: 43 additions & 0 deletions ip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { showError, showLoading, hideLoading, validateIP } from './utils.js';

export async function getMyIP() {
try {
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
document.getElementById('my-ip').textContent = `Your IP: ${data.ip}`;
} catch (error) {
document.getElementById('my-ip').textContent = 'Error fetching IP.';
}
}

export async function lookupIP() {
const ip = document.getElementById('ip-input').value;
if (!validateIP(ip)) {
showError('Please enter a valid IP address.');
return;
}
try {
showLoading();
const aiPrediction = await getAIIPPrediction(ip); // AI-based prediction
const response = await fetch(`https://ip-api.com/json/${ip}`);
const data = await response.json();
if (data.status === 'success') {
document.getElementById('ip-info').textContent =
`Location: ${data.city}, ${data.region}, ${data.country} (ISP: ${data.isp}) - AI Prediction: ${aiPrediction}`;
} else {
showError('Invalid IP address.');
}
} catch (error) {
showError('Error fetching data.');
console.error(error);
} finally {
hideLoading();
}
}

async function getAIIPPrediction(ip) {
const aiApi = 'https://your-ai-api.com/predict'; // Your AI API endpoint
const response = await fetch(`${aiApi}?ip=${ip}`);
const data = await response.json();
return data.prediction; // AI's predicted location or data
}
18 changes: 18 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getMyIP, lookupIP } from './ip.js';
import { runSpeedTest } from './speedTest.js';
import { ping } from './ping.js';
import { generatePassword, checkPasswordStrength, checkPasswordBreach } from './password.js';
import { showError, showLoading, hideLoading, validateIP, validateURL } from './utils.js';

Check warning on line 5 in main.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused ``` import { showError, showLoading, hideLoading, validateIP, validateURL } from './utils.js'; ```

document.addEventListener('DOMContentLoaded', () => {
// Fetch and display the user's IP
getMyIP();

Check notice on line 9 in main.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Result of method call returning a promise is ignored

Promise returned from getMyIP is ignored

// Attach event listeners to buttons
document.getElementById('lookup-ip-btn').addEventListener('click', lookupIP);
document.getElementById('speed-test-btn').addEventListener('click', runSpeedTest);

Check notice on line 13 in main.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicated code fragment

Duplicated code
document.getElementById('ping-btn').addEventListener('click', ping);
document.getElementById('generate-password-btn').addEventListener('click', generatePassword);
document.getElementById('check-password-strength-btn').addEventListener('click', checkPasswordStrength);
document.getElementById('check-password-breach-btn').addEventListener('click', checkPasswordBreach);
});
4 changes: 4 additions & 0 deletions message-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Ensure that 'MESSAGE_TYPES' is not declared multiple times
const MESSAGE_TYPES = {
// Object implementation
};
32 changes: 32 additions & 0 deletions password.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { showError } from './utils.js';

Check warning on line 1 in password.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import { showError } from './utils.js';

export function generatePassword() {
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";
let password = "";
for (let i = 0; i < 12; i++) {
password += charset.charAt(Math.floor(Math.random() * charset.length));
}
document.getElementById('generated-password').textContent = password;
}

export function checkPasswordStrength() {
const password = document.getElementById('password-input').value;
const strength = password.length > 12 ? "Strong" : password.length > 8 ? "Moderate" : "Weak";
document.getElementById('password-strength').textContent = `Strength: ${strength}`;
}

export async function checkPasswordBreach() {
const password = document.getElementById('breach-input').value;
const hash = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(password));
const hexHash = Array.from(new Uint8Array(hash)).map(b => b.toString(16).padStart(2, '0')).join('').toUpperCase();
const prefix = hexHash.slice(0, 5);
const suffix = hexHash.slice(5);
try {
const response = await fetch(`https://api.pwnedpasswords.com/range/${prefix}`);
const text = await response.text();
const breached = text.includes(suffix) ? "Password found in breaches!" : "Safe!";

Check warning on line 27 in password.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Redundant local variable

Local variable breached is redundant
document.getElementById('password-breach').textContent = breached;
} catch (error) {
document.getElementById('password-breach').textContent = 'Error checking breach status.';
}
}
18 changes: 18 additions & 0 deletions ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { showError, validateURL } from './utils.js';

export async function ping() {
const url = document.getElementById('ping-url').value;
if (!validateURL(url)) {
showError('Please enter a valid URL.');
return;
}
const start = Date.now();
try {
await fetch(url, { method: 'HEAD' });
const end = Date.now();
document.getElementById('ping-results').textContent = `Ping: ${end - start} ms`;
} catch (error) {
showError('Ping failed.');
console.error(error);
}
}
16 changes: 16 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function getMyIP() {
fetch('https://api.ipify.org?format=json')
.then(response => response.json())
.then(data => {
alert(`Your IP address is ${data.ip}`);
})
.catch(error => {
console.error('Error fetching IP:', error);
});
}

function lookupIP() {
// Function implementation
console.log("IP lookup function called");
// ...additional code...
}
Loading