Update index.html
Browse files- index.html +25 -17
index.html
CHANGED
@@ -450,23 +450,31 @@ function hello() {
|
|
450 |
}
|
451 |
|
452 |
// Function to insert a badge
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
|
471 |
// Function to insert a link
|
472 |
function insertLink() {
|
|
|
450 |
}
|
451 |
|
452 |
// Function to insert a badge
|
453 |
+
function insertBadge() {
|
454 |
+
const label = document.getElementById('badge-label').value || 'label';
|
455 |
+
const message = document.getElementById('badge-message').value || 'message';
|
456 |
+
const color = document.getElementById('badge-color').value || 'blue';
|
457 |
+
const icon = document.getElementById('badge-icon').value;
|
458 |
+
const url = document.getElementById('badge-url').value; // Get the URL
|
459 |
+
|
460 |
+
let badgeUrl = `https://img.shields.io/badge/${encodeURIComponent(label)}-${encodeURIComponent(message)}-${color}`;
|
461 |
+
if (icon) {
|
462 |
+
badgeUrl += `?logo=${icon}`;
|
463 |
+
}
|
464 |
+
|
465 |
+
// Create the badge Markdown
|
466 |
+
let badgeMarkdown = ``;
|
467 |
+
|
468 |
+
// If a URL is provided, wrap the badge in a link
|
469 |
+
if (url) {
|
470 |
+
badgeMarkdown = `[${badgeMarkdown}](${url})`;
|
471 |
+
}
|
472 |
+
|
473 |
+
// Insert the badge into the editor
|
474 |
+
input.value += `\n${badgeMarkdown}`;
|
475 |
+
updatePreview();
|
476 |
+
hideModal('badge-modal');
|
477 |
+
}
|
478 |
|
479 |
// Function to insert a link
|
480 |
function insertLink() {
|