User talk:Lunarity

Welcome
Hi, welcome to Wikia Developers Wiki! Thanks for your edit to the HideRail/code.js page.

Please leave a message on my talk page if I can help with anything! -- Grunny (Talk) 02:20, 10 August 2012

Thanks
Thanks. I've been planning to do this, but my first attempt at using extend failed miserably :P. Thanks for revamping the image lightbox thing, but I've found a better solution in someone's global js that I'm gonna implement, mainly because it doesn't trigger on videos ;). Best, - Kangaroopowah  ( Talk ) 04:57, August 12, 2012 (UTC)

Why?
Why Base64 encode? . -- Kangaroopowah  ( Talk ) 17:23, August 12, 2012 (UTC)


 * It's more network efficient when cold loading and keeps everything together. Loading the images from an URL on the server means that you end up with 1 request for the script then once the script is ready, it downloads 2 more files separately afterward which has a high latency if the images are important to the UI. It also helps keep the images in the browser cache; there's no risk that the browser will kick out the images and have to download them again. As long as the script itself is being cached, the images will be cached as well.


 * It's not something you always want to do. HideRail only uses 2 images and they're both only about 500 bytes each; if they were more than 2KiB then I wouldn't do that (base64 increases the size to about 133%). It's also important that the images are unique; they aren't being shared with any other scripts or already used in Wikia's UI. If the images were already being used in the Wiki interface by Wikia then they would already be cached making the optimisation pointless (counterproductive actually). There's also a small runtime cost from the  variable since the JS engine may keep a separate copy of the base64 strings in memory for each tab depending on the browser architecture, so you really don't want them to get very big.


 * It's a trade-off, so not always a good idea; for a small script like HideRail using a few small unique images, it works, if they were bigger, there were 30 of them, or I was using Wikia's images then it wouldn't. Lunarity 04:34, August 13, 2012 (UTC)

HideRail is not working
Hi Lunarity, since your last edit from August 19 & 20, the HideRail button (Expand Content) is not showing anymore, and I'm wondering, what happend?, I hope you please fix that. PS: I have added the Spanish language. Silver ( Discusión ) 06:17, August 21, 2012 (UTC).


 * I added the missing . Arkondi (talk) 09:27, August 21, 2012 (UTC)


 * Sorry about that. I'm usually much more careful; I retyped that code instead of copy-pasting from my Firefox scratchpad and broke it in the process. I didn't notice because I never Ctrl+R'd it. Lunarity 10:16, August 21, 2012 (UTC)

jQuery / JSHint
Thanks for polishing InactiveUsers/code.js! I especially like the log function. I'll so steal that for future projects :)

You also converted me to jshint btw. Or rather your global.js did :) The (former) code was tested with:

/*jshint jquery:true, browser:true, es5:true, devel:true, camelcase:true, curly:false, undef:true, unused:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:true */

But what's the point of changing  to  ? How is that "not recommended"? That's news to me... -- peco e s 07:06, September 02, 2012 (UTC)


 * is fine when y is a DOM node but not when it's a jQuery, the constructor function maps jQuerys to  internally but is ridiculously slow at doing that (something like 10% slower then just calling   directly). IIRC, the jQuery devs recommend against it for this reason, can't remember where I read it right now though, I think it was a blog post somewhere. Lunarity 07:36, September 2, 2012 (UTC)


 * Hm. Alright. I'll take your word for it. -- peco e s 08:23, September 02, 2012 (UTC)


 * Here's the jsperf, the site was down earlier so I couldn't check. Anyway, I checked and the actual problem with  is that it doesn't really set the internal context properly, the new jQuery's internal context is still the document. If you pass a DOM node as y then you actually change the context to a proper subtree of the page which can make jQuery more efficient. Practically speaking, it doesn't seem to make any difference in the general case so it probably doesn't matter. Lunarity 18:09, September 2, 2012 (UTC)


 * Ah. Jsperf! That site is quite the treasure-trove, isn't it? I haven't written any tests myself yet, so I did not think of it right away, but I've spent quite a bit of time there rummaging through other people's test. Some of that stuff is downright astonishing :) And some of it is completely nuts :D
 * Well from the jsperf it would seem that the .find method is indeed faster - but only marginally so - hardly enough to mention for anything that processes a handful of nodes...
 * But, uh, um, how do you arrive at the conclusion that jQuery doesn't use the second parameter as the context? The context of the resulting jQuery object is not much evidence to support that. That context was probably copied over from the second parameter's context. -- peco e s 18:36, September 02, 2012 (UTC)


 * I didn't mean that it doesn't constrain the query, it definitely does that. I was talking about, that definitely isn't set unless you use a DOM node. OTOH, the only thing I've been able to dig up is this, this and this so I must have misremembered whatever it was that I was thinking of. In the source it only seems to be used by .live which is deprecated anyway. Lunarity 19:32, September 2, 2012 (UTC)

DisplayClock - Custom format
Do you think it would have an impact on performance if you use (if it is available)? Arkondi (talk) 16:23, September 2, 2012 (UTC)


 * That function is non-standard, it only works in Firefox; I'd have to polyfill it in everything else. In order for the behaviour to be reliable in every browser, I need a strictly defined set of acceptable % flags otherwise someone will get clever and do something which works in their browser but not for anyone else [the month name flags like %a are a big trouble spot, there is no reliable way to get those in pure JS which means that it'll work with  but not in my reimplementation since I can't emulate it].
 * I've tried to offload all the heavy processing onto regexs and other native code which means it should be reasonably lightweight, I hope. I'll profile it later to check. Lunarity 16:55, September 2, 2012 (UTC)


 * I currently found out that wiki-language-localised monthnames can be found in the variables  and  . This information can also be found in the respective MediaWiki messages (ie. MediaWiki:January, MediaWiki:Jan, MediaWiki:Monday or MediaWiki:Mon). Perhaps this information is useful to you. —Preceding unsigned comment added by Arkondi (talk • contribs)


 * I'm aware of, the problem with it is:
 * They are based on the Wiki's language, not the User's language.
 * They only exist on MW 1.19, I'd have to AJAX them manually on MW 1.16.
 * The days (Monday, Tuesday, ...) don't seem to be available in a variable at all, those require AJAXing them.
 * I don't really want to implement AJAX functionality in the clock if I can avoid it, it feels like overkill for such a simple widget. Lunarity 20:01, September 2, 2012 (UTC)

SpoilerAlert
I'm in the process of rewriting SpoilerAlert right now. It's probably best if you hold off on editing until I'm done. There's no need to duplicate efforts. LocalStorage e.g. is already in my new codebase. Just wait a few more days and you can fix my broken code ;) -- peco e s 01:39, September 05, 2012 (UTC)


 * Okay. It still has problems but I wasn't actually planning on doing anything else to it; I've only removed the Cookies logic, fixed for MW1.19 and fixed all the JSHint errors. BTW, I saw your comment on the talk page about creating a custom preferences page, do you have somewhere set up to discuss that or is it still too early? Lunarity 02:15, September 5, 2012 (UTC)


 * The preferences stuff is here: w:c:pecoes:Preferences.js. You can test it on any Preferences page via the console with
 * EDIT: If you have any comments post them on my wall at my test wiki, please! w:c:pecoes:Message_wall:Pecoes
 * peco e s 02:36, September 05, 2012 (UTC) -- peco e s 02:39, September 05, 2012 (UTC)

RevealAnonIP
Hey, thanks for helping to work on this. I've left a note for you on the talk page because there also some changes I'd like to make in addition to yours.

Help
Any idea why my global.js is not working? 11:03, September 13, 2012 (UTC)


 * Can you be more specific? Is it not working anywhere? It loads correctly for me [although I did just discover another UserBadges bug]. If your Wiki is 1.16 then  isn't going to work, you'll have to use   instead. Lunarity 11:27, September 13, 2012 (UTC)
 * Aha, its working on 1.19.1
 * Ok. So basically whats the difference between mw.loader.load and importScriptURI? 11:51, September 13, 2012 (UTC)


 * Short version or long version? Short version: importScriptURI is older, mw.loader is the new hotness. Long version: importScriptURI is a dumb function that just loads an arbitrary URL as a script, mw.loader is an interface to ResourceLoader and provides all sorts of error checking, module loading, dependency management and so forth. Unfortunately, mw.loader was added in MediaWiki 1.17, Wikia is on a blend of 1.16 and 1.19 so it doesn't exist on about half of the Wikis. I recommend something like:


 * This will use mw.loader whenever possible but will stop it from imploding on 1.16. Lunarity 12:22, September 13, 2012 (UTC)
 * [Hows it? 12:36, September 13, 2012 (UTC)


 * Erm, yeah. You copied exactly what I typed but you were supposed to replace the '...' part of the URL with the location of your global.js that you already had. I fixed the example. Lunarity 12:39, September 13, 2012 (UTC)

Lol. Fixed. Thanx. 13:07, September 13, 2012 (UTC)

Just had one more question. Will this be faster or this? 13:12, September 13, 2012 (UTC)


 * importArticles is faster than transclusion. importArticles minifies the script code (eliminates comments and white space which makes it smaller so it downloads quicker). Lunarity 13:46, September 13, 2012 (UTC)

Just something that crossed my mind, what if I use $.getScript in global.js? 16:08, September 13, 2012 (UTC)


 * Yeah, that should work fine. jQuery is 1.7.2 across every Wiki, both 1.16 and 1.19. Lunarity 16:24, September 13, 2012 (UTC)

User Badges
How can I use two custom badges? I tried using: window.UserBadgesJS = { custom: { UltimateSupreme: ['Kage'] } }; window.UserBadgesJS = { custom: { Cerez365: ['Foolish Master'] } }; and window.UserBadgesJS = { custom: { UltimateSupreme: ['Kage'] } custom: { Cerez365: ['Foolish Master'] } }; But both don't seem to work. So how exactly can I do it? 13:40, September 14, 2012 (UTC)


 * You're overriding the entire block, you need to add multiple entries, not replace the entire thing with different copies:


 * Lunarity 15:20, September 14, 2012 (UTC)

Wikia has changed how user scripts work

 * "Wikia has disabled User Scripts from running on MediaWiki namespace pages that end with a '.JS' file extension"

Is this a future change you're aware of that will be coming in say next week's technical release -- or something that's already live? Because I definitely disagree that it's live. I'm staring at MediaWiki:Common.js on several different wikis right now, and my user scripts are running perfectly fine.


 * It's live right now, I filed a bug report and was told "this is intentional, it will be extended to user scripts in a coming update". The reason is that crappy user scripts that crash can screw up Wikia's editor making it impossible to edit the script page itself and disable the broken script. [It's the Edit page, BTW, not the view. Try editing MediaWiki:Common.js, your scripts won't load]. Lunarity 03:32, September 18, 2012 (UTC)


 * Does that mean user scripts won't run at all anymore on the edit page? -- peco e s 03:36, September 18, 2012 (UTC)


 * No, they still load on other Edit pages, just not the Edit pages for MediaWiki:Common|Wikia|Monobook.js or User:Name/wikia|monobook|common|global.js. They also load on all CSS pages, MediaWiki:whatever.css or not (That could be fun if you have  in your global.css; won't stop you from editing global.js but it will stop you from editing global.css).
 * Unfortunately, the entire point of AntiUnicruft was to intentionally run on Common.js, so that script is basically screwed now. I could work around it by AJAXing the page when manually prompted via a tool button added to the admin dashboard but that isn't as nice (and it means i18n again). Lunarity 03:46, September 18, 2012 (UTC)


 * Phew! That just scared me. Thanks for clearing that up :) Disabling those scripts while editing them, makes a lot of sense actually. -- peco e s 03:51, September 18, 2012 (UTC)

Oh, it's while editing - I didn't catch that part. While that does suck for AntiUnicruft... I suppose the point about user scripts breaking the editor kind of makes sense from a safety perspective, although it's not like you're completely out of options...
 * 1) Disable JavaScript in your browser and edit the page using Monobook.
 * 2) Create another account, admin yourself, edit the file.
 * 3) Use the MediaWiki API to make the edit.
 * 4) You can block the user script that is causing the problem (or any JavaScript/CSS files you want) by writing a one-line custom Adblock filter.


 * I know :). I've broken myself a couple of times, I just add an adblock rule for my global.js to disable it, refresh and fix it. That was the reason Wikia gave, I'll dig up the exact response:

