Skip to content
Open
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
9 changes: 9 additions & 0 deletions examples/Tip_Calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ <h1>Tip Calculator</h1>
<p>Total: ₹<span id="total">0.00</span></p>
<p>Each Pays: ₹<span id="each">0.00</span></p>
</div>

<div class="code-block">
<pre><code>
function calculateTip(bill, percentage) {
return (bill * percentage) / 100;
}
</code></pre>
Comment on lines +35 to +39
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code inside the <code> tag has inconsistent indentation. The opening line starts on line 35, but the function code on lines 36-38 has extra leading whitespace that will be copied when users click the copy button. Consider removing the extra indentation to provide cleaner copied code, or adjust the indentation to be consistent with typical JavaScript formatting.

Copilot uses AI. Check for mistakes.
</div>
</div>

<script src="script.js"></script>
</body>

Expand Down
21 changes: 21 additions & 0 deletions examples/Tip_Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,26 @@ function calculate() {
resultsDiv.style.background = '#f1f5f9';
}

document.querySelectorAll('pre > code').forEach(codeBlock => {
const button = document.createElement('button');
button.className = 'copy-btn';
button.textContent = 'Copy';

const pre = codeBlock.parentNode;
const wrapper = document.createElement('div');
wrapper.className = 'code-block';
pre.parentNode.insertBefore(wrapper, pre);
wrapper.appendChild(pre);
wrapper.appendChild(button);

button.addEventListener('click', () => {
const text = codeBlock.textContent;
navigator.clipboard.writeText(text).then(() => {
button.textContent = 'Copied!';
setTimeout(() => (button.textContent = 'Copy'), 2000);
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clipboard API usage lacks error handling. If the clipboard write fails (e.g., due to browser permissions or HTTPS requirement), the promise rejection is not caught, which could lead to unhandled promise rejections. Consider adding a .catch() handler to provide user feedback when copying fails.

Suggested change
setTimeout(() => (button.textContent = 'Copy'), 2000);
setTimeout(() => (button.textContent = 'Copy'), 2000);
}).catch(() => {
button.textContent = 'Failed!';
setTimeout(() => (button.textContent = 'Copy'), 2000);

Copilot uses AI. Check for mistakes.
});
});
});

// Initial calculation on load
calculate();
37 changes: 37 additions & 0 deletions examples/Tip_Calculator/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,43 @@ input[type="number"] {
border: 1px solid #ddd;
}

.code-block {
margin-top: 20px;
}
Comment on lines +36 to +38
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .code-block class is defined twice in this file (lines 36-38 and lines 68-70). The first definition sets margin-top: 20px and the second sets position: relative. These should be combined into a single rule block to avoid confusion and improve maintainability.

Copilot uses AI. Check for mistakes.

.code-block pre {
background-color: #f5f5f5;
border: 1px solid #ddd;
border-radius: 8px;
padding: 12px;
overflow-x: auto;
font-size: 14px;
line-height: 1.4;
}

.copy-btn {
position: absolute;
top: 8px;
right: 8px;
background: #4CAF50;
color: white;
border: none;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background 0.3s;
}

.copy-btn:hover {
background: #45a049;
}

.code-block {
position: relative;
}


.tips {
display: flex;
gap: 8px;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"main": "index.js",
"devDependencies": {
"@honkit/honkit-plugin-ga": "^1.0.1",
"cz-conventional-changelog": "^3.3.0",
"cz-conventional-changelog": "^3.0.1",
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change downgrades cz-conventional-changelog from ^3.3.0 to ^3.0.1. Unless there's a specific reason for this downgrade (such as compatibility issues), it's generally better to keep dependencies at their latest compatible versions to benefit from bug fixes and improvements. Please verify if this downgrade is intentional.

Suggested change
"cz-conventional-changelog": "^3.0.1",
"cz-conventional-changelog": "^3.3.0",

Copilot uses AI. Check for mistakes.
"gitbook-plugin-ace-editor": "github:sumn2u/gitbook-plugin-ace-editor",
"gitbook-plugin-chapter-fold": "^0.0.4",
"gitbook-plugin-edit-link": "^2.0.2",
"gitbook-plugin-exercises": "^3.0.0",
"gitbook-plugin-exercises": "^1.0.0",
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change downgrades gitbook-plugin-exercises from ^3.0.0 to ^1.0.0. This is a major version downgrade that could remove important features or break existing functionality. Please verify if this downgrade is intentional and ensure all dependent code remains compatible with version 1.0.0.

Suggested change
"gitbook-plugin-exercises": "^1.0.0",
"gitbook-plugin-exercises": "^3.0.0",

Copilot uses AI. Check for mistakes.
"gitbook-plugin-favicon-custom": "^1.0.0",
"gitbook-plugin-hide-published-with": "0.0.1",
"gitbook-plugin-hints": "^1.0.2",
Expand All @@ -18,7 +18,7 @@
"gitbook-plugin-sidebar-ad": "github:sumn2u/gitbook-plugin-sidebar-ad",
"gitbook-plugin-sitemap": "^1.2.0",
"gitbook-plugin-theme-creative": "github:sumn2u/gitbook-plugin-theme-creative",
"honkit": "^4.0.4",
"honkit": "^6.1.4",
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change upgrades honkit from ^4.0.4 to ^6.1.4, skipping version 5 entirely. This is a major version upgrade that may include breaking changes. Please ensure all honkit plugins and configurations are compatible with version 6.1.4, and test the build thoroughly.

Copilot uses AI. Check for mistakes.
"honkit-plugin-i18nsettings": "^1.0.0"
},
"scripts": {
Expand Down
Loading