Developing custom quote
3 posters
Page 1 of 1
Developing custom quote
I am trying to develop a bit different quote feature for PunBB version. When I select text, it should show two buttons (as it does) and then when I click let's say on "Quote" button it should put selected text inside textarea. However, this doesn't happen.
Forum: https://forumwitches.forumotion.com/
My script:
What is the issue there?
Forum: https://forumwitches.forumotion.com/
My script:
- Code:
$(document).ready(function() {
$(document).on('mouseup', function (e) {
const selection = window.getSelection();
const selectedText = selection.toString().trim();
const postEntry = $(e.target).closest('.post-entry');
if (selectedText.length > 0 && postEntry.length > 0) {
const range = selection.getRangeAt(0);
const rect = range.getBoundingClientRect();
// Remove existing buttons if any
$('#quote-buttons').remove();
// Create floating buttons
const quoteButtons = $('<div id="quote-buttons"></div>').css({
position: 'absolute',
top: `${rect.bottom + window.scrollY}px`,
left: `${rect.left + window.scrollX}px`,
backgroundColor: 'white',
border: '1px solid #ccc',
padding: '5px',
zIndex: '1000'
});
// Add "Add to quoted" button
const addToQuotedButton = $('<button id="add-to-quoted">Add to quoted</button>').on('click', function() {
console.log("Add to quoted button clicked");
let quotedText = localStorage.getItem('quotedText') || '';
quotedText += `[quote]${selectedText}[/quote]\n`;
localStorage.setItem('quotedText', quotedText);
quoteButtons.remove();
});
quoteButtons.append(addToQuotedButton);
// Add "Quote" button
const quoteNowButton = $('<button id="quote-now">Quote</button>').on('click', function() {
console.log("Quote button clicked");
const textarea = $('.sceditor-container textarea');
if (textarea.length > 0) {
textarea.val(textarea.val() + `[quote]${selectedText}[/quote]\n`);
}
quoteButtons.remove();
});
quoteButtons.append(quoteNowButton);
// Add floating buttons to the body
$('body').append(quoteButtons);
} else {
$('#quote-buttons').remove();
}
});
});
What is the issue there?
Last edited by King Baldwing IV on May 18th 2024, 8:33 pm; edited 1 time in total
Re: Developing custom quote
Ok, I have found the issue. I won't share it yet until code is ready to be shared publicly.
SarkZKalie likes this post
Re: Developing custom quote
Please don't double post. Your posts need to be separated by 24 hours before bumping. Please use the edit button, instead!
|
Re: Developing custom quote
Problem solved & topic archived.
|
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Custom quote buttons logic
» Unable to use some multi-quote, quote, edit, delete, help and answering yes or no buttons
» Quoting a quote - Script bug Quick quote?
» Background Color of Quote in Quote
» Problems with the background color on a 'Quote on Quote' response and problems with the background color on my 'Quick Reply' box
» Unable to use some multi-quote, quote, edit, delete, help and answering yes or no buttons
» Quoting a quote - Script bug Quick quote?
» Background Color of Quote in Quote
» Problems with the background color on a 'Quote on Quote' response and problems with the background color on my 'Quick Reply' box
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum