MediaWiki:Gadget-morebits.js: Difference between revisions

Content deleted Content added
Repo at 8efb3a0: lookupCreation: fix bug from JSON conversion; Allow CIDR notation
Repo at 4c64ec3: remove leftover todo; Fix bug parsing terminal template parameters
Line 4,375:
start = start || 0;
 
var level = []; // Track of how deep we are ({{, {{{, or [[)
var count = -1; // Number of parameters found
var unnamed = 0; // Keep track of what number an unnamed parameter should receive
var level = -1; // How many levels deep of template code we're in, 0-based
var equals = -1; // After finding "=" before a parameter, the index; otherwise, -1
var current = '';
Line 4,392:
* parameter and we need to remove the trailing `}}`.
*/
varfunction findParam = function(final) {
// Nothing found yet, this must be the template name
if (count === -1) {
Line 4,414:
}
}
};
 
for (var i = start; i < text.length; ++i) {
var test3 = text.substr(i, 3);
if (test3 === '{{{' || (test3 === '}}}' && level[level.length - 1] === 3)) {
current += test3;
i += 2;
if (test3 === '}}}{{{') ? --level : ++level;{
++ level.push(3);
} else {
-- level.pop();
++i;}
continue;
}
Line 4,429 ⟶ 4,433:
current += test2;
++i;
if (test2 === ']]{{') {
++level;
continue level.push(2);
} else {
level.push('wl');
// Leaving a link
}
if (test2 === ']]') {
current += ']]';
++i;
--level;
continue;
}
// Either leaving a templatelink or an internal template/parser function
if ((test2 === '}}' && level[level.length - 1] === 2) {||
(test2 === ']]' && level[level.length - 1] === 'wl')) {
// Regardless, decrement the level
current += test2;
++i;
--level.pop();
 
// Find the final parameter if this really is the end
if (test2 === '}}' && level.length === -10) {
findParam(true);
break;
Line 4,454 ⟶ 4,455:
}
 
if (text.charAt(i) === '|' && level.length === 01) {
// Another pipe found, toplevel, so parameter coming up!
findParam();
current = '';
} else if (equals === -1 && text.charAt(i) === '=' && level.length === 01) {
// Equals found, toplevel
equals = current.length;
Line 4,852 ⟶ 4,853:
* @param {string} status - Part of status message after colon.
* @param {string} type - 'status' (blue), 'info' (green), 'warn'
* (red), or 'error' (bold red). FIXME TODO possible options
*/
update: function(status, type) {