Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
Stopped the random selection for input 2 for better view
  • Loading branch information
sk66641 committed Jun 2, 2024
1 parent bde4cd6 commit 1fad91c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1 id="changingHeading" style="font-family: Arial, sans-serif; font-size: 39px;
<label for="color2"></label>
<input type="color" id="color2" />
</div>
<strong>[Choose different colors or else random color spectrum will be shown]</strong>
<strong>[Random color spectrum will be shown for the same colors]</strong>
<div>
<label for="time"
>3. Time interval
Expand Down
28 changes: 17 additions & 11 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,29 @@ document.addEventListener('DOMContentLoaded', () => {

randomizeButton.addEventListener('click', () => {
const colorInput = document.getElementById('color');
const randomNumColors = Math.floor(Math.random() * 100) + 1;
const randomNumColors = Math.floor(Math.random() * 1000) + 1;
colorInput.value = randomNumColors;

const colorInput1 = document.getElementById('color1');
const randomColor1 = "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);});
colorInput1.value = randomColor1;
// const colorInput1 = document.getElementById('color1');
// const randomColor1 = "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);});
// colorInput1.value = randomColor1;

const colorInput2 = document.getElementById('color2');
const randomColor2 = "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);});
colorInput2.value = randomColor2;
// const colorInput2 = document.getElementById('color2');
// const randomColor2 = "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);});
// colorInput2.value = randomColor2;

const timeInput = document.getElementById('time');
const randomTimeInterval = Math.floor(Math.random() * 1000) + 100;
timeInput.value = randomTimeInterval;


const unitSelect = document.getElementById('unit');
const randomUnitIndex = Math.random() < 1 ? 1 : 2;
const randomUnitIndex = Math.random() < 0.5 ? 1 : 2;
if (randomUnitIndex == 1) {
var randomTimeInterval = Math.floor(Math.random()*1000)+1;
timeInput.value = randomTimeInterval;
}
else{
var randomTimeInterval = Math.floor(Math.random()*10)+1;
timeInput.value = randomTimeInterval;
}
unitSelect.selectedIndex = randomUnitIndex;

const viewSelect = document.getElementById('view');
Expand Down

0 comments on commit 1fad91c

Please sign in to comment.