mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-26 21:04:58 -05:00
Add italic toggle button
This commit is contained in:
@@ -206,6 +206,7 @@
|
|||||||
<div class='readable-background padding margin-bottom'>
|
<div class='readable-background padding margin-bottom'>
|
||||||
<h5 class='margin-bottom padding input-description'>Enter card text</h5>
|
<h5 class='margin-bottom padding input-description'>Enter card text</h5>
|
||||||
<textarea id='text-editor' class='input margin-bottom' oninput='textEdited();'></textarea>
|
<textarea id='text-editor' class='input margin-bottom' oninput='textEdited();'></textarea>
|
||||||
|
<button class='input' onclick="toggleTextTag('i');">Italic</button>
|
||||||
<h5 class='margin-bottom padding input-description'>Edit the placement and size of the selected textbox</h5>
|
<h5 class='margin-bottom padding input-description'>Edit the placement and size of the selected textbox</h5>
|
||||||
<button class='input' onclick='textboxEditor();'>Edit Bounds</button>
|
<button class='input' onclick='textboxEditor();'>Edit Bounds</button>
|
||||||
<h5 class='margin-bottom padding input-description'>Adjust font size</h5>
|
<h5 class='margin-bottom padding input-description'>Adjust font size</h5>
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
<script defer src='js/main-1.js'></script>
|
<script defer src='js/main-1.js'></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<input hx
|
||||||
<div class='background'></div>
|
<div class='background'></div>
|
||||||
<header class='readable-background'>
|
<header class='readable-background'>
|
||||||
<h1 class='title center'>CARD CONJURER</h1>
|
<h1 class='title center'>CARD CONJURER</h1>
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
<div class='main-menu'>
|
<div class='main-menu'>
|
||||||
<h2>Navigation</h2>
|
<h2>Navigation</h2>
|
||||||
<h3><a href="#" hx-get="index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Home</a></h3>
|
<h3><a href="#" hx-get="index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Home</a></h3>
|
||||||
<h3><a href="#" hx-get="creator/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Card Creator</a></h3>
|
<h3><a href="#" hx-get="creator/index.html" hx-target="#content" hx-trigger="click, doCreate from:body" onclick='toggleMenu()'>Card Creator</a></h3>
|
||||||
<h3><a href="#" hx-get="print/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Printing Tool</a></h3>
|
<h3><a href="#" hx-get="print/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Printing Tool</a></h3>
|
||||||
<h3><a href="#" hx-get="askurza/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Ask Urza 2.0</a></h3>
|
<h3><a href="#" hx-get="askurza/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Ask Urza 2.0</a></h3>
|
||||||
<h3><a href="#" hx-get="phyrexian/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Phyrexian Generator</a></h3>
|
<h3><a href="#" hx-get="phyrexian/index.html" hx-target="#content" hx-trigger="click" onclick='toggleMenu()'>Phyrexian Generator</a></h3>
|
||||||
|
@@ -3907,6 +3907,36 @@ function fetchScryfallData(cardName, callback = console.log, searchUniqueArt = '
|
|||||||
console.log('Scryfall API search failed.')
|
console.log('Scryfall API search failed.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleTextTag(tag) {
|
||||||
|
var element = document.getElementById('text-editor');
|
||||||
|
|
||||||
|
var text = element.value;
|
||||||
|
|
||||||
|
var start = element.selectionStart;
|
||||||
|
var end = element.selectionEnd;
|
||||||
|
var selection = text.substring(start, end);
|
||||||
|
|
||||||
|
var openTag = '{' + tag + '}';
|
||||||
|
var closeTag = '{/' + tag + '}';
|
||||||
|
|
||||||
|
var prefix = text.substring(0, start);
|
||||||
|
var suffix = text.substring(end);
|
||||||
|
|
||||||
|
if (prefix.endsWith(openTag) && suffix.startsWith(closeTag)) {
|
||||||
|
prefix = prefix.substring(0, prefix.length-openTag.length);
|
||||||
|
suffix = suffix.substring(closeTag.length);
|
||||||
|
} else if (selection.startsWith(openTag) && selection.endsWith(closeTag)) {
|
||||||
|
selection = selection.substring(openTag.length, selection.length-closeTag.length);
|
||||||
|
} else {
|
||||||
|
selection = openTag + selection + closeTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
element.value = prefix + selection + suffix;
|
||||||
|
|
||||||
|
textEdited();
|
||||||
|
}
|
||||||
|
|
||||||
// INITIALIZATION
|
// INITIALIZATION
|
||||||
|
|
||||||
// auto load frame version (user defaults)
|
// auto load frame version (user defaults)
|
||||||
|
@@ -123,3 +123,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
document.body.dispatchEvent(new Event('doCreate'));
|
document.body.dispatchEvent(new Event('doCreate'));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.onkeyup = function(e) {
|
||||||
|
if (document.activeElement === document.getElementById('text-editor')) {
|
||||||
|
if (e.ctrlKey && e.which == 73) {
|
||||||
|
toggleTextTag('i');
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user