Rappy, Sep 14 07:29 pm (UTC):

Hello,

Thanks for contacting Wikia. This is actually intentional. The editor relies heavily on JS to load and any errors in custom user or site-wide JS can result in them not being able to open the editor at all. This allows users to fix errors in user and site-wide JS that would otherwise not be editable.

Soon, this will be extended to user's global/common/wikia/monobook.js pages as well.

Timothy Collins

Wikia Community Support


 * Lunarity 04:41, September 18, 2012 (UTC)

User Tags
With the UserTags, can you help me with something?

I'm trying to add a "Retired bureaucrat" tag to w:c:bloons:User:Roberto1205, however, it doesn't display properly. At the moment, this is my wiki's js configuration:

Thanks! — SW8573 (Message Wall) 07:35, October 9, 2012 (UTC)


 * The problem is that you haven't defined any text for the 'retired bureaucrat' tag, you need to actually tell it what to display:


 * If you open your web console (Press Ctrl+Shift+K in Firefox, or Ctrl+Shift+J in Chrome) then you'll see a bunch of messages produced by the script, amongst them is " ". BTW:
 * The  module is actually , not  . Sorry about that, it was a typo in the article.
 * Is Zelda311 the original founder? You don't need to manually add the group to the real founder unless Wikia is failing to tag them properly (although the founder tag won't show up in monobook unless you add it manually, if that's what you're trying to do then it's fine).
 * You don't need to set  to true, it is automatically enabled in monobook for you [it's more efficient if you don't set it to true as it reduces the amount of data queried from the server in Oasis, although there aren't any bad side effects from leaving it as it is].
 * Is there a precise reason you're defining custom text for the bot-global group? The script has built-in text for that and will automatically translate, overriding it like that will break the translation feature (i.e. someone who has their language set to German will see the English "Global Bot" instead of German "Globaler Bot")
 * Lunarity 09:18, October 9, 2012 (UTC)


 * Has been fixed.
 * Yes, Zelda311 is the original founder, but his rights were revoked due to inactivity, and his tag disappeared along with the rights.
 * Will hopefully be fixed ASAP
 * As above.
 * Thanks for the help, Lunarity. — SW8573 (Talk) 11:23, October 9, 2012 (UTC)


 * All fixed/good now :D — SW8573 (Talk) 11:35, October 9, 2012 (UTC)

It isn't working. I get this error:  ~ 09:34, October 16, 2012 (UTC)


 * Interesting. Apparently neither Firefox or Internet Explorer care about the console object but Chrome does. Odd. It's fixed now, thanks. Lunarity 09:49, October 16, 2012 (UTC)


 * I was actually having this same issue a couple days ago when writing my own logging code. Apparently it's a feature -_-


 * Well, log/info/etc are behaving as prototypical members of the Console interface so they expect  as the   object rather than the   object. It makes sense and I understand exactly what happened, my problem is actually that Firefox didn't complain. The mistake was accessing a non-existent object property and using that  as the scope after I moved the real value to a closured variable instead, the mistake was pretty obvious when I re-read the code but Fx really should have let me know I'd screwed that up. Lunarity 02:51, October 17, 2012 (UTC)


 * I still think the fact that it throws an exception is a bit extreme... preferably' log shouldn't care about  and should work in every context. Why the heck does Console need to ever use its   value for anything? It's not like you would ever plausibly have more than one instance of a Console object, it might as well be static...


 * Every frame and IFRAME has its own  object with its own separate   object. Lunarity 03:23, October 17, 2012 (UTC)


 * Oh yeah, I forgot about those. And JavaScript is single threaded.

Thankyou
The things you wrote gave me a good help modifing my wiki (I'm an admin on my wiki). Anyway, thankyou!

Help with a depricated script
Actually, there is a script which got depricated after the upgarde and someone requested me to see if I can make it compitible. But currently I am away from my home at a place without comp. I am using mobile currently and dont think i would return any soon. If you could upgrade the script, it would be really helpful —UltimateSupreme (Talk) 08:31, October 24, 2012 (UTC)

I'm not clear on what's deprecated about it. The code is ugly but seems to work fine. I'm not aware of any upcoming changes that would break it, especially since it's used on Commons, but I cleaned it up anyway: Lunarity 09:53, October 24, 2012 (UTC)

Why is it so big?
Why is HideRail SO BIG??? ;) I'm not saying it's a bad thing, but couldn't you the same thing with less code? -- Kangaroopowah  ( Talk ) 20:35, October 27, 2012 (UTC)


 * A lot of things seem simple at first glance but aren't when you dig into it. Creating toolbar buttons is a major pain in the ass; most scripts are killed by the "Customize" button which clears the entire toolbar and replaces it. HideRail is the only script I know of which isn't killed by it. Then there's the popup menu, something which doesn't always exist depending on configuration so has to be handled conditionally which complicates things (the fact that I'm sticking checkboxes in it when Wikia's code is only designed to handle links doesn't help either).
 * The actual rail hiding part of the code is quite small, but the other parts are not so much. Creating plugins for the Wikia Editor, especially plugins which drill into the internals of other plugins, is complex. Widening and narrowing the editor involves a lot of CSS and editor internals fiddling to avoid the multitude of bugs that collapsing the Visual Editor's rail causes.
 * Then there's rewriting the SASS stylesheets, I originally did that the easy way but the easy way causes the page to unstyle and restyle which is ugly so that became quite complicated as well (cloning tags, rewriting the URLs, being able to add and remove the cloned tags from the document [in the specific right locations] to turn it on/off without reparsing the CSS files each time [which is noticeably slow because they're big]). Then I had a bunch of problems with transitions which were causing the page to animate as it loaded.
 * The current code is a WIP, I'm not happy with it but I was forced to release it by the WikiaGrid which broke the previous version. I'm still deciding on what I'm going to do about it but HideRail isn't high on my priority list at the moment. Basically, the code sucks, but it works, so I'm not devoting a lot of time to it currently. If you have an idea for making it simpler without losing any features then I'm willing to listen. Lunarity 21:54, October 27, 2012 (UTC)


 * There actually i a easier way to do the toolbar buttons... see VDA it's currently broken because after the grid layout, wikia changed the selector for the toolbar but once you fix that it should work. -- Kangaroopowah  ( Talk ) 16:53, October 31, 2012 (UTC)


 * That's doing what I already do, but less efficiently. It also has the same problem that most of these scripts have: it dies when you click "Customize" &gt; "Save". The simple plugin framework is interesting though, I might use that. Lunarity 19:06, October 31, 2012 (UTC)

SigCheck Modification
Is there a way for the script to be modified so that it will warn users if there are no categories on a page. I'm not much of a JS expert, but glancing over the SigCheck script I noticed that it has been written to only apply to forum and talk namespaces. If it could be written to work with categories, then I would hope it could be modified to work with any namespace except for Thread, Message Wall, and Blog (the first two don't need categories and the third gets the default category of "blogs posts.")

If it is possible, would you be able to write it? As I said I'm not much of a JS expert. Paper  Talk   My Work  15:49, October 28, 2012 (UTC)


 * You are prohibited from doing that. Wikia does not permit forced categorisation. Lunarity 16:17, October 28, 2012 (UTC)
 * Maybe they would allow if its only a confirmation box. Ask tem first but.— UltimateSupreme (Talk) 02:51, October 29, 2012 (UTC)

Mentor
Can you mentor me in the art of coding? Forsbern (talk) 17:30, October 28, 2012 (UTC)


 * I'm not sure I understand what you mean. If you have a specific question about a particular problem then you can ask on the support requests forum at Community. I don't think I'd make a very good tutor, and it isn't really something I want to do. You might want to try the administrator mentoring project, they might be able to help if you want general pointers. Lunarity 02:18, October 29, 2012 (UTC)

mw.util and Resource Loader
I noticed you tweaked a few scripts that depend on mw.util, including RevealAnonIP. What's the rationale behind this? Is this a fix for a demonstrable bug or a "let's play it safe" thing?


 * It's mainly just "play it safe" since a lot of code depends on  so it is usually loaded, but that is not guaranteed. I looked into how ResourceLoader works a few weeks ago and discovered that only mw.config, mw.messages, mw.libs, mw.loader and jQuery exist by default, everything else (mw.user, mw.util, mw.Api, etc) are optional modules that may or may not be loaded.
 * This has actually bitten me twice already; the first time was when I tried to use  in UserTags which "worked" until it turned out that it wasn't loaded in Chrome (  seems to be loaded by something inside Wikia's code in Firefox and Internet Explorer, but not in Chrome). The second time was when I tried to use   in MediaWiki:Common.js and I was getting random crashes due to something "not being a function". That turned out to be that sometimes   hadn't actually been loaded by the time Common.js ran so I had to explicit declare a dependency on   to fix it. As such, I've become much more careful about actually declaring my dependencies in scripts to the loader. Lunarity 05:08, October 30, 2012 (UTC)


 * Here's what I've figure out:


 * You can get a list of all registered modules with
 * You can query the state of modules on that list with
 * The possible states are: 'registered', 'loading', 'loaded', 'ready', 'error' or 'missing'
 * You can load registered(!) modules with .   takes three arguments: the module name, the callback in case of a success and lastly the callback in case of a failure. The last two parameters are optional.
 * You may also request modules with  but it doesn't offer callbacks which makes it inferior to.


 * -- peco e s 05:52, October 30, 2012 (UTC)

(the stuff that was here, was move below to module list)

