What about... If I cut a code tag that's located in a nested quote? (i.e. not directly inside the main quote.)
Re: Another life-changing fantastic idea for quotes! (Bit silly, too.)
« Reply #30, on March 13th, 2011, 12:25 AM »
What about... If I cut a code tag that's located in a nested quote? (i.e. not directly inside the main quote.)
// Build a list of opened tags...
var
selection = this.value.substr(0, selectionStart), lcs = selection.toLowerCase(),
lcsl = lcs.length, pos = 0, tag, bbcode, taglist = [], extag, log_tags = true,
protect_tags = ['code', 'php', 'html'];
while (true)
{
pos = lcs.indexOf('[', pos) + 1;
if (!pos)
break;
tag = selection.substring(pos, lcs.indexOf(']', pos + 1));
bbcode = tag.substr(tag.charAt(0) === '/' ? 1 : 0);
if (tag.charAt(0) === '/')
{
if (!log_tags && bbcode != taglist[taglist.length - 1].substr(0, bbcode.length))
continue;
do
{
extag = taglist.pop();
if (in_array(extag, protect_tags))
log_tags = true;
}
while (extag && bbcode != extag.substr(0, bbcode.length).toLowerCase());
}
else if (log_tags)
taglist.push(bbcode);
if (log_tags && in_array(bbcode, protect_tags))
log_tags = false;
}
for (var closers = [], j = 0, l = taglist.length; j < l; j++)
closers[] = '[/' + (taglist[j].indexOf(' ') > 0 ? taglist[j].substr(0, taglist[j].indexOf(' ')) : taglist[j]) + ']';
surroundText(closers.reverse().join('') + '\n', '\n\n[' + taglist.join('][') + ']', this);
return true;// Split a quote if we press Enter inside it.
function splitQuote(oEvent)
{
// Did we just press Enter?
if (oEvent.which != 13)
return true;
// Where are we, already?
if ('selectionStart' in this)
var selectionStart = this.selectionStart;
else
{
var range = document.selection.createRange(), dul = range.duplicate();
dul.moveToElementText(this);
dul.setEndPoint('EndToEnd', range);
var selectionStart = dul.text.length - range.text.length;
}
// Build a list of opened tags...
var
selection = this.value.substr(0, selectionStart), lcs = selection.toLowerCase(),
lcsl = lcs.length, pos = 0, tag, bbcode, taglist = [], extag, log_tags = true,
protect_tags = [
'code',
'php',
'html',
],
closed_tags = [
'br',
'hr',
'more',
];
while (true)
{
pos = lcs.indexOf('[', pos) + 1;
if (!pos)
break;
tag = selection.substring(pos, lcs.indexOf(']', pos + 1));
bbcode = tag.substr(tag.charAt(0) === '/' ? 1 : 0);
if (tag.charAt(0) === '/')
{
if (!log_tags && bbcode != taglist[taglist.length - 1].substr(0, bbcode.length))
continue;
do
{
extag = taglist.pop();
if (in_array(extag, protect_tags))
log_tags = true;
}
while (extag && bbcode != extag.substr(0, bbcode.length).toLowerCase());
}
else if (log_tags && !in_array(bbcode, closed_tags))
taglist.push(bbcode);
if (log_tags && in_array(bbcode, protect_tags))
log_tags = false;
}
for (var closers = [], j = 0, l = taglist.length; j < l; j++)
closers.push('[/' + (taglist[j].indexOf(' ') > 0 ? taglist[j].substr(0, taglist[j].indexOf(' ')) : taglist[j]) + ']');
surroundText(closers.reverse().join('') + '\n', '\n\n[' + taglist.join('][') + ']', this);
return true;
};We'd actually have to pass the list of closed tags to the JS because although the list is only three tags now, it might not be in future.
As for the theme, just playing with some different header ideas and seeing how well the sidebar worked on the right.
I don't think forum wide would be very logical.
A per-user setting, yeah, I thought about that but am too lazy