Content deleted Content added
Writ Keeper (talk | contribs) fix |
Writ Keeper (talk | contribs) test |
||
Line 1:
function teahouseTalkbackLink()
{ if ($("#mw-content-text").length > 0)
{
var $nodeList = $('a[title^="User talk:"]'), pdne = ' (page does not exist)';▼
if ($nodeList !== null)
{
var i;
for
{
var $link = $($nodeList[i]);
var newLinkString = "<span class='reply-link-wrapper'>|";
$newLink = $('<a href="#' + $link[0].title.replace(pdne, "") + '" style="font-size:x-small; display:inline-block;" title="Send a talkback!" noPopup=1 id="TBsubmit' + i + '">TB</a>');▼
var newLinkId = $link[0].title.replace(pdne, "") ;
$newLink.click(function(e) {▼
▲
{
talkbackSubmit($(this).attr('href').substr(1), this.id)
});
▲ $($link).after("<!--1-->|");
▲ $($link).after($('<a href='+(($link[0].href).replace("User_talk:", "Special:Contributions/"))+' style="font-size:x-small; display:inline-block;">C</a>'));
}
}
}
}
function talkbackSubmit(page, id)
{ var questionTitle = prompt("Please enter the title of the question you're replying to (or just leave it blank):", ""),
sectionTitle = "{{Wikipedia:Teahouse/Teahouse talkback|WP:Teahouse|"; if (questionTitle === null)
{
}
else if (questionTitle === "")
{
sectionTitle += "ts=~~" + "~~}}";
}
else
{
sectionTitle += questionTitle + "|ts=~~" + "~~}}";
}
var data =
{
text: sectionTitle,
summary: "Teahouse talkback: you've got messages!", token
};
$.ajax(
{
url
success: function (data)
{ if (data && data.edit && data.edit.result && data.edit.result === 'Success') {
//window.___location = mw.util.getUrl(page);
}
else
{
alert('There was an error requesting the page edit. Code: ' + data.error.code + '": ' + data.error.info);
}
},
error
{
alert('There was an error using AJAX to edit the page.');
}
});
}
if (mw.config.get('wgPageName') === "Wikipedia:Teahouse")
{ teahouseTalkbackLink();
}
|