Skip to content

Commit

Permalink
added params
Browse files Browse the repository at this point in the history
  • Loading branch information
greybax authored Dec 13, 2023
1 parent ccb20ed commit fd80531
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
14 changes: 13 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
</head>
<body>
<iframe id="msBingFrame" width="100%" height="100%"> </iframe>
<script type="module" src="src/index.ts"></script>
<!-- Input elements for parameters -->
<label for="minDelay">Minimum Delay (ms): </label>
<input type="number" id="minDelay" value="10000">

<label for="maxDelay">Maximum Delay (ms): </label>
<input type="number" id="maxDelay" value="25000">

<label for="searchLimit">Search Limit: </label>
<input type="number" id="searchLimit" value="35">

<button onclick="startSearch()">Start Search</button>

<a href="https://www.buymeacoffee.com/IB2jYiCDf"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=☕&slug=IB2jYiCDf&button_colour=5F7FFF&font_colour=ffffff&font_family=Bree&outline_colour=000000&coffee_colour=FFDD00" /></a>

<script type="module" src="src/index.ts"></script>
</body>
</html>
18 changes: 11 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import randomWords from 'random-words';

const main = () => {
const startSearch = () => {

Check failure on line 3 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

'startSearch' is declared but its value is never read.
const iframe = document.getElementById('msBingFrame') as HTMLIFrameElement;
const minDelayInput = document.getElementById('minDelay') as HTMLInputElement;
const maxDelayInput = document.getElementById('maxDelay') as HTMLInputElement;
const searchLimitInput = document.getElementById('searchLimit') as HTMLInputElement;

let counter = 0;
let intervalId: number;

const getRandomDelay = () => {
// Generate a random delay between 10,000 and 25,000 milliseconds
return Math.floor(Math.random() * (25000 - 10000 + 1)) + 10000;
// Generate a random delay between user-defined minimum and maximum
const minDelay = parseInt(minDelayInput.value, 10);
const maxDelay = parseInt(maxDelayInput.value, 10);
return Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
}

const randomText = () => {
Expand All @@ -29,7 +35,7 @@ const main = () => {
counter++;
console.log('counter', counter);

if (counter === 35) {
if (counter >= parseInt(searchLimitInput.value, 10)) {
clearInterval(intervalId);
} else {
// Schedule the next search with a random delay
Expand All @@ -41,6 +47,4 @@ const main = () => {
// Start the initial search
const initialDelay = getRandomDelay();
setTimeout(func, initialDelay);
}

main();
};

0 comments on commit fd80531

Please sign in to comment.