Last modified: 2013-04-07 21:39:31 UTC
Gadgets and userscripts that interact with wikibase (wikidata) references in articles need the repository url and path and the interwiki id of the current wiki on the repository. An example is the editor gadget wikEd that linkifies {{#property:}} variables in wiki text, allowing to open the referenced page in the repository by ctrl-clicking. On Wikipedia, it is relatively easy to guess interwiki id and repo and it is often possible to get the repo path from the interlanguage edit link. However, these workarounds fail on non-Wikipedia wikis that use other repos. Therefore, gadgets and userscripts need wg-like variables for this. If these already exist, please document this crucial information.
The wikibase.client.currentSite module should hold all the information you need (it sets mw.config.get( 'wbCurrentSite' ) )
I forgot to mention the wikibase.repoAccess module for wbRepoUrl, wbRepoScriptPath and wbRepoArticlePath.
mw.config.get('wbCurrentSite') gives null when editing a Wikipedia page. Same for the other vars.
You need to load the modules I mentioned via mw.loader (see https://www.mediawiki.org/wiki/ResourceLoader/Default_modules)