r60106 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60105‎ | r60106 | r60107 >
Date:23:38, 15 December 2009
Author:tparscal
Status:ok
Tags:
Comment:
Rewrote the template boundry parser. Cleaned some things up here and there.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,19 +72,19 @@
7373 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7474 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 36 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 3 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 5 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
79 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 54 ),
 79+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 52 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 8 ),
81 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 3 ),
 81+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 5 ),
8282 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
8383 ),
8484 'combined' => array(
85 - array( 'src' => 'js/plugins.combined.js', 'version' => 114 ),
 85+ array( 'src' => 'js/plugins.combined.js', 'version' => 115 ),
8686 ),
8787 'minified' => array(
88 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 114 ),
 88+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 115 ),
8989 ),
9090 ),
9191 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -6,59 +6,39 @@
77 */
88 evt: {
99 mark: function( context, event ) {
10 - // This is shared by both the closure findOutermostTemplates and the calling code - is this a good idea?
11 - var tokenIterator = 0;
12 - /**
13 - * Finds the left and right character positions of the outer-most template declaration, playing nicely with
14 - * nested template calls of any depth. This function acts as an iterator, which is why the i var is shared - but
15 - * this seems a bit scary seeing as 'i' is so often used in loops.
16 - *
17 - * @param tokenStack Array of tokens to find boundries within
18 - */
19 - function findOutermostTemplates( tokenStack ) {
20 - var templateBeginFound = false;
21 - for ( ; tokenIterator < tokenStack.length; tokenIterator++ ) {
22 - if ( tokenStack[tokenIterator].label == 'TEMPLATE_BEGIN' ) {
23 - templateBeginFound = true;
24 - break;
 10+ // Get refrences to the markers and tokens from the current context
 11+ var markers = context.modules.highlight.markers;
 12+ var tokenArray = context.modules.highlight.tokenArray;
 13+ // Collect matching level 0 template call boundries from the tokenArrray
 14+ var level = 0;
 15+ var boundries = [];
 16+ var boundry = 0;
 17+ for ( token in tokenArray ) {
 18+ if ( tokenArray[token].label == 'TEMPLATE_BEGIN' ) {
 19+ if ( level++ == 0 ) {
 20+ boundry = boundries.push( { 'begin': tokenArray[token].offset } ) - 1;
2521 }
 22+ } else if ( tokenArray[token].label == 'TEMPLATE_END' ) {
 23+ if ( --level == 0 ) {
 24+ boundries[boundry].end = tokenArray[token].offset;
 25+ }
2626 }
27 - var j = tokenIterator++;
28 - if ( !templateBeginFound ) {
29 - return false;
30 - } else {
31 - // This is only designed to find the outermost template boundaries, the model handles nested template
32 - // and template-like objects better
33 - var nestedBegins = 1;
34 - while ( nestedBegins > 0 && j < tokenStack.length ) {
35 - var label = tokenStack[++j].label;
36 - nestedBegins += label == 'TEMPLATE_END' ? -1 : label == 'TEMPLATE_BEGIN' ? 1 : 0;
 27+ }
 28+ // Add encapsulations to markers at the offsets of matching sets of level 0 template call boundries
 29+ for ( boundry in boundries ) {
 30+ if ( 'begin' in boundries[boundry] && 'end' in boundries[boundry] ) {
 31+ // Ensure arrays exist at the begining and ending offsets for boundry
 32+ if ( !( boundries[boundry].begin in markers ) ) {
 33+ markers[boundries[boundry].begin] = [];
3734 }
38 - if ( nestedBegins == 0 ) {
39 - // Outer template begins at tokenStack[i].offset and ends at tokenStack[j].offset + 2
40 - var leftMarker = tokenIterator -1;
41 - var rightMarker = j;
42 - tokenIterator = j;
43 - return [leftMarker, rightMarker];
44 - } else {
45 - return false;
 35+ if ( !( boundries[boundry].end in markers ) ) {
 36+ markers[boundries[boundry].end] = [];
4637 }
 38+ // Append boundry markers
 39+ markers[boundries[boundry].begin].push( "<div class='wiki-template'>" );
 40+ markers[boundries[boundry].end].push( "</div>" );
 41+
4742 }
48 - };
49 - // Get the markers and tokens from the current context
50 - var markers = context.modules.highlight.markers;
51 - var tokenStack = context.modules.highlight.tokenArray;
52 - // Scan through and detect the boundries of template calls
53 - var templateBeginFound = false;
54 - var templateBoundaries;
55 - while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
56 - context.modules.highlight.markers.push( {
57 - start: tokenStack[templateBoundaries[0]].offset,
58 - end: tokenStack[templateBoundaries[1]].offset,
59 - wrapElement: function() {
60 - return $( '<div />' ).addClass( 'wikiEditor-highlight-template' );
61 - }
62 - } );
6343 }
6444 }
6545 },
@@ -90,69 +70,6 @@
9171 model: function( wikitext ) {
9272
9373 /* Private Functions */
94 - },
95 -
96 -
97 - stylize: function( context ) {
98 - var $templates = context.$content.find( ".wiki-template" );
99 - $templates.each( function(){
100 - if( typeof $( this ).data( 'model' ) != 'undefined' ){
101 - //we have a model, so all this init stuff has already happened
102 - return;
103 - }
104 -
105 - //hide this
106 - $(this).addClass('wikieditor-nodisplay');
107 -
108 - //build a model for this
109 - $( this ).data( 'model' , new model( $( this ).text() ) );
110 - var model = $( this ).data( 'model' );
111 -
112 -
113 - //expand
114 - function expandTemplate($displayDiv){
115 - //housekeeping
116 - $displayDiv.removeClass('wiki-collapsed-template');
117 - $displayDiv.addClass('wiki-expanded-template');
118 - $displayDiv.data('mode') = "expanded";
119 -
120 - $displayDiv.text( model.getText() );
121 -
122 - };
123 -
124 - //collapse
125 - function collapseTemplate($displayDiv){
126 - //housekeeping
127 - $displayDiv.addClass('wiki-collapsed-template');
128 - $displayDiv.removeClass('wiki-expanded-template');
129 - $displayDiv.data('mode') = "collapsed";
130 -
131 - $displayDiv.text( model.getName() );
132 -
133 - };
134 -
135 - //build the collapsed version of this template
136 - var $visibleDiv = $( "<div></div>" ).addClass( 'wikieditor-noinclude' );
137 -
138 - //let these two know about eachother
139 - $(this).data( 'display' , $visibleDiv );
140 - $visibleDiv.data('wikitext-node', $(this));
141 - $(this).after( $visibleDiv );
142 -
143 - //onClick
144 - $visibleDiv.click( function(){
145 - //is collapsed, switch to expand
146 - if( $(this).data('mode') == 'collapsed' ){
147 - expandTemplate( $(this) );
148 - }
149 - else{
150 - collapseTemplate( $(this) );
151 - }
152 - });//click
153 -
154 - collapseTemplate($visibleDiv);
155 - });
156 - },
15774
15875 /**
15976 * Builds a Param object.
@@ -373,15 +290,17 @@
374291 valueEndIndex = valueEnd.index + oldDivider + 2;
375292 ranges.push( new Range( ranges[ranges.length-1].end,
376293 valueBeginIndex ) ); //all the chars upto now
377 - nameIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) );
378 - nameIndex--;
379 - equalsIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) );
380 - equalsIndex--;
381 - valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) );
382 - valueIndex--;
383 - params.push( new Param( currentParamNumber,
 294+ nameIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) ) - 1;
 295+ equalsIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) ) - 1;
 296+ valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) ) - 1;
 297+ params.push( new Param(
 298+ currentParamNumber,
384299 wikitext.substring( ranges[valueIndex].begin, ranges[valueIndex].end ),
385 - currentParamNumber, nameIndex, equalsIndex, valueIndex ) );
 300+ currentParamNumber,
 301+ nameIndex,
 302+ equalsIndex,
 303+ valueIndex
 304+ ) );
386305 paramsByName[currentParamNumber] = currentParamNumber;
387306 } else {
388307 // There's an equals, could be comment or a value pair
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -40,7 +40,6 @@
4141 'type': 'text/css',
4242 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css',
4343 } ) );
44 -
4544 // Highlight stuff for the first time
4645 $.wikiEditor.modules.highlight.fn.scan( context, "" );
4746 $.wikiEditor.modules.highlight.fn.mark( context, "", "" );
@@ -99,8 +98,9 @@
10099 this.offset = offset;
101100 this.label = label;
102101 }
 102+ // Reset tokens
 103+ var tokenArray = context.modules.highlight.tokenArray = [];
103104 // We need to look over some text and find interesting areas, then return the positions of those areas as tokens
104 - context.modules.highlight.tokenArray = [];
105105 var text = context.fn.getContents();
106106 for ( module in $.wikiEditor.modules ) {
107107 if ( 'exp' in $.wikiEditor.modules[module] ) {
@@ -118,7 +118,7 @@
119119 if ( markAfter ) {
120120 markOffset += match[0].length;
121121 }
122 - context.modules.highlight.tokenArray.push(
 122+ tokenArray.push(
123123 new Token( match.index + oldOffset + markOffset, label )
124124 );
125125 oldOffset += match.index + match[0].length;
@@ -128,9 +128,8 @@
129129 }
130130 }
131131 }
132 -
133 - context.modules.highlight.tokenArray.sort( function( a, b ) { return a.offset - b.offset; } );
134 - return context.modules.highlight.tokenArray; // array of tokens
 132+ tokenArray.sort( function( a, b ) { return a.offset - b.offset; } );
 133+ context.fn.trigger( 'scan' );
135134 },
136135 /**
137136 * Marks up text with HTML
@@ -140,26 +139,19 @@
141140 */
142141 // FIXME: What do division and tokens do?
143142 mark: function( context, division, tokens ) {
 143+ // Reset markers
 144+ var markers = context.modules.highlight.markers = [];
144145 // Get all markers
145 - context.modules.highlight.markers = [];
146 - for ( module in $.wikiEditor.modules ) {
147 - if ( 'evt' in $.wikiEditor.modules[module] && 'mark' in $.wikiEditor.modules[module].evt ) {
148 - $.wikiEditor.modules[module].evt.mark( context ); // FIXME: event?
149 - }
150 - }
151 - var markers = context.modules.highlight.markers;
 146+ context.fn.trigger( 'mark' );
152147 markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
153 -
154 - // Traverse the iframe DOM, inserting markers where they're needed
155 - // The loop traverses all leaf nodes in the DOM, and uses DOM methods
156 - // rather than jQuery because it has to work with text nodes and for performance
 148+ // Traverse the iframe DOM, inserting markers where they're needed. The loop traverses all leaf nodes in the
 149+ // DOM, and uses DOM methods rather than jQuery because it has to work with text nodes and for performance.
157150 var pos = 0;
158151 var node = context.$content.get( 0 );
159152 var next = null;
160153 var i = 0; // index for markers[]
161154 var startNode = null;
162155 var depth = 0, nextDepth = 0, startDepth = null;
163 -
164156 // Find the leftmost leaf node in the tree
165157 while ( node.firstChild ) {
166158 node = node.firstChild;
@@ -179,17 +171,16 @@
180172 nextDepth++;
181173 }
182174 next = p;
183 -
184175 if ( node.nodeName != '#text' ) {
185 - if ( node.nodeName == 'BR' )
 176+ if ( node.nodeName == 'BR' ) {
186177 pos++;
 178+ }
187179 // Skip this node
188180 node = next;
189181 depth = nextDepth;
190182 continue;
191183 }
192184 var newPos = pos + node.nodeValue.length;
193 -
194185 // We want to isolate each marker, so we may need to split textNodes
195186 // if a marker starts or end halfway one.
196187 if ( !startNode && markers[i].start >= pos && markers[i].start < newPos ) {
@@ -204,30 +195,22 @@
205196 startNode = node;
206197 startDepth = depth;
207198 }
208 -
209199 // TODO: What happens when wrapping a zero-length string?
210200 // TODO: Detect that something's already been wrapped and leave it alone
211201 if ( startNode && markers[i].end > pos && markers[i].end <= newPos ) {
212202 // The marker ends somewhere in this textNode
213203 if ( markers[i].end < newPos ) {
214 - // Split off the suffix
215 - // This puts the suffix in a new node and leaves the rest
216 - // in the current node. We have to make sure the split-off
217 - // node will be visited correctly
218 -
 204+ // Split off the suffix - This puts the suffix in a new node and leaves the rest in the current
 205+ // node. We have to make sure the split-off node will be visited correctly
219206 // node.nodeValue.length - ( newPos - markers[i].end )
220207 next = node.splitText( node.nodeValue.length - newPos + markers[i].end );
221208 newPos = markers[i].end;
222209 }
223 -
224 - // Now wrap everything between startNode and node (may be equal).
225 - // First find the common ancestor of startNode and node.
226 - // ca1 and ca2 will be children of this common ancestor, such that
227 - // ca1 is an ancestor of startNode and ca2 of node.
228 - // We also check that startNode and node are the leftmost and rightmost
229 - // leaves in the subtrees rooted at ca1 and ca2 respectively; if this is
230 - // not the case, we can't cleanly wrap things without misnesting and we
231 - // silently fail.
 210+ // Now wrap everything between startNode and node (may be equal). First find the common ancestor of
 211+ // startNode and node. ca1 and ca2 will be children of this common ancestor, such that ca1 is an
 212+ // ancestor of startNode and ca2 of node. We also check that startNode and node are the leftmost and
 213+ // rightmost leaves in the subtrees rooted at ca1 and ca2 respectively; if this is not the case, we
 214+ // can't cleanly wrap things without misnesting and we silently fail.
232215 var ca1 = startNode, ca2 = node;
233216 // Correct for startNode and node possibly not having the same depth
234217 if ( startDepth > depth ) {
@@ -249,38 +232,37 @@
250233 ca2 = ca2.parentNode;
251234 }
252235 }
253 -
254236 if ( ca1 && ca2 ) {
255 - // We have to store things like .parentNode and .nextSibling
256 - // because appendChild() changes these properties
 237+ // We have to store things like .parentNode and .nextSibling because appendChild() changes these
 238+ // properties
257239 var newNode = markers[i].wrapElement;
258 - if ( typeof newNode == 'function' )
 240+ if ( typeof newNode == 'function' ) {
259241 newNode = newNode();
260 - if ( newNode.jquery )
 242+ }
 243+ if ( newNode.jquery ) {
261244 newNode = newNode.get( 0 );
 245+ }
262246 var commonAncestor = ca1.parentNode;
263247 var nextNode = ca2.nextSibling;
264 -
265 - // Append all nodes between ca1 and ca2 (inclusive)
266 - // to newNode
 248+ // Append all nodes between ca1 and ca2 (inclusive) to newNode
267249 var n = ca1;
268250 while ( n != nextNode ) {
269251 var ns = n.nextSibling;
270252 newNode.appendChild( n );
271253 n = ns;
272254 }
273 -
274255 // Insert newNode in the right place
275 - if ( nextNode )
 256+ if ( nextNode ) {
276257 commonAncestor.insertBefore( newNode, nextNode );
277 - else
 258+ } else {
278259 commonAncestor.appendChild( newNode );
 260+ }
279261 }
280 - startNode = null; // Clear for next iteration
 262+ // Clear for next iteration
 263+ startNode = null;
281264 startDepth = null;
282265 i++;
283266 }
284 -
285267 pos = newPos;
286268 node = next;
287269 depth = nextDepth;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2168,7 +2168,6 @@
21692169 'type': 'text/css',
21702170 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css',
21712171 } ) );
2172 -
21732172 // Highlight stuff for the first time
21742173 $.wikiEditor.modules.highlight.fn.scan( context, "" );
21752174 $.wikiEditor.modules.highlight.fn.mark( context, "", "" );
@@ -2227,8 +2226,9 @@
22282227 this.offset = offset;
22292228 this.label = label;
22302229 }
 2230+ // Reset tokens
 2231+ var tokenArray = context.modules.highlight.tokenArray = [];
22312232 // We need to look over some text and find interesting areas, then return the positions of those areas as tokens
2232 - context.modules.highlight.tokenArray = [];
22332233 var text = context.fn.getContents();
22342234 for ( module in $.wikiEditor.modules ) {
22352235 if ( 'exp' in $.wikiEditor.modules[module] ) {
@@ -2246,7 +2246,7 @@
22472247 if ( markAfter ) {
22482248 markOffset += match[0].length;
22492249 }
2250 - context.modules.highlight.tokenArray.push(
 2250+ tokenArray.push(
22512251 new Token( match.index + oldOffset + markOffset, label )
22522252 );
22532253 oldOffset += match.index + match[0].length;
@@ -2256,9 +2256,8 @@
22572257 }
22582258 }
22592259 }
2260 -
2261 - context.modules.highlight.tokenArray.sort( function( a, b ) { return a.offset - b.offset; } );
2262 - return context.modules.highlight.tokenArray; // array of tokens
 2260+ tokenArray.sort( function( a, b ) { return a.offset - b.offset; } );
 2261+ context.fn.trigger( 'scan' );
22632262 },
22642263 /**
22652264 * Marks up text with HTML
@@ -2268,26 +2267,19 @@
22692268 */
22702269 // FIXME: What do division and tokens do?
22712270 mark: function( context, division, tokens ) {
 2271+ // Reset markers
 2272+ var markers = context.modules.highlight.markers = [];
22722273 // Get all markers
2273 - context.modules.highlight.markers = [];
2274 - for ( module in $.wikiEditor.modules ) {
2275 - if ( 'evt' in $.wikiEditor.modules[module] && 'mark' in $.wikiEditor.modules[module].evt ) {
2276 - $.wikiEditor.modules[module].evt.mark( context ); // FIXME: event?
2277 - }
2278 - }
2279 - var markers = context.modules.highlight.markers;
 2274+ context.fn.trigger( 'mark' );
22802275 markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
2281 -
2282 - // Traverse the iframe DOM, inserting markers where they're needed
2283 - // The loop traverses all leaf nodes in the DOM, and uses DOM methods
2284 - // rather than jQuery because it has to work with text nodes and for performance
 2276+ // Traverse the iframe DOM, inserting markers where they're needed. The loop traverses all leaf nodes in the
 2277+ // DOM, and uses DOM methods rather than jQuery because it has to work with text nodes and for performance.
22852278 var pos = 0;
22862279 var node = context.$content.get( 0 );
22872280 var next = null;
22882281 var i = 0; // index for markers[]
22892282 var startNode = null;
22902283 var depth = 0, nextDepth = 0, startDepth = null;
2291 -
22922284 // Find the leftmost leaf node in the tree
22932285 while ( node.firstChild ) {
22942286 node = node.firstChild;
@@ -2307,17 +2299,16 @@
23082300 nextDepth++;
23092301 }
23102302 next = p;
2311 -
23122303 if ( node.nodeName != '#text' ) {
2313 - if ( node.nodeName == 'BR' )
 2304+ if ( node.nodeName == 'BR' ) {
23142305 pos++;
 2306+ }
23152307 // Skip this node
23162308 node = next;
23172309 depth = nextDepth;
23182310 continue;
23192311 }
23202312 var newPos = pos + node.nodeValue.length;
2321 -
23222313 // We want to isolate each marker, so we may need to split textNodes
23232314 // if a marker starts or end halfway one.
23242315 if ( !startNode && markers[i].start >= pos && markers[i].start < newPos ) {
@@ -2332,30 +2323,22 @@
23332324 startNode = node;
23342325 startDepth = depth;
23352326 }
2336 -
23372327 // TODO: What happens when wrapping a zero-length string?
23382328 // TODO: Detect that something's already been wrapped and leave it alone
23392329 if ( startNode && markers[i].end > pos && markers[i].end <= newPos ) {
23402330 // The marker ends somewhere in this textNode
23412331 if ( markers[i].end < newPos ) {
2342 - // Split off the suffix
2343 - // This puts the suffix in a new node and leaves the rest
2344 - // in the current node. We have to make sure the split-off
2345 - // node will be visited correctly
2346 -
 2332+ // Split off the suffix - This puts the suffix in a new node and leaves the rest in the current
 2333+ // node. We have to make sure the split-off node will be visited correctly
23472334 // node.nodeValue.length - ( newPos - markers[i].end )
23482335 next = node.splitText( node.nodeValue.length - newPos + markers[i].end );
23492336 newPos = markers[i].end;
23502337 }
2351 -
2352 - // Now wrap everything between startNode and node (may be equal).
2353 - // First find the common ancestor of startNode and node.
2354 - // ca1 and ca2 will be children of this common ancestor, such that
2355 - // ca1 is an ancestor of startNode and ca2 of node.
2356 - // We also check that startNode and node are the leftmost and rightmost
2357 - // leaves in the subtrees rooted at ca1 and ca2 respectively; if this is
2358 - // not the case, we can't cleanly wrap things without misnesting and we
2359 - // silently fail.
 2338+ // Now wrap everything between startNode and node (may be equal). First find the common ancestor of
 2339+ // startNode and node. ca1 and ca2 will be children of this common ancestor, such that ca1 is an
 2340+ // ancestor of startNode and ca2 of node. We also check that startNode and node are the leftmost and
 2341+ // rightmost leaves in the subtrees rooted at ca1 and ca2 respectively; if this is not the case, we
 2342+ // can't cleanly wrap things without misnesting and we silently fail.
23602343 var ca1 = startNode, ca2 = node;
23612344 // Correct for startNode and node possibly not having the same depth
23622345 if ( startDepth > depth ) {
@@ -2377,38 +2360,37 @@
23782361 ca2 = ca2.parentNode;
23792362 }
23802363 }
2381 -
23822364 if ( ca1 && ca2 ) {
2383 - // We have to store things like .parentNode and .nextSibling
2384 - // because appendChild() changes these properties
 2365+ // We have to store things like .parentNode and .nextSibling because appendChild() changes these
 2366+ // properties
23852367 var newNode = markers[i].wrapElement;
2386 - if ( typeof newNode == 'function' )
 2368+ if ( typeof newNode == 'function' ) {
23872369 newNode = newNode();
2388 - if ( newNode.jquery )
 2370+ }
 2371+ if ( newNode.jquery ) {
23892372 newNode = newNode.get( 0 );
 2373+ }
23902374 var commonAncestor = ca1.parentNode;
23912375 var nextNode = ca2.nextSibling;
2392 -
2393 - // Append all nodes between ca1 and ca2 (inclusive)
2394 - // to newNode
 2376+ // Append all nodes between ca1 and ca2 (inclusive) to newNode
23952377 var n = ca1;
23962378 while ( n != nextNode ) {
23972379 var ns = n.nextSibling;
23982380 newNode.appendChild( n );
23992381 n = ns;
24002382 }
2401 -
24022383 // Insert newNode in the right place
2403 - if ( nextNode )
 2384+ if ( nextNode ) {
24042385 commonAncestor.insertBefore( newNode, nextNode );
2405 - else
 2386+ } else {
24062387 commonAncestor.appendChild( newNode );
 2388+ }
24072389 }
2408 - startNode = null; // Clear for next iteration
 2390+ // Clear for next iteration
 2391+ startNode = null;
24092392 startDepth = null;
24102393 i++;
24112394 }
2412 -
24132395 pos = newPos;
24142396 node = next;
24152397 depth = nextDepth;
@@ -2671,59 +2653,39 @@
26722654 */
26732655 evt: {
26742656 mark: function( context, event ) {
2675 - // This is shared by both the closure findOutermostTemplates and the calling code - is this a good idea?
2676 - var i = 0;
2677 - /**
2678 - * Finds the left and right character positions of the outer-most template declaration, playing nicely with
2679 - * nested template calls of any depth. This function acts as an iterator, which is why the i var is shared - but
2680 - * this seems a bit scary seeing as 'i' is so often used in loops.
2681 - *
2682 - * @param tokenStack Array of tokens to find boundries within
2683 - */
2684 - function findOutermostTemplates( tokenStack ) {
2685 - var templateBeginFound = false;
2686 - for ( ; i < tokenStack.length; i++ ) {
2687 - if ( tokenStack[i].label == 'TEMPLATE_BEGIN' ) {
2688 - templateBeginFound = true;
2689 - break;
 2657+ // Get refrences to the markers and tokens from the current context
 2658+ var markers = context.modules.highlight.markers;
 2659+ var tokenArray = context.modules.highlight.tokenArray;
 2660+ // Collect matching level 0 template call boundries from the tokenArrray
 2661+ var level = 0;
 2662+ var boundries = [];
 2663+ var boundry = 0;
 2664+ for ( token in tokenArray ) {
 2665+ if ( tokenArray[token].label == 'TEMPLATE_BEGIN' ) {
 2666+ if ( level++ == 0 ) {
 2667+ boundry = boundries.push( { 'begin': tokenArray[token].offset } ) - 1;
26902668 }
 2669+ } else if ( tokenArray[token].label == 'TEMPLATE_END' ) {
 2670+ if ( --level == 0 ) {
 2671+ boundries[boundry].end = tokenArray[token].offset;
 2672+ }
26912673 }
2692 - var j = i++;
2693 - if ( !templateBeginFound ) {
2694 - return false;
2695 - } else {
2696 - // This is only designed to find the outermost template boundaries, the model handles nested template
2697 - // and template-like objects better
2698 - var nestedBegins = 1;
2699 - while ( nestedBegins > 0 && j < tokenStack.length ) {
2700 - var label = tokenStack[++j].label;
2701 - nestedBegins += label == 'TEMPLATE_END' ? -1 : label == 'TEMPLATE_BEGIN' ? 1 : 0;
 2674+ }
 2675+ // Add encapsulations to markers at the offsets of matching sets of level 0 template call boundries
 2676+ for ( boundry in boundries ) {
 2677+ if ( 'begin' in boundries[boundry] && 'end' in boundries[boundry] ) {
 2678+ // Ensure arrays exist at the begining and ending offsets for boundry
 2679+ if ( !( boundries[boundry].begin in markers ) ) {
 2680+ markers[boundries[boundry].begin] = [];
27022681 }
2703 - if ( nestedBegins == 0 ) {
2704 - // Outer template begins at tokenStack[i].offset and ends at tokenStack[j].offset + 2
2705 - var leftMarker = i -1;
2706 - var rightMarker = j;
2707 - i = j;
2708 - return [leftMarker, rightMarker];
2709 - } else {
2710 - return false;
 2682+ if ( !( boundries[boundry].end in markers ) ) {
 2683+ markers[boundries[boundry].end] = [];
27112684 }
 2685+ // Append boundry markers
 2686+ markers[boundries[boundry].begin].push( "<div class='wiki-template'>" );
 2687+ markers[boundries[boundry].end].push( "</div>" );
 2688+
27122689 }
2713 - };
2714 - // Get the markers and tokens from the current context
2715 - var markers = context.modules.highlight.markers;
2716 - var tokenStack = context.modules.highlight.tokenArray;
2717 - // Scan through and detect the boundries of template calls
2718 - var templateBeginFound = false;
2719 - var templateBoundaries;
2720 - while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
2721 - context.modules.highlight.markers.push( {
2722 - start: tokenStack[templateBoundaries[0]].offset,
2723 - end: tokenStack[templateBoundaries[1]].offset,
2724 - wrapElement: function() {
2725 - return $( '<div />' ).addClass( 'wikiEditor-highlight-template' );
2726 - }
2727 - } );
27282690 }
27292691 }
27302692 },
@@ -2975,15 +2937,17 @@
29762938 valueEndIndex = valueEnd.index + oldDivider + 2;
29772939 ranges.push( new Range( ranges[ranges.length-1].end,
29782940 valueBeginIndex ) ); //all the chars upto now
2979 - nameIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) );
2980 - nameIndex--;
2981 - equalsIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) );
2982 - equalsIndex--;
2983 - valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) );
2984 - valueIndex--;
2985 - params.push( new Param( currentParamNumber,
 2941+ nameIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) ) - 1;
 2942+ equalsIndex = ranges.push( new Range( valueBeginIndex, valueBeginIndex ) ) - 1;
 2943+ valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) ) - 1;
 2944+ params.push( new Param(
 2945+ currentParamNumber,
29862946 wikitext.substring( ranges[valueIndex].begin, ranges[valueIndex].end ),
2987 - currentParamNumber, nameIndex, equalsIndex, valueIndex ) );
 2947+ currentParamNumber,
 2948+ nameIndex,
 2949+ equalsIndex,
 2950+ valueIndex
 2951+ ) );
