MediaWiki talk:Common.js/Archive 6: Difference between revisions

Content deleted Content added
Shadowbot3 (talk | contribs)
m Automated archival of 1 sections from MediaWiki talk:Common.js
 
Shadowbot3 (talk | contribs)
m Automated archival of 2 sections from MediaWiki talk:Common.js
Line 5:
Hello, i'd like to change our current star icon at [[:es:Plantilla:Destacado]] (it's a big bronze star) for the small yellow star used for the same porpouse at the French and English wikipedia. Could someone help me? I Post this at the template's discussion, and an librarian told me to come here. Thank you!--[[User:Fernandopascullo|Fernandopascullo]] 19:30, 2 May 2007 (UTC)
:Well, the section [[Template_talk:Link_FA#How_does_it_work.3F|how does it work]] pretty much explains how {{tl|Link FA}} works here. You have it slightly differently in [[:es:MediaWiki:Monobook.js]]: your function <tt>LinkFA()</tt> directly specifies [[Image:LinkFA-star.png]] image. You could just change it to <tt>http://upload.wikimedia.org/wikipedia/en/d/d4/Monobook-bullet-star.png</tt> ([[Image:Monobook-bullet-star.png]]). Or even better, do it the way it works here. [[User:Alex Smotrov|Alex Smotrov]] 20:25, 2 May 2007 (UTC)
<span id="63303953643" />
== Enhancements to importScript ==
 
I'm interested in seeing the following enhancements made to <code>importScript()</code>:
 
# Ability to specify base server name
# Ability to specify specific script revision with oldid
 
I've seen something like the first one in place at [[:ru:MediaWiki:Common.js]]. I haven't seen the second one, but I think it would be useful to let users stick with a known-good version of a script. For example, I currently have copies of [[User:Lupin/popups.js]] and [[User:Zocky/PicturePopups.js]] in my own userspace because I've been burnt by upgrades to scripts and prefer to stick with a known version and not be forcibly upgraded. If I could easily pull in a script using oldid, I wouldn't have this problem.
 
Here are my proposed versions of <code>importScript()</code> and <code>importStylesheet()</code>:
 
<pre>
function importScript( page, options ) {
if( importedScripts[page] ) {
return;
}
if (!options) options = {};
importedScripts[page] = true;
var server = '';
if (options.server) {
server = "http://" + options.server;
}
var url = server + wgScriptPath
+ '/index.php?title='
+ encodeURIComponent( page.replace( ' ', '_' ) )
+ '&action=raw&ctype=text/javascript';
if (options.oldid) {
url += "&oldid=" + encodeURIComponent(options.oldid);
}
var scriptElem = document.createElement( 'script' );
scriptElem.setAttribute( 'src' , url );
scriptElem.setAttribute( 'type' , 'text/javascript' );
document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
}
 
function importStylesheet( page, options ) {
if (!options) options = {};
var server = '';
if (options.server) {
server = "http://" + options.server;
}
var url = server + wgScriptPath
+ '/index.php?title='
+ encodeURIComponent( page.replace( ' ', '_' ) )
+ '&action=raw&ctype=text/css';
if (options.oldid) {
url += "&oldid=" + encodeURIComponent(options.oldid);
}
var sheet = '@import "' + url + '";';
var styleElem = document.createElement( 'style' );
styleElem.setAttribute( 'type' , 'text/css' );
styleElem.appendChild( document.createTextNode( sheet ) );
document.getElementsByTagName( 'head' )[0].appendChild( styleElem );
}
</pre>
 
The Russian version takes a single "lang" parameter instead of a hash of options, but I figured that using "server" would be more accomodating to hosting scripts on Meta or Commons, since they are under wikimedia.org, not wikipedia.org. Plus, I needed it to take a hash to support both "server" and "oldid". It would be pretty easy to support both "server" and "lang", but I didn't really see the point. The code would look something like this:
 
<pre>
if (options.server) {
server = "http://" + options.server;
} else if (options.lang) {
server = wgServer.replace("\\b" + wgContentLanguage + "\\b", options.lang);
// server = "http://" + options.lang + ".wikipedia.org";
}
</pre>
 
What do people think of doing this? I think that it would improve the ability to reuse scripts across multiple Wikimedia projects, especially if combined with an internationalization library like the one I'm playing around with [[User:Mike Dillon/Scripts/i18n.js|here]]. [[User talk:Mike Dillon|Mike Dillon]] 00:36, 7 May 2007 (UTC)
 
:It might be worth adding support for the "smaxage" parameter here as well. [[User talk:Mike Dillon|Mike Dillon]] 15:34, 9 May 2007 (UTC)
 
<span id="63303917703" />
== JavaScript version of [[MediaWiki:Edittools]] ==
 
Please contribute to the discussion of a JavaScript version of [[MediaWiki:Edittools]] at [[MediaWiki talk:Edittools#Request]]. If there is agreement to move in this direction, the code will have to be moved to [[MediaWiki:Edittools.js]] or some such and imported from [[MediaWiki:Common.js]]. [[User talk:Mike Dillon|Mike Dillon]] 05:35, 9 May 2007 (UTC)