UESPWiki talk:Javascript

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

Intermittent Javascript Problems[edit]

On a hunch, I removed the Modify Sidebar code from my monobook.js file today, and all the other Javascripts have been loading perfectly. Can anybody else second this observation? Robin HoodTalk 04:48, 18 March 2010 (UTC)

What kind of problems exactly? -- Nx / talk 18:02, 18 March 2010 (UTC)
When Modify Sidebar is being used, it will randomly fail, even just repeatedly refreshing the same page, and then take other javascripts with it. Re-loading repeatedly, it'll show different tabs on the top-bar with each load, for instance. I think I'm the only person who's actually loading every last JS file we have, so I tend to notice these things a bit more. :) Robin HoodTalk 18:38, 18 March 2010 (UTC)
What browser are you using? -- Nx / talk 18:49, 18 March 2010 (UTC)
Personally, I have never had this problem with Firefox (3.6). Chrome and Safari both had the problem. rpeh •TCE 20:11, 18 March 2010 (UTC)
Then I know what you're talking about. Chrome (and apparently webkit too, although I haven't tested in Safari) cannot find the function ModifySidebar, because it's loaded in another script using importscript. Whether it's a security restriction or a bug, I don't know. The solution is to copypaste the modifysidebar code into your monobook.js. -- Nx / talk 20:14, 18 March 2010 (UTC)
Yeah, that was my impression from the error message...I don't remember exactly what it was. I think it's being loaded asynchronously (by AJAX it looked like?) and the timing is just causing issues. I'll try your suggestion of moving it to monobook.js. I don't suppose there's a way to force it to wait, even if it's a hack/workaround, like I was thinking of trying importScriptURI, just to see if that works better. Moving it is good enough, but I'd like something better if possible. :) Robin HoodTalk 21:38, 18 March 2010 (UTC)
Well, it's just a Chrome problem. I haven't researched it though - maybe they know a solution at WP? You might want to ask there. -- Nx / talk 21:40, 18 March 2010 (UTC)

<- Thanks for editing the problem report section, Nx, I've been meaning to come back to try your suggestion and double-check everything and just haven't found the time. Robin HoodTalk 22:51, 22 March 2010 (UTC)

No problem. I haven't found anything relevant on Google or Wikipedia btw, although I didn't search very thoroughly. -- Nx / talk 22:57, 22 March 2010 (UTC)
Just to follow-up on this, you were 100% correct. Now that Modify Sidebar has been copied to my personal .js file, it works like a charm. Robin HoodTalk 02:07, 24 March 2010 (UTC)

Navpopup[edit]

Basics seem to be working, although namespaces aren't set up properly yet. I'm going to tackle that tomorrow. I think it only affects the "edit talk page" and similar functions though, so it's not a huge problem. -- Nx / talk 22:57, 22 March 2010 (UTC)

Ok, I moved it here, fixed the namespaces and made sure the extension that adds namespace prefixes automatically didn't mangle it like the last time. -- Nx / talk 13:48, 23 March 2010 (UTC)

Pages in User Space[edit]

I notice that Nx has added a page deliberately left it in User space. Can I suggest that we move that to an "Under development" or perhaps "Personalized" section, just to distinguish it from those that are generic and considered to be finalized? Robin HoodTalk 22:57, 22 March 2010 (UTC)

Makes good sense. rpeh •TCE 23:07, 22 March 2010 (UTC)
I don't think either name is entirely appropriate, but otherwise I agree, (with a warning that if you don't trust the user, you shouldn't install the gadget, since they can steal your account :) ). Maybe "User gadgets?" -- Nx / talk 13:48, 23 March 2010 (UTC)

Gadgets[edit]

Wouldn't it be best to add these scripts to the 'Gadget' section in the preferences pane? That doesn't require editing to change, and you can easily test things out. Elliot 01:14, 23 March 2010 (UTC)

Some of them, yes. Not all of the scripts are appropriate (eg, Modify Sidebar). Plus, some method of testing on UESP's slightly non-standard configuration before scripts are committed to the Gadget infrastructure. rpeh •TCE 01:56, 23 March 2010 (UTC)
I see Gadgets as the next step up from here. Once people have used these for a while and we can confirm they're working well for everybody, they can be proposed for Gadget status. Robin HoodTalk 03:01, 23 March 2010 (UTC)

Personalizing your sidebar - Copied from Jak's talk page[edit]

I'm copying this conversation from Jak Atackka's talk page. He and Daric Gaersmith showed me how to customize my sidebar, and I think the info should be archived with the JS article so others can benefit from their knowledge: --Xyzzy Talk 15:54, 5 June 2013 (GMT)

Can you please show me how to edit my sidebar to put it back the way it was before we implemented the collapsible sidebar site-wide. I prefer to have mine expanded. Thanks. --Xyzzy Talk 04:07, 9 May 2013 (GMT)