29882952 paramsByName[currentParamNumber] = currentParamNumber;
29892953 } else {
29902954 // There's an equals, could be comment or a value pair
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -120,27 +120,24 @@
121121 var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
122122 maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);}
123123 $(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={evt:{change:function(context,event){if(event.data.scope=='keydown'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){context.$content.parent().find('head').append($j('<link />').attr({'rel':'stylesheet','type':'text/css','href':wgScriptPath+'/extensions/UsabilityInitiative/css/wikiEditor.highlight.css',}));$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label){this.offset=offset;this.label=label;}
124 -context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
 124+var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
125125 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;}
126 -context.modules.highlight.tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
127 -context.modules.highlight.tokenArray.sort(function(a,b){return a.offset-b.offset;});return context.modules.highlight.tokenArray;},mark:function(context,division,tokens){context.modules.highlight.markers=[];for(module in $.wikiEditor.modules){if('evt'in $.wikiEditor.modules[module]&&'mark'in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt.mark(context);}}
128 -var markers=context.modules.highlight.markers;markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var pos=0;var node=context.$content.get(0);var next=null;var i=0;var startNode=null;var depth=0,nextDepth=0,startDepth=null;while(node.firstChild){node=node.firstChild;depth++;}
 126+tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
 127+tokenArray.sort(function(a,b){return a.offset-b.offset;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=context.modules.highlight.markers=[];context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var pos=0;var node=context.$content.get(0);var next=null;var i=0;var startNode=null;var depth=0,nextDepth=0,startDepth=null;while(node.firstChild){node=node.firstChild;depth++;}
129128 while(i<markers.length&&node){var p=node;nextDepth=depth;while(p&&!p.nextSibling){p=p.parentNode;nextDepth--;}
130129 p=p?p.nextSibling:null;while(p&&p.firstChild){p=p.firstChild;nextDepth++;}
131 -next=p;if(node.nodeName!='#text'){if(node.nodeName=='BR')
132 -pos++;node=next;depth=nextDepth;continue;}
 130+next=p;if(node.nodeName!='#text'){if(node.nodeName=='BR'){pos++;}
 131+node=next;depth=nextDepth;continue;}
133132 var newPos=pos+node.nodeValue.length;if(!startNode&&markers[i].start>=pos&&markers[i].start<newPos){if(markers[i].start>pos){node=node.splitText(markers[i].start-pos);pos=markers[i].start;}
134133 startNode=node;startDepth=depth;}
135134 if(startNode&&markers[i].end>pos&&markers[i].end<=newPos){if(markers[i].end<newPos){next=node.splitText(node.nodeValue.length-newPos+markers[i].end);newPos=markers[i].end;}
136135 var ca1=startNode,ca2=node;if(startDepth>depth){for(var j=0;j<startDepth-depth&&ca1;j++){ca1=ca1.parentNode;}}
137136 else if(startDepth<depth){for(var j=0;j<depth-startDepth&&ca2;j++){ca2=ca2.parentNode;}}
138137 while(ca1&&ca2&&ca1.parentNode!=ca2.parentNode){if(ca1.parentNode.firstChild!=ca1||ca2.parentNode.lastChild!=ca2){ca1=ca2=null;}else{ca1=ca1.parentNode;ca2=ca2.parentNode;}}
139 -if(ca1&&ca2){var newNode=markers[i].wrapElement;if(typeof newNode=='function')
140 -newNode=newNode();if(newNode.jquery)
141 -newNode=newNode.get(0);var commonAncestor=ca1.parentNode;var nextNode=ca2.nextSibling;var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;}
142 -if(nextNode)
143 -commonAncestor.insertBefore(newNode,nextNode);else
144 -commonAncestor.appendChild(newNode);}
 138+if(ca1&&ca2){var newNode=markers[i].wrapElement;if(typeof newNode=='function'){newNode=newNode();}
 139+if(newNode.jquery){newNode=newNode.get(0);}
 140+var commonAncestor=ca1.parentNode;var nextNode=ca2.nextSibling;var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;}
 141+if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}}
145142 startNode=null;startDepth=null;i++;}
146143 pos=newPos;node=next;depth=nextDepth;}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={fn:{create:function(context,config){if('initialized'in context.modules.preview){return;}
147144 context.modules.preview={'initialized':true,'previewText':null,'changesText':null};context.modules.preview.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;}
@@ -172,9 +169,10 @@
173170 $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked'))
174171 $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0)
175172 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
176 -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={evt:{mark:function(context,event){var i=0;function findOutermostTemplates(tokenStack){var templateBeginFound=false;for(;i<tokenStack.length;i++){if(tokenStack[i].label=='TEMPLATE_BEGIN'){templateBeginFound=true;break;}}
177 -var j=i++;if(!templateBeginFound){return false;}else{var nestedBegins=1;while(nestedBegins>0&&j<tokenStack.length){var label=tokenStack[++j].label;nestedBegins+=label=='TEMPLATE_END'?-1:label=='TEMPLATE_BEGIN'?1:0;}
178 -if(nestedBegins==0){var leftMarker=i-1;var rightMarker=j;i=j;return[leftMarker,rightMarker];}else{return false;}}};var markers=context.modules.highlight.markers;var tokenStack=context.modules.highlight.tokenArray;var templateBeginFound=false;var templateBoundaries;while(templateBoundaries=findOutermostTemplates(tokenStack)){context.modules.highlight.markers.push({start:tokenStack[templateBoundaries[0]].offset,end:tokenStack[templateBoundaries[1]].offset,wrapElement:function(){return $('<div />').addClass('wikiEditor-highlight-template');}});}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;}
 173+$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={evt:{mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var boundries=[];var boundry=0;for(token in tokenArray){if(tokenArray[token].label=='TEMPLATE_BEGIN'){if(level++==0){boundry=boundries.push({'begin':tokenArray[token].offset})-1;}}else if(tokenArray[token].label=='TEMPLATE_END'){if(--level==0){boundries[boundry].end=tokenArray[token].offset;}}}
 174+for(boundry in boundries){if('begin'in boundries[boundry]&&'end'in boundries[boundry]){if(!(boundries[boundry].begin in markers)){markers[boundries[boundry].begin]=[];}
 175+if(!(boundries[boundry].end in markers)){markers[boundries[boundry].end]=[];}
 176+markers[boundries[boundry].begin].push("<div class='wiki-template'>");markers[boundries[boundry].end].push("</div>");}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;}
179177 function Range(begin,end){this.begin=begin;this.end=end;}
180178 function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";}
181179 rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);}
@@ -189,7 +187,7 @@
190188 var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
191189 nameMatch=wikitext.substring(oldDivider,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(oldDivider,nameMatch.index));templateNameIndex=ranges.push(new Range(nameMatch.index,nameMatch.index+nameMatch[0].length));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}
192190 params.push(ranges[templateNameIndex].old);var currentParamNumber=0;var valueEndIndex;var paramsByName=[];while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
193 -currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex));nameIndex--;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex));equalsIndex--;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex));valueIndex--;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){divider++;currentParamNumber--;continue;}
 191+currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){divider++;currentParamNumber--;continue;}
194192 nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}}
195193 ranges.push(new Range(valueEndIndex,wikitext.length));}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
196194 context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;}

Status & tagging log