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

Content deleted Content added
Shadowbot3 (talk | contribs)
m Automated archival of 2 sections from MediaWiki talk:Common.js
Shadowbot3 (talk | contribs)
m Automated archival of 4 sections from MediaWiki talk:Common.js
Line 81:
 
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)
<span id="63304215427" />
== Audio pop-ups ==
 
We have an {{tl|audio}} template for inline audio clips:
 
:<code><nowiki>'''Bordeaux''' ({{Audio|Fr-Bordeaux.ogg|pronunciation}}) is a [[Seaport|port]] city in...</nowiki></code>
gives this:
:'''Bordeaux''' ({{Audio|Fr-Bordeaux.ogg|pronunciation}}) is a [[Seaport|port]] city in...
 
[[Image:Audiopopswithspeaker.png|thumb|400px|What the new version looks like in Firefox]]
 
A lot of people think the extra links are cluttery, but they're necessary for newcomers. I proposed that the links be removed with javascript and put in a pop-up instead. I don't know enough about javascript to write more than a mock-up, though. Could someone else finish this and deploy it site-wide?
 
* [[Template_talk:Audio#Javascript_solution.3F|Javascript solution?]]
* [[Template_talk:Audio#Newer_javascript_version|Newer version]]
 
When we finally get inline java players, the player could be inside the pop-up, too? — [[User:Omegatron|Omegatron]] 18:24, 28 April 2007 (UTC)
 
:Yes, I agree with this new JavaScript. Count me in. --[[User:Steinninn|Steinninn]] 10:19, 6 May 2007 (UTC)
 
:That's an interesting script, but it seems like it would be more appropriate as a [[WP:US/S|user script]] than as a site-wide thing. What more do you think needs to be changed for it to be usable? I'd assume it needs some more cross-browser testing to deal with weird layout/margin issues. Also, I'd suggest requesting that some extra spans with their own distinct classes be added to {{tl|audio}} to simplify some of the more fragile parts of the code relating to extracting and moving the "help" and "info" links (i.e. spans that contain only the help and info links respectively). [[User talk:Mike Dillon|Mike Dillon]] 02:42, 8 May 2007 (UTC)
 
:: I think it's more appropriate as a site-wide thing. There are numerous complaints about the help and info links cluttering up articles, but there's really no way around them. We need to link to the help so that people can open ogg files, and we need to link to the description for copyright reasons and to find out more details about the audio sample.
:: The things that still need work: cross-browser, not extending past the edge of the browser window, not obstructing the original link, the timing with which it opens and closes and whether you're hovering over it, etc. etc. Just needs to be tweaked to work really nicely.
:: Agreed about the spans. I used class audiolink and audiolinkinfo, but they might be better in another place, etc. If the audio template is ever changed, it would break the javascript. The javascript should test to see whether the audio template has been changed, and if it has, do nothing, so that it degrades gracefully. — [[User:Omegatron|Omegatron]] 16:17, 12 May 2007 (UTC)
 
<span id="63303953647" />
== 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="63303917707" />
== 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)
 
<span id="63304210867" />
== PROPOSAL: Adding New Java Script Code to Wikipedia ==
How can I request that new Java Script code be added to Wikipedia by an Administrator? The code would allow for entries in a Table/Chart to be autonumbered ... much like entries in a simple List can be autonumbered with the # symbol. Please advise. Thanks. ([[User:JosephASpadaro|JosephASpadaro]] 03:57, 12 May 2007 (UTC))
:Just propose it below on this page :-) —<span style="color: red;">[[User:Mets501|M<small>ETS</small>501]] ([[User talk:Mets501|talk]])</span> 13:58, 12 May 2007 (UTC)
 
::While Joseph was discussing this with me, I wrote the code he wanted at [[User:Mike Dillon/Scripts/autonumber.js]]. It basically detects tables with <code>class="autonumber"</code> and adds a new cell to each row to create a column of automatic numbers. It's currently a little Monobook-specific in that it relies on the presence of "bodyContent" and I think we'd need to see a consensus for adding the feature somewhere before adding it site-wide. I've deployed similar code on another wiki and it works in Firefox and Internet Explorer. One thing that is weird about it is that you can't currently make an autonumbered table where the synthetic column is sortable because of a timing issue with the sortable code and onload hooks.
 
::For what it's worth, I don't see this addition being worthwhile for Wikipedia, but I posted the code since I had already written it. [[User talk:Mike Dillon|Mike Dillon]] 15:01, 12 May 2007 (UTC)