(reset indent) Interesting. I've looked at Resource loader on mediawiki.org and done a little digging through the codebase on github, but I've never seen a typical case of a user or site-wide script fail because it runs before mw.util or some other mediawiki code. If you do have a reduced test case or really any example you can show me a script failing for lack of declared dependency, please share (especially if the failure happens after ). All empirical evidence in my experience points to the contrary, and I would like to be convinced by means of demonstrable bug.
 * ListFiles uses the same $.fn.makeCollapsible and I've never seen a single random crash.
 * Never saw RevealAnonIP fail while using mw.util for a month before you declared the dependency.
 * I do know by experience that if you place a script on a page with verbatim tags, the script will (highly reproducible) run before the mediawiki code or even jQuery are available simply because the script tag is higher up in the DOM than all the stuff dumped by resource loader. Not a huge concern, edge case.
 * I stuck  in my wikia.js on my test wiki and I've done about 30 page loads with action=view (I use Chrome) and never seen it fail.
 * I do see it fail with action=edit, it alerts undefined (and then you check the console later and mw.Api is defined). I place this as an edge case, just like scripts failing with verbatim tags. Wonky behavior is expected when the editor is opening. Delaying until  is sufficient.


 * The question is one of technical correctness vs pragmatism, or, more simply "future proofing" vs "what happens to work now". Failing to declare a dependency on mw.util is a bug by simple definition; the code is incorrect (an interface contract violation with ResourceLoader) if it does not. The ResourceLoader docs on MediaWiki.org say as much. Does the bug cause visible problems? Usually not; like I said, most code depends on mediawiki.util so it usually works because you can piggyback on other people doing the right thing while you don't.
 * The problem I had with Common.js was because I had the code in Common.js itself, ListFiles is loaded by importArticles/importScriptPage which induces a delay that makes the race condition much less likely. The fundamental problem is that if you look at what the page does, you'll see a giant asynchronous request for a ton of modules, one of which is . Since that request is issued before the browser starts executing Common.js (module=site), it will usually complete before the importArticles does so there's no problem. Code in Common.js itself does not have that luxury; sometimes Wikia's servers are slower than usual, then the race condition hits when things don't load in the perfect order and you get random crashes. (Tends to happen most frequently with a cold cache, hot cache files run instantly without the unpredictable download time race)
 * [I can assure you that  does not load consistently, on user profile pages it was absent on some wikis. Avatar Wiki was the biggest offender, try this page in Chrome,   "undefined"] Lunarity 08:17, October 30, 2012 (UTC)


 * Actually, I just double checked.  is a dependency of  . It has nothing to do with Chrome, it has to do with not being logged in. People who are logged in get , anons do not get  . Lunarity 08:37, October 30, 2012 (UTC)


 * Failing to declare a dependency on mw.util is a bug by simple definition ... The ResourceLoader docs on MediaWiki.org say as much
 * 1) Link please, quote please (spell it out explicitly for me, if you would be so kind). 2) Sounds like a reasonable concern if you're talking about system admin writing a MediaWiki Extension or Gadget which is included on his own MediaWiki installation. 3) Which is a different thing altogether from writing site-wide and user scripts on Wikia.


 * The fundamental problem is that if you look at what the page does, you'll see a giant asynchronous request for a ton of modules, one of which is .
 * Clarification: Are you suggesting that Resource Loader modules may load asynchronously? Because that's news to me. Here's what my knowledge tells me:
 * tags that are part of the HTML document (not dynamically inserted by another script, e.g. importArticles / importScriptPage) will load synchronously when parsed with the rest of the HTML.
 * Resource Loader (PHP server-side) dumps module tags, site-wide tags and user tags inside the tag near the bottom in the HTML document served to the browser. These will all load synchronously (unless you use importArticles / importScriptPage etc. to generate an asynchronous request).
 * Furthermore, the order of those tags in the HTML document is reliable and consistent. First comes Resource Loader modules. Then comes site-wide scripts (Common.js). Then comes user scripts (Username/global.js).
 * P.S. I checked avatar wiki in Chrome and mw.Api was consistently defined.


 * (Edit conflict) Your understanding of script tags is correct, however makeCollapsible is not a script tag. There is no script tag for the ResourceLoader modules in the HTML, the tag that downloads runs those ResourceLoader scripts is generated by  dynamically as the page is building. Unfortunately, the site scripts (Common.js) ARE script tags in the HTML so those do run synchronously, unlike the modules on which they depend. [Try doing a "View Source" and search for "makeCollapsible", you won't find it. It's a dynamic script tag created at runtime. You can find a script tag for   though, this is the root of the problem.]
 * Unfortunately, the MediaWiki site is badly organised so I can't dig up the exact page as I didn't bookmark it, there is this though which talks about gadgets being equivalent to extensions.
 * You missed my appendix,  is required for the Followed Pages feature. Try logging out, you'll find   disappears. Lunarity 09:57, October 30, 2012 (UTC)


 * Amendment/question to #2: Yes, but the Resource Loader module tag is:


 * And if you look inside of that file, you see:


 * ^ addSource creates a dynamic script tag, e.g. the "giant asynchronous request" you vaguely referred to?


 * adds entries to 's internal state, it doesn't download anything, merely says "go here when you want to download stuff". The purpose of the startup module (which I linked to on GitHub earlier, see ResourceLoaderStartUpModule) is to transfer all the wg vars, the resource loader module registrations and to automatically start downloading the mediawiki and jquery modules. It does not load any modules other than those 2.

 if(window.mw){ mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax","mediawiki.user","mediawiki.page.ready","mediawiki.action.watch.ajax","mediawiki.legacy.mwsuggest"]); }
 * This is where the default module load comes from, this happens right before the modules=site and modules=user. This is supposed to be synchronous but it has known bugs (according to the code) where it is, in fact, NOT synchronous. Lunarity 09:57, October 30, 2012 (UTC)


 * I should point out that everything in that list above is decided by PHP extensions on the server, entries can be added or removed at any time by Wikia, and the stuff in it can vary from wiki to wiki depending on what extensions are active or not. Lunarity 10:05, October 30, 2012 (UTC)

(Reset indent) I found some more related materials: here and here. The MW devs are moving in to a "user script = ResourceLoader module using special page format" design, as mentioned here. The direction of movement is this bug which is about the actual implementation of gadgets = ResourceLoader modules. Lunarity 18:30, October 30, 2012 (UTC)

mw.util and Resource Loader, part 2

 * "Your understanding of script tags is correct, however ... There is no script tag for the ResourceLoader modules in the HTML, the tag that downloads runs those ResourceLoader scripts is generated by  dynamically as the page is building. Unfortunately, the site scripts (Common.js) ARE script tags in the HTML so those do run synchronously, unlike the modules on which they depend ... this is the root of the problem."
 * Understood. Extremely counter-intuitive... but okay. (Resource loader) Why in the world would you use JavaScript to load JavaScript when you have access to the PHP layer? Put it all in the HTML. Make. It. Synchronous. That way all the dependencies are guaranteed to be loaded before modules=site and modules=user ... and end-users don't have to litter their code with.
 * What I don't like about : It uses callbacks. So if you have 10 dependencies, you need 10 different callbacks. And if you need ALL 10 of those dependencies to be ready before you can execute something, then you have to do some more juggling. Whoever thought up that brilliant idea? -sigh- If this were C or Java where you just declare your includes/imports at the top of the file, that'd be perfectly reasonable. But no, we have callbacks ... because somebody thought it would be a good idea for Resource Loader to load extremely important modules asynchronously?


 * Actually, source code for  says it accepts an array of modules for its dependencies parameter (despite the fact that documentation at ResourceLoader/Default_modules only demonstrates a string with a single module as dependency), so you wouldn't need 10 callbacks... whew. Still irks me that I must now think about dependencies due to some hidden, asynchronous resource loader module nonsense.


 * I can confirm that mediawiki.Api is not a core module. I tried to use it for the Preferences module and had quite the opposite experierence from you (Mathmatician): It wasn't loaded on any of the pages I tried it on.


 * It's a bit baffling that mediawiki.Util is not a core module that's loaded by default. The list of modules that use it, seems to be so long, that I wasn't even aware it's not loaded by default. That seems to be an omission that will probably corrected eventually.


 * But I'll probably stop using it for now - unless I have to load something else as well. For what it does, mediawiki.Util doesn't seem to be worth the wait. -- peco e s 21:54, October 30, 2012 (UTC)


 * is a dependency of  so it should always be loaded by that if nothing else AFAICT. The only problem is that it is loaded asynchronously due to the aforementioned problem that   is not reliably synchronous. Declaring a dep on it should only cause a load delay in the rare circumstance that the not-synchronous bug happens + importArticles completing before the load.php for the start-up modules does.   is a bigger problem since that is only loaded if you have the follow/unfollow button in your Wikia toolbar. Lunarity 22:26, October 30, 2012 (UTC)


 * (Edit conflict) The developers like the fact that the PHP doesn't have to do any dependency graph calculations. The network of dependencies can be somewhat complex if you look at the Resources.php file, the ResourceLoader design pushes the graph construction and execution onto the client so the server can be stupid and just accept an array of names without doing its own dependency checking. I agree with you though, the server should be the smart part, not the client scripts.
 * BTW, even if it did require separate calls, you wouldn't necessarily need 10 callbacks, there are alternative patterns like this:


 * Of course, you should use the array form instead since doing it this way will cause 10 separate  requests.
 * As far as declaring dependencies goes, it's one of the standard drudgeries of programming; not declaring dependencies means importing everything which has negative performance and size consequences, it also floods the namespaces which makes the software difficult to understand and debug. OTOH, I have my own problem with RL, specifically that it tries to implement AMD but does not do so correctly [the callback receives no parameters]. Lunarity 22:14, October 30, 2012 (UTC)


 * That code example is a bit silly. Why trigger 10 requests, when one would suffice? Also: If you must indeed chain Deferreds use $.when - it's already built into jQuery. -- peco e s 22:37, October 30, 2012 (UTC)
 * peco e s 22:37, October 30, 2012 (UTC)


 * doesn't return promises, the only thing it does is invoke the callback. Mathmagician was saying that he'd need 10 callbacks to deal with an asynchronous function that only took callbacks instead of using promises. I was simply demonstrating that you don't actually need to nest 10 callbacks to deal with that sort of problem. Of course, if you can get promises instead, conglomerating them with  is definitely the best way to go. Lunarity 22:46, October 30, 2012 (UTC)


 * You're right. It doesn't return promises. I stand corrected. I just assumed because that's what jQuery does with $.getScript and $.ajax. -- peco e s 22:59, October 30, 2012 (UTC)


 * That is a neat pattern. I haven't really used Deferreds (and hence Promises) before, so that wouldn't have been immediately obvious to me. This is probably a case of "the asynchronous stuff isn't really as bad as I think it is, but it seemingly creates hard to solve problems if you don't have the right knowledge to work with". Although, I am comfortable with callbacks off of $.ajax, which returns an object that implements the Promise interface, so it's sort of like I've been using (one type of) Promise all along and just didn't really pay much attention to it.

(Reset indent) Hm. How about correcting the loader then?

peco e s 00:09, October 31, 2012 (UTC)


 * You can do that, certainly. It's less efficient though since you're creating a lot more deferreds. Of course, this is all academic anyway since you'll usually only need the one callback for your entire array of dependencies (which functions as an implicit  across all of the array entries anyway). Lunarity 00:58, October 31, 2012 (UTC)

Resource Loader (Again)
"A call to document.write from an asynchronously-loaded external script was ignored. @ http://slot1.wikia.com/load.php?debug=false&lang=en&modules=mediawiki&only=scripts&skin=oasis&version=20121031T183057Z&*:7"

*facepalm* (That's inside )

Code that caused this? Race conditions; race conditions as far as the eye can see... god damn it.

The solution to this crap is: Argh. This is what happens when you don't commit to being asynchronous; the fact that the loader tries to have it both ways just creates more problems than it solves. The best part is that there is no way to recover from this fault! Once the stupid  fails, RL will get stuck in the   state while it waits forever for a request that it didn't successfully make in the first place. I don't really want to imagine what happens if you do a synchronous  after something else already made an async request for some subset of the same modules that the second one needs, I'm sure that will work perfectly (not). Lunarity 03:20, November 1, 2012 (UTC)

Module list
(split from previous discussion)

The relevant code (Wikia's modified versions) files are here (standard modules) and here (Wikia's non-standard extra ones). There's also the relevant classes like which is the one responsible for dumping all the , the list of module registrations, and inserts the script tags for the "jquery" and "mediawiki" core modules [the only "guaranteed" ones which I was alluding to earlier]. You can also stare at the modules themselves here. (The official mainline source is in Gerrit which I find to be pig-dipped-in-molasses slow, GitHub is much faster for browsing through) Lunarity 06:18, October 30, 2012 (UTC)


 * Looking at the list of all those modules I cannot tell from the names what most of them are supposed to do. Maybe we should start a list here and add a little context to the names... -- peco e s 06:49, October 30, 2012 (UTC)


 * There's somewhat poor descriptions of most of them on mediawiki.org. Lunarity 08:17, October 30, 2012 (UTC)

(Reset indent) Ha. If only... :) Here's the list of modules that Wikia lists which aren't features on that MediaWiki page:

peco e s 13:29, October 30, 2012 (UTC)


 * site &mdash; PHP class that is responsible for merging Wikia.js, Common.js, bureaucrat/sysop/user/insert-group-here.js into a single minified file.
 * noscript &mdash; generates &lt;noscript&gt; CSS link stylesheet tags to compensate for browsers with JS disabled
 * startup &mdash; explained above, dumps the server state (module list, wg vars) into a JS file
 * user &mdash; Same as site, but for users. (Merge wikia.js/global.js/common.js into a single minified file and return it)
 * user.groups &mdash; these are parts of.
 * user.options
 * user.cssprefs
 * user.tokens &mdash; contains the edit and watch tokens for api.php, these are always available separately from  itself
 * filepage
 * skins.chick &mdash; these are all generic code specific to a particular skin, like JS support for special buttons.
 * skins.cologneblue
 * skins.modern
 * skins.monobook
 * skins.nostalgia
 * skins.simple
 * skins.standard
 * skins.vector
 * jquery &mdash; self explanatory, this is the jQuery core.
 * jquery.appear &mdash; Adds a new jQuery event for whenever something scrolls into view
 * jquery.arrowSteps
 * jquery.autoEllipsis &mdash; Finds text that is too long and chops the end off, replacing it with an ellipsis
 * jquery.byteLength &mdash; determines length of string in bytes instead of characters. I wouldn't use this though, the algorithm doesn't seem to know the difference between a byte and a short.
 * jquery.byteLimit &mdash; plugin for limiting a textbox length by bytes instead of characters (e.g. UTF-8 chars, 1-5bytes=1char)
 * jquery.checkboxShiftClick &mdash; allows you to check and uncheck a heap of checkboxes at once by clicking one and holding shift when clicking the second (every box in between will be toggled as well)
 * jquery.collapsibleTabs &mdash; something to do with making the top tabs in Monobook/Vector collapsible.
 * jquery.colorUtil &mdash; this is a jQuery plugin for converting colors, e.g. take a  and convert it to RGB so it will work in IE which doesn't support HSL. It's also useful for manipulating colors, you can convert an RGB value to HSL, tweak it (reduce the luminance by 10% to make it darker) then convert it back to RGB.
 * jquery.delayedBind &mdash; this is a jQuery plugin for debouncing event handlers
 * jquery.expandableField &mdash; automatic animation plugin, makes textboxes wider when they gain focus and shrinks them when they lose it
 * jquery.farbtastic &mdash; A color wheel widget for letting the users pick colors.
 * jquery.footHovzer &mdash; floating footer (like the Wikia toolbar), it's an arbitrary space in which to stick things that you want to float in the viewport. It's used to replace console.log in IE since that doesn't work reliably there.
 * jquery.form
 * jquery.getAttrs
 * jquery.highlightText
 * jquery.hoverIntent
 * jquery.localize
 * jquery.makeCollapsible &mdash;
 * jquery.messageBox
 * jquery.mockjax &mdash; You can find this with Google, it's a plugin for testing your code using fake AJAX responses (replaces $.ajax with a fake one that returns predefined data)
 * jquery.mw-jump &mdash; accessibility feature for links (something about motor impaired people, the code doesn't really explain)
 * jquery.mwExtension &mdash; legacy stuff, includes trimRight, trimLeft, escapeRE and a few other random functions.
 * jquery.qunit &mdash; Unit test framework, don't know much about it
 * jquery.qunit.completenessTest
 * jquery.spinner &mdash; A throbber.
 * jquery.tabIndex
 * jquery.textSelection &mdash; framework for selecting text in a textbox, or design mode iframe. Also allows you to wrap the selection with prefix and postfix. Used by Edit Tools (e.g. the toolbar buttons use this in the Source mode of the editor to insert the stuff, I've used it here)
 * jquery.validate
 * jquery.xmldom
 * jquery.ui.core &mdash; jQuery UI framework pieces.
 * jquery.ui.widget
 * jquery.ui.mouse
 * jquery.ui.position
 * jquery.ui.draggable
 * jquery.ui.droppable
 * jquery.ui.resizable
 * jquery.ui.selectable
 * jquery.ui.sortable
 * jquery.ui.accordion
 * jquery.ui.autocomplete
 * jquery.ui.button
 * jquery.ui.datepicker
 * jquery.ui.dialog
 * jquery.ui.progressbar
 * jquery.ui.slider
 * jquery.ui.tabs
 * jquery.effects.core &mdash; more jQuery UI pieces
 * jquery.effects.blind
 * jquery.effects.bounce
 * jquery.effects.clip
 * jquery.effects.drop
 * jquery.effects.explode
 * jquery.effects.fade
 * jquery.effects.fold
 * jquery.effects.highlight
 * jquery.effects.pulsate
 * jquery.effects.scale
 * jquery.effects.shake
 * jquery.effects.slide
 * jquery.effects.transfer
 * mediawiki &mdash; the MediaWiki core module.
 * mediawiki.api.category &mdash; parts of mw.Api for various specific interfaces. This one is for requesting categories a page belongs to, determine if a category exists, etc via API.
 * mediawiki.api.edit &mdash; mw.Api for editing API
 * mediawiki.api.parse &mdash; action=parse
 * mediawiki.api.titleblacklist &mdash; add page title to site's black list (if Extension is installed and active)
 * mediawiki.api.watch &mdash; API for add/remove from Followed Pages (Watchlist)
 * mediawiki.debug &mdash; not sure, some sort of "debugging toolbar"
 * mediawiki.debug.init
 * mediawiki.feedback &mdash; some sort of feedback prompt dialog thing
 * mediawiki.htmlform
 * mediawiki.Title &mdash; Cut down JavaScript implementation of the PHP Title class.
 * mediawiki.Uri &mdash; Library for working with URLs. Provides window.location for any arbitrary URL string (separates out query string, path string, port, host, protocol, hash).
 * mediawiki.action.edit &mdash; these are UI components, this is for edit page, things like the MediaWiki toolbar (Bold/Italic/Signature/etc in Source mode)
 * mediawiki.action.history
 * mediawiki.action.history.diff
 * mediawiki.action.view.dblClickEdit &mdash; implementation of the "double click heading to edit" feature from Special:Preferences
 * mediawiki.action.view.metadata
 * mediawiki.action.view.rightClickEdit &mdash; dblClickEdit, but right clicking instead
 * mediawiki.action.watch.ajax &mdash; Followed pages framework (implements Follow/Unfollow for the toolbar)
 * mediawiki.language &mdash; framework for i18n stuff, handles number conversions, plurals, per gender nouns, etc
 * mediawiki.jqueryMsg &mdash; A basic WikiText-&gt;HTML parser. It exists to let you do
 * mediawiki.libs.jpegmeta
 * mediawiki.page.ready &mdash; Standard page features like mw-collapsible and such, all that automatic JS stuff that happens when the page loads.
 * mediawiki.page.startup &mdash; marks the page with the JS enabled CSS class
 * mediawiki.special &mdash; these are JS pieces for various special pages
 * mediawiki.special.block &mdash; Special:Block, etc
 * mediawiki.special.changeemail
 * mediawiki.special.changeslist
 * mediawiki.special.movePage
 * mediawiki.special.preferences
 * mediawiki.special.recentchanges
 * mediawiki.special.search
 * mediawiki.special.undelete
 * mediawiki.special.upload
 * mediawiki.special.javaScriptTest
 * mediawiki.tests.qunit.testrunner
 * mediawiki.legacy.ajax &mdash; these are all old things that are being phased out (these all add stuff to  rather than  )
 * mediawiki.legacy.commonPrint
 * mediawiki.legacy.config
 * mediawiki.legacy.IEFixes
 * mediawiki.legacy.mwsuggest &mdash; search suggestions while you type
 * mediawiki.legacy.preview &mdash; AJAX preview of some sort, not Wikia's, some other one for Monobook/Vector
 * mediawiki.legacy.protect &mdash; action=protect
 * mediawiki.legacy.shared
 * mediawiki.legacy.oldshared
 * mediawiki.legacy.upload &mdash; Special:Upload
 * mediawiki.legacy.wikibits &mdash; legacy junk: importScript, importScriptURI, etc
 * mediawiki.legacy.wikiprintable

Lunarity 15:29, October 30, 2012 (UTC)


 * Wow! Nice! You've done some research already! :)


 * Okay, I admit some of the stuff on the list is quite obvious. All the jQuery stuff e.g. This list simply contains the array keys from https://github.com/Wikia/app/blob/dev/resources/Resources.php . I did not hand-edit it. But I will. This should be turned into a page of its own. If we can write a few lines about each module - plus some deep links to the jQuery and mediaWiki docs - we'll do ourselves and others a big favor. This needn't be a huge project either. Just something we complete piece by piece as we go along... -- peco e s 21:54, October 30, 2012 (UTC)

Rating
Hey there Lunarity! :D

How's it hangin'?

It's amazing that you've done so much for this wiki in such a short period of time! :D

Anyway, I have been very curious about this for a while. Is it possible to introduce a similar star rating system like the ones on IMDb and TV.com ? Like a star rating system to rate articles or episodes of TV shows in particular? Just since apparently 'practically anything is possible with CSS and JS'. I'd just like to know if this in particular is possible? Thanks! :D

Ḡwẵine Ḹٍٍkƨ Ĺiĸe Ͼềлȑềd aka Alfons 09:49, October 31, 2012 (UTC)


 * Implementing such a thing is possible, the problem is storing the data. I assume you want to actually save the ratings somewhere. I'd recommend looking for a third party widget and importing it with verbatim tags since Wikia's servers don't really offer anything more sophisticated than the  tag AFAIK. I suppose it would be possible to construct a fake UI for a normal wiki poll to make it show stars instead the normal appearance.
 * I'd need a mock-up of what exactly you want to be before I can be more precise.
 * In any case, here's something I found on Google, if that fits your needs then you can probably just use that. Lunarity 11:51, October 31, 2012 (UTC)


 * Wikia actually has a system for voting on articles. I don't know if it ever went live though. Maybe it did and they couldn't make it work. Or maybe it never became popular. Maybe it was just an idea they toyed with. I haven't been around long enough to know. It's still accessible via the API though. If you were to establish a strict equivalency one page <-> one episode/movie/game/whatever, you could probably use this system. -- peco e s 16:10, October 31, 2012 (UTC)


 * It was a lab that they discontinued. -- Kangaroopowah  ( Talk ) 16:48, October 31, 2012 (UTC)


 * Right. I remember you mentioning that :) Did it work? Or didn't it and that was the reason they discontinued it? -- peco e s 16:57, October 31, 2012 (UTC)


 * I think it was a combo of that it was buggy, the way they presented it was all wrong and that the WMF was working on Article Feedback which could then be incorporated into Wikia. -- Kangaroopowah  ( Talk ) 01:21, November 1, 2012 (UTC)


 * I tried to add the link you suggested to me Lunarity however I don't see any change happening... Ḡwẵine Ḹٍٍkƨ Ĺiĸe Ͼềлȑềd aka Alfons 07:20, November 3, 2012 (UTC)

You have to create a page in the MediaWiki namespace on the wiki and import the code with verbatim tags. E.g.  then in the page put. Lunarity 07:35, November 3, 2012 (UTC)


 * So I need to copy the entire code to a page called 'MediaWiki:Stars ' and then add the StarsS01E01 to articles?Ḡwẵine Ḹٍٍkƨ Ĺiĸe Ͼềлȑềd aka Alfons, November 3, 2012 (UTC)


 * That's correct. The stars should appear wherever you place the Verbatim in the article. [Make sure you have a different userkey for each article, otherwise the stars will be for everything instead of separate] Lunarity 16:10, November 3, 2012 (UTC)


 * Still not working. I've followed your steps.
 * http://merlin.wikia.com/wiki/MediaWiki:S04E10
 * http://merlin.wikia.com/wiki/A_Herald_of_the_New_Age
 * Yet nothing is happening.
 * Could you help me out? I have given your admin rights on the wiki.
 * User:Ḡwẵine Ḹٍٍkƨ Ĺiĸe Ͼềлȑềd

Preferences
The Preferences module is nearing completion. And there's already a full-fledged demo for the language preferences we talked about. You can find the documentation and links to the demo and the module itself here. Let me know what you think, please! -- peco e s 23:39, November 03, 2012 (UTC)

I've tried to absorb as much as I can. Notes: Lunarity 01:49, November 4, 2012 (UTC)
 * Special:Scripts crashes in Monobook.
 * The post on form objects doesn't seem to offer any way to abort the post due to invalid/required field values. If that's intentional, you should probably add a note.
 * Wikia doesn't have jQuery UI stylesheets but I notice you're using a slider in the UI, having jQuery UI stylesheets set up for the basic widgets by the form loader may be a useful feature.


 * Here's the list of missing features:


 * Monobook support is missing. Completely.
 * The update promise is still missing
 * There's still no way to access the localStorage


 * As for the post promise: I was hoping - maybe that's a little naive - that everybody could make it so that it's impossible to enter invalid data. This isn't your regular webform after all. In regular web forms the user can bypass the JavaScript and post whatever he wants regardless. That's impossible here. The languages form is an example of what I mean. You cannot enter an unknown language or an unknown level for it.


 * Also keep in mind that Special:Scripts will ultimately run code from many different addons and addon-authors. It should not be up to a single one of them to block everything for everybody else.


 * Not sure, if you've noticed but I also wrote this other quick little hack in the last few days: FloatingToc. It uses the jQuery UI dialog and button widgets. I'm seriously asking myself now whether I should try to create a Wikia theme for the entire jQuery UI. That's the kind of thing I should be able to get support from Wikia Staff for. And then maybe I could get the stylesheet onto their actual SASS server.


 * It should be a little more than a theme though. There should be a lot of presets for buttons and the like. A "dock to siderail" button e.g. would be very useful e.g. You should be able to manipulate the menu at the top of page with the jQuery UI menu widget. etc. etc. The goal should be to seamlesslessly integrate the jQuery UI into the Wikia environment.


 * That would not be a quick little hack however. That would be a really ambitious project. One that would keep me busy for weeks and I do not have that kind of time right now. I'll probably do this though... -- peco e s 06:40, November 04, 2012 (UTC)


 * EDIT: Oh, and yes I will also add presets for a few basic jQuery UI features to the Special:Scripts stylesheet. At the moment the list is short. I have presets for these HTML tags: input[type="text"], input[type="button"], button, select, a, legend, fieldset, label and for the jQuery UI slider. That list needs to be expanded.


 * But returning to the language preferences for a moment :) My hope was that you would integrate them (and the skill preferences I'll soon add) into your UserTags. Otherwise I'd have to start editing UserTags in a major way and I'd rather not. Also: I do need a tester other than myself for the Preferences module :D


 * The format for the languages is quite simple:


 * peco e s 07:05, November 04, 2012 (UTC)


 * Here's the complete language list:


 * The property of the shared object is called "languages". It is itself an object. The language codes are its keys and the levels are their values. Values will be between 1 (basic) and 5 (native). 0 (none) will not be saved.


 * For the skills the structure will be: An object named "skills" with the keys "css", "js" and "templates". The values will range from 1 (basic) to 4 (pro). -- peco e s 07:21, November 04, 2012 (UTC)


 * Okay, I've got the prototype module written. You can try it by running (in your console):


 * If you want to modify the code then you can, I'm not sure about the I18N implications of this. Lunarity 08:34, November 4, 2012 (UTC)


 * Seems to work fine. But say, why don't you add the CSS that's required for UserTags with JS?
 * peco e s 08:44, November 04, 2012 (UTC)

(Reset indent) The CSS isn't technically required, except in Monobook. I prefer to keep it separate to keep it customisable. If I set the spacing between tags with JS, the cascade order would make it hard to override if people wanted a bigger or smaller gap without resorting to. Lunarity 08:52, November 4, 2012 (UTC)


 * You are an option spammer! :D
 * peco e s 09:34, November 04, 2012 (UTC)


 * I just contradicted myself by killing that entirely. The CSS is no longer needed at all, except for the link-tag colors. Lunarity 09:36, November 4, 2012 (UTC)


 * A wise choice! :)
 * peco e s 09:43, November 04, 2012 (UTC)


 * One last thing though: There's no need to put the Preferences-related bits of UserTags into a separate script. You can simply put the loader in an if-block and Preferences.js will not be loaded if the user/site doesn't want it. -- peco e s 09:48, November 04, 2012 (UTC)


 * This is originally what I created the the module system to do, piling stuff into the core is just a convenience. Putting the preferences module in the core would have the negative consequence that "My scripts" would only show up on user pages and Special:Scripts won't work. The script core is only loaded on user pages (See UserTags/code.js). Determining that the module isn't wanted isn't possible, the core decides that internally and will simply not call any of the module's functions if it isn't enabled. That means I'd have to put the loader inside the start function which doesn't appeal to me from an architectural standpoint. Executing the loader in the top level lets it start doing the IFRAME/AJAX load-wait whilst the UserTags core is running.


 * An additional consideration is that the core modules have no external dependencies. In any case, the core is also rather large so whenever I feel like doing major work on UT again, I was planning to improve the loader then factor out most of the core modules into separate files that will only load on demand via bulk /load.php anyway. Lunarity 10:54, November 4, 2012 (UTC)

(Reset indent) Hm. Not sure we understood each other... I'll have to double-check:

"IFRAME/AJAX load-wait"? Everything loads completely asynchronously if that's what you're getting at. And as I said: You can run the loader conditionally:  The only caveat is that this would have to happen before the conditional that checks whether this is a user-page or not. If the users want a feature that requires Preferences, then the Preferences module has to load everywhere - not just on user-pages. The loader itself is less than 1K in size. So if you're worried about bloat: Don't worry about the loader! Also keep in mind that Preferences.js, the iframe, etc. will only be loaded once - regardless of how many addons run the loader. Or to put it differently: If Preferences catches on, it will probably load regardless of whether your script happens to be the one to request it. peco e s 13:10, November 04, 2012 (UTC)


 * Accessing the values in the UserTagsJS global is not part of the module interface. The core is responsible for interpreting the global, even the loader doesn't touch it. Separation of Concerns dictates that doing that would increase coupling between the loader, modules and the core, which makes it an anti-pattern. The problem is that there isn't really a reason for the UserTags core to depend on Preferences directly. The module is what needs it so it should be responsible for loading it; the core itself is entirely administrator controlled with no user configuration. Like I said, the difference should become less pronounced after I work on UT again; I'm going to move all of the rest of the modules into separate script files as well then have the loader conceal that from users by automatically doing an importArticles across all of them. Preferences is more at home being built into HideRail and ReferencePopups.


 * On a tangentially related note, did you know that this works?


 * Is that intentional? Also, it feels rather odd that I need to look up the current user's username when Preferences already knows the answer to that, shouldn't  work? Lunarity 05:05, November 5, 2012 (UTC)


 * Please look at what you've done: You've banished the Preferences code onto an extra page - outside of the main UserTags page - where it's much harder to notice. You've banished the code that uses the Preferences into an exta script and thus you're making people who might be interested jump through an extra hoop. It's good to hear that makes a lot of sense from an architectural perspective but it doesn't help much in promoting the Preferences module.


 * The idea to add a boolean parameter is a good one. I'll probably adopt that.


 * And, er, what exactly is odd about that code? -- peco e s 05:59, November 05, 2012 (UTC)


 * That's not intentional, the documentation pages for UserTags are just crap and massively disorganised at the moment; I fully admit that the main page is not light reading and the sub-page makes it harder it find. That is not intentional, it's just a lack of good article design around the documentation on my part [You can reorganise it if you want, I honestly have no idea what I'm going to do to clean that mess up]. I can add a hack to the loader to hide the extra import required if you really want me to but I'm not sure that actually gains very much.


 * The question about that code was whether adding arbitrary unauthorised data to the shared store is intentionally allowed or not. Lunarity 06:23, November 5, 2012 (UTC)

[More] Preferences
Okay, I added a hack to the loader. The module is now loaded automatically and implicitly. On the plus side, I know how I'm going to do the redesign for the loader now.

The module is auto-pulled when prefCoding or prefLanguages is enabled. Lunarity 06:57, November 5, 2012 (UTC)


 * I've rewritten the loader entirely. UserTags is now formally modularised instead of just practically. There is now no distinguishing difference between the preferences module and the rest of the others. Lunarity 12:06, November 5, 2012 (UTC)


 * So that means your users won't have to install extra-scripts if they want to use one of the modules, right? That's nifty. That kind of thing will help a lot in popularizing UserTags (and Preference by extension :O) You can build the finest tools, but if the learning curve for the first steps is to steep, few will use them.


 * Also: I've given your remark about the shared object some consideration and I'll follow your suggestion to prevent addons from adding properties to the shared object. That'll throw an Error in the next version.
 * peco e s 01:21, November 06, 2012 (UTC)

Random comment about Preferences / your talk page

 * Preferences conversation with Pecoes is interesting. I'm following it, but not really saying much because it's about halfway over my head.
 * I think your talk page is possessed by a ghost, because I'm seeing a lot of this:

Only happens here on your talk page on this wiki. Doesn't happen on other people's talk pages. Happens logged in and logged out. After purging many times, 100% reproducible on my end. Only in Chrome, Firefox is perfectly fine.


 * Interesting. The problem is that jQuery isn't working, so everything that uses jQuery (i.e. everything) is crashing, but it only happens in Chrome. That's rather bizarre. If you do  in your console, you get " ", I've checked and that's an alias for  . I'm also getting window.jQuery = " ". This seems to imply that, somehow, the jQuery H2 heading on this page is finding its way into the   object and replacing jQuery with the DOM node... All I can say to that is, WTF? I think this may be a Special:Contact/bug, I'll need to try it on another page. Lunarity 05:05, November 5, 2012 (UTC)


 * Confirmed. It's the heading that does it, beats me how it does it though... Lunarity 05:17, November 5, 2012 (UTC)


 * Yeah, I'm seeing that too. Really, really bizarre... P.S Special:Contact/bug report filed, albiet this is probably a pretty obscure one.

User Tags
Hey,

Just wondering about UserTags/code.js. Why is it obvious that the core script be loaded last? Aren't the modules dependent on the core script... or is it the other way around? If it's the other way around, you might want to consider naming the "modules", "libs" to make it clearing IMHO. -- Kangaroopowah  ( Talk ) 05:53, November 7, 2012 (UTC)


 * The modules are plugins that are executed by the core. The modules register their existence in the UserTagsJS global then the UserTags core starts running, looks at the list of registered modules and picks which ones it wants to use (based on the user's configuration). The core will then start processing the page and invoke callback functions on each module as it reaches certain points. The core script must be last because it runs immediately upon loading and begins processing the page using whatever modules are loaded at that point; you can't alter the behaviour of something that has already completed everything it set out to do and exited.


 * This works like most plug-ins, e.g. Flash Player. The browser doesn't need Flash, but Flash does need a browser (The core doesn't need the modules, but the modules do need the core). Some programs let you load plugins whilst they are already running, but UserTags is a batch program that does not stay resident so it doesn't. Plug-in (computing) -Lunarity 06:58, November 7, 2012 (UTC)


 * To be clear, there is no dependency from the core to the modules. All you need to do is write:


 * in Common.js. That's all that's required to create a module, load and run it. Lunarity 07:08, November 7, 2012 (UTC)

Documentation Templates
We need a few templates for documenting methods, properties, class and modules. It would be swell if we could agree on common requirements and design. I've started a page named DocTemplates. Take a quick look, please!

Alternatively I could also unearth my work on a custom JsDoc Toolkit skin. Here's a prototype.

Please comment on Talk:DocTemplates! -- peco e s 08:44, November 07, 2012 (UTC)

Reference Popups
Hi Lunarity, I installed Reference Popups on my Wiki (merlin.wikia.com) but I do not want "Reference popups" showing in the edit button drop down on every page. Is there a code to remove this and how? Thank you. —Preceding unsigned comment added by Dryuuu (talk • contribs)


 * The question that leaves is where to put that if you don't want it there? I put it there because it's hidden unless you pop the edit dropdown, I could move it somewhere else but I'd need a suggestion of where it should go. Lunarity 10:47, November 10, 2012 (UTC)


 * Could you edit it so we have no pop out options at all? We will never use them anyway. Thanks ;). (So in other words, nowhere). —Preceding unsigned comment added by Dryuuu (talk • contribs)


 * That's a problem. Those options are for users, not administrators, and they are somewhat important for accessibility reasons. I can compromise by making it impossible to disable the popups, then there would be no need for the menu item so I can remove it if that's acceptable for you. Lunarity 13:23, November 10, 2012 (UTC)

Pop out messages
Hi Lunarity, is possible to make, out of that code, a pop up feature but for normal text and not references? E.g. You roll over a piece of text with pop up applied to it for a list of navigation links. That'd be REALLY awesome! —Preceding unsigned comment added by Dryuuu (talk • contribs)


 * Coincidentally, I'm actually rewriting ReferencePopups currently. The version 2 separates the popup logic from the reference logic so it would be possible to write your own script that used the reference popups to display something else instead. You can't do that with the current version 1 though. Lunarity 13:27, November 10, 2012 (UTC)

Horizontal rail hide
Hi Lunarity, it's me bothering you again! Firstly I REALLY look forward to seeing if you can get the pop outs working for any normal text and if it is possible to create a simple method to implement it (e.g. an easy template). Our Wiki would appreciate that hugely.

Secondly, the hiderail JS I just added to the Wiki is great, but, we get two duplicate search bars on the right side. The reason is that we, unlike any other Wiki put a search bar at the bottom of pages too. This may be difficult and probably an issue you haven't come across before ;) But I'm hoping you have the skills to help us out?

Thank you a lot!

-Merlin Wiki


 * Heh. So you pinched that script off Slightly Damned Wiki? I actually only wrote that yesterday, it's largely experimental to test an idea had for HideRail. I'm actually not sure if Wikia will allow me to keep it as a site script or not, since you're not supposed to alter the rail with site code. I only wrote it because Nintendo Wikia has something similar and they apparently got away with it. Lunarity 15:37, November 10, 2012 (UTC)

Page content scroller
It's me from Merlin Wiki.

Do you know of any type of sideways page scroller I can use? The click onto next area of content type of scroller, like this:

so the content (but not just images, any HTML) goes in between those arrows, or the arrows go underneath or something like that (with the nice sliding transition effect). I have long yearned for something like that. The closest I can get is this slider here, which is badly coded.

I appreciate your help and knowledge! Please get back to me soon if you can!


 * Wikia's photo slider in the rail is, you can make your own version by replicating the HTML structure of the rail module then calling   on it. I don't actually know how the carousel works since I've never looked into that deeply. You can probably find the source for it somewhere on Wikia's GitHub to figure out how it works. Lunarity 02:55, November 11, 2012 (UTC)


 * might be wrong but I think wikia uses twitter bootstrap for their carousel. -- Kangaroopowah  ( Talk ) 15:22, November 11, 2012 (UTC)


 * That would explain why I've never ever seen the carousel :) twitter.com is not on my JavaScript whitelist. -- peco e s 15:26, November 11, 2012 (UTC)

DemoScripts
I was going to leave you a message about the correction I made to your code, but I see you already corrected my correction :)

