diff --git a/# Code Citations.md b/# Code Citations.md new file mode 100644 index 0000000..41dfef2 --- /dev/null +++ b/# Code Citations.md @@ -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][ +``` + diff --git a/README.md b/README.md index bc1f0c6..7d7e21f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/api.js b/api.js new file mode 100644 index 0000000..fc558cc --- /dev/null +++ b/api.js @@ -0,0 +1,4 @@ +// Ensure that 'serverApi' is not declared multiple times +const serverApi = { + // Object implementation +}; diff --git a/block-css-value.js b/block-css-value.js new file mode 100644 index 0000000..8b9df86 --- /dev/null +++ b/block-css-value.js @@ -0,0 +1,3 @@ +const BLOCK_CSS_VALUE = { + // Object implementation +}; diff --git a/block-types.js b/block-types.js new file mode 100644 index 0000000..a63fac3 --- /dev/null +++ b/block-types.js @@ -0,0 +1,4 @@ +// Ensure that 'BLOCK_TYPES' is not declared multiple times +const BLOCK_TYPES = { + // Object implementation +}; diff --git a/browser-info.js b/browser-info.js new file mode 100644 index 0000000..c62da3e --- /dev/null +++ b/browser-info.js @@ -0,0 +1,4 @@ +// Ensure that 'BrowserInfo' is not declared multiple times +const BrowserInfo = { + // Object implementation +}; diff --git a/debug.js b/debug.js new file mode 100644 index 0000000..fadbfac --- /dev/null +++ b/debug.js @@ -0,0 +1,3 @@ +const debug = (message) => { + console.log(message); +}; diff --git a/dialog.js b/dialog.js new file mode 100644 index 0000000..954536b --- /dev/null +++ b/dialog.js @@ -0,0 +1 @@ +const Dialog = {}; // ...existing code... diff --git a/getMyIP.js b/getMyIP.js new file mode 100644 index 0000000..0abb636 --- /dev/null +++ b/getMyIP.js @@ -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; + } +} diff --git a/helpers.js b/helpers.js new file mode 100644 index 0000000..e44f9ae --- /dev/null +++ b/helpers.js @@ -0,0 +1,4 @@ +// Ensure that 'guidSeed' is not declared multiple times +const guidSeed = { + // Object implementation +}; diff --git a/icon-badge-periods.js b/icon-badge-periods.js new file mode 100644 index 0000000..8f1f9a0 --- /dev/null +++ b/icon-badge-periods.js @@ -0,0 +1,3 @@ +const ICON_BADGE_PERIODS = { + // Object implementation +}; diff --git a/index.html b/index.html index d1f4ad7..d272019 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,8 @@ AI-Powered Toolbox + +
@@ -15,32 +17,82 @@

AI-Powered Online Toolbox

What's My IP Address

- +

Your IP will appear here.

+

IP Lookup / Geolocation

- +

Results will appear here.

Internet Speed Test

- +

Speed test results will appear here.

Ping

- +

Ping results will appear here.

+
+

Password Generator

+ +

Generated password will appear here.

+
+
+

Password Strength Checker

+ + +

Strength will appear here.

+
+
+

Password Breach Checker

+ + +

Breach status will appear here.

