working state
This commit is contained in:
parent
d69b8aad67
commit
814adbd334
@ -74,7 +74,7 @@
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p>Pastes will be stored for 2 hours only.</p>
|
||||
<p>Pastes are stored for 2 hours only. © 2025 Walzen665</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
@ -20,7 +20,10 @@ $(document).ready(function() {
|
||||
html: `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 3H3C1.89 3 1 3.89 1 5V19C1 20.11 1.89 21 3 21H21C22.11 21 23 20.11 23 19V5C23 3.89 22.11 3 21 3Z"></path><path d="M7 8L12 13L17 8"></path></svg>
|
||||
Format JSON
|
||||
`
|
||||
`,
|
||||
css: {
|
||||
display: $languageSelector.val() === 'json' ? 'inline-flex' : 'none'
|
||||
}
|
||||
});
|
||||
|
||||
$('.controls').prepend($formatJsonBtn);
|
||||
@ -164,6 +167,7 @@ $(document).ready(function() {
|
||||
const detectedLanguage = detectContentType($editor.val());
|
||||
if (detectedLanguage === 'json') {
|
||||
$languageSelector.val('json');
|
||||
$formatJsonBtn.show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,10 +249,14 @@ $(document).ready(function() {
|
||||
window.history.pushState({}, '', '/'); // Reset URL to homepage
|
||||
$editorContainer.removeClass('viewer-active');
|
||||
$languageSelector.val('javascript');
|
||||
$formatJsonBtn.hide(); // Hide JSON button when switching to new paste with JavaScript
|
||||
});
|
||||
|
||||
// Language change
|
||||
$languageSelector.on('change', () => {
|
||||
// Toggle Format JSON button visibility based on language selection
|
||||
$formatJsonBtn.toggle($languageSelector.val() === 'json');
|
||||
|
||||
if ($editorContainer.hasClass('viewer-active')) {
|
||||
$viewer.attr('class', `language-${$languageSelector.val()}`);
|
||||
hljs.highlightElement($viewer[0]);
|
||||
@ -264,7 +272,6 @@ $(document).ready(function() {
|
||||
|
||||
// Format JSON handler
|
||||
$formatJsonBtn.on('click', () => {
|
||||
if ($languageSelector.val() === 'json') {
|
||||
try {
|
||||
const parsed = JSON.parse($editor.val());
|
||||
const formatted = JSON.stringify(parsed, null, 2);
|
||||
@ -276,9 +283,6 @@ $(document).ready(function() {
|
||||
} catch (e) {
|
||||
showNotification('Invalid JSON: ' + e.message, 'error');
|
||||
}
|
||||
} else {
|
||||
showNotification('Select JSON language first', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
// Sync scroll between line numbers and editor
|
||||
|
Loading…
x
Reference in New Issue
Block a user