Forum:Post signing reminder js

From Yugipedia
Jump to: navigation, search


I was testing something out, but I ended up making it work. It's a javascript which checks your post (while on a talk or forum page) as you click on either "Publish" or "Preview", and if your post does not contain the four tildes it will stop you and remind you to sign.

If you want to preview it, you can add:
importScript('User:Falzar FZ/FormatChecker.js');
to your common.js page

Should/Can I add it to MediaWiki:Common.js?

EDIT: Changed SignChecker to FormatChecker. +Functions for auto-adding {{Navigation}} and {{Talkheader}} to relevant pages.
I'll eventually just add it if there are no objections.
-Falzar FZ- (talk page|useful stuff) 05:33, October 7, 2012 (UTC) edited on 13:50, October 11, 2012 (UTC)

There's a similar gadget on Wikipedia that I use; I'll have to find what it is so you can compare. ;) ディノ千?!? · ☎ Dinoguy1000 07:49, October 12, 2012 (UTC)
Sounds great! That is very similar to the gadget which reminds you when you haven't provided an edit summary. As you may have guessed; I have that enabled. :) --BobblesTalk 08:28, October 12, 2012 (UTC)
It's a good idea, but I'm not so sure about some elements. Unless I'm mistaken, that code won't just alert you if you haven't signed, it also won't let you save your edit until you do. There are a few false positives, including:
  • It will be triggered if someone performs an action which doesn't require them to sign, such as:
    • Correcting a mistake in their previous message.
    • Removing someone else's inappropriate message.
    • Adding the talkheader or any kind of notice.
    • Archiving topics.
  • Some people customise their signatures to decorate the timestamp and only sign with three tildes.
Some browsers alert boxes will include an option to stop the site you're on from generating more alert boxes, but some don't. In general, I'm not a huge fan of alert boxes either way.
Aside from the false positives, it's essentially either forcing your to sign or stopping you from posting if you cannot sign. I know it's obvious to us how to sign and I don't understand how people can't figure it out when clear instructions are shoved in front of them, but it still happens. Is this something we should really be punishing people for?
Would it be okay to set it so that you get notified, but not forced to sign?
It might also be interesting to do a 180 on this idea and have it stop people adding signatures to content pages. Although AbuseFilter might be better for that.
The {{Navigation}} and {{Talkheader}} JS looks great. I've no major issues with it. -- Deltaneos (talk) 17:58, October 12, 2012 (UTC)
I could make it so that it only alerts a few times. If someone uses custom stuff, they can add something to their JS to disable or modify it.
Well, the instructions you usually come across says "sign your posts using four tildes (~~~~)", which some people might not understand. I know it can be changed, anyways, this says "by adding 4 tildes (~~~~) to the end of your post." which is slightly clearer.
It can also be bypassed by using the shortcut shift+alt+s.
Signing on main pages is quite a rare occurrence, so I didn't really consider it before. -Falzar FZ- (talk page|useful stuff) 23:59, October 12, 2012 (UTC)
Add those, and if you mark your edit as minor it will not check, so it'll bypass those false positives. -Falzar FZ- (talk page|useful stuff) 00:53, October 16, 2012 (UTC)

The code I had been using was

addOnloadHook(function()
{
    if(wgAction == 'edit' || wgAction == 'submit')
    {
        if(wgPageName.match(/^[^:]*talk:/i) || wgPageName.match(/^Forum:/))
    {
        $('#wpSave').click(function(e)
        {
        if(typeof enforceSign === 'undefined')
        {
            enforceSign = true;
        }
  var text = $('#cke_wpTextbox1 iframe').contents().find('#bodyContent').text() || $('#wpTextbox1').val();
        if(enforceSign && !$('#wpMinoredit').is(':checked') && !text.replace(/(<nowiki>.*?<\/nowiki>)/g, '').match('~~~') && !window.location.search.match(/(?:\?|&)undo=/))
            {
                if(!confirm('It looks like you forgot to sign your comment.\nAre you sure you want to post it?'))
                {
                    e.preventDefault();
                }
        }
        });
    }
    }
});