"#UserProfileMasthead, body.skin-monobook.ns-2, body.skin-monobook.ns-3" looks like a good compromise to me. --

ReferencePopups
Hello. I was wondering if you are able to help me with ReferencePopups. I'd like to make the animation turned off by default (or disable it completely, either's fine). I don't mind not being able to use importArticles etc (which I guess would be the case for me to have this feature), but I can't figure out what section controls the animation. Any help would be appreciated. Many thanks, -- 20:05, November 14, 2012 (UTC)


 * The first question is why? It's not hard to turn off for anyone who doesn't want it. The settings panel will even work for unregistered anons. If you really want to do that, I've added admin control of the defaults:


 * Lunarity 06:22, November 15, 2012 (UTC)
 * I've had some feedback from a few users suggesting that the animation be turned off by default. I think the reasoning behind it is that some of our users may not realize it's customizable (really) and because it's the style we'd like to present from our wiki by default, at this time. Thanks very much for the code! -- 01:28, November 24, 2012 (UTC)

Really?
Really? Using DemoScripts.js to advertise yourself as usertags author? This might just be my mindset but that's not what DemoScripts is for. If you really want to say your the author, just stick it on your userpage and/or talk. I'm not going to change the code for you, but I'd appreciate if you did. -- Kangaroopowah  ( Talk ) 04:40, November 16, 2012 (UTC)


 * And fyi, I realize that you want to show it as a demo. But think about it... a) most people probably won't come to your userpage for a demo b) most people won't think that you made that using UserTags and c) you've already shown pictures and this really isn't that big of an interactable script. -- Kangaroopowah  ( Talk ) 04:46, November 16, 2012 (UTC)


 * The masthead restyling requires a unique tag. The first tag on the row is the one applied to the masthead, without a custom tag I'd have to style Code Editor which would apply to everyone with that tag, not just me.


 * FYI, I'm not advertising as I honestly don't care that much but I thought "User Tags Author" was a better choice than "Blah". If it seriously bothers you that much then I'll change it. Lunarity 05:41, November 16, 2012 (UTC)


 * "This is a custom tag demonstrating the UserTags script" would be a better tag than "Blah" or "User Tags Author". If you are intending to use your profile masthead as a demo, I agree with Kangaroopower that it is very unnecessary because the picture in the infobox is already completely sufficient, although I don't see any problem with doing so, nor did I see the usage of "User Tags Author" as being particularly inappropriate.


 * The point of the demo isn't about custom tags, it was about giving different mastheads to different users when they're in different groups. Like normal users have blue mastheads, sysops have green, bureaucrats have yellow. The text on the tag is arbitrary, I just needed a custom tag as I didn't want to force the different masthead style on anyone else. Unfortunately, this seems to be a total failure since everyone has fixated on the tag itself, rather than the fact that my masthead is a darker shade of blue...


 * That suggestion is overly long for a tag; I already thought "User Tags Author" was too long but I couldn't come up with anything sufficiently sensible and descriptive in 2 words or less. I'll just remove it. Lunarity 07:00, November 16, 2012 (UTC)

