MediaWiki talk:Gadget-teahouse/content.js
Edit Request
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
I'd like someone to remove the added newline to the posted question. It would entail changing line 49 from:
var newText = oldText.replace( /^==/m, "\n"+wikitext+"==" );
to:
var newText = oldText.replace( /^==/m, wikitext+"==" );
that is, deleting the "\n"+
.
This would resolve a bug where each question asked through this gadget adds an extra newline above it; these newlines accumulate as more questions are added and mess up the spacing of the page. Thanks. Writ Keeper ⚇♔ 14:48, 10 April 2012 (UTC)
Edit request
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Can someone replace $('h2:gt(0)').find('.mw-editsection')
with $('h2:gt(0)').find('.mw-editsection:first')
? The script goes crazy if more than one .mw-editsection element is present in a headline (e.g. if another script adds something to the header, to be styled identically). Nothing will change in the typical case. Keφr 12:02, 23 May 2013 (UTC)
- I still think that this script should be tied to .mw-headline and not .mw-editsection which would avoid this situation entirely. People are responding to/joining the section using a custom script/edit box, not directly editing the page like if they were using the [edit] link. Technical 13 (talk) 12:40, 23 May 2013 (UTC)
- Done. I've fulfilled the request as Keφr stated it for now, with no prejudice against further improvements in line with Technical 13's suggestion. — Mr. Stradivarius ♪ talk ♪ 12:32, 31 May 2013 (UTC)
Interface edit request (May 31, 2013)
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please change:
var headline = $(this).parents('h2').find('span.mw-headline').html();
to:
var headline = $(this).parents('h2').find('span.mw-headline').html();
var headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
This will fix the bug as seen in the edit summary of this edit as can be seen in this edit based on test edits using the code in my test script I created just for this purpose. Thanks. Technical 13 (talk) 23:13, 31 May 2013 (UTC)
- Done. Thanks for your work! — Mr. Stradivarius ♪ talk ♪ 02:10, 1 June 2013 (UTC)
Edit request
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
I would do this myself but I am not proficient with javascript. Per Wikipedia talk:Teahouse/Archive 7#Why Signatures necessary?, please replace:
- On Wikipedia, you should sign all of your posts by ending them with four tildes (~~~~)
With:
- On Wikipedia, you should sign all of your non-article posts by ending them with four tildes (~~~~)
Please add directly below this, using some kind of a break, the following text in a smaller font:
- (Note: this question submission form will not work without them.)
Thanks.--Fuhghettaboutit (talk) 00:59, 18 July 2013 (UTC)
- Fuhghettaboutit, simply replace:
<p>\
<span class="wp-th-sign-hint">On Wikipedia, you should sign all of your posts by ending them with four tildes (~~~~)</span> \
<a href="#" id="wp-th-question-ask">Ask my question</a> \
</p> \
WITH:
<p>\
<span class="wp-th-sign-hint">On Wikipedia, you should sign all of your non-article posts by ending them with four tildes (~~~~)</span>\
<a href="#" id="wp-th-question-ask">Ask my question</a>\
</p>\
<p>\
<span class="wp-th-sign-req"><small>(Note: this question submission form will not work without them.)</small></span>\
</p>\
- Thanks Tecnical. I was mainly concerned that the small text had to be (or was better done) in a different way in javascript than the normal method and wasn't sure of the line break would be before or after the ask my question text--Fuhghettaboutit (talk) 02:36, 18 July 2013 (UTC)
Edit Request 15 Aug 2013
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please replace:
var wikitext = '\n\n:' + text;
With:
var wikitext = '\n\n* ' + text;
This will put a bullet at the front of every response to the question which I feel is needed as it is kind of hard to see one user's answer from another, and I expect it is even more difficult for a new user. Thanks Technical 13 (talk) 12:42, 15 August 2013 (UTC)
- Not done: per WP:TPYES, bullets do not yield standard indentation. --Redrose64 (talk) 15:06, 7 September 2013 (UTC)
- Bullets
- Do indeed
- Yield a standard indentation. WP:INDENT is only and essay and mentions nothing of not using bullets as an indentation type. Technical 13 (talk) 03:01, 24 December 2013 (UTC)
- Not done: Sorry, but now that we have disagreement about the change, enacting it without discussion would be controversial. Could you ask people at the Teahouse what they think? If there's a consensus from a discussion there, I'd be willing to enact this. Best — Mr. Stradivarius ♪ talk ♪ 05:49, 24 December 2013 (UTC)
Edit Request 26 Aug 2013
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please replace:
api.post(
{
'action' : 'edit',
'title' : 'Wikipedia:Teahouse/Questions',
'text' : newText,
'summary' : 'New question: '+title,
'token' : page.edittoken
},
with:
api.post(
{
'action' : 'edit',
'title' : 'Wikipedia:Teahouse/Questions',
'text' : newText,
'summary' : 'New question: [[Wikipedia:Teahouse/Questions#' + title + '|' + title + ']]',
'token' : page.edittoken
},
so that the new question name will be a section link in the edit summary. Thanks! Technical 13 (talk) 14:37, 26 August 2013 (UTC)
- Not done: please establish a consensus for this alteration before using the
{{edit protected}}
template. That would make the edit summary even more non-standard. Why is the standard edit summary for a new thread - which would be coded as
'summary' : '/'+'* '+title+' *'+'/ new section',
- not being used? Placing the section heading between comment markers creates a link automatically. --Redrose64 (talk) 15:11, 7 September 2013 (UTC)
- That would be fine. The purpose of the edit request is to add a link to the summary by whatever means acceptable. Technical 13 (talk) 16:30, 7 September 2013 (UTC)
- Done --Redrose64 (talk) 18:45, 7 September 2013 (UTC)
- This change broke a lot of my logging scripts. HostBot keeps track of questions and answers on the Teahouse Q&A board, and it depends on a consistent edit comment format to identify Q/A pairs. I can update the scripts, but it'll take a bit of time. My bad for not documenting these dependencies better; I'll do that from now on. However, is there a good place for me to place a request to be notified about proposed changes to this script in future? Any advice is appreciated. Cheers, - J-Mo Talk to Me Email Me 19:47, 16 September 2013 (UTC)
Section headings with a wikilink
[edit]If the section heading contains a wikilink then the automatic edit summary contains html code for the link. See [1]. The section heading was [[LeSean McCoy]]
but the edit summary contained <a href="/wiki/LeSean_McCoy" title="LeSean McCoy">LeSean McCoy</a>
. If the normal "edit" link at the section is clicked then MediaWiki makes the prefilled edit summary /* LeSean McCoy */
which makes a correct link to the section on the arrow "→" at the edit summary. It's not a big deal. If it's hard to fix then we can live with the issue. PrimeHunter (talk) 02:20, 24 December 2013 (UTC)
- Okay PH, so I looked this over and the fix would look something like appending:
var headline = $(this).parents('h2').find('span.mw-headline').html();
headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
- with the following code
var headline = $(this).parents('h2').find('span.mw-headline').html();
headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
if ($(this).parents('h2').find('span.mw-headline').find('a')) {
var linkedPage = $(this).parents('h2').find('span.mw-headline').find('a').attr('title');
var pipedPage = $(this).parents('h2').find('span.mw-headline').find('a').html();
if(linkedPage == pipedPage){
var link = "[[" + linkedPage + "]]";
} else {
var link = "[[" + linkedPage + "|" + pipedPage + "]]";
}
headline = headline.replace(/<a href=(.*?)<\/a>/, link);
}
- which will check if there is a link in the header and replace the html with the proper wikilink version. This will find and replace only the first wikilink in each section header, if there are more than one, there will still be an issue. I'll work out how to get all of the links in a bit, but figured I'd offer this to start so you would know it can be done fairly easily. Technical 13 (talk) 03:47, 24 December 2013 (UTC)
- A wikilink in the header should not be reproduced. The link code should be removed completely, exactly like MediaWiki did in [2] when editing
==[[LeSean McCoy]]==
became/* LeSean McCoy */
, and an arrow "→" with a section link is automatically made when the edit is viewed, as described at Wikipedia:Edit summary#Section editing. PrimeHunter (talk) 04:10, 24 December 2013 (UTC)
- PH, I was actually more worried about multiple differnt links in the header, your concern is easily fixed (and shortens the code a hair). The fix would look something like appending:
- A wikilink in the header should not be reproduced. The link code should be removed completely, exactly like MediaWiki did in [2] when editing
var headline = $(this).parents('h2').find('span.mw-headline').html();
headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
- with the following code
var headline = $(this).parents('h2').find('span.mw-headline').html();
headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
$('h2').find('span.mw-headline').find('a').each(function () {
var linkedPage = $(this).attr('title');
var pipedPage = $(this).html();
var htmlLink = "<a href=\"/wiki/" + linkedPage + "\" title=\"" + linkedPage + "\">" + pipedPage + "<\/a>";
headline = headline.replace(htmlLink, pipedPage);
});
- which will check if there are links in the header and replace the html with raw text for each link. See a working truncated example in this jsfiddle. Technical 13 (talk) 04:39, 24 December 2013 (UTC)
Edit Request 29 Jan 2014
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
As you can see in this screencast, there seems to be some z-index problem related to this script. Helder 12:11, 29 January 2014 (UTC)
- Not done: please be more specific about what needs to be changed. --Redrose64 (talk) 12:56, 29 January 2014 (UTC)
- See also WP:Village pump (technical)#Unable to copy at the Teahouse. Helder 13:23, 29 January 2014 (UTC)
- Yes, I saw that: but it still doesn't indicate how the script should be amended. --Redrose64 (talk) 13:41, 29 January 2014 (UTC)
Update request (October 2014)
[edit]{{sudo}}
Hi. Please sync this page with testwiki:MediaWiki:Gadget-teahouse/content.js. This is related to this discussion. Thanks. --MZMcBride (talk) 04:48, 13 October 2014 (UTC)
- I did it. --Closedmouth (talk) 05:03, 13 October 2014 (UTC)
- Heh, my bad. There's a bit of debugging code left in there. You can remove the "console.log()" line. <3 --MZMcBride (talk) 05:16, 13 October 2014 (UTC)
- Yes. --Closedmouth (talk) 05:19, 13 October 2014 (UTC)
- Heh, my bad. There's a bit of debugging code left in there. You can remove the "console.log()" line. <3 --MZMcBride (talk) 05:16, 13 October 2014 (UTC)
Protected edit request on 9 January 2017
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
References to Wikipedia:Teahouse/Questions
on lines 43, 58, 147, 167 and 181 need to be changed to Wikipedia:Teahouse
to reflect the recent page move. As it is, the Teahouse gadget is completely broken. – Joe (talk) 10:50, 9 January 2017 (UTC)
- Done -- Samtar talk · contribs 10:59, 9 January 2017 (UTC)
Edit request April 6, 2017
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
The discussion Wikipedia talk:Teahouse#Top v bottom resulted in a decision to have new questions posted at the bottom of the page rather than the top. There is some confusion about how to implement this. See Wikipedia talk:Teahouse#Implementation. If this is the place to make the change, please do so. Thankyou. StarryGrandma (talk) 18:07, 7 April 2017 (UTC)
- Not done Discussion here is fine, once the technical code change is ready feel free to reactivate the edit request so patrolling administrators can implement it. — xaosflux Talk 12:36, 15 April 2017 (UTC)
- Hi Xaosflux where would we find someone who understands the current code and can figure out how to change it to get the desired result? Roger (Dodger67) (talk) 12:59, 15 April 2017 (UTC)
- Dodger67 perhaps recent editors to the page: @Fuhghettaboutit and There'sNoTime: - if not, try WP:VPT. — xaosflux Talk 14:23, 15 April 2017 (UTC)
- Thanks for the ping! Hmm, who I would first have thought of, Werdna (obviously, as the original coder), is inactive. No I am not competent to oversee this (though I am happy to implement a plan if provided). I can sometimes figure out technical stuff just by its internal logic, by playing around and emulation but I'm charitably a dilettante. However, I know of a few users who are wizes. Hope none of them mind these pings: Mr. Stradivarius MZMcBride and Johnuniq.--Fuhghettaboutit (talk) 15:08, 15 April 2017 (UTC)
- Sorry, JavaScript is outside my area (I'm good for Lua modules). Johnuniq (talk) 00:14, 16 April 2017 (UTC)
- I've just changed the gadget to add new questions at the bottom. In the end, the necessary edit was pretty simple (although not helped by my backwards edit summary...). — Mr. Stradivarius ♪ talk ♪ 06:52, 16 April 2017 (UTC)
- Mr. Stradivarius, thank you very much. StarryGrandma (talk) 08:54, 16 April 2017 (UTC)
- Thanks for the ping! Hmm, who I would first have thought of, Werdna (obviously, as the original coder), is inactive. No I am not competent to oversee this (though I am happy to implement a plan if provided). I can sometimes figure out technical stuff just by its internal logic, by playing around and emulation but I'm charitably a dilettante. However, I know of a few users who are wizes. Hope none of them mind these pings: Mr. Stradivarius MZMcBride and Johnuniq.--Fuhghettaboutit (talk) 15:08, 15 April 2017 (UTC)
- Dodger67 perhaps recent editors to the page: @Fuhghettaboutit and There'sNoTime: - if not, try WP:VPT. — xaosflux Talk 14:23, 15 April 2017 (UTC)
- Hi Xaosflux where would we find someone who understands the current code and can figure out how to change it to get the desired result? Roger (Dodger67) (talk) 12:59, 15 April 2017 (UTC)
Huh, I argued many years ago against top-posting. I guess everyone else has now come around as well. Mr. Stradivarius: if you're interested, the code could be improved to be more efficient. MediaWiki naturally supports appending sections to a page. This script hacked around the limitation/inability to top-post sections in MediaWiki by getting the existing revision text and then prepending to it. Instead of doing this, we could use section=new, as documented in <https://en.wikipedia.org/w/api.php?action=help&modules=edit>. This would obviate the need to grab the existing revision text and would automatically handle the edit summary instead of manually concatenating/emulating the new section edit summary. --MZMcBride (talk) 05:47, 23 April 2017 (UTC)
- @MZMcBride: Thanks for the tip! That saved 507 bytes of code. — Mr. Stradivarius ♪ talk ♪ 08:15, 23 April 2017 (UTC)
Remove from gadgets?
[edit]This gadget is no longer used, as the "Ask a question" button at Teahouse now uses mw:Extension:DiscussionTools. In addition, it will be broken by the upcoming mw:Heading HTML changes. It should either me removed or userfied. --Ahecht (TALK
PAGE) 15:51, 12 June 2024 (UTC)