Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
zelosleone authored Oct 24, 2024
1 parent 5918de8 commit 78bf9a4
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ <h1>I CHING</h1>
<div class="container">
<div class="oracle-card">
<div class="question-container">
<div style="margin-top: 1rem;">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" id="unchangingOnly" style="cursor: pointer;">
<span>Show only unchanging hexagrams</span>
</label>
</div>
<textarea id="question" placeholder="Enter your question with a clear and focused mind..."></textarea>
</div>
<button onclick="castHexagram()" id="castButton">Cast Hexagram</button>
Expand Down Expand Up @@ -326,36 +332,37 @@ <h1>I CHING</h1>
'101010': { name: 'Hexagram 63: After Completion', url: 'https://www.no2do.com/hexagramme_en/787878.htm' },
'010101': { name: 'Hexagram 64: Before Completion', url: 'https://www.no2do.com/hexagramme_en/878787.htm' }
};
async function getRandomNumbers() {
// Previous getRandomNumbers function remains exactly the same
try {
const response = await fetch(
'https://www.random.org/integers/?num=6&min=6&max=9&col=1&base=10&format=plain&rnd=new',
{
method: 'GET',
headers: {
'Accept': 'text/plain'
}
}
);

if (!response.ok) {
throw new Error('Failed to get true random numbers from Random.org');
async function getRandomNumbers() {
const unchangingOnly = document.getElementById('unchangingOnly').checked;

try {
const response = await fetch(
`https://www.random.org/integers/?num=6&min=${unchangingOnly ? 7 : 6}&max=${unchangingOnly ? 8 : 9}&col=1&base=10&format=plain&rnd=new`,
{
method: 'GET',
headers: {
'Accept': 'text/plain'
}
}
);

const text = await response.text();
const numbers = text.trim().split('\n').map(n => parseInt(n));
if (!response.ok) {
throw new Error('Failed to get true random numbers from Random.org');
}

if (numbers.length !== 6) {
throw new Error('Did not receive the correct number of random numbers');
}
const text = await response.text();
const numbers = text.trim().split('\n').map(n => parseInt(n));

return numbers;
} catch (error) {
throw new Error('Cannot proceed without true randomness from Random.org. Please try again later.');
}
if (numbers.length !== 6) {
throw new Error('Did not receive the correct number of random numbers');
}

return numbers;
} catch (error) {
throw new Error('Cannot proceed without true randomness from Random.org. Please try again later.');
}
}

function numberToLine(num, lineNumber) {
const isYang = (num === 7 || num === 9);
const isChanging = (num === 6 || num === 9);
Expand Down

0 comments on commit 78bf9a4

Please # to comment.