MediaWiki talk:Gadget-HotArticleRate.js

Criticism/Todo list: Ponder Stibbons talk 19:09, 4 October 2011 (UTC)
 * I've made it so that clicking the rate button again hides the form. The form should be made persistent. The easiest way would be to save the return value of removeChild when the form is removed, and then reinsert that instead of reconstructing it.
 * There's lots of code duplication.
 * The Rate button should be next to the edit button, on the right side in vector, since that's where actions that you can perform on the page go.
 * Also, give the Rate button's li element the class "selected" when the rate form is shown.
 * Use sajax. It's purpose is to save you the trouble of having to do the whole if window.XMLHttpRequest stuff. The gettoken function already uses it.
 * POST requests should send their parameters in req.send, not in the url. See MediaWiki:Gadget-resurrect.js for an example of how it should be done. (Yeah, I know, I've done this myself too, just because I'm lazy)
 * And it would be nice to be able to edit an existing rated template, but that's a much bigger task.
 * Great list, thanks for going through this. I know there's a lot of sloppiness, and I'll do a bit of an overhaul soon. 22:54, 4 October 2011 (UTC)
 * Another thing. Captcha. Since it's on for all edits now, the gadget fails for non-autoconfirmed users. I don't know exactly how a script is supposed to do captchas, but the api does support it, see the documentation for action=edit on http://rationalwiki.org/w/api.php -- Nx  / talk 06:38, 5 October 2011 (UTC)

Version 2
Todo: Ponder Stibbons talk 03:05, 6 October 2011 (UTC)
 * Automatically resubmit in case of edit conflct if none of the values changed
 * Use mediawiki's injectSpinner/removeSpinner to put a spinner next to the rate button while submitting and waiting for a response.
 * See MediaWiki:UploadPreview.js for example.
 * Get the categories via the api when we're on the talk page
 * Figure out how to do captchas
 * The api returns a simple captcha instead of recaptcha, i.e. something like "what's 18+23" plus a captcha id. Just show the question to the user with an inputbox then resubmit with the result and the captcha id.
 * {"edit":{"captcha":{"type":"simple","mime":"text\/plain","id":"676842286","question":"70 - 6"},"result":"Failure"}}
 * ReCaptcha doesn't support the api. The api therefore returns a simple captcha, but ReCaptcha is still called to check it, and fails. ReCaptcha extension needs to be fixed.
 * preview icon (use code from User:Nx/Scripts/LinkSuggest.js)
 * display all icons from Category:Portal icons and allow user to pick one, similar to the smiley toolbar gadget.
 * Offer to create a redirect instead of explicitly specifying an image.

Fix
ratespan.appendChild(document.createTextNode("Rate")); ratebutton.appendChild(ratespan); holdingtab.appendChild(ratebutton);

should be changed to

ratebutton.appendChild(document.createTextNode("Rate")); ratespan.appendChild(ratebutton); holdingtab.appendChild(ratespan);

-- Nx  / talk 06:54, 23 July 2012 (UTC)