and by the way,the extension i called ClipUpload,it's my first public extension,but seems not mush people need to use it,so now is only my self:) if you wana use clipboard to upload photo to mediawiki,you can have a look,but only support for chrome now.
http://www.mediawiki.org/wiki/Extension:ClipUpload
Regrades Sen
From SLboat(http://see.sl088.com)
在 2013-12-15,17:07,Thomas Gries mail@tgries.de 写道:
Am 15.12.2013 09:37, schrieb Sen:
hi,i had a confuse,how can i pass a value to the js content script
for nowi,i use the way from msupload: $wgOut->addScript("<script type='text/javascript'>var clipup_vars = $clipup_vars ;</script>\n"); it's work but sometimes it seems not work well,the js cant get the value clipup_vars. it's any nature way to doing this?
A short section of the ResourceLoader guide explains this.
If you used to insert javascript like:
var wgFoo = "bar";
You can now use resource loader to add your variable as a config variable. If the variable is the same for all pages and should be on all pages, use the ResourceLoaderGetConfigVars https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars hook. Otherwise if the variable depends on the current page being viewed you can either use the MakeGlobalVariablesScript https://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript hook or if you have an OutputPage object, the addJsConfigVars https://doc.wikimedia.org/mediawiki-core/master/php/html/classOutputPage.html#a81c86f0fc996076ed05467f63b3fb154 method. Variables added can be accesed in javascript using |mw.config.get( 'variable name' );|
and look to the example in
- https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars (If the variable is the same for all pages and should be on all pages)
- https://doc.wikimedia.org/mediawiki-core/master/php/html/classOutputPage.htm... (if the variable depends on the current page)
Sometimes in my php I use a construct like
if ( $out->getTitle()->equals( SpecialPage::getTitleFor(
'OpenIDConvert' ) ) { $out->addHeadItem( 'openid-providerstyle', self::providerStyle() ); }
to embed code (here: a style) only for certain pages, not for all. Perhaps you want this, too.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l