Re: [Wikitech-l] pass value from extension to extension's js

2013-12-15 Thread Sen
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  写道:

> 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("var clipup_vars = 
>> $clipup_vars ;\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.
> 
>  * 
> https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_for_extension_developers#Configuration_variables
> 
> 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
>  
> hook.
> Otherwise if the variable depends on the current page being viewed you
> can either use the MakeGlobalVariablesScript
> 
> hook or if you have an OutputPage object, the addJsConfigVars
> 
> 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.html
>(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

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] pass value from extension to extension's js

2013-12-15 Thread Sen
great thx,i will research this,my english is not so good for read all this.

i like the way use "$out",before this,i only know one way to only showing some 
case:
if ($this->getSkin()->getUser()->getName() != "Sen"){}  


Regrades
Sen

From SLboat(http://see.sl088.com)

在 2013-12-15,17:07,Thomas Gries  写道:

> 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("var clipup_vars = 
>> $clipup_vars ;\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.
> 
>  * 
> https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_for_extension_developers#Configuration_variables
> 
> 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
>  
> hook.
> Otherwise if the variable depends on the current page being viewed you
> can either use the MakeGlobalVariablesScript
> 
> hook or if you have an OutputPage object, the addJsConfigVars
> 
> 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.html
>(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

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] pass value from extension to extension's js

2013-12-15 Thread Thomas Gries
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("var clipup_vars = 
> $clipup_vars ;\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.

  * 
https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_for_extension_developers#Configuration_variables

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
 hook.
Otherwise if the variable depends on the current page being viewed you
can either use the MakeGlobalVariablesScript

hook or if you have an OutputPage object, the addJsConfigVars

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.html
(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

[Wikitech-l] pass value from extension to extension's js

2013-12-15 Thread 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("var clipup_vars = 
$clipup_vars ;\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?


Regrades
Sen

From SLboat(http://see.sl088.com)

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l