This Forum has been archived

Forums: Admin Central Index Technical Help Scripts not loaded
Wikia's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.

It seems that my common.js is not loaded, does anyone see any errors? leviathan_89 13:18, 27 August, 2012 (UTC)

Heh, awesome. importArticles has a badly explained syntax. It'll be faster just to show you how to fix it:
//       Importazioni funzioni
    type: "script",
    articles: [
        //       Funzioni di utilità generale
        // Test if an Element has a Certain Class
        // Funzioni accessorie per Cookie
        //          Funzioni applicative
        // Username Replace
        // Togglers (toggles the display of elements on a page)
        // Ajax auto-refresh
        // Link in uscita
        // Upload
        // FixWantedFiles
        //     Personalizzazione dell'interfaccia     
        // Codici asincroni socials
        // Display Timer
        // Cambio skin
        // Utenti inattivi
// END Importazioni

The short version: The article paths are NOT interwiki links, they are the internal database name for the target site ("w:database:ArticlePath"). To find what the database name is for a given site, you'll need to use the javascript console in your browser on that target site to get the value of wgDBname (it is usually just the subdomain on Wikia though).
It may be worth filing a bug, the help page does not explain this so it may not be intentional. Lunarity 17:52, August 27, 2012 (UTC)
The help page sure is misleading: "This method will work with local articles (such as "MediaWiki:Wikia.js") or external articles (such as "w:c:dev:Mediawiki:External_include.js" -- see Interwiki Links for more information)". Thank you, I would never figure that out. leviathan_89 18:35, 27 August, 2012 (UTC)
The trick there is that, for English Wikis, the database name is the same as the site subdomain: is kept in a database called 'onepiece' so 'w:c:onepiece' works fine. Apparently whoever designed this didn't consider the non-English wikis. Lunarity 19:19, August 27, 2012 (UTC)
Although I tried to clear my cache many times, it seem that they are still not loading... if they would be, you should see a time clock on the top-right for example. Moreover I forgot to mention that there is this weird bug that loads only the first image on the right column in the main page... if I don't find a solution soon I'll just special:contact this. leviathan_89 18:49, 27 August, 2012 (UTC)
Well, it does sort of work. I can see the getElementsByClass now works, along with some other stuff. Unfortunately, the URL contains a mess:|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Fcookie.js|MediaWiki%3ACommon.js%2FusernameReplace.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Ftogglers.js|w%3Adev%3AAjaxRC%2Fcode.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Flinks.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Fupload.js|w%3Adev%3AFixWantedFiles%2Fcode.js|MediaWiki%3ACommon.js%2Fasync.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2FdisplayTimer.js%E2%80%8E|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2FskinSwitch.js%E2%80%8E|w%3Adev%3AInactiveUsers%2Fcode.js&only=scripts
I've highlighted the broken parts in bold, only those 2 aren't loading (the clock and skin switch). I'm not sure what's causing that though. It should look like this:|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Fcookie.js|MediaWiki%3ACommon.js%2FusernameReplace.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Ftogglers.js|w%3Adev%3AAjaxRC%2Fcode.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Flinks.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2Fupload.js|w%3Adev%3AFixWantedFiles%2Fcode.js|MediaWiki%3ACommon.js%2Fasync.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2FdisplayTimer.js|w%3Aitonepiece%3AMediaWiki%3ACommon.js%2FskinSwitch.js|w%3Adev%3AInactiveUsers%2Fcode.js&only=scripts
Which does load correctly and contain all the scripts. I'll look in to how importArticles works internally, it might be screwing something up. Lunarity 19:19, August 27, 2012 (UTC)
Okay, got it. That piece of junk in the URL is a unicode character: Unicode character 8206. It's invisible to us because it's a control character that instructs the browser on how to display text properly but the JavaScript engine can see it and is including it in the URL sent to the server which is why it's broken. I suspect you copy and pasted some of those filenames from somewhere else and unfortunately brought that little evil tag-along with it.
Anyway, I've fixed the script here in the forum, switch to source mode and copy/paste it into your Common.js. Or, for fun, go into your Common.js, place the cursor here:
        // Display Timer
        // PUT YOU TEXT CURSOR ----------------------------^ before the quote mark and press backspace once
        // Cambio skin
        // ----------------------------------------------^ here as well

and press backspace once. The cursor won't move but something will be deleted. Talk about a damn obscure problem :). Lunarity 19:42, August 27, 2012 (UTC)
WOW! That's true... I would never found that! I'll correct it right away... I guess it was the same problem causing this CSS to break up, as you can see I fixed although I didn't know what I've fixed! (I just rewrote it) How can I check if that character is present though? I may have the same problem in the future... leviathan_89 20:18, 27 August, 2012 (UTC)

(reset indent) Now it seems that it's working, though there is still that problem in the main page... any ideas? And if you know a handy way to spot that character right away tell me please. Thank you anyway. leviathan_89 20:37, 27 August, 2012 (UTC)

These sorts of 'magic' characters give programmers nightmares since every character, even invisible ones, matter to the computer itself; people spend hours debugging for something that you simply cannot see with your eyes. I wouldn't have caught this if it wasn't for the fact I was already looking at the output URL (I ran %E2%80%8E through decodeURI and got a blank string which is when it clicked, so I did decodeURI('%E2%80%8E').charCodeAt(0) and got 8206).
Avoiding this sort of awfulness is hard, the best I can suggest is that you paste your code into Notepad then save the file with "ANSI" as the character encoding. When you exit and reopen it, all the Unicode characters will have been converted to '?' which means that you can now see where those invisible ones are. If you use Notepad++, it provides an Encoding>Convert to ANSI which will achieve the same without needing to save and reopen.
I found this Stack Overflow question related to this exact sort of problem: [1]. I could write a gadget for global.js/Common.js that would automatically fix this sort of thing when you click publish, that might be worthwhile.
As for the main page, I'm not sure I see the problem. All the images seem to be loading for me, though I don't know what it's supposed to look like. Can you give me a more detailed description of what I should look for? Lunarity 21:34, August 27, 2012 (UTC)
Okay, I'm an idiot. I was looking in the wrong tab. I see the problem with the main page. One of Wikia's scripts is looking for the Wiki's contribute button but it doesn't exist so the script is crashing which then causes everything to explode and die. I don't think you can fix that, (you could try creating a fake contribute button) the problem is in Wikia's stuff. Lunarity 22:16, August 27, 2012 (UTC)
[...] The article paths are NOT interwiki links, they are the internal database name for the target site ("w:database:ArticlePath"). [...] It may be worth filing a bug, the help page does not explain this so it may not be intentional.
I completely agree. Would you please report this to Staff! That sounds very wrong. It should either be a proper interwiki link or something else entirely. Some weird pseudo-construct that kind of behaves like an interwiki link - except when it doesn't - serves nobody.
@Leviathan_89: You can find a fix for your main page problem here. Unfortunately it's a very common one. The main pages of all answers wikis are broken after the MediaWiki update. The bug has been reported, but you shouldn't get your hopes up. Apparently answers wikis rank very low on Wikia's priority list. --  pecoes  23:49, August 27, 2012 (UTC) 

Okay, here: w:c:dev:AntiUnicruft. I wrote a gadget that automatically strips out those invisible characters as soon as you click Publish/Save, just add it to your global.js or Common.js or whatever and hopefully this won't happen again. Lunarity 09:00, August 28, 2012 (UTC)

Really thank you guys, I'll definitely try your code Lunarity, I don't want to have "nightmares" anymore! : )
"The bug has been reported, but you shouldn't get your hopes up. Apparently answers wikis rank very low on Wikia's priority list." <-- That's painful true. leviathan_89 10:02, 28 August, 2012 (UTC)