Sorry it took me so long to respond. Try adding this to your monobook.js page:
    ModifySidebar("clear", "sections");
    ModifySidebar("add",   "sections",  "Lore",                "http://www.uesp.net/wiki/Lore:Main_Page");
    ModifySidebar("add",   "sections",  "Books",               "http://www.uesp.net/wiki/Books:Books");
    ModifySidebar("add",   "sections",  "Elder Scrolls Online","http://www.uesp.net/wiki/Online:Online");
    ModifySidebar("add",   "sections",  "Skyrim",              "http://www.uesp.net/wiki/Skyrim:Skyrim",
                                        "Dawnguard",           "http://www.uesp.net/wiki/Skyrim:Dawnguard",
                                        "Hearthfire",          "http://www.uesp.net/wiki/Skyrim:Hearthfire",
                                        "Dragonborn",          "http://www.uesp.net/wiki/Dragonborn:Dragonborn",
                                        "Other DLC",           "http://www.uesp.net/wiki/Skyrim:Official_Plug-ins");
    ModifySidebar("add",   "sections",  "Oblivion",            "http://www.uesp.net/wiki/Oblivion:Oblivion",
                                        "Knights of the Nine", "http://www.uesp.net/wiki/Oblivion:Knights_of_the_Nine",
                                        "Shivering Isles",     "http://www.uesp.net/wiki/Shivering:Shivering_Isles",
                                        "Other DLC",           "http://www.uesp.net/wiki/Oblivion:Official_Plug-ins");
    ModifySidebar("add",   "sections",  "Morrowind",           "http://www.uesp.net/wiki/Morrowind:Morrowind",
                                        "Tribunal",            "http://www.uesp.net/wiki/Tribunal:Tribunal",
                                        "Bloodmoon",           "http://www.uesp.net/wiki/Bloodmoon:Bloodmoon",
                                        "Other DLC",           "http://www.uesp.net/wiki/Morrowind:Official_Plug-ins");
    ModifySidebar("add",   "sections",  "Daggerfall",          "http://www.uesp.net/wiki/Daggerfall:Daggerfall");
    ModifySidebar("add",   "sections",  "Arena",               "http://www.uesp.net/wiki/Arena:Arena");
I took this from Daric Gaersmith's monobook.js file. The spacing isn't necessary at all - I just did it so it would be somewhat clear what each part is. You can tweak this however you want, but the above should give you an idea where to start. • JAT 04:58, 12 May 2013 (GMT)
Thanks for your help, and please don't apologize for the delay in replying. I know you're busy with real-life obligations. I was able to copy/paste the lines I want on my sidebar, but I can't seem to get it to stop collapsing. Is there a javascript command I need to add to prevent that, or should that have been removed by the "clear" in the first line? --Xyzzy Talk 06:17, 12 May 2013 (GMT)
Thanks Jak, I just copied your re-spaced copy of my code back to my own monobook.js as your layout is definitely superior. Xyzzy, in order to use these modifications, you need to add importScript('UESPWiki:Javascript/modifysidebar.js'); to your monobook.js as well, otherwise it won't work, as you have already experienced. The ModifySidebar() function is located within modifysidebar.js, so you either need to link to it as I have done, or copy the entire modifysidebar.js code into your monobook.js, as some people have done. Daric 22:56, 13 May 2013 (GMT)
Thanks for the assist, Daric, but nothing seems to be able to change my sidebar. I've tried many different things to no avail. Do either of you know if maybe there is a preference option that I need to change to get these changes to take affect? I looked through them and unchecked the "Neaten up toolbar..." thingy, but that didn't help. --Xyzzy Talk 04:34, 14 May 2013 (GMT)
Okay, I wasn't sure about this before, but it is worth a try. Jak gave you a list of commands to execute from within your monoboook.js file. I've never seen them executed just like that before. Normally they would form part of a function call, rather than be separate instructions. If you were to wrap all those ModifySidebar() commands inside a function, give it any name you like, then execute that function with a addOnloadHook() statement, that should work. The end result should look something like this...
importScript('UESPWiki:Javascript/modifysidebar.js');
function dothis() {
    ModifySidebar("clear",    "sections");
    ModifySidebar("add",      "sections",  "Lore",                "http://www.uesp.net/wiki/Lore:Main_Page");
        .
        .
        .
    ModifySidebar("add",      "sections",  "Arena",               "http://www.uesp.net/wiki/Arena:Arena");
}
addOnloadHook(dothis);

Daric 05:54, 14 May 2013 (GMT)

() Ah ha! That did it. Thanks, Daric. --Xyzzy Talk

Making Navpopups into a Gadget[edit]

Can that be done? ~ Ad intellige (talk) 20:11, 10 January 2015 (GMT)