Popups
Hi, your PopupRefrence thingy isn't working here could you help? OA


 * You're trying to use custom popups but haven't imported the code file for custom popups. You need to import  as well as  . Lunarity 02:11, November 25, 2012 (UTC)


 * Did it still don't work? Original Authority Contrib 02:32, November 25, 2012 (UTC)


 * Works for me. Press Ctrl+F5. Lunarity 02:35, November 25, 2012 (UTC)


 * That one works but now, the UserTag color's are playing up? Original Authority Contrib 02:40, November 25, 2012 (UTC)


 * I'm not seeing it. The CSS rules indicate that the grey is coming from Wikia's stylesheets as per normal. Unless you mean that you changed the colors but it isn't working. Lunarity 02:44, November 25, 2012 (UTC)


 * Yes, I imported your code for Tags but its not changing Original Authority Contrib 02:46, November 25, 2012 (UTC)


 * Could you explain what you're trying to do? That script has about a hundred features, I can't really guess what you're trying to do with it. Lunarity 02:49, November 25, 2012 (UTC)


 * I'm trying to change the background color/gradient of the tag... Original Authority Contrib 02:52, November 25, 2012 (UTC)


 * Your tag is . Apply the styles using   in Wikia.css. Lunarity 02:55, November 25, 2012 (UTC)


 * Actually, you should probably use  in order for the cascade to override Wikia's properly. Lunarity 03:01, November 25, 2012 (UTC)


 * It worked but only the Founder tab!. Original Authority Contrib 03:06, November 25, 2012 (UTC)


 * If you just want to change the default colors of all of them then you don't actually need the UserTags script. Just apply the styles to  Lunarity 03:11, November 25, 2012 (UTC)

