Last modified: 2008-05-19 22:52:31 UTC
Created attachment 4689 [details] tab-indented plaintext of proposed functions, per http://test.wikipedia.org/w/index.php?title=MediaWiki_talk:Common.js&oldid=39798 Per discussions on mediawiki javascript bloat, and dom-safe script/style functions in common use on the major wikis, users in #mediawiki-scripts have written some browser-safe import*() functions for CSS and JS, which could be added to wikibits.js, and replace many instances of document.write()(which can be buggy in safari and other browsers) as well as give script writers more options to optionally include libraries. This proposed version (5 functions with little redundancy, importScript(), importScriptURI(), importStylesheet(), importStylesheetURI(), and appendCSS() -- see attachment, sorry it isn't a patch) maintain full backward compatabilty with existing copies of importScript() and importStylesheet() (as used on the English Wikipedia), and fix a few bugs in IE and Safari as well. They have been tested on the following browsers: * Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1 (Windows 98) * Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12 (Linux) * Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b3pre) Gecko/2008020507 Firefox/3.0b3pre (Linux) * Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071128 Iceweasel/2.0.0.11 (Debian-2.0.0.11-1) (Linux) * Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 (Windows XP) * Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.2) (Windows XP) * Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.0.3705; .NET CLR 1.1.4322; rm ; .NET CLR 2.0.50727) (Win XP) * Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.15.1 (KHTML, like Gecko) Version/3.0.4 Safari/523.15 * Opera/9.10 (Macintosh; Intel Mac OS X; U; en) * Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 * Opera/8.5 (Macintosh; Intel Mac OS X; U; en) The functions should be added near the top, but probably below function addOnloadHook() and function hookEvent(). The current attachment version is from http://test.wikipedia.org/w/index.php?title=MediaWiki_talk:Common.js&oldid=39798 (which differs from the tested version only in function names and appearance).
Created attachment 4691 [details] patch of changes against current trunk added patch of the diff between current trunk and Splarka's modifications as per Splarka's request on IRC
Note: patch 4691 also resolves https://bugzilla.wikimedia.org/show_bug.cgi?id=12773
Created attachment 4696 [details] Updated plaintext with new return statements. Taken from http://test.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=40963 This new plaintext version of the proposed functions adds a few return statements. These can be useful in order to do things like: var s=importScript('User:AzaToth/morebits.js'); s.onload = function loadRestOfTwinkle(){ }; And other changes or checks of the added DOM element.
Created attachment 4697 [details] re-diffed against current trunk with updates
(In reply to comment #4) > Created an attachment (id=4697) [details] > re-diffed against current trunk with updates > Oops, 4697 has an extranuous semicolon in it, I probably sent the wrong file to Ryan. + onloadFuncts[onloadFuncts.length]; = hookFunct; should be + onloadFuncts[onloadFuncts.length] = hookFunct; Also, only the original patch was tested against all the listed browsers, the feature creeping may get to the point of invalidating those tests somewhat. Also, please send all future suggested changes as unified patches (or we'll make a mess, and #mediawiki-scripts will be laughed at).
Created attachment 4701 [details] Updated diff. removed extraneous semicolon and ^M chars
If a script requires JavaScript 1.7 or 1.8 this needs to be declared in the <script> tag. To make this possible importScript needs an optional JavaScript version parameter.
We discussed this a bit in #mediawiki-scripts We currently do not see the need to add this. 1.7 and 1.8 features are hardly used. If someone does need it, we can add it easily enough at a later time.
Looks pretty sweet. :D Applied in r35064