I’m looking for a code that will allow me to use images (or CSS) as prefixes when creating a new post.
But I want to be able to edit the topic title (or post) and add a prefix (like if you forgot to add it when making the topic or editing an older topic). Also want it to show everywhere the topic title shows (the image/css).
I’d highly prefer to be able to use images via css instead of having to style each prefix I can just add the image url.
I have a code that was made for me but it didn’t quite work as planned. As you can see in the first 2 screenshots the code doesn’t take effect on those pages. And the dropdown menu that shows the prefixes when creating a new topic isn’t present at all.
[CODE]
<script type=”text/javascript”>
//<![CDATA[
$(function () {
var pos = $(‘table.posting input[name=”title”]’).position();
$(‘table.posting input[name=”title”]’).before(‘<a href=”javascript: void(0);” id=”aPrefix” style=”margin-right: 5px”>Add Prefix</a>’);
$(‘#main’).append(‘<div id=”prefixes” class=”meta_box” style=”display: none; position: absolute; left: ‘ + pos.left + ‘px; top: ‘ + (pos.top + 21) + ‘px”></div>’);
$(‘#aPrefix’).click(function () {
$(‘#prefixes’).fadeIn(‘slow’);
});
function addPrefix(prefix) {
$(‘#prefixes’).append(‘<div class=”prefix” style=”cursor: pointer”>’ + prefix + ‘</div>’);
}
addPrefix(‘Prefix 1’);
addPrefix(‘Prefix2’);
addPrefix(‘Prefix 3’);
$(‘#prefixes’).append(‘<div class=”no_prefix” style=”cursor: pointer”>No Prefix</div>’);
$(‘div.prefix’).each(function () {
$(this).attr(‘class’, ‘prefix’ + $(this).index());
});
$(‘div.no_prefix’).click(function () {
$(‘#prefixes’).fadeOut(‘slow’);
$(‘table.posting input[name=”title”]’).val($(‘table.posting input[name=”title”]’).val().replace(/[(.+?)]/ig, ”));
});
$(‘div[class*=”prefix”]:not(div.no_prefix)’).click(function () {
if ($(‘table.posting input[name=”title”]’).val().length === 0) {
$(‘table.posting input[name=”title”]’).val(‘[‘ + $(this).text() + ‘] ‘);
} else {
$(‘table.posting input[name=”title”]’).val(‘[‘ + $(this).text() + ‘] ‘ + $(‘table.posting input[name=”title”]’).val());
}
$(‘#prefixes’).fadeOut(‘slow’);
});
});
function stylePrefix(pName, cName) {
$(‘a:contains([‘ + pName + ‘])’).each(function () {
$(this).html($(this).html().replace(‘[‘ + pName + ‘]’, ‘<span class=”‘ + cName + ‘”>’ + pName + ‘</span>’));
});
}
stylePrefix(‘prefix1’, ‘prefix1’);
stylePrefix(‘Prefix2’, ‘Prefix2’);
stylePrefix(‘PREFIX3’, ‘PREFIX3’);
//]]>
</script>
I’m using a Zetaboards forum/board.