RelatedDiscussions
While I acknowledge that the RelatedDiscussionsModule code originated from a line of code you put in the comments section of a blog, I would appreciate it if you consulted me before making those changes today. You have made rather extreme changes to my code without even telling me, and this does not help in the slightest when I am still ironing out all of the bugs.

Star Rating System
Why did you remove the Star Rating System? I just recommended it to somebody and the Merlin wiki likes it :) --


 * That code doesn't work, it was garbage (raw HTML and JS mixed together in a single file). The code on Merlin, I wrote almost from scratch specifically for that wiki. You need to generate a per-site user key (hash) on the service site and various other things (template), you can't just drop it in. Lunarity 07:59, December 8, 2012 (UTC)


 * I see. Do you think it's worth formalising and presenting it here at all? I kinda like the idea... --


 * I'm not sure. If I was going to do it 'properly' I'd design a reskin for Wikia's poll tag (Generic 1,2,3,4,...,10 options then have a display:none on the Poll and insert a custom UI instead that s and  s the invisible poll). The code Merlin has is a 3rd party widget (http://rating-widget.com/) that I figured would be fast and easy to implement (although overcoming wikitext integration problems with the stupid not-so-  tag was still annoying).


 * To use the widget, you need to walk through the design wizard to choose styles, colors and fonts and generate a user key on their site, then you glue the key into the JS configuration lump it spat out. Then you have to fight with it and wrap it up in a way that will work on a wiki, i.e. rewrite the JS it gives you to use jQuery and check the page for the presence of the widget DIV which will be inserted by a template, since it crashes if the DIV is missing. The major usage problem is that it requires a Unique Poll Id for each separate rating; on Merlin I just multiplied the series number by 1000 then added the episode number to use as the ID but different wikis will need wiki specific ID calculation formulas to ensure that one-id = one-page only. Lunarity 08:34, December 8, 2012 (UTC)
 * Hi. I don't know of what use this might be to you guys. But this wiki seems to be trying to use some kind of a rating system. ~ Ultimate  Supreme  10:00, December 31, 2012 (UTC)


 * That's the same rating system as on the Merlin wiki. Alfons is an admin on both ;) --

