Forum:Adding Personal EditCount as a JS Variable

I'm trying to create a "Level" system to motivate users to edit, since I don't like the achievement system. The idea is to have a progress bar that resets every time you get so many edits, or "level up". For example, Level 1 will be 0 edits, Level 2 will be 1 edit, Level 3 will be 3 edits, Level 4 will be 6 edits, etc. The problem is, throughout all of the "wg" variables in the default Javascript, there is none for edit counts. So I set out to create one. I'm learning jQuery, don't know Javascript, and am stuck with the following results so far:

The idea is to import the number that's on their user page as a variable, which can be used to carry out functions for the rest of the project. The code is modified from a snippet I got from Wikia Staff a while back when trying to do the same thing:

As seen, this takes any element with the class "editcount" and loads in the user's number of edits from their Editcount page (user page in the case of my own code, above). Any ideas on whether/if this can be put into a variable for use in another function? Thanks. -Sherm/Talk


 * A few things - your code above (that you wrote) doesn't do what you want - you're setting  to a string that is the url for the user's userpage, plus a CSS selector. The CSS selector is specifically for the   jQuery method, which is specifically for using ajax to put HTML on the page. What you want to do is get the HTML for the editcount page, convert the table into a set of variables, and then create your progress bar accordingly. You can do this without creating another   variable (and, in fact, you will find it easier not to). You can use jQuery's   method to get the HTML for the editcount page. It accepts a callback function, which you can use to first parse the table for the information you want, and then build your progress bar. I would also suggest using   instead of , because this will decrease your bandwidth consumption.


 * Special pages ignore any action= values in the URL, e.g. http://community.wikia.com/index.php?title=Special:Editcount&action=render is not rendered, so printable=1 is your only recourse in that case.


 * Normally I would suggest that you should use the MediaWiki API (mw:API:Users) for this, but it doesn't seem to be very accommodating when it comes to getting user edit counts. E.g. http://community.wikia.com/api.php?action=query&list=users&ususers=Mathmagician&usprop=editcount doesn't display the correct user edit count (and that module can't get edit counts in individual namespaces, only the overall total).


 * Monch's suggestion about ajax-ing the edit count page may be your best option, because you can get edit counts by namespace that way. If you just need total edit counts, your plan to ajax the user's profile page will also work.


 * Okay, thanks for the help. As I said, I don't know JavaScript, so I'll be asking a friend what this means in literal terms, but the basics made sense. Thanks. -Sherm/Talk