Nowa Micropedia jest jeszcze w fazie beta. W razie problemów, napisz maila na pomoc@wiki.mikronacje.info albo zgłoś go na kanale na Mikronacyjnym Discordzie!

MediaWiki:Common.js: Różnice pomiędzy wersjami

Z Micropedia
Nie podano opisu zmian
(Navbar tools)
 
(Nie pokazano 2 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 1: Linia 1:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GLYEQY5D4T"></script>
/* Dynamic Navigation Bars */
<script>
// set up the words in your language
  window.dataLayer = window.dataLayer || [];
var NavigationBarHide = '[ukryj]';
  function gtag(){dataLayer.push(arguments);}
var NavigationBarShow = '[pokaż]';
  gtag('js', new Date());
 
  gtag('config', 'G-GLYEQY5D4T');
// set up max count of Navigation Bars on page,
</script>
// if there are more, all will be hidden
<script type="text/javascript">
// NavigationBarShowDefault = 0; // all bars will be hidden
  var _paq = window._paq = window._paq || [];
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
var NavigationBarShowDefault = 0;
  _paq.push(['trackPageView']);
 
  _paq.push(['enableLinkTracking']);
 
  (function() {
// shows and hides content and picture (if available) of navigation bars
  var u="//stats.makary.online/";
// Parameters:
  _paq.push(['setTrackerUrl', u+'matomo.php']);
//    indexNavBar: the index of navigation bar to be toggled
  _paq.push(['setSiteId', '1']);
function toggleNavigationBar(indexNavBar)
  var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
{
  g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
var NavToggle = document.getElementById("NavToggle" + indexNavBar);
  })();
var NavFrame = document.getElementById("NavFrame" + indexNavBar);
</script>
if (!NavFrame || !NavToggle)
return
;
// values to be set
var currDisplay;
var currTitle;
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide)
{
currDisplay = 'none';
currTitle = NavigationBarShow;
}
// if hidden now
else if (NavToggle.firstChild.data == NavigationBarShow)
{
currDisplay = 'block';
currTitle = NavigationBarHide;
}
for (var NavChild=NavFrame.firstChild; NavChild!=null; NavChild=NavChild.nextSibling)
{
if (NavChild.nodeType==1) // only if this is an element node
{
if (NavChild.className=='NavPic' || NavChild.className=='NavContent')
NavChild.style.display = currDisplay
else if (NavChild.className == 'NavToggle')
NavChild.firstChild.data = currTitle
;
}
}
}
 
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var i;
var indexNavBar = 0;
var divs = document.getElementById('bodyContent').getElementsByTagName("div");
// iterate over all < div >-elements
for (i=0; i<divs.length; i++)
{
// if found a navigation bar
if (divs[i].className == "NavFrame")
{
var NavFrame = divs[i];
indexNavBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in < div class="NavFrame" >
NavFrame.insertBefore(NavToggle, NavFrame.firstChild);
NavFrame.setAttribute('id', 'NavFrame' + indexNavBar);
}
}
// if more Navigation Bars found than Default then hide all
if (NavigationBarShowDefault < indexNavBar)
{
for(i=1; i<=indexNavBar; i++)
toggleNavigationBar(i)
;
}
 
}
 
addOnloadHook(createNavigationBarToggleButton);

Aktualna wersja na dzień 13:28, 9 sty 2021

/* Dynamic Navigation Bars */
// set up the words in your language
var NavigationBarHide = '[ukryj]';
var NavigationBarShow = '[pokaż]';

// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;


// shows and hides content and picture (if available) of navigation bars
// Parameters:
//     indexNavBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavBar)
{
	var NavToggle = document.getElementById("NavToggle" + indexNavBar);
	var NavFrame = document.getElementById("NavFrame" + indexNavBar);
	
	if (!NavFrame || !NavToggle)
		return
	;
	
	// values to be set
	var currDisplay;
	var currTitle;
	
	// if shown now
	if (NavToggle.firstChild.data == NavigationBarHide)
	{
		currDisplay = 'none';
		currTitle = NavigationBarShow;
	}
	// if hidden now
	else if (NavToggle.firstChild.data == NavigationBarShow)
	{
		currDisplay = 'block';
		currTitle = NavigationBarHide;
	}
	
	for (var NavChild=NavFrame.firstChild; NavChild!=null; NavChild=NavChild.nextSibling)
	{
		if (NavChild.nodeType==1)	// only if this is an element node
		{
			if (NavChild.className=='NavPic' || NavChild.className=='NavContent')
				NavChild.style.display = currDisplay
			else if (NavChild.className == 'NavToggle')
				NavChild.firstChild.data = currTitle
			;
		}
	}
}

// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
	var i;
	var indexNavBar = 0;
	var divs = document.getElementById('bodyContent').getElementsByTagName("div");
	// iterate over all < div >-elements
	for (i=0; i<divs.length; i++)
	{
		// if found a navigation bar
		if (divs[i].className == "NavFrame")
		{
			var NavFrame = divs[i];
			indexNavBar++;
			var NavToggle = document.createElement("a");
			NavToggle.className = 'NavToggle';
			NavToggle.setAttribute('id', 'NavToggle' + indexNavBar);
			NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavBar + ');');
			
			var NavToggleText = document.createTextNode(NavigationBarHide);
			NavToggle.appendChild(NavToggleText);
			
			// add NavToggle-Button as first div-element 
			// in < div class="NavFrame" >
			NavFrame.insertBefore(NavToggle, NavFrame.firstChild);
			NavFrame.setAttribute('id', 'NavFrame' + indexNavBar);
		}
	}
	// if more Navigation Bars found than Default then hide all
	if (NavigationBarShowDefault < indexNavBar)
	{
		for(i=1; i<=indexNavBar; i++)
			toggleNavigationBar(i)
		;
	}

}

addOnloadHook(createNavigationBarToggleButton);