Index: branches/js2-work/phase3/skins/common/wikibits.js |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | var opera7_bugs = is_opera_seven && !is_opera_95; |
27 | 27 | var opera95_bugs = /opera\/(9\.5)/.test( clientPC ); |
28 | 28 | } |
| 29 | +// Start at 4 to minimize the chance of breaking on IE10 :) |
| 30 | +var ie6_bugs = /msie [4-6]/.test( clientPC ); |
29 | 31 | |
30 | 32 | // Global external objects used by this script. |
31 | 33 | /*extern ta, stylepath, skin */ |
— | — | @@ -36,144 +38,145 @@ |
37 | 39 | var onloadFuncts = []; |
38 | 40 | } |
39 | 41 | |
40 | | -// code that is dependent on js2 functions should use mw.ready |
41 | | -function addOnloadHook(hookFunct) { |
| 42 | +function addOnloadHook( hookFunct ) { |
42 | 43 | // Allows add-on scripts to add onload functions |
43 | | - if(!doneOnloadHook) { |
| 44 | + if( !doneOnloadHook ) { |
44 | 45 | onloadFuncts[onloadFuncts.length] = hookFunct; |
45 | 46 | } else { |
46 | 47 | hookFunct(); // bug in MSIE script loading |
47 | 48 | } |
48 | 49 | } |
49 | 50 | |
50 | | - |
51 | | -function hookEvent(hookName, hookFunct) { |
52 | | - addHandler(window, hookName, hookFunct); |
| 51 | +function hookEvent( hookName, hookFunct ) { |
| 52 | + addHandler( window, hookName, hookFunct ); |
53 | 53 | } |
54 | 54 | |
55 | | -function importScript(page) { |
| 55 | +function importScript( page ) { |
56 | 56 | // TODO: might want to introduce a utility function to match wfUrlencode() in PHP |
57 | 57 | var uri = wgScript + '?title=' + |
58 | 58 | encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') + |
59 | 59 | '&action=raw&ctype=text/javascript'; |
60 | | - return importScriptURI(uri); |
| 60 | + return importScriptURI( uri ); |
61 | 61 | } |
62 | 62 | |
63 | 63 | var loadedScripts = {}; // included-scripts tracker |
64 | | -function importScriptURI(url) { |
65 | | - if (loadedScripts[url]) { |
| 64 | +function importScriptURI( url ) { |
| 65 | + if ( loadedScripts[url] ) { |
66 | 66 | return null; |
67 | 67 | } |
68 | 68 | loadedScripts[url] = true; |
69 | | - var s = document.createElement('script'); |
70 | | - s.setAttribute('src',url); |
71 | | - s.setAttribute('type','text/javascript'); |
72 | | - document.getElementsByTagName('head')[0].appendChild(s); |
| 69 | + var s = document.createElement( 'script' ); |
| 70 | + s.setAttribute( 'src', url ); |
| 71 | + s.setAttribute( 'type', 'text/javascript' ); |
| 72 | + document.getElementsByTagName('head')[0].appendChild( s ); |
73 | 73 | return s; |
74 | 74 | } |
75 | 75 | |
76 | | -function importStylesheet(page) { |
77 | | - return importStylesheetURI(wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent(page.replace(/ /g,'_'))); |
| 76 | +function importStylesheet( page ) { |
| 77 | + return importStylesheetURI( wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent( page.replace(/ /g,'_') ) ); |
78 | 78 | } |
79 | 79 | |
80 | | -function importStylesheetURI(url,media) { |
81 | | - var l = document.createElement('link'); |
| 80 | +function importStylesheetURI( url, media ) { |
| 81 | + var l = document.createElement( 'link' ); |
82 | 82 | l.type = 'text/css'; |
83 | 83 | l.rel = 'stylesheet'; |
84 | 84 | l.href = url; |
85 | | - if(media) l.media = media |
86 | | - document.getElementsByTagName('head')[0].appendChild(l); |
| 85 | + if( media ) { |
| 86 | + l.media = media; |
| 87 | + } |
| 88 | + document.getElementsByTagName('head')[0].appendChild( l ); |
87 | 89 | return l; |
88 | 90 | } |
89 | 91 | |
90 | | -function appendCSS(text) { |
91 | | - var s = document.createElement('style'); |
| 92 | +function appendCSS( text ) { |
| 93 | + var s = document.createElement( 'style' ); |
92 | 94 | s.type = 'text/css'; |
93 | 95 | s.rel = 'stylesheet'; |
94 | | - if (s.styleSheet) s.styleSheet.cssText = text //IE |
95 | | - else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null |
96 | | - document.getElementsByTagName('head')[0].appendChild(s); |
| 96 | + if ( s.styleSheet ) { |
| 97 | + s.styleSheet.cssText = text; // IE |
| 98 | + } else { |
| 99 | + s.appendChild( document.createTextNode( text + '' ) ); // Safari sometimes borks on null |
| 100 | + } |
| 101 | + document.getElementsByTagName('head')[0].appendChild( s ); |
97 | 102 | return s; |
98 | 103 | } |
99 | 104 | |
100 | | -// special stylesheet links |
101 | | -if (typeof stylepath != 'undefined' && typeof skin != 'undefined') { |
102 | | - // FIXME: This tries to load the stylesheets even for skins where they |
103 | | - // don't exist, i.e., everything but Monobook. |
104 | | - if (opera6_bugs) { |
105 | | - importStylesheetURI(stylepath+'/'+skin+'/Opera6Fixes.css'); |
106 | | - } else if (opera7_bugs) { |
107 | | - importStylesheetURI(stylepath+'/'+skin+'/Opera7Fixes.css'); |
108 | | - } else if (opera95_bugs) { |
109 | | - importStylesheetURI(stylepath+'/'+skin+'/Opera9Fixes.css'); |
110 | | - } else if (ff2_bugs) { |
111 | | - importStylesheetURI(stylepath+'/'+skin+'/FF2Fixes.css'); |
| 105 | +// Special stylesheet links for Monobook only (see bug 14717) |
| 106 | +if ( typeof stylepath != 'undefined' && skin == 'monobook' ) { |
| 107 | + if ( opera6_bugs ) { |
| 108 | + importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' ); |
| 109 | + } else if ( opera7_bugs ) { |
| 110 | + importStylesheetURI( stylepath + '/' + skin + '/Opera7Fixes.css' ); |
| 111 | + } else if ( opera95_bugs ) { |
| 112 | + importStylesheetURI( stylepath + '/' + skin + '/Opera9Fixes.css' ); |
| 113 | + } else if ( ff2_bugs ) { |
| 114 | + importStylesheetURI( stylepath + '/' + skin + '/FF2Fixes.css' ); |
112 | 115 | } |
113 | 116 | } |
114 | 117 | |
115 | 118 | |
116 | | -if (wgBreakFrames) { |
| 119 | +if ( wgBreakFrames ) { |
117 | 120 | // Un-trap us from framesets |
118 | | - if (window.top != window) { |
| 121 | + if ( window.top != window ) { |
119 | 122 | window.top.location = window.location; |
120 | 123 | } |
121 | 124 | } |
122 | 125 | |
123 | 126 | function showTocToggle() { |
124 | | - if (document.createTextNode) { |
| 127 | + if ( document.createTextNode ) { |
125 | 128 | // Uses DOM calls to avoid document.write + XHTML issues |
126 | 129 | |
127 | | - var linkHolder = document.getElementById('toctitle'); |
128 | | - var existingLink = document.getElementById('togglelink'); |
129 | | - if (!linkHolder || existingLink) { |
| 130 | + var linkHolder = document.getElementById( 'toctitle' ); |
| 131 | + var existingLink = document.getElementById( 'togglelink' ); |
| 132 | + if ( !linkHolder || existingLink ) { |
130 | 133 | // Don't add the toggle link twice |
131 | 134 | return; |
132 | 135 | } |
133 | 136 | |
134 | | - var outerSpan = document.createElement('span'); |
| 137 | + var outerSpan = document.createElement( 'span' ); |
135 | 138 | outerSpan.className = 'toctoggle'; |
136 | 139 | |
137 | | - var toggleLink = document.createElement('a'); |
| 140 | + var toggleLink = document.createElement( 'a' ); |
138 | 141 | toggleLink.id = 'togglelink'; |
139 | 142 | toggleLink.className = 'internal'; |
140 | 143 | toggleLink.href = 'javascript:toggleToc()'; |
141 | | - toggleLink.appendChild(document.createTextNode(tocHideText)); |
| 144 | + toggleLink.appendChild( document.createTextNode( tocHideText ) ); |
142 | 145 | |
143 | | - outerSpan.appendChild(document.createTextNode('[')); |
144 | | - outerSpan.appendChild(toggleLink); |
145 | | - outerSpan.appendChild(document.createTextNode(']')); |
| 146 | + outerSpan.appendChild( document.createTextNode( '[' ) ); |
| 147 | + outerSpan.appendChild( toggleLink ); |
| 148 | + outerSpan.appendChild( document.createTextNode( ']' ) ); |
146 | 149 | |
147 | | - linkHolder.appendChild(document.createTextNode(' ')); |
148 | | - linkHolder.appendChild(outerSpan); |
| 150 | + linkHolder.appendChild( document.createTextNode( ' ' ) ); |
| 151 | + linkHolder.appendChild( outerSpan ); |
149 | 152 | |
150 | | - var cookiePos = document.cookie.indexOf("hidetoc="); |
151 | | - if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1) { |
| 153 | + var cookiePos = document.cookie.indexOf( "hidetoc=" ); |
| 154 | + if ( cookiePos > -1 && document.cookie.charAt( cookiePos + 8 ) == 1 ) { |
152 | 155 | toggleToc(); |
153 | 156 | } |
154 | 157 | } |
155 | 158 | } |
156 | 159 | |
157 | | -function changeText(el, newText) { |
| 160 | +function changeText( el, newText ) { |
158 | 161 | // Safari work around |
159 | | - if (el.innerText) { |
| 162 | + if ( el.innerText ) { |
160 | 163 | el.innerText = newText; |
161 | | - } else if (el.firstChild && el.firstChild.nodeValue) { |
| 164 | + } else if ( el.firstChild && el.firstChild.nodeValue ) { |
162 | 165 | el.firstChild.nodeValue = newText; |
163 | 166 | } |
164 | 167 | } |
165 | 168 | |
166 | 169 | function toggleToc() { |
167 | | - var tocmain = document.getElementById('toc'); |
| 170 | + var tocmain = document.getElementById( 'toc' ); |
168 | 171 | var toc = document.getElementById('toc').getElementsByTagName('ul')[0]; |
169 | | - var toggleLink = document.getElementById('togglelink'); |
| 172 | + var toggleLink = document.getElementById( 'togglelink' ); |
170 | 173 | |
171 | | - if (toc && toggleLink && toc.style.display == 'none') { |
172 | | - changeText(toggleLink, tocHideText); |
| 174 | + if ( toc && toggleLink && toc.style.display == 'none' ) { |
| 175 | + changeText( toggleLink, tocHideText ); |
173 | 176 | toc.style.display = 'block'; |
174 | 177 | document.cookie = "hidetoc=0"; |
175 | 178 | tocmain.className = 'toc'; |
176 | 179 | } else { |
177 | | - changeText(toggleLink, tocShowText); |
| 180 | + changeText( toggleLink, tocShowText ); |
178 | 181 | toc.style.display = 'none'; |
179 | 182 | document.cookie = "hidetoc=1"; |
180 | 183 | tocmain.className = 'toc tochidden'; |
— | — | @@ -183,40 +186,39 @@ |
184 | 187 | var mwEditButtons = []; |
185 | 188 | var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js |
186 | 189 | |
187 | | -function escapeQuotes(text) { |
188 | | - var re = new RegExp("'","g"); |
189 | | - text = text.replace(re,"\\'"); |
190 | | - re = new RegExp("\\n","g"); |
191 | | - text = text.replace(re,"\\n"); |
192 | | - return escapeQuotesHTML(text); |
| 190 | +function escapeQuotes( text ) { |
| 191 | + var re = new RegExp( "'", "g" ); |
| 192 | + text = text.replace( re, "\\'" ); |
| 193 | + re = new RegExp( "\\n", "g" ); |
| 194 | + text = text.replace( re, "\\n" ); |
| 195 | + return escapeQuotesHTML( text ); |
193 | 196 | } |
194 | 197 | |
195 | | -function escapeQuotesHTML(text) { |
196 | | - var re = new RegExp('&',"g"); |
197 | | - text = text.replace(re,"&"); |
198 | | - re = new RegExp('"',"g"); |
199 | | - text = text.replace(re,"""); |
200 | | - re = new RegExp('<',"g"); |
201 | | - text = text.replace(re,"<"); |
202 | | - re = new RegExp('>',"g"); |
203 | | - text = text.replace(re,">"); |
| 198 | +function escapeQuotesHTML( text ) { |
| 199 | + var re = new RegExp( '&', "g" ); |
| 200 | + text = text.replace( re, "&" ); |
| 201 | + re = new RegExp( '"', "g" ); |
| 202 | + text = text.replace( re, """ ); |
| 203 | + re = new RegExp( '<', "g" ); |
| 204 | + text = text.replace( re, "<" ); |
| 205 | + re = new RegExp( '>', "g" ); |
| 206 | + text = text.replace( re, ">" ); |
204 | 207 | return text; |
205 | 208 | } |
206 | 209 | |
207 | | - |
208 | 210 | /** |
209 | 211 | * Set the accesskey prefix based on browser detection. |
210 | 212 | */ |
211 | 213 | var tooltipAccessKeyPrefix = 'alt-'; |
212 | | -if (is_opera) { |
| 214 | +if ( is_opera ) { |
213 | 215 | tooltipAccessKeyPrefix = 'shift-esc-'; |
214 | | -} else if (!is_safari_win && is_safari && webkit_version > 526) { |
| 216 | +} else if ( !is_safari_win && is_safari && webkit_version > 526 ) { |
215 | 217 | tooltipAccessKeyPrefix = 'ctrl-alt-'; |
216 | | -} else if (!is_safari_win && (is_safari |
| 218 | +} else if ( !is_safari_win && ( is_safari |
217 | 219 | || clientPC.indexOf('mac') != -1 |
218 | | - || clientPC.indexOf('konqueror') != -1 )) { |
| 220 | + || clientPC.indexOf('konqueror') != -1 ) ) { |
219 | 221 | tooltipAccessKeyPrefix = 'ctrl-'; |
220 | | -} else if (is_ff2) { |
| 222 | +} else if ( is_ff2 ) { |
221 | 223 | tooltipAccessKeyPrefix = 'alt-shift-'; |
222 | 224 | } |
223 | 225 | var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/; |
— | — | @@ -235,28 +237,28 @@ |
236 | 238 | // containers which contain the relevant links. This is really just an |
237 | 239 | // optimization technique. |
238 | 240 | var linkContainers = [ |
239 | | - "column-one", // Monobook and Modern |
240 | | - "head", "panel", "p-logo" // Vector |
| 241 | + 'column-one', // Monobook and Modern |
| 242 | + 'head', 'panel', 'p-logo' // Vector |
241 | 243 | ]; |
242 | 244 | for ( var i in linkContainers ) { |
243 | 245 | var linkContainer = document.getElementById( linkContainers[i] ); |
244 | 246 | if ( linkContainer ) { |
245 | | - updateTooltipAccessKeys( linkContainer.getElementsByTagName("a") ); |
| 247 | + updateTooltipAccessKeys( linkContainer.getElementsByTagName( 'a' ) ); |
246 | 248 | } |
247 | 249 | } |
248 | 250 | // these are rare enough that no such optimization is needed |
249 | | - updateTooltipAccessKeys( document.getElementsByTagName("input") ); |
250 | | - updateTooltipAccessKeys( document.getElementsByTagName("label") ); |
| 251 | + updateTooltipAccessKeys( document.getElementsByTagName( 'input' ) ); |
| 252 | + updateTooltipAccessKeys( document.getElementsByTagName( 'label' ) ); |
251 | 253 | return; |
252 | 254 | } |
253 | 255 | |
254 | 256 | for ( var i = 0; i < nodeList.length; i++ ) { |
255 | 257 | var element = nodeList[i]; |
256 | | - var tip = element.getAttribute("title"); |
257 | | - if ( tip && tooltipAccessKeyRegexp.exec(tip) ) { |
| 258 | + var tip = element.getAttribute( 'title' ); |
| 259 | + if ( tip && tooltipAccessKeyRegexp.exec( tip ) ) { |
258 | 260 | tip = tip.replace(tooltipAccessKeyRegexp, |
259 | | - "["+tooltipAccessKeyPrefix+"$5]"); |
260 | | - element.setAttribute("title", tip ); |
| 261 | + '[' + tooltipAccessKeyPrefix + "$5]"); |
| 262 | + element.setAttribute( 'title', tip ); |
261 | 263 | } |
262 | 264 | } |
263 | 265 | } |
— | — | @@ -289,60 +291,75 @@ |
290 | 292 | * |
291 | 293 | * @return Node -- the DOM node of the new item (an LI element) or null |
292 | 294 | */ |
293 | | -function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { |
294 | | - var root = document.getElementById(portlet); |
295 | | - if ( !root ) return null; |
296 | | - var node = root.getElementsByTagName( "ul" )[0]; |
297 | | - if ( !node ) return null; |
| 295 | +function addPortletLink( portlet, href, text, id, tooltip, accesskey, nextnode ) { |
| 296 | + var root = document.getElementById( portlet ); |
| 297 | + if ( !root ) { |
| 298 | + return null; |
| 299 | + } |
| 300 | + var node = root.getElementsByTagName( 'ul' )[0]; |
| 301 | + if ( !node ) { |
| 302 | + return null; |
| 303 | + } |
298 | 304 | |
299 | 305 | // unhide portlet if it was hidden before |
300 | 306 | root.className = root.className.replace( /(^| )emptyPortlet( |$)/, "$2" ); |
301 | 307 | |
302 | | - var span = document.createElement( "span" ); |
| 308 | + var span = document.createElement( 'span' ); |
303 | 309 | span.appendChild( document.createTextNode( text ) ); |
304 | 310 | |
305 | | - var link = document.createElement( "a" ); |
| 311 | + var link = document.createElement( 'a' ); |
306 | 312 | link.appendChild( span ); |
307 | 313 | link.href = href; |
308 | 314 | |
309 | | - var item = document.createElement( "li" ); |
| 315 | + var item = document.createElement( 'li' ); |
310 | 316 | item.appendChild( link ); |
311 | | - if ( id ) item.id = id; |
| 317 | + if ( id ) { |
| 318 | + item.id = id; |
| 319 | + } |
312 | 320 | |
313 | 321 | if ( accesskey ) { |
314 | | - link.setAttribute( "accesskey", accesskey ); |
315 | | - tooltip += " ["+accesskey+"]"; |
| 322 | + link.setAttribute( 'accesskey', accesskey ); |
| 323 | + tooltip += ' [' + accesskey + ']'; |
316 | 324 | } |
317 | 325 | if ( tooltip ) { |
318 | | - link.setAttribute( "title", tooltip ); |
| 326 | + link.setAttribute( 'title', tooltip ); |
319 | 327 | } |
320 | 328 | if ( accesskey && tooltip ) { |
321 | 329 | updateTooltipAccessKeys( new Array( link ) ); |
322 | 330 | } |
323 | 331 | |
324 | | - if ( nextnode && nextnode.parentNode == node ) |
| 332 | + if ( nextnode && nextnode.parentNode == node ) { |
325 | 333 | node.insertBefore( item, nextnode ); |
326 | | - else |
| 334 | + } else { |
327 | 335 | node.appendChild( item ); // IE compatibility (?) |
| 336 | + } |
328 | 337 | |
329 | 338 | return item; |
330 | 339 | } |
331 | 340 | |
332 | | -function getInnerText(el) { |
333 | | - if (typeof el == "string") return el; |
334 | | - if (typeof el == "undefined") { return el }; |
335 | | - if (el.textContent) return el.textContent; // not needed but it is faster |
336 | | - if (el.innerText) return el.innerText; // IE doesn't have textContent |
337 | | - var str = ""; |
| 341 | +function getInnerText( el ) { |
| 342 | + if ( typeof el == 'string' ) { |
| 343 | + return el; |
| 344 | + } |
| 345 | + if ( typeof el == 'undefined' ) { |
| 346 | + return el; |
| 347 | + } |
| 348 | + if ( el.textContent ) { |
| 349 | + return el.textContent; // not needed but it is faster |
| 350 | + } |
| 351 | + if ( el.innerText ) { |
| 352 | + return el.innerText; // IE doesn't have textContent |
| 353 | + } |
| 354 | + var str = ''; |
338 | 355 | |
339 | 356 | var cs = el.childNodes; |
340 | 357 | var l = cs.length; |
341 | | - for (var i = 0; i < l; i++) { |
342 | | - switch (cs[i].nodeType) { |
343 | | - case 1: //ELEMENT_NODE |
344 | | - str += ts_getInnerText(cs[i]); |
| 358 | + for ( var i = 0; i < l; i++ ) { |
| 359 | + switch ( cs[i].nodeType ) { |
| 360 | + case 1: // ELEMENT_NODE |
| 361 | + str += ts_getInnerText( cs[i] ); |
345 | 362 | break; |
346 | | - case 3: //TEXT_NODE |
| 363 | + case 3: // TEXT_NODE |
347 | 364 | str += cs[i].nodeValue; |
348 | 365 | break; |
349 | 366 | } |
— | — | @@ -360,21 +377,25 @@ |
361 | 378 | function setupCheckboxShiftClick() { |
362 | 379 | checkboxes = []; |
363 | 380 | lastCheckbox = null; |
364 | | - var inputs = document.getElementsByTagName('input'); |
365 | | - addCheckboxClickHandlers(inputs); |
| 381 | + var inputs = document.getElementsByTagName( 'input' ); |
| 382 | + addCheckboxClickHandlers( inputs ); |
366 | 383 | } |
367 | 384 | |
368 | | -function addCheckboxClickHandlers(inputs, start) { |
369 | | - if ( !start) start = 0; |
| 385 | +function addCheckboxClickHandlers( inputs, start ) { |
| 386 | + if ( !start ) { |
| 387 | + start = 0; |
| 388 | + } |
370 | 389 | |
371 | 390 | var finish = start + 250; |
372 | | - if ( finish > inputs.length ) |
| 391 | + if ( finish > inputs.length ) { |
373 | 392 | finish = inputs.length; |
| 393 | + } |
374 | 394 | |
375 | 395 | for ( var i = start; i < finish; i++ ) { |
376 | 396 | var cb = inputs[i]; |
377 | | - if ( !cb.type || cb.type.toLowerCase() != 'checkbox' ) |
| 397 | + if ( !cb.type || cb.type.toLowerCase() != 'checkbox' ) { |
378 | 398 | continue; |
| 399 | + } |
379 | 400 | var end = checkboxes.length; |
380 | 401 | checkboxes[end] = cb; |
381 | 402 | cb.index = end; |
— | — | @@ -382,14 +403,14 @@ |
383 | 404 | } |
384 | 405 | |
385 | 406 | if ( finish < inputs.length ) { |
386 | | - setTimeout( function () { |
387 | | - addCheckboxClickHandlers(inputs, finish); |
| 407 | + setTimeout( function() { |
| 408 | + addCheckboxClickHandlers( inputs, finish ); |
388 | 409 | }, 200 ); |
389 | 410 | } |
390 | 411 | } |
391 | 412 | |
392 | | -function checkboxClickHandler(e) { |
393 | | - if (typeof e == 'undefined') { |
| 413 | +function checkboxClickHandler( e ) { |
| 414 | + if ( typeof e == 'undefined' ) { |
394 | 415 | e = window.event; |
395 | 416 | } |
396 | 417 | if ( !e.shiftKey || lastCheckbox === null ) { |
— | — | @@ -405,10 +426,11 @@ |
406 | 427 | start = lastCheckbox; |
407 | 428 | finish = this.index - 1; |
408 | 429 | } |
409 | | - for (var i = start; i <= finish; ++i ) { |
| 430 | + for ( var i = start; i <= finish; ++i ) { |
410 | 431 | checkboxes[i].checked = endState; |
411 | | - if( i > start && typeof checkboxes[i].onchange == 'function' ) |
| 432 | + if( i > start && typeof checkboxes[i].onchange == 'function' ) { |
412 | 433 | checkboxes[i].onchange(); // fire triggers |
| 434 | + } |
413 | 435 | } |
414 | 436 | lastCheckbox = this.index; |
415 | 437 | return true; |
— | — | @@ -421,68 +443,76 @@ |
422 | 444 | Author says "The credit comment is all it takes, no license. Go crazy with it!:-)" |
423 | 445 | From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ |
424 | 446 | */ |
425 | | -function getElementsByClassName(oElm, strTagName, oClassNames){ |
| 447 | +function getElementsByClassName( oElm, strTagName, oClassNames ) { |
426 | 448 | var arrReturnElements = new Array(); |
427 | | - if ( typeof( oElm.getElementsByClassName ) == "function" ) { |
| 449 | + if ( typeof( oElm.getElementsByClassName ) == 'function' ) { |
428 | 450 | /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */ |
429 | 451 | var arrNativeReturn = oElm.getElementsByClassName( oClassNames ); |
430 | | - if ( strTagName == "*" ) |
| 452 | + if ( strTagName == '*' ) { |
431 | 453 | return arrNativeReturn; |
432 | | - for ( var h=0; h < arrNativeReturn.length; h++ ) { |
433 | | - if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() ) |
| 454 | + } |
| 455 | + for ( var h = 0; h < arrNativeReturn.length; h++ ) { |
| 456 | + if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() ) { |
434 | 457 | arrReturnElements[arrReturnElements.length] = arrNativeReturn[h]; |
| 458 | + } |
435 | 459 | } |
436 | 460 | return arrReturnElements; |
437 | 461 | } |
438 | | - var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); |
| 462 | + var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName ); |
439 | 463 | var arrRegExpClassNames = new Array(); |
440 | | - if(typeof oClassNames == "object"){ |
441 | | - for(var i=0; i<oClassNames.length; i++){ |
| 464 | + if( typeof oClassNames == 'object' ) { |
| 465 | + for( var i = 0; i < oClassNames.length; i++ ) { |
442 | 466 | arrRegExpClassNames[arrRegExpClassNames.length] = |
443 | 467 | new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"); |
444 | 468 | } |
445 | | - } |
446 | | - else{ |
| 469 | + } else { |
447 | 470 | arrRegExpClassNames[arrRegExpClassNames.length] = |
448 | 471 | new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"); |
449 | 472 | } |
450 | 473 | var oElement; |
451 | 474 | var bMatchesAll; |
452 | | - for(var j=0; j<arrElements.length; j++){ |
| 475 | + for( var j = 0; j < arrElements.length; j++ ) { |
453 | 476 | oElement = arrElements[j]; |
454 | 477 | bMatchesAll = true; |
455 | | - for(var k=0; k<arrRegExpClassNames.length; k++){ |
456 | | - if(!arrRegExpClassNames[k].test(oElement.className)){ |
| 478 | + for( var k = 0; k < arrRegExpClassNames.length; k++ ) { |
| 479 | + if( !arrRegExpClassNames[k].test( oElement.className ) ) { |
457 | 480 | bMatchesAll = false; |
458 | 481 | break; |
459 | 482 | } |
460 | 483 | } |
461 | | - if(bMatchesAll){ |
| 484 | + if( bMatchesAll ) { |
462 | 485 | arrReturnElements[arrReturnElements.length] = oElement; |
463 | 486 | } |
464 | 487 | } |
465 | | - return (arrReturnElements) |
| 488 | + return ( arrReturnElements ); |
466 | 489 | } |
467 | 490 | |
468 | | -function redirectToFragment(fragment) { |
| 491 | +function redirectToFragment( fragment ) { |
469 | 492 | var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/); |
470 | | - if (match) { |
471 | | - var webKitVersion = parseInt(match[1]); |
472 | | - if (webKitVersion < 420) { |
| 493 | + if ( match ) { |
| 494 | + var webKitVersion = parseInt( match[1] ); |
| 495 | + if ( webKitVersion < 420 ) { |
473 | 496 | // Released Safari w/ WebKit 418.9.1 messes up horribly |
474 | 497 | // Nightlies of 420+ are ok |
475 | 498 | return; |
476 | 499 | } |
477 | 500 | } |
478 | | - if (is_gecko) { |
479 | | - // Mozilla needs to wait until after load, otherwise the window doesn't scroll |
480 | | - addOnloadHook(function () { |
481 | | - if (window.location.hash == "") |
482 | | - window.location.hash = fragment; |
483 | | - }); |
484 | | - } else { |
485 | | - if (window.location.hash == "") |
486 | | - window.location.hash = fragment; |
| 501 | + if ( window.location.hash == '' ) { |
| 502 | + window.location.hash = fragment; |
| 503 | + |
| 504 | + // Mozilla needs to wait until after load, otherwise the window doesn't |
| 505 | + // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>. |
| 506 | + // There's no obvious way to detect this programmatically, so we use |
| 507 | + // version-testing. If Firefox fixes the bug, they'll jump twice, but |
| 508 | + // better twice than not at all, so make the fix hit future versions as |
| 509 | + // well. |
| 510 | + if ( is_gecko ) { |
| 511 | + addOnloadHook(function() { |
| 512 | + if ( window.location.hash == fragment ) { |
| 513 | + window.location.hash = fragment; |
| 514 | + } |
| 515 | + }); |
| 516 | + } |
487 | 517 | } |
488 | 518 | } |
489 | 519 | |
— | — | @@ -497,11 +527,11 @@ |
498 | 528 | * @todo support all accepted date formats (bug 8226) |
499 | 529 | */ |
500 | 530 | |
501 | | -var ts_image_path = stylepath+"/common/images/"; |
502 | | -var ts_image_up = "sort_up.gif"; |
503 | | -var ts_image_down = "sort_down.gif"; |
504 | | -var ts_image_none = "sort_none.gif"; |
505 | | -var ts_europeandate = wgContentLanguage != "en"; // The non-American-inclined can change to "true" |
| 531 | +var ts_image_path = stylepath + '/common/images/'; |
| 532 | +var ts_image_up = 'sort_up.gif'; |
| 533 | +var ts_image_down = 'sort_down.gif'; |
| 534 | +var ts_image_none = 'sort_none.gif'; |
| 535 | +var ts_europeandate = wgContentLanguage != 'en'; // The non-American-inclined can change to "true" |
506 | 536 | var ts_alternate_row_colors = false; |
507 | 537 | var ts_number_transform_table = null; |
508 | 538 | var ts_number_regex = null; |
— | — | @@ -509,31 +539,33 @@ |
510 | 540 | function sortables_init() { |
511 | 541 | var idnum = 0; |
512 | 542 | // Find all tables with class sortable and make them sortable |
513 | | - var tables = getElementsByClassName(document, "table", "sortable"); |
514 | | - for (var ti = 0; ti < tables.length ; ti++) { |
515 | | - if (!tables[ti].id) { |
516 | | - tables[ti].setAttribute('id','sortable_table_id_'+idnum); |
| 543 | + var tables = getElementsByClassName( document, 'table', 'sortable' ); |
| 544 | + for ( var ti = 0; ti < tables.length ; ti++ ) { |
| 545 | + if ( !tables[ti].id ) { |
| 546 | + tables[ti].setAttribute( 'id', 'sortable_table_id_' + idnum ); |
517 | 547 | ++idnum; |
518 | 548 | } |
519 | | - ts_makeSortable(tables[ti]); |
| 549 | + ts_makeSortable( tables[ti] ); |
520 | 550 | } |
521 | 551 | } |
522 | 552 | |
523 | | -function ts_makeSortable(table) { |
| 553 | +function ts_makeSortable( table ) { |
524 | 554 | var firstRow; |
525 | | - if (table.rows && table.rows.length > 0) { |
526 | | - if (table.tHead && table.tHead.rows.length > 0) { |
| 555 | + if ( table.rows && table.rows.length > 0 ) { |
| 556 | + if ( table.tHead && table.tHead.rows.length > 0 ) { |
527 | 557 | firstRow = table.tHead.rows[table.tHead.rows.length-1]; |
528 | 558 | } else { |
529 | 559 | firstRow = table.rows[0]; |
530 | 560 | } |
531 | 561 | } |
532 | | - if (!firstRow) return; |
| 562 | + if ( !firstRow ) { |
| 563 | + return; |
| 564 | + } |
533 | 565 | |
534 | 566 | // We have a first row: assume it's the header, and make its contents clickable links |
535 | | - for (var i = 0; i < firstRow.cells.length; i++) { |
| 567 | + for ( var i = 0; i < firstRow.cells.length; i++ ) { |
536 | 568 | var cell = firstRow.cells[i]; |
537 | | - if ((" "+cell.className+" ").indexOf(" unsortable ") == -1) { |
| 569 | + if ( (' ' + cell.className + ' ').indexOf(' unsortable ') == -1 ) { |
538 | 570 | cell.innerHTML += '<a href="#" class="sortheader" ' |
539 | 571 | + 'onclick="ts_resortTable(this);return false;">' |
540 | 572 | + '<span class="sortarrow">' |
— | — | @@ -543,16 +575,16 @@ |
544 | 576 | + '" alt="↓"/></span></a>'; |
545 | 577 | } |
546 | 578 | } |
547 | | - if (ts_alternate_row_colors) { |
548 | | - ts_alternate(table); |
| 579 | + if ( ts_alternate_row_colors ) { |
| 580 | + ts_alternate( table ); |
549 | 581 | } |
550 | 582 | } |
551 | 583 | |
552 | | -function ts_getInnerText(el) { |
| 584 | +function ts_getInnerText( el ) { |
553 | 585 | return getInnerText( el ); |
554 | 586 | } |
555 | 587 | |
556 | | -function ts_resortTable(lnk) { |
| 588 | +function ts_resortTable( lnk ) { |
557 | 589 | // get the span |
558 | 590 | var span = lnk.getElementsByTagName('span')[0]; |
559 | 591 | |
— | — | @@ -561,107 +593,118 @@ |
562 | 594 | var column = td.cellIndex; |
563 | 595 | |
564 | 596 | var table = tr.parentNode; |
565 | | - while (table && !(table.tagName && table.tagName.toLowerCase() == 'table')) |
| 597 | + while ( table && !( table.tagName && table.tagName.toLowerCase() == 'table' ) ) { |
566 | 598 | table = table.parentNode; |
567 | | - if (!table) return; |
| 599 | + } |
| 600 | + if ( !table ) { |
| 601 | + return; |
| 602 | + } |
568 | 603 | |
569 | | - if (table.rows.length <= 1) return; |
| 604 | + if ( table.rows.length <= 1 ) { |
| 605 | + return; |
| 606 | + } |
570 | 607 | |
571 | 608 | // Generate the number transform table if it's not done already |
572 | | - if (ts_number_transform_table == null) { |
| 609 | + if ( ts_number_transform_table === null ) { |
573 | 610 | ts_initTransformTable(); |
574 | 611 | } |
575 | 612 | |
576 | 613 | // Work out a type for the column |
577 | 614 | // Skip the first row if that's where the headings are |
578 | | - var rowStart = (table.tHead && table.tHead.rows.length > 0 ? 0 : 1); |
| 615 | + var rowStart = ( table.tHead && table.tHead.rows.length > 0 ? 0 : 1 ); |
579 | 616 | |
580 | | - var itm = ""; |
581 | | - for (var i = rowStart; i < table.rows.length; i++) { |
582 | | - if (table.rows[i].cells.length > column) { |
| 617 | + var itm = ''; |
| 618 | + for ( var i = rowStart; i < table.rows.length; i++ ) { |
| 619 | + if ( table.rows[i].cells.length > column ) { |
583 | 620 | itm = ts_getInnerText(table.rows[i].cells[column]); |
584 | | - itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, ""); |
585 | | - if (itm != "") break; |
| 621 | + itm = itm.replace(/^[\s\xa0]+/, '').replace(/[\s\xa0]+$/, ''); |
| 622 | + if ( itm != '' ) { |
| 623 | + break; |
| 624 | + } |
586 | 625 | } |
587 | 626 | } |
588 | 627 | |
589 | 628 | // TODO: bug 8226, localised date formats |
590 | 629 | var sortfn = ts_sort_generic; |
591 | 630 | var preprocessor = ts_toLowerCase; |
592 | | - if (/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/.test(itm)) { |
| 631 | + if ( /^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/.test( itm ) ) { |
593 | 632 | preprocessor = ts_dateToSortKey; |
594 | | - } else if (/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/.test(itm)) { |
| 633 | + } else if ( /^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/.test( itm ) ) { |
595 | 634 | preprocessor = ts_dateToSortKey; |
596 | | - } else if (/^\d\d[\/.-]\d\d[\/.-]\d\d$/.test(itm)) { |
| 635 | + } else if ( /^\d\d[\/.-]\d\d[\/.-]\d\d$/.test( itm ) ) { |
597 | 636 | preprocessor = ts_dateToSortKey; |
598 | | - // pound dollar euro yen currency cents |
599 | | - } else if (/(^[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/.test(itm)) { |
| 637 | + // (minus sign)([pound dollar euro yen currency]|cents) |
| 638 | + } else if ( /(^([-\u2212] *)?[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/.test( itm ) ) { |
600 | 639 | preprocessor = ts_currencyToSortKey; |
601 | | - } else if (ts_number_regex.test(itm)) { |
| 640 | + } else if ( ts_number_regex.test( itm ) ) { |
602 | 641 | preprocessor = ts_parseFloat; |
603 | 642 | } |
604 | 643 | |
605 | | - var reverse = (span.getAttribute("sortdir") == 'down'); |
| 644 | + var reverse = ( span.getAttribute( 'sortdir' ) == 'down' ); |
606 | 645 | |
607 | 646 | var newRows = new Array(); |
608 | 647 | var staticRows = new Array(); |
609 | | - for (var j = rowStart; j < table.rows.length; j++) { |
| 648 | + for ( var j = rowStart; j < table.rows.length; j++ ) { |
610 | 649 | var row = table.rows[j]; |
611 | | - if((" "+row.className+" ").indexOf(" unsortable ") < 0) { |
612 | | - var keyText = ts_getInnerText(row.cells[column]); |
613 | | - if(keyText == undefined) { |
614 | | - keyText = ""; |
| 650 | + if( (' ' + row.className + ' ').indexOf(' unsortable ') < 0 ) { |
| 651 | + var keyText = ts_getInnerText( row.cells[column] ); |
| 652 | + if( keyText === undefined ) { |
| 653 | + keyText = ''; |
615 | 654 | } |
616 | | - var oldIndex = (reverse ? -j : j); |
617 | | - var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "") ); |
| 655 | + var oldIndex = ( reverse ? -j : j ); |
| 656 | + var preprocessed = preprocessor( keyText.replace(/^[\s\xa0]+/, '').replace(/[\s\xa0]+$/, '') ); |
618 | 657 | |
619 | | - newRows[newRows.length] = new Array(row, preprocessed, oldIndex); |
620 | | - } else staticRows[staticRows.length] = new Array(row, false, j-rowStart); |
| 658 | + newRows[newRows.length] = new Array( row, preprocessed, oldIndex ); |
| 659 | + } else { |
| 660 | + staticRows[staticRows.length] = new Array( row, false, j-rowStart ); |
| 661 | + } |
621 | 662 | } |
622 | 663 | |
623 | | - newRows.sort(sortfn); |
| 664 | + newRows.sort( sortfn ); |
624 | 665 | |
625 | 666 | var arrowHTML; |
626 | | - if (reverse) { |
627 | | - arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="↓"/>'; |
| 667 | + if ( reverse ) { |
| 668 | + arrowHTML = '<img src="' + ts_image_path + ts_image_down + '" alt="↓"/>'; |
628 | 669 | newRows.reverse(); |
629 | | - span.setAttribute('sortdir','up'); |
| 670 | + span.setAttribute( 'sortdir', 'up' ); |
630 | 671 | } else { |
631 | | - arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="↑"/>'; |
632 | | - span.setAttribute('sortdir','down'); |
| 672 | + arrowHTML = '<img src="' + ts_image_path + ts_image_up + '" alt="↑"/>'; |
| 673 | + span.setAttribute( 'sortdir', 'down' ); |
633 | 674 | } |
634 | 675 | |
635 | | - for (var i = 0; i < staticRows.length; i++) { |
| 676 | + for ( var i = 0; i < staticRows.length; i++ ) { |
636 | 677 | var row = staticRows[i]; |
637 | | - newRows.splice(row[2], 0, row); |
| 678 | + newRows.splice( row[2], 0, row ); |
638 | 679 | } |
639 | 680 | |
640 | 681 | // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones |
641 | 682 | // don't do sortbottom rows |
642 | | - for (var i = 0; i < newRows.length; i++) { |
643 | | - if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") == -1) |
644 | | - table.tBodies[0].appendChild(newRows[i][0]); |
| 683 | + for ( var i = 0; i < newRows.length; i++ ) { |
| 684 | + if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') == -1 ) { |
| 685 | + table.tBodies[0].appendChild( newRows[i][0] ); |
| 686 | + } |
645 | 687 | } |
646 | 688 | // do sortbottom rows only |
647 | | - for (var i = 0; i < newRows.length; i++) { |
648 | | - if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") != -1) |
649 | | - table.tBodies[0].appendChild(newRows[i][0]); |
| 689 | + for ( var i = 0; i < newRows.length; i++ ) { |
| 690 | + if ( ( ' ' + newRows[i][0].className + ' ').indexOf(' sortbottom ') != -1 ) { |
| 691 | + table.tBodies[0].appendChild( newRows[i][0] ); |
| 692 | + } |
650 | 693 | } |
651 | 694 | |
652 | 695 | // Delete any other arrows there may be showing |
653 | | - var spans = getElementsByClassName(tr, "span", "sortarrow"); |
654 | | - for (var i = 0; i < spans.length; i++) { |
655 | | - spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="↓"/>'; |
| 696 | + var spans = getElementsByClassName( tr, 'span', 'sortarrow' ); |
| 697 | + for ( var i = 0; i < spans.length; i++ ) { |
| 698 | + spans[i].innerHTML = '<img src="' + ts_image_path + ts_image_none + '" alt="↓"/>'; |
656 | 699 | } |
657 | 700 | span.innerHTML = arrowHTML; |
658 | 701 | |
659 | | - if (ts_alternate_row_colors) { |
660 | | - ts_alternate(table); |
| 702 | + if ( ts_alternate_row_colors ) { |
| 703 | + ts_alternate( table ); |
661 | 704 | } |
662 | 705 | } |
663 | 706 | |
664 | 707 | function ts_initTransformTable() { |
665 | | - if ( typeof wgSeparatorTransformTable == "undefined" |
| 708 | + if ( typeof wgSeparatorTransformTable == 'undefined' |
666 | 709 | || ( wgSeparatorTransformTable[0] == '' && wgDigitTransformTable[2] == '' ) ) |
667 | 710 | { |
668 | 711 | digitClass = "[0-9,.]"; |
— | — | @@ -691,7 +734,7 @@ |
692 | 735 | digit.replace( /[\\\\$\*\+\?\.\(\)\|\{\}\[\]\-]/, |
693 | 736 | function( s ) { return '\\' + s; } ) |
694 | 737 | ); |
695 | | - if (digit.length > maxDigitLength) { |
| 738 | + if ( digit.length > maxDigitLength ) { |
696 | 739 | maxDigitLength = digit.length; |
697 | 740 | } |
698 | 741 | } |
— | — | @@ -706,9 +749,9 @@ |
707 | 750 | // if percents and regular numbers aren't being mixed. |
708 | 751 | ts_number_regex = new RegExp( |
709 | 752 | "^(" + |
710 | | - "[+-]?[0-9][0-9,]*(\\.[0-9,]*)?(E[+-]?[0-9][0-9,]*)?" + // Fortran-style scientific |
| 753 | + "[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific |
711 | 754 | "|" + |
712 | | - "[+-]?" + digitClass + "+%?" + // Generic localised |
| 755 | + "[-+\u2212]?" + digitClass + "+%?" + // Generic localised |
713 | 756 | ")$", "i" |
714 | 757 | ); |
715 | 758 | } |
— | — | @@ -717,57 +760,81 @@ |
718 | 761 | return s.toLowerCase(); |
719 | 762 | } |
720 | 763 | |
721 | | -function ts_dateToSortKey(date) { |
| 764 | +function ts_dateToSortKey( date ) { |
722 | 765 | // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX |
723 | | - if (date.length == 11) { |
724 | | - switch (date.substr(3,3).toLowerCase()) { |
725 | | - case "jan": var month = "01"; break; |
726 | | - case "feb": var month = "02"; break; |
727 | | - case "mar": var month = "03"; break; |
728 | | - case "apr": var month = "04"; break; |
729 | | - case "may": var month = "05"; break; |
730 | | - case "jun": var month = "06"; break; |
731 | | - case "jul": var month = "07"; break; |
732 | | - case "aug": var month = "08"; break; |
733 | | - case "sep": var month = "09"; break; |
734 | | - case "oct": var month = "10"; break; |
735 | | - case "nov": var month = "11"; break; |
736 | | - case "dec": var month = "12"; break; |
737 | | - // default: var month = "00"; |
| 766 | + if ( date.length == 11 ) { |
| 767 | + switch ( date.substr( 3, 3 ).toLowerCase() ) { |
| 768 | + case 'jan': |
| 769 | + var month = '01'; |
| 770 | + break; |
| 771 | + case 'feb': |
| 772 | + var month = '02'; |
| 773 | + break; |
| 774 | + case 'mar': |
| 775 | + var month = '03'; |
| 776 | + break; |
| 777 | + case 'apr': |
| 778 | + var month = '04'; |
| 779 | + break; |
| 780 | + case 'may': |
| 781 | + var month = '05'; |
| 782 | + break; |
| 783 | + case 'jun': |
| 784 | + var month = '06'; |
| 785 | + break; |
| 786 | + case 'jul': |
| 787 | + var month = '07'; |
| 788 | + break; |
| 789 | + case 'aug': |
| 790 | + var month = '08'; |
| 791 | + break; |
| 792 | + case 'sep': |
| 793 | + var month = '09'; |
| 794 | + break; |
| 795 | + case 'oct': |
| 796 | + var month = '10'; |
| 797 | + break; |
| 798 | + case 'nov': |
| 799 | + var month = '11'; |
| 800 | + break; |
| 801 | + case 'dec': |
| 802 | + var month = '12'; |
| 803 | + break; |
| 804 | + // default: var month = '00'; |
738 | 805 | } |
739 | | - return date.substr(7,4)+month+date.substr(0,2); |
740 | | - } else if (date.length == 10) { |
741 | | - if (ts_europeandate == false) { |
742 | | - return date.substr(6,4)+date.substr(0,2)+date.substr(3,2); |
| 806 | + return date.substr( 7, 4 ) + month + date.substr( 0, 2 ); |
| 807 | + } else if ( date.length == 10 ) { |
| 808 | + if ( ts_europeandate == false ) { |
| 809 | + return date.substr( 6, 4 ) + date.substr( 0, 2 ) + date.substr( 3, 2 ); |
743 | 810 | } else { |
744 | | - return date.substr(6,4)+date.substr(3,2)+date.substr(0,2); |
| 811 | + return date.substr( 6, 4 ) + date.substr( 3, 2 ) + date.substr( 0, 2 ); |
745 | 812 | } |
746 | | - } else if (date.length == 8) { |
747 | | - yr = date.substr(6,2); |
748 | | - if (parseInt(yr) < 50) { |
749 | | - yr = '20'+yr; |
| 813 | + } else if ( date.length == 8 ) { |
| 814 | + yr = date.substr( 6, 2 ); |
| 815 | + if ( parseInt( yr ) < 50 ) { |
| 816 | + yr = '20' + yr; |
750 | 817 | } else { |
751 | | - yr = '19'+yr; |
| 818 | + yr = '19' + yr; |
752 | 819 | } |
753 | | - if (ts_europeandate == true) { |
754 | | - return yr+date.substr(3,2)+date.substr(0,2); |
| 820 | + if ( ts_europeandate == true ) { |
| 821 | + return yr + date.substr( 3, 2 ) + date.substr( 0, 2 ); |
755 | 822 | } else { |
756 | | - return yr+date.substr(0,2)+date.substr(3,2); |
| 823 | + return yr + date.substr( 0, 2 ) + date.substr( 3, 2 ); |
757 | 824 | } |
758 | 825 | } |
759 | | - return "00000000"; |
| 826 | + return '00000000'; |
760 | 827 | } |
761 | 828 | |
762 | 829 | function ts_parseFloat( s ) { |
763 | 830 | if ( !s ) { |
764 | 831 | return 0; |
765 | 832 | } |
766 | | - if (ts_number_transform_table != false) { |
| 833 | + if ( ts_number_transform_table != false ) { |
767 | 834 | var newNum = '', c; |
768 | 835 | |
769 | 836 | for ( var p = 0; p < s.length; p++ ) { |
770 | 837 | c = s.charAt( p ); |
771 | | - if (c in ts_number_transform_table) { |
| 838 | + if ( c in ts_number_transform_table ) { |
772 | 839 | newNum += ts_number_transform_table[c]; |
773 | 840 | } else { |
774 | 841 | newNum += c; |
— | — | @@ -775,37 +842,37 @@ |
776 | 843 | } |
777 | 844 | s = newNum; |
778 | 845 | } |
779 | | - |
780 | | - num = parseFloat(s.replace(/,/g, "")); |
781 | | - return (isNaN(num) ? 0 : num); |
| 846 | + num = parseFloat( s.replace(/[, ]/g, '').replace("\u2212", '-') ); |
| 847 | + return ( isNaN( num ) ? -Infinity : num ); |
782 | 848 | } |
783 | 849 | |
784 | 850 | function ts_currencyToSortKey( s ) { |
785 | | - return ts_parseFloat(s.replace(/[^0-9.,]/g,'')); |
| 851 | + return ts_parseFloat(s.replace(/[^-\u22120-9.,]/g,'')); |
786 | 852 | } |
787 | 853 | |
788 | | -function ts_sort_generic(a, b) { |
| 854 | +function ts_sort_generic( a, b ) { |
789 | 855 | return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : a[2] - b[2]; |
790 | 856 | } |
791 | 857 | |
792 | | -function ts_alternate(table) { |
| 858 | +function ts_alternate( table ) { |
793 | 859 | // Take object table and get all it's tbodies. |
794 | | - var tableBodies = table.getElementsByTagName("tbody"); |
| 860 | + var tableBodies = table.getElementsByTagName( 'tbody' ); |
795 | 861 | // Loop through these tbodies |
796 | | - for (var i = 0; i < tableBodies.length; i++) { |
| 862 | + for ( var i = 0; i < tableBodies.length; i++ ) { |
797 | 863 | // Take the tbody, and get all it's rows |
798 | | - var tableRows = tableBodies[i].getElementsByTagName("tr"); |
| 864 | + var tableRows = tableBodies[i].getElementsByTagName( 'tr' ); |
799 | 865 | // Loop through these rows |
800 | 866 | // Start at 1 because we want to leave the heading row untouched |
801 | | - for (var j = 0; j < tableRows.length; j++) { |
| 867 | + for ( var j = 0; j < tableRows.length; j++ ) { |
802 | 868 | // Check if j is even, and apply classes for both possible results |
803 | | - var oldClasses = tableRows[j].className.split(" "); |
804 | | - var newClassName = ""; |
805 | | - for (var k = 0; k < oldClasses.length; k++) { |
806 | | - if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd") |
807 | | - newClassName += oldClasses[k] + " "; |
| 869 | + var oldClasses = tableRows[j].className.split(' '); |
| 870 | + var newClassName = ''; |
| 871 | + for ( var k = 0; k < oldClasses.length; k++ ) { |
| 872 | + if ( oldClasses[k] != '' && oldClasses[k] != 'even' && oldClasses[k] != 'odd' ) { |
| 873 | + newClassName += oldClasses[k] + ' '; |
| 874 | + } |
808 | 875 | } |
809 | | - tableRows[j].className = newClassName + (j % 2 == 0 ? "even" : "odd"); |
| 876 | + tableRows[j].className = newClassName + ( j % 2 == 0 ? 'even' : 'odd' ); |
810 | 877 | } |
811 | 878 | } |
812 | 879 | } |
— | — | @@ -841,7 +908,7 @@ |
842 | 909 | messageDiv, |
843 | 910 | document.getElementById( 'content' ).firstChild |
844 | 911 | ); |
845 | | - } else if ( document.getElementById('content') |
| 912 | + } else if ( document.getElementById( 'content' ) |
846 | 913 | && document.getElementById( 'article' ) ) { |
847 | 914 | // Non-Monobook but still recognizable (old-style) |
848 | 915 | document.getElementById( 'article').insertBefore( |
— | — | @@ -856,15 +923,15 @@ |
857 | 924 | messageDiv.setAttribute( 'id', 'mw-js-message' ); |
858 | 925 | messageDiv.style.display = 'block'; |
859 | 926 | if( className ) { |
860 | | - messageDiv.setAttribute( 'class', 'mw-js-message-'+className ); |
| 927 | + messageDiv.setAttribute( 'class', 'mw-js-message-' + className ); |
861 | 928 | } |
862 | 929 | |
863 | | - if (typeof message === 'object') { |
864 | | - while (messageDiv.hasChildNodes()) // Remove old content |
865 | | - messageDiv.removeChild(messageDiv.firstChild); |
866 | | - messageDiv.appendChild (message); // Append new content |
867 | | - } |
868 | | - else { |
| 930 | + if ( typeof message === 'object' ) { |
| 931 | + while ( messageDiv.hasChildNodes() ) { // Remove old content |
| 932 | + messageDiv.removeChild( messageDiv.firstChild ); |
| 933 | + } |
| 934 | + messageDiv.appendChild( message ); // Append new content |
| 935 | + } else { |
869 | 936 | messageDiv.innerHTML = message; |
870 | 937 | } |
871 | 938 | return true; |
— | — | @@ -877,10 +944,10 @@ |
878 | 945 | * @param id Identifier string (for use with removeSpinner(), below) |
879 | 946 | */ |
880 | 947 | function injectSpinner( element, id ) { |
881 | | - var spinner = document.createElement( "img" ); |
882 | | - spinner.id = "mw-spinner-" + id; |
883 | | - spinner.src = stylepath + "/common/images/spinner.gif"; |
884 | | - spinner.alt = spinner.title = "..."; |
| 948 | + var spinner = document.createElement( 'img' ); |
| 949 | + spinner.id = 'mw-spinner-' + id; |
| 950 | + spinner.src = stylepath + '/common/images/spinner.gif'; |
| 951 | + spinner.alt = spinner.title = '...'; |
885 | 952 | if( element.nextSibling ) { |
886 | 953 | element.parentNode.insertBefore( spinner, element.nextSibling ); |
887 | 954 | } else { |
— | — | @@ -894,7 +961,7 @@ |
895 | 962 | * @param id Identifier string |
896 | 963 | */ |
897 | 964 | function removeSpinner( id ) { |
898 | | - var spinner = document.getElementById( "mw-spinner-" + id ); |
| 965 | + var spinner = document.getElementById( 'mw-spinner-' + id ); |
899 | 966 | if( spinner ) { |
900 | 967 | spinner.parentNode.removeChild( spinner ); |
901 | 968 | } |
— | — | @@ -902,7 +969,7 @@ |
903 | 970 | |
904 | 971 | function runOnloadHook() { |
905 | 972 | // don't run anything below this for non-dom browsers |
906 | | - if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) { |
| 973 | + if ( doneOnloadHook || !( document.getElementById && document.getElementsByTagName ) ) { |
907 | 974 | return; |
908 | 975 | } |
909 | 976 | |
— | — | @@ -915,7 +982,7 @@ |
916 | 983 | sortables_init(); |
917 | 984 | |
918 | 985 | // Run any added-on functions |
919 | | - for (var i = 0; i < onloadFuncts.length; i++) { |
| 986 | + for ( var i = 0; i < onloadFuncts.length; i++ ) { |
920 | 987 | onloadFuncts[i](); |
921 | 988 | } |
922 | 989 | } |
— | — | @@ -959,6 +1026,17 @@ |
960 | 1027 | element.detachEvent( 'on' + remove, handler ); |
961 | 1028 | } |
962 | 1029 | } |
963 | | -//note: all skins should call runOnloadHook() at the end of html output, |
| 1030 | +// note: all skins should call runOnloadHook() at the end of html output, |
964 | 1031 | // so the below should be redundant. It's there just in case. |
965 | | -hookEvent("load", runOnloadHook); |
| 1032 | +hookEvent( 'load', runOnloadHook ); |
| 1033 | + |
| 1034 | +if ( ie6_bugs ) { |
| 1035 | + importScriptURI( stylepath + '/common/IEFixes.js' ); |
| 1036 | +} |
| 1037 | + |
| 1038 | +// For future use. |
| 1039 | +if ( typeof mw == 'undefined' ) { |
| 1040 | + mw = {}; |
| 1041 | +} |
| 1042 | + |
| 1043 | + |