<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.gfkari.com/index.php?action=history&amp;feed=atom&amp;title=User%3AErina%2Ffindargdups.js</id>
		<title>User:Erina/findargdups.js - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.gfkari.com/index.php?action=history&amp;feed=atom&amp;title=User%3AErina%2Ffindargdups.js"/>
		<link rel="alternate" type="text/html" href="http://wiki.gfkari.com/index.php?title=User:Erina/findargdups.js&amp;action=history"/>
		<updated>2026-05-27T00:52:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.3</generator>

	<entry>
		<id>http://wiki.gfkari.com/index.php?title=User:Erina/findargdups.js&amp;diff=3772&amp;oldid=prev</id>
		<title>Erina: Protected &quot;User:Erina/findargdups.js&quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</title>
		<link rel="alternate" type="text/html" href="http://wiki.gfkari.com/index.php?title=User:Erina/findargdups.js&amp;diff=3772&amp;oldid=prev"/>
				<updated>2016-06-17T01:39:07Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/wiki/User:Erina/findargdups.js&quot; title=&quot;User:Erina/findargdups.js&quot;&gt;User:Erina/findargdups.js&lt;/a&gt;&amp;quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 01:39, 17 June 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Erina</name></author>	</entry>

	<entry>
		<id>http://wiki.gfkari.com/index.php?title=User:Erina/findargdups.js&amp;diff=3771&amp;oldid=prev</id>
		<title>Erina: Created page with &quot;jQuery(document).ready(function($) {  var myContent = document.getElementsByName('wpTextbox1')[0]; // -------------------------------------------------------------------------...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.gfkari.com/index.php?title=User:Erina/findargdups.js&amp;diff=3771&amp;oldid=prev"/>
				<updated>2016-06-17T01:38:53Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;jQuery(document).ready(function($) {  var myContent = document.getElementsByName(&amp;#039;wpTextbox1&amp;#039;)[0]; // -------------------------------------------------------------------------...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;jQuery(document).ready(function($) {&lt;br /&gt;
&lt;br /&gt;
var myContent = document.getElementsByName('wpTextbox1')[0];&lt;br /&gt;
// -------------------------------------------------------------------------------- //&lt;br /&gt;
var mysummary = &amp;quot;Clean up [[:Category:Pages using duplicate arguments in template calls|duplicate template arguments]] using [[:en:User:Frietjes/findargdups|findargdups]]&amp;quot;;&lt;br /&gt;
if(typeof findargdupseditsummary == 'string') {mysummary = findargdupseditsummary;}&lt;br /&gt;
var morefound = &amp;quot;More duplicates found, fix some and run again!&amp;quot;;&lt;br /&gt;
if(typeof findargdupsmorefound == 'string') {morefound = findargdupsmorefound;}&lt;br /&gt;
var linktext = &amp;quot;Find dups&amp;quot;;&lt;br /&gt;
if(typeof findargdupslinktext == 'string') {linktext = findargdupslinktext;}&lt;br /&gt;
var showresultsbox = 0;&lt;br /&gt;
if(typeof findargdupsresultsbox == 'string') { showresultsbox = 1;}&lt;br /&gt;
var showalertbox = 1;&lt;br /&gt;
if(typeof findargdupsnoalertbox == 'string') { showalertbox = 0; showresultsbox = 1;}&lt;br /&gt;
// -------------------------------------------------------------------------------- //&lt;br /&gt;
&lt;br /&gt;
if(mw.config.get('wgNamespaceNumber') != -1 &amp;amp;&amp;amp; myContent) {&lt;br /&gt;
  var portletlink = mw.util.addPortletLink('p-tb', '#', linktext, 't-fdup');&lt;br /&gt;
  $(portletlink).click(function(e) {&lt;br /&gt;
    e.preventDefault();&lt;br /&gt;
    wpFindDuplicateArgs(0);&lt;br /&gt;
  });&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// -------------------------------------------------------------------------------- //&lt;br /&gt;
function wpAddResultsBox(text, num)&lt;br /&gt;
{&lt;br /&gt;
	var div = document.getElementById('wpSummaryLabel').parentNode;&lt;br /&gt;
	if( div ) {&lt;br /&gt;
		if( num &amp;lt; 2 ) {&lt;br /&gt;
			if( document.getElementById('FindArgDupsResultsBox') ) {&lt;br /&gt;
				document.getElementById('FindArgDupsResultsBox').innerHTML = '';&lt;br /&gt;
			} else {&lt;br /&gt;
				div.innerHTML = '&amp;lt;div id=&amp;quot;FindArgDupsResultsBox&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;' + div.innerHTML;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		div1 = document.getElementById('FindArgDupsResultsBox');&lt;br /&gt;
		if( div1 ) {&lt;br /&gt;
		text = text.replace(/&amp;lt;/g, '&amp;amp;lt;');&lt;br /&gt;
		text = text.replace(/&amp;gt;/g, '&amp;amp;gt;');&lt;br /&gt;
		div1.innerHTML = div1.innerHTML + '&amp;lt;div class=&amp;quot;FindArgDupsResultsBox&amp;quot; ' +&lt;br /&gt;
		  'id=&amp;quot;FindArgDupsResultsBox-' + num + '&amp;quot; ' +&lt;br /&gt;
		  'style=&amp;quot;max-height:5em; overflow:auto; padding:5px; border:#aaa 1px solid; ' +&lt;br /&gt;
		  'background-color:cornsilk;&amp;quot;&amp;gt;' + text + '&amp;lt;/div&amp;gt;' + &amp;quot;\n&amp;quot;;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
function wpClearResultsBox()&lt;br /&gt;
{&lt;br /&gt;
	var div = document.getElementById('wpSummaryLabel').parentNode;&lt;br /&gt;
	if( div ) {&lt;br /&gt;
		if( document.getElementById('FindArgDupsResultsBox') ) {&lt;br /&gt;
				document.getElementById('FindArgDupsResultsBox').innerHTML = '';&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
// -------------------------------------------------------------------------------- //&lt;br /&gt;
function wpFindDuplicateArgs(debugflag)&lt;br /&gt;
{&lt;br /&gt;
  // Flag used to determine if we have issued an alert popup&lt;br /&gt;
  var alertissued=0;&lt;br /&gt;
  // Internal for and while loop variables&lt;br /&gt;
  var i=0; var j=0; var loopcount=0;&lt;br /&gt;
  // Array used to hold the list of unnested templates&lt;br /&gt;
  var tlist = []; &lt;br /&gt;
  // Regular expression which matchs a template arg&lt;br /&gt;
  var argexp = new RegExp(&amp;quot;\\|[\\s]*([^\\s=\\|\\[\\]\\{\\}][^=\\|\\[\\]\\{\\}]*[^\\s=\\|\\[\\]\\{\\}]|[^\\s=\\|\\[\\]\\{\\}]|)[\\s]*=&amp;quot;, &amp;quot;gm&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  // Copy the contents of the text window so we can modify it without problems&lt;br /&gt;
  var mytxt = myContent.value;&lt;br /&gt;
  // Remove some includeonly, noinclude, and onlyinclude tags&lt;br /&gt;
  mytxt = mytxt.replace(/&amp;lt;\/?[ ]*(?:includeonly|noinclude|onlyinclude)[ ]*&amp;gt;/gi, '');&lt;br /&gt;
  // Remove PAGENAME, BASEPAGENAME, ... nested inside of triple braces&lt;br /&gt;
  mytxt = mytxt.replace(/\{\{\{[^\{\}]*\|[ ]*\{\{[A-Z]+\}\}\}\}\}/g, '');&lt;br /&gt;
  // Remove some triple braces and parserfunctions inside of triple braces&lt;br /&gt;
  loopcount = 0; &lt;br /&gt;
  while((mytxt.search(/\{\{\{[^\{\}]*\}\}\}/g) &amp;gt;= 0) &amp;amp;&amp;amp; (loopcount &amp;lt; 5) ) {&lt;br /&gt;
    mytxt = mytxt.replace(/\{\{\{[^\{\}]*\}\}\}/g, '');&lt;br /&gt;
    mytxt = mytxt.replace(/\{\{#[a-z]+:[^{}=]*\}\}/gi, '');&lt;br /&gt;
    loopcount++;&lt;br /&gt;
  }&lt;br /&gt;
  // Replace some bare braces with HTML equivalent&lt;br /&gt;
  mytxt = mytxt.replace(/([^\{])\{([^\{])/g, '$1&amp;amp;#123;$2');&lt;br /&gt;
  mytxt = mytxt.replace(/([^\}])\}([^\}])/g, '$1&amp;amp;#125;$2');&lt;br /&gt;
  // Remove newlines and tabs which confuse the regexp search&lt;br /&gt;
  mytxt = mytxt.replace(/[\s]/gm, ' ');&lt;br /&gt;
  // Compress whitespace&lt;br /&gt;
  mytxt = mytxt.replace(/[\s][\s]+/gm, ' ');&lt;br /&gt;
  // Remove some nowiki and pre text&lt;br /&gt;
  mytxt = mytxt.replace(/&amp;lt;nowiki[^&amp;lt;&amp;gt;]*&amp;gt;(?:&amp;lt;[^\/]|[^&amp;lt;])*&amp;lt;\/nowiki[^&amp;lt;&amp;gt;]*&amp;gt;/gi, '');&lt;br /&gt;
  mytxt = mytxt.replace(/&amp;lt;pre[^&amp;lt;&amp;gt;]*&amp;gt;(?:&amp;lt;[^\/]|[^&amp;lt;])*&amp;lt;\/pre[^&amp;lt;&amp;gt;]*&amp;gt;/gi, '');&lt;br /&gt;
  // Remove some HTML comments&lt;br /&gt;
  mytxt = mytxt.replace(/&amp;lt;!--(?:[^&amp;gt;]|[^\-]&amp;gt;|[^\-]-&amp;gt;)*--&amp;gt;/gm, '');&lt;br /&gt;
  // Modify some = inside of file/image/wikilinks which cause false positives&lt;br /&gt;
  loopcount = 0;&lt;br /&gt;
  while((mytxt.search(/\[\[[^\[\]\{\}]*=/gi) &amp;gt;= 0) &amp;amp;&amp;amp; (loopcount &amp;lt; 5) ) {&lt;br /&gt;
    mytxt = mytxt.replace(/(\[\[[^\[\]\{\}]*)=/gi, '$1&amp;amp;#61;');&lt;br /&gt;
    loopcount++;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Now start unnesting the templates&lt;br /&gt;
  loopcount = 0;&lt;br /&gt;
  while( (mytxt.search(/(?:\{\{|\}\})/g) &amp;gt;= 0) &amp;amp;&amp;amp; (loopcount &amp;lt; 20) ) {&lt;br /&gt;
  	// Split into chunks, isolating the unnested templates&lt;br /&gt;
    var strlist = mytxt.split(/(\{\{[^\{\}]*\}\})/);&lt;br /&gt;
    // Loop through the chunks, removing the unnested templates&lt;br /&gt;
    for (i = 0; i &amp;lt; strlist.length; i++) {&lt;br /&gt;
      if( strlist[i].search(/^\{\{[^\{\}]*\}\}$/) &amp;gt;= 0 ) {&lt;br /&gt;
         tlist.push(strlist[i]);&lt;br /&gt;
         strlist[i] = '';&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // Join the chunks back together for the next iteration&lt;br /&gt;
    mytxt = strlist.join('');&lt;br /&gt;
    loopcount++;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // Preprocess some = signs inside of non-citation-templated citations&lt;br /&gt;
  for(i=0; i &amp;lt; tlist.length; ++i) {&lt;br /&gt;
  	j=0;&lt;br /&gt;
  	while( (tlist[i].search(/&amp;lt;ref[^&amp;lt;&amp;gt;\/]*&amp;gt;(?:&amp;lt;[^\/]|[^&amp;lt;])*=/gi) &amp;gt;= 0) &lt;br /&gt;
  		&amp;amp;&amp;amp; (j &amp;lt; 50) ) {&lt;br /&gt;
  		tlist[i] = tlist[i].replace(/(&amp;lt;ref[^&amp;lt;&amp;gt;\/]*&amp;gt;(?:&amp;lt;[^\/]|[^&amp;lt;])*)=/gi, '$1&amp;amp;#61;');&lt;br /&gt;
	}&lt;br /&gt;
  }&lt;br /&gt;
  // Now find duplicates in the list of unnested templates&lt;br /&gt;
  for(i=0; i &amp;lt; tlist.length; ++i) {&lt;br /&gt;
    // Add numbers for unnamed parameters&lt;br /&gt;
    var unp=0;&lt;br /&gt;
    tlist[i] = tlist[i].replace(/(\{\{[\s_]*#invoke[\s ]*:[^{}\|]*)\|([^{}\|=]*\|)/gi, '$1|0=$2');&lt;br /&gt;
    while((tlist[i].search(/(\{\{(?:[^{}\[\]]|\[\[[^\[\]]*\]\])*?\|)((?:[^{}\[\]=\|]|\[[^\[\]=]*\]|\[\[[^\[\]]*\]\])*(?:\||\}\}))/) &amp;gt;= 0)&lt;br /&gt;
          &amp;amp;&amp;amp; (unp &amp;lt; 25)) {&lt;br /&gt;
      unp++;&lt;br /&gt;
      tlist[i] = tlist[i].replace(/(\{\{(?:[^{}\[\]]|\[\[[^\[\]]*\]\])*?\|)((?:[^{}\[\]=\|]|\[[^\[\]=]*\]|\[\[[^\[\]]*\]\])*(?:\||\}\}))/, '$1' + unp + '=$2');&lt;br /&gt;
    }&lt;br /&gt;
    // Array to hold any found duplicate args (reduce number of alerts)&lt;br /&gt;
    var f = [];&lt;br /&gt;
    // Split the template into an array of | arg = ... strings&lt;br /&gt;
    var p = tlist[i].match(argexp);&lt;br /&gt;
    if( p ) {&lt;br /&gt;
      for(j=0; j &amp;lt; p.length; ++j) {&lt;br /&gt;
        p[j] = p[j].replace(argexp, '$1');&lt;br /&gt;
      }&lt;br /&gt;
      p = p.sort();&lt;br /&gt;
      for(j=0; j &amp;lt; p.length - 1; ++j) {&lt;br /&gt;
        if( p[j] == p[j+1]) {&lt;br /&gt;
          f.push(p[j]);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if(f.length &amp;gt; 0) {&lt;br /&gt;
      alertissued = alertissued + 1;&lt;br /&gt;
      if(alertissued &amp;lt; 5) {&lt;br /&gt;
        if(showresultsbox &amp;gt; 0) {&lt;br /&gt;
        	wpAddResultsBox('Duplicate \&amp;quot;' + f.join('\&amp;quot;, \&amp;quot;') + '\&amp;quot; in\n' + tlist[i], alertissued);&lt;br /&gt;
        }&lt;br /&gt;
        if(showalertbox &amp;gt; 0) {&lt;br /&gt;
        	alert('\&amp;quot;' + f.join('\&amp;quot;, \&amp;quot;') + '\&amp;quot; in\n' + tlist[i]);&lt;br /&gt;
        }&lt;br /&gt;
      } else if(alertissued == 6) {&lt;br /&gt;
      	alert(morefound);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  if (alertissued) {&lt;br /&gt;
    var editsummary = document.getElementsByName('wpSummary')[0];&lt;br /&gt;
    if(typeof editsummary == 'object') {&lt;br /&gt;
      if (editsummary.value.indexOf(mysummary) == -1) {&lt;br /&gt;
        if (editsummary.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {&lt;br /&gt;
          editsummary.value += '; ' + mysummary;&lt;br /&gt;
        } else {&lt;br /&gt;
          editsummary.value += mysummary;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  } else {&lt;br /&gt;
  	if(showresultsbox &amp;gt; 0) { wpClearResultsBox(); }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
// -------------------------------------------------------------------------------- //&lt;br /&gt;
&lt;br /&gt;
});&lt;/div&gt;</summary>
		<author><name>Erina</name></author>	</entry>

	</feed>