MediaWiki talk:Common.js

From JoCopedia
Jump to navigation Jump to search

A request for comment has been made for this page. Please add your thoughts!


I would like to have the following code added please, I don't have access:

function userNameReplace() {
if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || wgUserName == null) return;
   for(var i=0; userName = document.getElementsByTagName("span")[i]; i++) {
       if ((document.getElementById('pt-userpage'))&&(UserName.getAttribute('class') == "insertusername")) {
           userName.innerHTML = wgUserName;
       }
   }
}
addOnloadHook(userNameReplace);

It allows the Template:Title to work which can then be used to change the title which displays on a page. ~ Percephene ~ talk contribs 02:02, 27 May 2008

I'll trust you on this. Not that I know what need we'd have to replace a page's title, but... --Lex (talk - contribs) 15:10, 27 May 2008 (EDT)
Cheers! Bry asked me the same question and I gave a couple examples off the top of my head, but really its not a crucial template, its more a nice to have way of jazzing up a page when used properly ;) If we don't find we use it much, we can always remove it. ~ Percephene ~ talk contribs 07:02, 28 May 2008
Sorry, I pasted the wrong code, when you get a chance, could you please replace it with this:
function rewriteTitle()
 {
    if(typeof(SKIP_TITLE_REWRITE) != 'undefined' && SKIP_TITLE_REWRITE)
        return;
    var titleDiv = document.getElementById('title-meta');
    if(titleDiv == null || titleDiv == undefined)
        return;
    var cloneNode = titleDiv.cloneNode(true);
    var firstHeading = YAHOO.util.Dom.getElementsByClassName('firstHeading', 'h1', document.getElementById('content') )[0];
    var node = firstHeading.childNodes[0];
    firstHeading.replaceChild(cloneNode, node);
    cloneNode.style.display = "inline";
    var titleAlign = document.getElementById('title-align');
    firstHeading.style.textAlign = titleAlign.childNodes[0].nodeValue;
 }
 
 addOnloadHook(rewriteTitle, false);
Sorry to be a pain! :( ~ Percephene ~ talk contribs 08:26, 28 May 2008
Done d-done done! --Lex (talk - contribs) 14:34, 29 May 2008 (EDT)

Oh man, I seriously hate to do this, but apparently that code had issues too. If this doesn't work, Spang is gonna get some major hurt!

function rewriteTitle()
 {
    if(typeof(SKIP_TITLE_REWRITE) != 'undefined' && SKIP_TITLE_REWRITE)
        return;
    var titleDiv = document.getElementById('title-meta');
    if(titleDiv == null || titleDiv == undefined)
        return;
    var cloneNode = titleDiv.cloneNode(true);
    var firstHeading = document.getElementById('content').getElementsByTagName('h1')[0];
    var node = firstHeading.childNodes[0];
    firstHeading.replaceChild(cloneNode, node);
    cloneNode.style.display = "inline";
    var titleAlign = document.getElementById('title-align');
    firstHeading.style.textAlign = titleAlign.childNodes[0].nodeValue;
 }
 
 addOnloadHook(rewriteTitle, false);

If you wouldn't mind sometime adding this instead, hopefully it works now, but put it very low down your list of priorities because its not a major! Sorry Lex! :( ~ Percephene ~ talk contribs 10:25, 30 May 2008

Okay, but just for you :P --Lex (talk - contribs) 05:59, 31 May 2008 (EDT)
Yay! Thanks so much, it totally works now! Hooray! :D ~ Percephene ~ talk contribs 08:13, 02 June 2008