MediaWiki:Common.js

Z NETBOX IPv6
Přejít na: navigace, hledání

Poznámka: Po uložení musíte smazat cache vašeho prohlížeče, jinak změny neuvidíte: Mozilla / Firefox: Ctrl-Shift-R, IE: Ctrl-F5, Safari: Cmd-Shift-R, Konqueror: F5.

/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky.  */

$(function() {

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}


 var n6i = $('#p-n6IPInfo ul');
 window.n6info = {
   n6mode: n6i.find('#n-n6mode + li a').html(),
   e4ip: n6i.find('#n-e4ip + li a').html(),
   i4ip: n6i.find('#n-i4ip + li a').html(),
   p4ip: n6i.find('#n-p4ip + li a').html(),
   v6prefix: n6i.find('#n-v6prefix + li a').html(),
   v6net: n6i.find('#n-v6net + li a').html(),
   v6ip: n6i.find('#n-v6ip + li a').html(),
 };

 switch (n6info.n6mode) {
   case 'auto': n6info.mode = 'Automatický'; break;
   case 'manual': n6info.mode = 'Manuální'; break;
   default: n6info.mode = 'Vypnuto'; n6info.n6mode = 'off'; break;
 }

 n6info.n6box = $('\
<div id="n6box" class="n6mode-' + n6info.n6mode + ' ' + (getCookie('n6show')?'n6shown':'n6hidden')+ '">\
  <ul>\
   <li id="n6hide-button" class="n6showhide-button"><a href="#" id="n6hide-button">&darr; Skrýt &darr;</a></li>\
   <li id="n6setup-button"><a href="/mediawiki/index.php/N6:IPInfo">Nastavit &rarr;</a></li>\
   <li id="n6show-button" class="n6showhide-button"><a href="#" id="n6show">&uarr; Zobrazit IP Info &uarr;</a></li>\
  </ul>\
  <dl>\
   <dt>Režim</dt>\n\
   <dd>' + n6info.mode + '</dd>\n\
  </dl>\n\
  <dl>\n\
   <dt>Veřejná IPv4</dt>\n\
   <dd>' + n6info.e4ip + '</dd>\n\
  </dl>\n\
  <dl>\n\
   <dt>Vnitřní IPv4</dt>\n\
   <dd>' + n6info.i4ip + '</dd>\n\
  </dl>\n\
  <dl>\n\
   <dt>PoP IPv4</dt>\n\
   <dd>' + n6info.p4ip + '</dd>\n\
  </dl>\n\
  <dl>\n\
   <dt>IPv6 prefix</dt>\n\
   <dd>' + n6info.v6prefix + '</dd>\n\
  </dl>\n\
  <dl>\n\
   <dt>IPv6 síť</dt>\n\
   <dd>' + n6info.v6net + '</dd>\n\
  </dl>\n\
  <dl>\n\
   <dt>Doporučená IPv6 adresa</dt>\n\
   <dd>' + n6info.v6ip + '</dd>\n\
  </dl>\n\
</div>\n\
');

 n6info.n6box.appendTo('body');
$('.n6showhide-button a').click(function(e) {
  e.preventDefault();
  $('#n6box').toggleClass('n6hidden').toggleClass('n6shown');
  if (getCookie('n6show')) {
    setCookie('n6show', '');
  } else {
    setCookie('n6show', '1');
  }
  return false;
});


var WizardState = "unloaded";


function wizardDie(message) {
   alert('Chyba: ' + message);
Error:
null.dummy;
Exception
throw "exit";
}

var $w = $('<div />');

function wizardForm ($widgets) {
   var $form = this;
   $w.dialog("isOpen") && $w.dialog("close");
   $w.dialog("destroy");

   $w = $('<div class="wizardHandle">', {
      title: "Wizard",
      }).html($form.html());
   alert($form.parent().eq(0).prop('class').match(/\bwizard-\d+/));
   $w.data('name', $form.parent().eq(0).prop('class').match(/\bwizard-\d+/));

   $widgets.each(function() {
      var $widget = $(this);
      var wcode = '';
      if ($widget.hasClass('button')) {
         wcode = $('<div>').html($widget.html());
         wcode.click(function () { $widget.trigger("click"); });
      	 wcode.button();
      }

      !!wcode.appendTo && wcode.appendTo($w);
   });

   $w.appendTo($('body'));

   $w.dialog({
      dialogClass: 'wizardWindow',
      autoOpen: true,
   });
   WizardsFreeze();

   return $w;
}

var nidR = /\bnid-.+?\b/g;

function clickHandler() {
   $.each(this.className.match(nidR), function(i, v) {
      var nid = v.substring(4);
      var $form = $('.wizard dt#wi_form_' + nid);
      if ($form.length) {
          wizardForm.call($form, $form.nextUntil("dt"));
      } else {
          wizardDie("Form number " + nid + " not found!");
      }
   });
}

$('.wizard .button').click(clickHandler);
$('.wizard .action').click(clickHandler);

$('.wizard dd.action:first-child').click();

$('input[type=submit]').button();

$('span.button a').button();

$('.msg > ul > li > a').removeClass('external').button();

$('.pbody ul').buttonset();

/*
function WizardsFreeze() {
	var handles = $('.wizardHandle');
	var states = new Array();

	$('.wizardHandle').each(function() {
		states.push({
			name: $(this).data('name'),
			id: this.id,
		});
	});

	var json = states.toSource();

	setCookie('WizardStates', json);
	alert(json);

	WizardState = "frozen";
	return json;
}

$(document).bind('beforeunload', function () {
//	if (!!WizardState && WizardState == 'frozen')
  //           return;
	WizardsFreeze();
	WizardState = "frozen";
});


$(document).bind('unload', function() {
//	if (!!WizardState && WizardState == 'frozen')
  //           return;
	WizardsFreeze();
	WizardState = "frozen";
});
*/

$('body.ns-4 #n6confForm span.formInput').each(function() {
   var i = $('<input type="text" />'). 
                   attr('name', $(this).prop('id')).
                   attr('value',$(this).html()).
                   insertAfter($(this));
   $(this).css('display', 'none');
});

$('body.ns-4 #n6confForm span.formHidenInput').each(function() {
   var i = $('<input type="hidden" />'). 
                   attr('name', $(this).prop('id')).
                   attr('value',$(this).html()).
                   insertAfter($(this));
   $(this).css('display', 'none');
});

var form = $('<form method="GET"></form>');
$('body.ns-4 #n6confForm').wrap(form);

$('body.ns-4 #n6confForm span.formSubmit').each(function() {
   var s = $('<input type="submit" />').
                    attr('name', 'submit').
                    attr('value', $(this).find('span').html()).
                    insertAfter($(this)).button();
   $(this).css('display', 'none');
})

/*
$('#mw_content .msg').dialog({
   width: 840,
   height: 350,
   resizable: false,
});
*/

});
Osobní nástroje