+
- + + + diff --git a/ip.js b/ip.js new file mode 100644 index 0000000..d912f55 --- /dev/null +++ b/ip.js @@ -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 +} diff --git a/main.js b/main.js new file mode 100644 index 0000000..743b7a7 --- /dev/null +++ b/main.js @@ -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'; + +document.addEventListener('DOMContentLoaded', () => { + // Fetch and display the user's IP + getMyIP(); + + // Attach event listeners to buttons + document.getElementById('lookup-ip-btn').addEventListener('click', lookupIP); + document.getElementById('speed-test-btn').addEventListener('click', runSpeedTest); + 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); +}); diff --git a/message-types.js b/message-types.js new file mode 100644 index 0000000..7834002 --- /dev/null +++ b/message-types.js @@ -0,0 +1,4 @@ +// Ensure that 'MESSAGE_TYPES' is not declared multiple times +const MESSAGE_TYPES = { + // Object implementation +}; diff --git a/password.js b/password.js new file mode 100644 index 0000000..aa3f762 --- /dev/null +++ b/password.js @@ -0,0 +1,32 @@ +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!"; + document.getElementById('password-breach').textContent = breached; + } catch (error) { + document.getElementById('password-breach').textContent = 'Error checking breach status.'; + } +} diff --git a/ping.js b/ping.js new file mode 100644 index 0000000..493b2ef --- /dev/null +++ b/ping.js @@ -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); + } +} diff --git a/script.js b/script.js new file mode 100644 index 0000000..3b1d1f2 --- /dev/null +++ b/script.js @@ -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... +} diff --git a/scripts.js b/scripts.js index f08df1e..ff40997 100644 --- a/scripts.js +++ b/scripts.js @@ -1,115 +1,22 @@ +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, logDebug } from './utils.js'; + document.addEventListener('DOMContentLoaded', () => { + logDebug('Document loaded'); // Fetch and display the user's IP - 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) { - showError('Error fetching IP.'); - console.error(error); - } - } - - // IP Lookup / Geolocation with AI integration - 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(); - } - } - - // AI-based IP Prediction (AI model can be integrated here) - 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 - } - - // Internet Speed Test with AI optimization - function runSpeedTest() { - const start = Date.now(); - const imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/a/a7/Logo_of_the_United_States_Department_of_Veterans_Affairs.png'; // Example file URL - fetch(imageUrl) - .then(response => response.blob()) - .then(blob => { - const end = Date.now(); - const timeTaken = (end - start) / 1000; // time in seconds - const speed = (5000000 / timeTaken / 1024).toFixed(2); // speed in KB/s - document.getElementById('speed-results').textContent = `Download speed: ${speed} KB/s`; - }) - .catch(error => { - showError('Speed test failed.'); - console.error(error); - }); - } - - // AI-powered Ping - 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); - } - } - - // Show error message - function showError(message) { - const errorMessage = document.getElementById('error-message'); - errorMessage.textContent = message; - errorMessage.style.display = 'block'; - setTimeout(() => { - errorMessage.style.display = 'none'; - }, 5000); - } - - // Show loading indicator - function showLoading() { - document.getElementById('loading-indicator').style.display = 'block'; - } - - // Hide loading indicator - function hideLoading() { - document.getElementById('loading-indicator').style.display = 'none'; - } - - // Validate IP address format - function validateIP(ip) { - const regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; - return regex.test(ip); - } - - // Validate URL format - function validateURL(url) { - const regex = /^(https?:\/\/)?([a-z0-9]+[.-_])*[a-z0-9]+\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/i; - return regex.test(url); - } + getMyIP(); + + // Attach event listeners to buttons + document.getElementById('lookup-ip-btn').addEventListener('click', () => { + logDebug('Lookup IP button clicked'); + lookupIP(); + }); + document.getElementById('speed-test-btn').addEventListener('click', runSpeedTest); + 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); }); diff --git a/speedTest.js b/speedTest.js new file mode 100644 index 0000000..376a418 --- /dev/null +++ b/speedTest.js @@ -0,0 +1,18 @@ +import { showError } from './utils.js'; + +export function runSpeedTest() { + const start = Date.now(); + const imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/a/a7/Logo_of_the_United_States_Department_of_Veterans_Affairs.png'; // Example file URL + fetch(imageUrl) + .then(response => response.blob()) + .then(blob => { + const end = Date.now(); + const timeTaken = (end - start) / 1000; // time in seconds + const speed = (5000000 / timeTaken / 1024).toFixed(2); // speed in KB/s + document.getElementById('speed-results').textContent = `Download speed: ${speed} KB/s`; + }) + .catch(error => { + showError('Speed test failed.'); + console.error(error); + }); +} diff --git a/storage-service.js b/storage-service.js new file mode 100644 index 0000000..d945628 --- /dev/null +++ b/storage-service.js @@ -0,0 +1,4 @@ +// Ensure that 'storageService' is not declared multiple times +const storageService = { + // Object implementation +}; diff --git a/styles.css b/styles.css index 2bcbd0e..870a25a 100644 --- a/styles.css +++ b/styles.css @@ -3,6 +3,8 @@ body { margin: 0; padding: 0; line-height: 1.6; + background-color: #f4f4f4; + text-align: center; } header { @@ -17,11 +19,48 @@ main { } section#tools div { - margin: 1rem 0; + margin: 1rem auto; padding: 1rem; + width: 80%; border: 1px solid #ddd; border-radius: 5px; - background: #f9f9f9; + background: #fff; + box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1); +} + +#tools div { + margin-bottom: 20px; +} + +#tools h2 { + font-size: 1.5em; + margin-bottom: 10px; +} + +#tools button { + padding: 10px 20px; + font-size: 1em; + cursor: pointer; +} + +#tools input { + padding: 10px; + font-size: 1em; + margin-right: 10px; +} + +#tools p { + margin-top: 10px; + font-size: 1em; + color: #333; +} + +input { + padding: 0.5rem; + margin-top: 0.5rem; + border: 1px solid #ddd; + border-radius: 3px; + width: 80%; } button { diff --git a/utils.js b/utils.js new file mode 100644 index 0000000..2c0582c --- /dev/null +++ b/utils.js @@ -0,0 +1,30 @@ +export function showError(message) { + const errorMessage = document.getElementById('error-message'); + errorMessage.textContent = message; + errorMessage.style.display = 'block'; + setTimeout(() => { + errorMessage.style.display = 'none'; + }, 5000); +} + +export function showLoading() { + document.getElementById('loading-indicator').style.display = 'block'; +} + +export function hideLoading() { + document.getElementById('loading-indicator').style.display = 'none'; +} + +export function validateIP(ip) { + const regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; + return regex.test(ip); +} + +export function validateURL(url) { + const regex = /^(https?:\/\/)?([a-z0-9]+[.\-_])*[a-z0-9]+\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/i; + return regex.test(url); +} + +export function logDebug(message) { + console.log(`DEBUG: ${message}`); +}