Length of code (again)
Forgive my ignorance, but why does StarRatings need to be such a large piece of code. I realize that it's important to minimize the amount of bugs, but it seems to me that you're trying to fix every edge case out there- a good ideal, but is it really necessary? For example, in w:c:kangaroopower:Mediawiki:Scope.js/dev.js I leave out some checks to see if stuff has loaded because it's simply impossible for the user to click the start button before the rest of the code has loaded because a CPU is much, much faster than the user. Doesn't that apply to StarRatings as well? Or is StarRatings just technically difficult to code due to Wikia's Poll tag not having a proper API. I'm genuinely curious. Btw, I still think that you should round to either the nearest half, or nearest quarter. Most users dont care about anything further than that. If they hover over the poll I suppose you could show them the exact percent, rounded to two decimal points- eg 94.34%. -- Kangaroopowah  ( Talk ) 05:51, December 22, 2012 (UTC)


 * I'm not sure which parts you're referring to as being faster than the user... Almost all the uses of events and promises are related to AJAX which can take from milliseconds up to 30 or more seconds. The code often physically can't proceed until the AJAX is done. I do aim to eliminate every edge-case I can think of, simply because I've always found that those ignored problems inevitably pile-up and interact with each other in obscure ways causing impossible to trace and reproduce errors and random glitches later. That's especially bad when I'm trying to find and fix bugs in new code I'm writing that depends on it, it's just easier in terms of maintainability to design them out. At the very least, I like my code to fail gracefully instead of screwing up the page.


 * The current code has become more complicated than it originally was because I had to redesign it. Cam's request to have an exploration page that lists every rating widget on the wiki in a sorted table from highest voted to lowest simply could not be done with the original simple system. The design of the Poll class is intended to meet the needs of that application which is why the library is as complicated as it is [I need the ability to handle 1000s of polls via a single AJAX request where each poll represents a separate wiki page and each poll needs to have the full suite of stats so they can be displayed in the table]. It's easier and less buggy to write the code once then it is to produce 2 libraries that do the same thing with different limitations as there will inevitably be bugs due to inconsistencies, especially given the complexities of contorting the poll tags into this application.


 * As far as rounding goes, whenever I use these sorts of widgets I personally prefer ones that are accurate to 2 decimal places. Rounding to the nearest quarter is more complicated to do in code, and does something that the user can easily do in their head (plus there's the graphical representation). A user can't get the precise numbers back if the code forces them to see a rounded value. Lunarity 08:53, December 22, 2012 (UTC)

Ezimport
What do you think about http://kangaroopower.wikia.com/wiki/Ezimport.js -- Kangaroopowah  ( Talk ) 23:39, December 23, 2012 (UTC)


 * Do you mean you'd like a code review?
 * You can use  instead of  .   maps to   in browsers which support it which is something like 500% faster as well as being shorter and easier to read.
 * Your  function is incorrect. It should be using , not   [Try  , it returns false]. You also should cache the result in a variable instead of calling it twice since the string search is O(n).
 * The  function does not process the array correctly, you aren't indexing into it.
 * The  function does not coordinate with whatever is calling this library. The DOM ready is unpredictable relative to external code; more importantly, the ready may actually fire immediately if the page is already ready causing the code to run instantly before any of the arrays are populated. If the ezImport is being imported itself then there's a very good chance that the DOM will already be ready by the time it loads. IMHO, either the   function should call   itself, or   should be exposed as part of the API to be called when needed. [If you intend this to be used directly by people in Common.js then you can use a debounce algorithm instead]
 * The  function is importing each script one at a time. That's a good idea for the scripts loaded with the debug flag set, but the normal non-debug ones should be imported all at once. It's also trying to load each script as both debug and not debug at the same time even though it can only be one or the other which it shouldn't do.
 * Lunarity 05:52, December 24, 2012 (UTC)
 * Solved 1-3. They were all pretty silly- that's why I asked for a code review :P. Per #5, it actually imports the scripts all at once in the end. And I have no idea to fix #4. Any ideas? -- Kangaroopowah  ( Talk ) 02:28, December 25, 2012 (UTC)


 * .#5 if the code is supposed to be doing that, it doesn't. The way the loop is structured, it creates 2 empty arrays, adds one entry to one array then dispatches both before preceding to the next iteration and doing the whole thing over again (2 new empty arrays).
 * .#4 Remove the document ready binding, add a call to  to the end of  . To expose the   function instead, just add  . The debounce is slightly more complicated, use   to create a   proxy and call that in.
 * Lunarity 05:29, December 27, 2012 (UTC)

Ref pop
Hey there,

Just wanna say I'm now using your Ref Pop script for my wiki. Works great! Works perfect for an article such as this one:

http://thethreekingdoms.wikia.com/wiki/List_of_cited_works_in_Records_of_the_Three_Kingdoms/Book_of_Wu#Book_of_Wu_20

So, thanks :-) - Zantam03 ( Talk ) 21:40, December 31, 2012 (UTC)

WikiActivity
What's http://dev.wikia.com/wiki/RevealAnonIP/code.js?diff=10710&oldid=10153 for? What's the difference between WikiActivity and RC? I'm cleaning up AjaxRC right now- AjaxRC/beta.js so is it something I need to know for that? Also can you code review the ajaxrc beta? -- Kangaroopowah  ( Talk ) 19:27, January 13, 2013 (UTC)


 * If you scroll to the bottom of Special:WikiActivity, there's a "show more recent activity" link which adds more stuff to the page via AJAX when clicked. I was adding support for that link so that RAIP would unmask anon-edits that come through when you click it.


 * As far as AjaxRC goes, you need to call  after reloading the Special:WikiActivity page in order to re-arm that link. Lunarity 07:40, January 16, 2013 (UTC)

User badges
Hello I was wondering if you could take a look at my coding and see what needs to be changed inorder for it to work and please help this is very important. Thanks!

http://brotherhoodofthefallen.wikia.com/wiki/MediaWiki:Common.js

You're overwriting UserBadgesJS and you haven't actually imported anything. -- Kangaroopowah  ( Talk ) 02:30, January 18, 2013 (UTC)

Oh I did some lite reading on advanced programming and coding and I fixed every thing but their is one problem I believe the script is conflicting with CSS if im right see when ever I import the script in to common.js it overrides my rights icon which is http://brotherhoodofthefallen.wikia.com/wiki/MediaWiki:Wikia.js/userRightsIcons.js and as you can see on my profile http://brotherhoodofthefallen.wikia.com/wiki/User:MythicConditor there is only one but there should be another by the name of Website Creator and Owner as seen in MediaWiki:Wikia.js/userRightsIcons.js Ive tryed everything I know and there doesnt seem to be anyway around this confiction so pretty much its either I have my rights icon or delete the script which doesnt sound reasonable at all please help me with this error. Thanks!

Your friend, your leader, The Fallen (talk) 07:03, January 18, 2013 (UTC)


 * The userRightsIcons.js script is incompatible. UserTags subsumes (provides everything and then some) all of that script's features. You can't use both at the same time. You need to either convert your userRightsIcons configuration into a UserTags configuration, or just keep using userRightsIcons.


 * Replace the contents of your Common.js with this and remove userRightsIcons.js. The result should come out looking like how you had userRightsIcons set up, but with all the extra features of UserTags added. Lunarity 14:15, January 18, 2013 (UTC)


 * And how long will it take for the code to have an effect on the wiki?
 * Your friend, your leader, The Fallen (talk) 20:27, January 18, 2013 (UTC)


 * Alterations to the JavaScript files take about 10 minutes give or take 5 before everyone can see the changes. Lunarity 17:08, January 19, 2013 (UTC)

New script
On this wiki they have some sort of tool that checks new questions towards old ones, and if it found a question with similar words, it asks the user if any of the old questions is the same as the new one. When the user clicks one, a redirect is created. Can a javascript be created similar to this for the answers wikis?~ Ultimate  Supreme  08:10, January 30, 2013 (UTC)


 * I don't know how answers wikis work. The only thing that comes to mind is making the create question button send everyone to Special:Search instead of creating a question then having the actual create button on the search page instead. Lunarity 08:56, January 30, 2013 (UTC)


 * That would be a bit redundant..
 * And perhaps a TOU violation too.
 * Isn't that ^ possible?~ Ultimate  Supreme  09:08, January 30, 2013 (UTC)


 * I'm not clear on the redundant part. If it already does that then that's all you've got, searching related questions is a wiki search. Suggesting existing questions would just be searching the wiki and displaying the results. There's an API for doing a search but that's the same thing as the UI search.


 * Doing this is straightforward. Just grab the "Ask" buttons and attach a script that cancels it and redirects to index.php?search="Question Here"&fullText=Search. On the search page, turn the search button into an Ask button with a script that redirects to the original create page thing, whatever that is. Automatically creating a redirect is more complicated; hook all the links in the search results to block the navigate and use the edit API to create a page for the search string that redirects to the target before navigating normally. This may be a ToU problem, yes, although it seems like it wouldn't matter since Wikia isn't exactly encouraging answers wikis.


 * If you just want the result suggestions then you can just use the search API and render it using a  on the textbox or stick a DIV underneath and fill that out. Pecoes' SearchSuggest probably already does 90% of what you need, you just need to make it work on the Ask box instead of the search page. Lunarity 10:34, January 30, 2013 (UTC)


 * Yeah, I understand what you are trying to say... But then how would new questions be created?~ Ultimate  Supreme  11:00, January 30, 2013 (UTC)

(Reset indent) The SearchSuggest approach is simple. Thinking about it, using Special:Search may actually not work very well since that doesn't search titles... Questions use page titles don't they? Opensearch doesn't actually help though, that's a prefix title search. There doesn't seem to be a good solution to this, looks like a rather large flaw in MediaWiki.

The direct Ask to search page solution has the create button on the search page. Type question, click Ask, takes you to search, click Ask again, new page created. Lunarity 11:12, January 30, 2013 (UTC)


 * But Ask → Search → Ask → Search....
 * Right?~ Ultimate  Supreme  11:21, January 30, 2013 (UTC)


 * No, that would be circular. The Ask button on the search page would create the question instead of searching. Ask → Search → Create. The idea is just to insert an extra step into the question asking process by making the user look at the search results instead of just jumping directly to creating the question, but if they click ask again after being shown the search results then it would just go forward and actually create it. Lunarity 11:29, January 30, 2013 (UTC)


 * Aha, sounds really great.
 * Now the hard part; do you think you can make something like that?~ Ultimate  Supreme  11:49, January 30, 2013 (UTC)

I haven't tested the automatic redirect creating part, you'll have to check that yourself and tell me if it works or not. Lunarity 13:41, January 30, 2013 (UTC)


 * confused* What do I need to do to create a redirect?~ Ultimate  Supreme  16:06, January 30, 2013 (UTC)

