I wanted to bring this back up into your attention, hoping that I can get a response.
On Thu, Aug 20, 2015 at 10:46 PM, Huji Lee huji.huji@gmail.com wrote:
Excellent answers. Thank you!
Here is a final question: how long does it generally take for a change made in a script to be reflected in the output of RL? Is it in the order of minutes or hours?
On Thu, Aug 20, 2015 at 10:26 AM, Bartosz Dziewoński matma.rex@gmail.com wrote:
On Thu, 20 Aug 2015 04:07:57 +0200, Huji Lee huji.huji@gmail.com wrote:
However, if you don't
bypass ResourceLoader, the "+" links won't work and an error is thrown reading "SimpleWindow is not defined" (try on my talk page without bypassing RL https://fa.wikipedia.org/wiki/User_talk:Huji). Note that SimpleWindow is defined in morebits.js
When you load a script through ResourceLoader, it's not executed in global context. This means that global variables you define are actually *not global* (they are local to the function your code is wrapped in), unless you explicitly assign them as `window` properties.
The code of the gadget in question actually does it right:
// https://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%... var UserMessages = {}; window.UserMessages = UserMessages; // global access
(It would be sufficient to just do `window.UserMessages = {}`, but this is also just as correct.)
morebits doesn't:
// https://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%... var SimpleWindow = function( width, height ) { ...
This should be changed to:
window.SimpleWindow = function( width, height ) {
- How come it works when you bypass ResourceLoader? Note that nothing
else has changed recently (including the morebits.js code on that Wiki)
When you use ?debug=true, the global variables are actually global. This is an implementation detail of how debug mode works, and hopefully will be changed to behave like normal mode at some point.
- Is it safe to assume that just by listing ext.gadgets.morebits as a
dependency, morebits will be properly loaded by ResourceLoader?
Yes, just be careful about explicitly allowing access to globals by attaching them to `window`.
-- Bartosz Dziewoński
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l