User:Quarl/newmessages.js

In this article, dedicated to User:Quarl/newmessages.js, we will delve into a fascinating topic that has captured the interest of people around the world. Along these lines, we will explore the most relevant and impactful aspects related to User:Quarl/newmessages.js, diving into its history, characteristics and current challenges. From its origins to its current situation, we will analyze in depth the importance of User:Quarl/newmessages.js and its influence in different areas. Through this journey, we hope to provide a comprehensive and enriching vision of User:Quarl/newmessages.js, inviting our readers to reflect and learn more about this exciting topic.
// ] - annotate the "You have new messages" alert
// to add "diff since" and "hist" links.

// requires: wikipage.js, diffsince.js, util.js

// quarl 2006-01-16 initial version

// <pre><nowiki>

var newmessages = new Object();

newmessages._load = function() {
    var talkmessagebox = getElementsByClass('usermessage',document.getElementById('bodyContent'),'div');
    if (!talkmessagebox || talkmessagebox.textContent != "You have new messages (diff).") return;

    newmessages.wpTalk = new WikiPage(null,'User talk:' + wikiDoc.username);
    var histUrl = newmessages.wpTalk.qurl + '&action=history';
    var diffSinceUrl = diffsince.makeUrl(newmessages.wpTalk);

    talkmessagebox.className += ' plainlinks';

    var t = (' (<span id="newmessages-diffsince">' +
             '<a onclick="javascript:return newmessages.diffSince()" href="'+diffSinceUrl+'">' +
             'diff since</a></span>)' +
             ' (<a href="'+histUrl+'">history</a>)');

    // insert before final period
    talkmessagebox.innerHTML = talkmessagebox.innerHTML.replace(/(?=$)/, t);
}

newmessages.diffSince = function() {
    return diffsince.diffPageAsync(newmessages.wpTalk,
                            document.getElementById('newmessages-diffsince'),
                            '<b>diff since...</b>');
}

$(newmessages._load);

// </nowki></pre></nowiki></pre>