_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:TerraCyprus/infoboxgap.js

In the article we present below, we are going to delve into the fascinating world of User:TerraCyprus/infoboxgap.js. We will explore its origins, its evolution over time and its relevance today. From its many facets to its impact on society, we will delve into each aspect to give you a complete and enriching vision. Whether User:TerraCyprus/infoboxgap.js is a historical figure, a social phenomenon, or a current topic, this article will provide you with the information you need to understand his importance and influence on the world around us. So get ready to dive into this exciting topic and discover everything there is to know about User:TerraCyprus/infoboxgap.js.
jQuery(document).ready(function($) {

var myContent = document.getElementsByName('wpTextbox1');

if(mw.config.get('wgNamespaceNumber') != -1 && myContent) {
	mw.loader.using().done( function() {
	var portletlink1 = mw.util.addPortletLink('p-tb', '#', 'Infobox gap', 't-gap', 'Insert a numbering gap in an infobox', '');
	$(portletlink1).click(function(e) {
      e.preventDefault();
      wpInfoboxGap();
    });
    var portletlink2 = mw.util.addPortletLink('p-tb', '#', 'Infobox renumber', 't-ren', 'Remove numbering gaps in an infobox', '');
    $(portletlink2).click(function(e) {
      e.preventDefault();
      wpInfoboxRenumber();
    });
	});
}

// -------------------------------------------------------------------------------- //
function wpInfoboxGap()
{
 var i = 0;
 var nums = myContent.value.match(/(?:label|data|header|class)+(?:*=|*=)/g);
 for(i = 0; i < nums.length; i++) {
   nums = nums.replace(/*(+)*/, '$1');
 }
 nums = nums.sort(function(a,b){return a-b});
 var firstnum = Number(nums.shift());
 var lastnum = Number(nums.pop());

 var s = Number(prompt("Gap number (between " + String(firstnum) + " and " + String(lastnum) + ")?"));
 if ( (s >= firstnum) && (s <= lastnum + 1) ) {
 	var firstgap = 0;
 	for(i = s; i < lastnum; i++) {
 		var re = new RegExp('(label|data|header|class|rowstyle)' + String(i) + '(*=|*=)', 'g');
 		if(myContent.value.search(re) < 0) {
 			if(firstgap > 0) {
	 			lastnum = i - 1;
 			}
 		} else {
 			firstgap = 1;
 		}
 	}
 	for(i = lastnum; i >= s; i--) {
 		var re = new RegExp('(label|data|header|class|rowstyle)' + String(i) + '(*=|*=)', 'g');
 		myContent.value = myContent.value.replace(re,'$1' + String(i+1) + '$2');
   }
 }
}

function wpInfoboxRenumber()
{
 var i = 0;
 var nums = myContent.value.match(/(?:label|data|header|class|rowstyle)+(?:*=|*=)/g);
 for(i = 0; i < nums.length; i++) {
   nums = parseInt(nums.replace(/*(+)*/, '$1'));
 }

 var k = 1;
 var currnum  = nums;
 var lastnum = nums;
 for(i = 0; i < nums.length; i++) {
   currnum = nums;
   if (currnum != lastnum) {
     k = k + 1;
     lastnum = currnum;
   }
   var re = new RegExp('(label|data|header|class|rowstyle)' + String(nums) + '(*=|*=)', 'g');
   myContent.value = myContent.value.replace(re,'$1 WPFOOMARK ' + String(k) + '$2');
 }
 myContent.value = myContent.value.replace(/ WPFOOMARK /g, '');
}

});