. Hope that helps. UltimateSupreme ƒ(♫) 11:48 UTC, Thursday, 18 October 2012

Matching the wgCanonicalNamespace is more stable (and less complex) than matching the wgPageName. The other difference is the use of JQuery, but it's nice to see another approach on how to do the same task.
Another reason that alerts can be used over confirmation boxes is that, after telling people to sign by adding 4 tildes to the end of their post, they either sign or ignore the comment anyway. IIRC, I've come across zero cases where they said they still did not understand.
@Deltaneos: On the topic of format checks, I remember you saying something about page title length limits, and so I've been moving super long page title forums for a while. But I've never actually asked what the limit actually is. What is the character limit? A maxlength can be added. -Falzar FZ- (talk page|useful stuff) 12:52, October 20, 2012 (UTC)
You mean in this edit summary? I think the part of the summary that got cut off was something like "[scr]ewing up the index page" and the problem was that it was causing the "topic" and "last edit" columns to run over more than one line. Our content area is now smaller than it was back then, so if we were to impose a limit to stop this happening, it would probably be too short. We can at least use CSS to stop the "last edit" column from breaking if necessary. The technical maximum page name length is 255 chars, excluding the namespace prefix. Realistically we won't need anything that long, but I can't think of an appropriate lower maximum and there's probably a configuration setting that can be used to change it.
When people try creating a forum with a name that already exists, they are prompted to enter a new name (message), but not forced to start it with "Forum:". Would it be okay if we use this JS to also stop pages starting with {{Forum/header being created outside the Forum and Template namespaces? -- Deltaneos (talk) 16:47, October 20, 2012 (UTC)
Yes, that summary.
Why not make it so that it re-adds "Forum:" as you click "Create"?
There is another problem which is that the already exists page doesn't seem to load the forum header preload.
-Falzar FZ- (talk page|useful stuff) 22:49, October 20, 2012 (UTC)
I see no problem with that.
It used to work. I think this change is what messed it up. (You can see the entire PHP code by clicking on the revision IDs.) If I'm reading it right, in the old method when "action=create" was in the current URL, it grabbed $preload from the current URL before putting it in the form, and when "action=create" was not in the current URL, it got it from between the <createbox> tags. In the new method, it gets it from between the <createbox> tags regardless of whether "action=create" is in the URL or not. -- Deltaneos (talk) 02:07, October 21, 2012 (UTC)
I remember it used to work as well. So the real question would be, why isn't it fixed after all this time? -Falzar FZ- (talk page|useful stuff) 06:41, October 21, 2012 (UTC)
I meant to link to this when I said "this change", but the link I gave probably gave the idea.
I guess nobody reported the bug. But since preserving stuff like preloads after an existing name has been entered is the whole purpose of the CreateBox extension, you'd think that event would be tested immediately after a change is made. I might make an account for Wikimedia's Bugzilla later, unless someone who already has one wants to report it. -- Deltaneos (talk) 15:23, October 21, 2012 (UTC)
Reporting to Bugzilla wouldn't get us anywhere, since the extension is not in Gerrit (extensions that haven't been migrated by now are considered unsupported and their Bugzilla bugs are closed as WONTFIX). Our only real course of action, short of finding someone willing to migrate the extension and start maintaining it again, is to report to Special:Contact and hope that Wikia fixes it. ディノ千?!? · ☎ Dinoguy1000 19:29, October 21, 2012 (UTC)
Thought of an alternate fix, which I think would be preferred over using js.
Adding prefix={{NAMESPACE}}: to MediaWiki:Createbox-exists seems to fix the namespace problem.
If that fixed the problem, then wouldn't that mean the preload problem might not be that. Instead, you need to add the correct "preload=..." to MediaWiki:Createbox-exists somehow.
-Falzar FZ- (talk page|useful stuff) 13:49, October 24, 2012 (UTC)
The new signing feature is annoying for some places like Forum:Decks for Free!, we don't always comment on a post, but instead move or remove requests, having to sign afterwards is annoying. ---Dark Ace SP (Talk) 13:20, November 6, 2012 (UTC)

Moving posts count as a minor edit does it not?
alt+shift+s also bypasses it.
Both of which I have already mentioned.
There is also a way to personally disable it by adding var signCheck = "Disable"; to Special:MyPage/common.js. -Falzar FZ- (talk page|useful stuff) 13:37, November 6, 2012 (UTC)
Thanks Falzer. ---Dark Ace SP (Talk) 23:52, November 6, 2012 (UTC)

Preloads per namespace[edit]

Lets say you clicked http://yugioh.wikia.com/wiki/Card_Errata:Shyneet_Magician?action=edit&redlink=1 instead of having to go to another artworks page and hope it has the correct format and copy paste it. It will load a preload, in this case:

{{Navigation}}

{{Errata table
| lore0  = 
| image0 = 
| cap0   = [[Set Number]]<br />[[Set Name]]

| lore1  = 
| image1 = 
| cap1   = [[Set Number]]<br />[[Set Name]]
}}

Yes or no? (and if "new editors" "accidentally" misuse it, I could add a check which, if they try to save just the default preload without changes, it won't save) -Falzar FZ- (talk page|useful stuff) 13:23, November 10, 2012 (UTC)

Looks good to me. When you're adding the JS to stop "blank" creates, could you also add something to stop pages being created with just the MediaWiki:Newpagelayout? -- Deltaneos (talk) 13:28, November 10, 2012 (UTC)
Done, added to User:Falzar FZ/FormatChecker.js, seems to work, I'll leave it there for a while to see if I encounter any bugs and to see if there are other comments. -Falzar FZ- (talk page|useful stuff) 14:00, November 10, 2012 (UTC)
Works perfectly on Chrome, but doesn't do anything on Firefox. -Falzar FZ- (talk page|useful stuff) 01:54, November 11, 2012 (UTC)
{{Navigation2}} will now automatically change to {{Navigation|mode=nonGame}}.
I'm also trying to figure out what the most common defaults would be for new pages. For example, currently for Card Appearances, it would be ZEXAL, so the preload adds ZEXAL as the default. -Falzar FZ- (talk page|useful stuff) 13:35, November 11, 2012 (UTC)

Preview button[edit]

Is the interruption for when you click "Preview" necessary? Would it be okay to remove that part? I know there are ways of bypassing it, but I don't think there's any harm in someone previewing a talk page edit without signing. -- Deltaneos (talk) 01:57, November 17, 2012 (UTC)

In wikia skin, the preview button creates a box by adding new code to the page, which contains the preview and a new publish button. I couldn't figure out a way to change that new publish button because of that, so I added it to preview.
-Falzar FZ- (talk page|useful stuff) 12:03, November 17, 2012 (UTC)

Why don't you use the one they use on Narutopedia? It seems to free from this problem.199.190.46.185 (talk) 12:45, November 26, 2012 (UTC)

Are you talking about w:c:naruto:User:UltimateSupreme/SigReminder.js? That code scares me - there's no indentation, making it much harder to read; it seems to use a mixture of jQuery/ResourceLoader conventions and "vanilla" Javascript (that is, there are places where it doesn't use jQuery/RL where they could quite easily be used - and would make the code quite a bit more readable); it seems to use all sorts of overly-clever hacks that aren't explained anywhere (({edit:1, editredlink:1, submit:1})[mw.config.get('wgAction')]? what the heck is going on there?); and it shows a less-than-preferable understanding of regexes (/[\.\?\*\ \[\]\(\)\{\}\\\-\|\^\$]/g can be reduced to something like /[][.?* (){}\\|$^-]/g). If we were to use it here, I'd want a rewritten version that addressed these issues. ディノ千?!? · ☎ Dinoguy1000 19:26, November 26, 2012 (UTC)

Hi. Sorry if that thing scared you. Actually I am doing some experiments with it. The current version does work perfectly but you might find this version a little better and easy to understand.— UltimateSupreme ƒ(♫) 07:08 UTC, Tuesday, 27 November 2012

What really scares me is your sig. I have no love for editor signatures that require unsubstituted templates to prevent discussion pages from being swamped with extraneous code, and as far as I'm concerned, a #ifexist in a sig is an Unforgivable Sin.
Ignoring that, though, I do like the version of the script you've linked to quite a bit better than the live version, but there are still problems with it - again, no indentation makes it harder to read than it needs to be, and there are still spots not taking advantage of jQuery/RL - for example, the code (/(?:^\?|&)undo=/).test(window.location.search) can be replaced by something like mw.util.getParamValue('undo') (and the code where you're using a regex to match an HTML-like fragment... ha ha ha). ディノ千?!? · ☎ Dinoguy1000 07:57, November 27, 2012 (UTC)
Hmm... Thanx for the compliment.
Neither of those changes make the code faster or more reliable. The raw regex is slightly faster than calling the mw API. The second thing is just wrong, removing all of the escapes changes the meaning of the expression and breaks it. Strictly speaking, only 3 of those backlashes are actually needed but removing the others changes nothing; IMHO, it's more readable to make it clear that every one of those special characters is non-functional, the magic rules that change the meaning of them based on their position in the expression are harder to remember (and also cause errors in JSHint).— UltimateSupreme ƒ(♫) 09:48 UTC, Tuesday, 27 November 2012
Sorry about the sig rant, I just have rather strong opinions on them (I'm sure much of it arises from my time on Wikipedia). At least yours doesn't have an image in it. ;)
Performance of Javascript generally shouldn't be a concern, especially for something so minor as this. We're writing Javascript for modern browsers here, after all, not C for constrained systems. Therefore, if you have to choose between "slightly faster" and "more readable", you should go with the latter, and only change it when you determine that the code in question is a significant bottleneck speed-wise (though this is to say nothing of more encompassing rewrites that achieve the former while maintaining the latter). If you were truly concerned about eking every last drop of speed out of your script, you wouldn't be using jQuery at all, since a framework is always slower than "vanilla" code in an interpreted language.
I never tested the regex before posting it, which is why I hedged my bets by saying "something like"; I was fully prepared to find out that the particular expression I provided would be non-functional, but that doesn't change my point that all the escaping is unnecessary and unreadable. When you're dealing with something as information-dense as regex, more code is never more readable, regardless of what that code contains, unless you're breaking a regex down into two or more separate ones that, individually, are shorter than the original but, taken together, are longer (and, if you're not careful, even that can be harder to understand than the original regex). If you want to make it clear what characters are being removed, you use a comment rather than almost doubling the size of the regex with escaping. Comments would also be how you remember what characters get escaped by virtue of their position in the expression. ディノ千?!? · ☎ Dinoguy1000 18:12, November 27, 2012 (UTC)
Nothing much to bother about. Btw, is the welcome bot broken? I didn't recieve one yet.— UltimateSupreme ƒ(♫) 07:56 UTC, Wednesday, 28 November 2012
The welcome bot is disabled here. I think there's been mention of enabling it every now and then, but nothing's come of it. ディノ千?!? · ☎ Dinoguy1000 17:25, November 28, 2012 (UTC)
Indentation isn't really a problem for me. I just copy/paste it into Eclipse and Ctrl+⇧ Shift+F and it cleans up the format.
I'll comment on the rest after figuring out/analyzing how it works. -Falzar FZ- (talk page|useful stuff) 01:51, November 29, 2012 (UTC)
Actually the script I made was properly indented. Once I edited it using my mobile and that removed the indentation somehow. I have re-added them.— UltimateSupreme ƒ(♫) 05:31 UTC, Thursday, 29 November 2012

I agreed with Deltaneos for one big part - Archived Talk articles, I tried to put up old topics into one of my own Archived articles and it still asked me to sign a signature - suggest you to laying it off a little bit, can you? --iFredCat 12:46, November 27, 2012 (UTC)

The latest version which I haven't put up includes ignoring /Archive pages. I'm figuring out if there is a way to ignore moving content to another page. Maybe if your summary says something, ignore it. Or if the page that is going to be saved is significantly shorter than it was before, ignore it. -Falzar FZ- (talk page|useful stuff) 01:51, November 29, 2012 (UTC)