Got it. It works :)~ Ultimate  Supreme  16:14, January 30, 2013 (UTC)

Is it necessary to copy search contents to Ask box?~ Ultimate  Supreme  07:32, February 1, 2013 (UTC)


 * You want it to not do that when doing a normal search? Lunarity 07:35, February 1, 2013 (UTC)

Exactly~ Ultimate  Supreme  07:49, February 1, 2013 (UTC)


 * I've updated it so it only does that if you got there by an Ask submit. Lunarity 07:55, February 1, 2013 (UTC)

JSLint
I thought I'd try out JSLint, and indeed it's rather handy. But it's throwing up a few errors that when fixed then don't work back here. for example: if (mw.config.get('wgNamespaceNumber') == '0') { console.log('mainspace'); } else { console.log('error'); } Will give the errors: 3 of those are fine and nothing for me to lose any sleep over, but changing the == to === then causes the code to break. Is this meant to happen? The entire code is here.
 * 'mw' was used before it was defined.
 * if (mw.config.get('wgNamespaceNumber') == '0') {
 * line 1 character 40Expected '===' and instead saw '=='.
 * if (mw.config.get('wgNamespaceNumber') == '0') {
 * line 2 character 5'console' was used before it was defined.
 * console.log('mainspace');
 * line 4 character 5'console' was used before it was defined.
 * console.log('error');


 * Use  at the top of the script to eliminate those errors. Keep in mind that   does not exist in Internet Explorer unless the Developer Tools are open, so those warnings about   will result in crashes for some people if you deploy that.


 * As for  vs  . The rule is basically to use   unless you have a very specific reason for using  . Double equals does type coercion which results in insanity like ,  ,  ,  ,  ,  , and a couple of others (Double equals is not transitive which is very bad). Triple equals is a straight comparison without conversion so it will only match if   is both the same type and equal in value&dagger;.   is always a number so the problem with your code is that you're doing   which is always going to be false. You need to drop the quotes.
 * &dagger; comparing objects compares references (pointers) not contents. i.e. that the same object is being referenced.  is false.
 * Lunarity 21:35, February 21, 2013 (UTC)
 * Lunarity 21:35, February 21, 2013 (UTC)

Fourth level menu items
Hi Lunarity, I actually had a grasp of this a while ago but now I've completely forgotten, how do I add a fourth menu item to the navigation? Which is the plugin I need? So like this: Thanks! Dryuuu 03:27, February 22, 2013 (UTC)


 * AFAIK, Wikia's code doesn't support 4th levels. Pecoes' Wikimarks is the only script I know of that adds additional code which allows 4th levels, I don't believe there's any built-in way, or any scripts on here, to do it. I have been mildly interested in replacing the core logic for Expanded Nav in order to fix a few problems and add more Level 2 items. You could ask Pecoes to extract the relevant parts of Wikimarks into a separate script specifically for this purpose but you should probably Special:Contact Wikia first, I suspect they won't allow us add 4th levels. Lunarity 06:34, February 22, 2013 (UTC)


 * 4th level navigation actually does have some history on a few wikis, going back a bit further than Pecoes' Wikimarks (which is an awesome script, by the way, probably my favorite). The way the story goes, so far as I know, is that it used to be the case that MediaWiki:Wiki-navigation would parse templates and HTML. And there used to be a template + CSS file you could use to add 4th level navigation menus (developed here by Tjcool on Professor Layton wiki). In February 2012, Wikia made an update so that MediaWiki:Wiki-navigation no longer parses templates or HTML, which of course caused that template to no longer work.


 * In response to that update, Rappy created a JS solution to replace the template, the original code for which is still used on Aion Wiki (to see an example, move your mouse over Locations > Instances > Group in the navigation bar on Aion Wiki).


 * Anyways, so far as I am aware, it's perfectly fine to add 4th level items to the menu, as I've not heard of a case of it being removed as a violation of the Customization policy.


 * However, Rappy's source code for this is not designed in a user friendly way. Sometime last year I went through the rather involved process of isolating the necessary bits of code from Aion Wiki and copying them to my wiki here and here and making some necessary coding tweaks. However, even if you were to copy the isolated code from me, installation on your wiki would still not be so straight-forward as a copy/paste process -- the HTML for the links must be edited by hand in the JS file and the appropriate import statements for the JS and CSS files must be created in your wiki's MediaWiki:Wikia.js and MediaWiki:Wikia.css. And if there are styling errors, which there very well could be, additional tweaks to the CSS coding would be necessary.


 * So to conclude, I think Rappy's code should be redesigned to make the installation process user friendly (i.e. just copy/paste, no coding required to install it). I'd be happy to do the rewriting and then give you the user friendly version afterwards if it's something you're interested in for your wiki -- if so, let me know.


 * @Lunarity: If this is something that interests you, I'd be happy to work together with you on it (you mentioned wanting to add more level 2 items / fix some other things). Or if you'd rather just build it yourself, I'd be cool with leaving it up to you :)

(Reset indent) If Rappy has it set up then that makes a pretty good case I suppose. My presupposition was based on things I read in the past where people explicitly asked about 4th level items on Tech Update blogs and were rebuffed by other users, I don't recall staff replying at all which makes it difficult to assume their position.

My notes on Wikia's current expanded nav code are:
 * Tabbing through links in the Nav breaks it.
 * Tabbing through links so that a drop-menu opens then hovering over a different level-1 link wipes out all the level-2 and 3 links on every tab, leaving only the level-1s.
 * Wikia's code binds event handlers to every single link individually instead of delegating from the  root element which would be more efficient.
 * Wikia's code uses /  to display the level-2/3 menus, as well as playing with   for some reason when it would have been easier to just use CSS.

Here's my basic framework code. I haven't done anything for actually adding more items, or populating the Level-4s, but Level-4 is supported (If you insert the necessary DOM structure for an L4 menu, this code will pop them out correctly).

CSS fragment: JavaScript fragment:

Format for a Level-4 menu:

As far as usability for adding Level-4 and overcoming the 4 Level-1, 7 Level-2, 10 Level-3 caps goes, my idea was to simply AJAX the contents of the MediaWiki:Wiki-navigation page in raw mode then parse it manually. The format is pretty simple to the point that you can just use a regex. ought to be sufficient to parse a single line. You'd need to pre-parse to eliminate all the HTML comments first though ( should take care of those in the common case (ignoring the possibility of recursive and nested comments). I'm not sure how HTML comments interact with   though, this may need some experimentation to figure out exactly how the Nav page is supposed to work.). The only major difficulty I can see are the "#category1#" magic words and "MediaWiki:Message-name" labels, those would have to preserved from the initial server response version of the nav.

The parsing code can basically assemble the new menu DOM on the fly as it parses. When it's done, just remove everything except the "On the Wiki" tab and dump the new menu DOM after it. It would also be a good idea to dump a copy of the produced HTML into LocalStorage with a 6-hour timeout so that the nav can be updated instantly without the AJAX+parse delay after the first page view.

Unfortunately, adding more Level-1/2/3s stops the editor's "too wide" warning from working meaningfully on the MediaWiki:Wiki-navigation page. That page requires a bit of work to fix. Adding Level-4s without allowing additional 1/2/3s shouldn't be a problem, though making L4s work in the preview will be an issue. 

You're welcome to work on this if you'd like, I'm fiddling with another project currently so it may be a while before I can work on this myself. Lunarity 06:13, February 23, 2013 (UTC)


 * What do you think of dropping support for magic words like #category1#? It would make the parsing algorithm much, much simpler. Also, it would then be possible to kill Wikia's preview and use a custom one (just call the parsing algorithm and display the results in a new modal), which I think is much, much easier than trying to dink around with Wikia's preview and figure out how to get level 4 items to display in it. I don't think it would terribly inconvenience people if those magic words weren't supported and that the tradeoff in terms of simplified coding is worth it.
 * Instead of dropping support, it may be possible to come up with a custom implementation of the output for those magic words. E.g. for #newlychanged#, AJAXing recent changes through the API could work. For efficiency, the submenu would be generated "on demand" (when mouse first hovers over menu) instead of on pageload.
 * I would prefer to re-add the Publish button into the UI. I think it's confusing that you have to click Preview to get to Publish.
 * If the menus overflow, user shouldn't be prevented from publishing. Instead, user should simply get a warning saying that there's overflow and that the overflowing items will be hidden after you publish. Not entirely sure about that. Could go either way.


 * Loading stuff on demand is doable, though more complicated, one problem is that I'm not certain if all those magic words are available by the API. I think #mostvisited# isn't. The popping code I wrote is using delegation so it's flexible, if you add in an empty placeholder UL to be populated via AJAX when it's opened then the code should be perfectly happy with that, although you will probably want to throw a  into   so that you can actually detect when it's opened.


 * I've just discovered that it's actually possible to do rather zany things with magic words:

**#newlychanged#||Recently Edited
 * Some page|This will be shown at the bottom of the L3 after the items produced by #newlychanged#
 * That could be ugly when combining with dynamic loading since you'd need to remember the correct insertion points. My inclination is to just drop the magic words altogether, they could be implemented either on-demand or by consuming the existing DOM structure and matching it to the original definition but it looks like it's not worth the hassle until someone actually asks for them to work. [If we do do that then it would be better to just bake up a plugin arch so that people can dynamically load whatever crap they like, not just Wikia's magic words (they could make up their own words, like a per-page dynamic menu that populates itself differently depending on what categories the current page is in or whatever). Worry about this later though, requires coming up with an extension of the Wiki-navigation page's syntax that doesn't break the default parser, also previewing this would be hard.]


 * The width check on the editor page has a practical benefit; namely that without it, menu items wraparound. You end up with a second row of L1s being mixed in amongst the L2 links. The L2s likewise wrap around when they reach the end so you end up with multiple rows of L2s extending down the page. [This can be hard to see on light wikis since the text color is white but you can find them with hovering / element inspection] Wikia's editor UI is intended to prevent people from doing this and making an unusable nav.


 * The lack of the publish button in the editor is born of the need for a server round-trip to parse the nav code and send it back in HTML form before the JS can check the widths. If you choose to go the "parse from scratch and load complex stuff on-demand" direction then you can drop the server round-trip and do the parse entirely locally instead, that would let you put Publish back in the UI and do the width check immediately whenever it's clicked. The unfortunate consequence of this approach is that you won't have a DOM template to work with, you'd need to correctly construct the entire Nav DOM from scratch instead of just rewriting part of the existing structure. As for the preview, supporting the existing preview to make L4s work inside it shouldn't be too hard, you just need to check for  being true then patch/replace   with your own init function (that's called every time a new menu preview is created), you can also replace the   (L1) and   (L2) functions with your own implementations to handle the width tests. Lunarity 13:48, February 23, 2013 (UTC)

Reference Popups
Hi,

I want to add references popus in my wiki, and I began to add some parts of code. But now, I want to know if I can add a new language (French) in the code, because I don't really know if I can add it by my-self. I didn't see any note that expains if that can be done and as I saw that you have created the code so I ask you if I can do it.

Thank you.

Celdrøn (talk) 23:13, April 29, 2013 (UTC)

Usertags
Hi there! I use your Usertags.js on my wiki, Percy Jackson Fanfiction Wiki. However, I have a problem with the script. Recently a user, Captin' Rin, just became a bureaucrat. I tried adding her name, but because she has an apostrophe in her username, it doesn't work. Is there any way you would be able to help me? :) --Hermione Chase