Wikipedista:Dominikmatus/vector.js
Vzhled
Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.
// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript"></' + 'script>');
// install the (Language) translation for [[:en:User:Cacycle/wikEd]]
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Sevela.p/wikEd international cs.js'
+ '&action=raw&ctype=text/javascript"></script>');
// [[User:Lupin/popups.js]]
var popScript = 'http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-popups.js';
var popStyleSheet = 'http://en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=User:Lupin/navpopdev.css';
if ( window.localCSS ) { popStyleSheet = 'http://localhost:8080/js/navpop.css'; }
function popups_importScriptURI(url) {
var s = document.createElement('script');
s.setAttribute('src',url);
s.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
return s;
}
function popups_importStylesheetURI(url) {
return document.createStyleSheet ? document.createStyleSheet(url) : popups_appendCSS('@import "' + url + '";');
}
function popups_appendCSS(text) {
var s = document.createElement('style');
s.type = 'text/css';
s.rel = 'stylesheet';
if (s.styleSheet) s.styleSheet.cssText = text //IE
else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
document.getElementsByTagName('head')[0].appendChild(s);
return s;
}
popups_importStylesheetURI(popStyleSheet);
popups_importScriptURI(popScript);
// [[User:Zocky/PicturePopupsVector.js]]
/*
jquery.event.drag.js ~ v1.5 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
Liscensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt
*/
(function(E){E.fn.drag=function(L,K,J){if(K){this.bind("dragstart",L)}if(J){this.bind("dragend",J)}return !L?this.trigger("drag"):this.bind("drag",K?K:L)};var A=E.event,B=A.special,F=B.drag={not:":input",distance:0,which:1,dragging:false,setup:function(J){J=E.extend({distance:F.distance,which:F.which,not:F.not},J||{});J.distance=I(J.distance);A.add(this,"mousedown",H,J);if(this.attachEvent){this.attachEvent("ondragstart",D)}},teardown:function(){A.remove(this,"mousedown",H);if(this===F.dragging){F.dragging=F.proxy=false}G(this,true);if(this.detachEvent){this.detachEvent("ondragstart",D)}}};B.dragstart=B.dragend={setup:function(){},teardown:function(){}};function H(L){var K=this,J,M=L.data||{};if(M.elem){K=L.dragTarget=M.elem;L.dragProxy=F.proxy||K;L.cursorOffsetX=M.pageX-M.left;L.cursorOffsetY=M.pageY-M.top;L.offsetX=L.pageX-L.cursorOffsetX;L.offsetY=L.pageY-L.cursorOffsetY}else{if(F.dragging||(M.which>0&&L.which!=M.which)||E(L.target).is(M.not)){return }}switch(L.type){case"mousedown":E.extend(M,E(K).offset(),{elem:K,target:L.target,pageX:L.pageX,pageY:L.pageY});A.add(document,"mousemove mouseup",H,M);G(K,false);F.dragging=null;return false;case !F.dragging&&"mousemove":if(I(L.pageX-M.pageX)+I(L.pageY-M.pageY)<M.distance){break}L.target=M.target;J=C(L,"dragstart",K);if(J!==false){F.dragging=K;F.proxy=L.dragProxy=E(J||K)[0]}case"mousemove":if(F.dragging){J=C(L,"drag",K);if(B.drop){B.drop.allowed=(J!==false);B.drop.handler(L)}if(J!==false){break}L.type="mouseup"}case"mouseup":A.remove(document,"mousemove mouseup",H);if(F.dragging){if(B.drop){B.drop.handler(L)}C(L,"dragend",K)}G(K,true);F.dragging=F.proxy=M.elem=false;break}return true}function C(M,K,L){M.type=K;var J=E.event.handle.call(L,M);return J===false?false:J||M.result}function I(J){return Math.pow(J,2)}function D(){return(F.dragging===false)}function G(K,J){if(!K){return }K.unselectable=J?"off":"on";K.onselectstart=function(){return J};if(K.style){K.style.MozUserSelect=J?"":"none"}}})(jQuery);
importStylesheetURI('http://en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=User%3AZocky%2FPicturePopups.css');
(function($) {
var zTop = 10;
var $doc = $(document);
$('.imagenotetoggle').live('click', function(e) {
$(this).closest('.imagenote').toggleClass('imagenoteminimized');
});
$('.imagenoteclose').live('click', function(e) {
$(this).closest('.imagenote').remove();
});
$('#content a.image img').live('click',function(e){
if (e.ctrlKey || e.shiftKey) return;
var $this = $(this);
var $link = $this.closest('a.image');
if (!$link.length) return;
e.preventDefault();
var filename = decodeURIComponent($link.attr('href').match(/\/wiki\/File:(.*)$/)[1].replace(/_/g," "));
var $thumb = $this.closest('.thumbinner');
var title = '<a href="' + $link.attr('href') + '">[>]</a> ' + filename;
var caption = $thumb.length ? $thumb.find('.thumbcaption').html() : '';
var content = '<blink>loading...</blink>';
var $popup = $('<div class="imagenote">'
+ '<table><tr class="imagenotetitlebar">'
+ '<td class="imagenotetitle" ><span>' + title + '</span></td>'
+ '<td class="imagenoteicons" align="right">'
+ '<span class="imagenotebutton imagenotetoggle">[–]</a> '
+ '<span class="imagenotebutton imagenoteclose">[×]</a>'
+ '</td></tr>'
+ '<tr><td class="imagenotecontent" colspan="2">'+content+'</td></tr>'
+ '<tr><td class="imagenotecaption" colspan="2">'+caption+'</td></tr></table>'
);
$popup
.appendTo($('body'))
.css({
top: Math.round(Math.random()*200)+'px',
left: Math.round(Math.random()*200)+'px',
// width:'600px',
zIndex: zTop++
})
.mousedown(function(e) {
$popup.css({
zIndex: zTop++
})
})
.bind('drag', function(e) {
$popup.css({
top: e.offsetY-$doc.scrollTop()+'px',
left: e.offsetX-$doc.scrollLeft()+'px'
});
});
$.getJSON (
'/w/api.php', {
format: 'json',
action: 'query',
prop: 'imageinfo',
titles: 'file:' + filename,
iiprop: 'url|size|dimensions|mime',
iiurlwidth: window.picturePopupsWidth || 800,
iiurlheight: window.picturePopupsHeight || 600
}, function (data) {
var info;
var page;
for (var i in data.query.pages) {
page = data.query.pages[i];
info = data.query.pages[i].imageinfo[0];
}
var content =
'<img src="' + info.thumburl+ '"/>'
+ '<br/>'
+ '<a href="'+info.url+'"> full resolution ('+info.width+'×'+info.height+', '+info.mime+')</a>';
$popup.find('.imagenotecontent').html(content);
});
});
})(jQuery);
[[User:Supadawg/secedit.js]]/////////////////////////////////////////
// By Alek Storm
// Please see talk page for instructions
/////////////////////////////////////////
var body; // shortcut for body node
var xmlhttp; // XMLHTTPRequest object
var startNode; // div that includes section header and edit link
var editSec; // edit link
var editForm; // spliced edit form
var preview; // spliced preview or diff content
var oldContent; // original content of section
var xmlhttpDone = false; // kludge to prevent multiple calls to callback
importScript("http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Supadawg/util.js");
function inc(path) {
var lt = String.fromCharCode(60);
var gt = String.fromCharCode(62);
document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+path+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}
function initSecEdit()
{
body = document.getElementsByTagName("body")[0];
// apply to all divs of class "editsection"
var editSecs = document.getElementsByTagName("span");
var secCount = 1;
var pagetitleRe=/\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; // from [Wikipedia:WikiProject User scripts/Techniques]
for ( var i = 0; i < editSecs.length; i++ ) {
if ( editSecs[i].getAttribute("class") == "editsection" ) {
for ( var k = 0; k < editSecs[i].childNodes.length; k++ ) {
if ( editSecs[i].childNodes[k].nodeName == "A" ) {
// grab editing uri, escape it, then put it back in
var editURI = "http://en.wikipedia.org/w/index.php?title="+encodeURIComponent2(pagetitleRe.exec(decodeURI(editSecs[i].childNodes[k].getAttribute("href")))[2]).replace(/\"/gi, "%22").replace(/\'/gi, "%27")+"&action=edit§ion="+secCount;
// give it a unique id
editSecs[i].childNodes[k].setAttribute( "id", "editSection"+secCount );
// swap the href with a function call, passing the original href as the second parameter
editSecs[i].childNodes[k].setAttribute( "href", "javascript:editSection( document.getElementById('editSection" + secCount + "'), '"+editURI+"' );" );
secCount++;
}
}
}
}
}
// called on click of section edit link
function editSection( elem, editURI )
{
cancelEdit(); // get rid of any other sections being edited
editSec = elem;
startNode = elem.parentNode.parentNode;
// initiate xmlhttprequest for section edit page
xmlhttpDone = false;
xmlhttp = null // kludge
xmlhttp = createXMLHTTP( "GET", editURI, stateChange );
}
// put raw input returned from XMLHTTPRequest into a div so we can grab specific elements
function makeDiv( rawHTML )
{
var div = createNode( body, "div", {style: "visibility: hidden; position: absolute;"} );
div.innerHTML = rawHTML.replace(/<script[^>]*><\/script>/gi, ""); // if script tags are placed into the DOM, they force reload of files, and nasty things happen
return div;
}
function isHTag( node )
{
return node.nodeName.charAt(0) == 'H' && !isNaN( parseInt( node.nodeName.charAt(1) ) );
}
// callback for onclick of an edit link
function stateChange()
{
if ( xmlhttp && xmlhttp.readyState == 4 ) {
if ( xmlhttp.status == 200 ) {
if ( xmlhttpDone )
return;
xmlhttpDone = true;
// store old content of section - loop until we hit header of same spot in hierarchy
if ( !oldContent ) {
oldContent = makeDiv("");
var curElem = startNode.nextSibling;
while ( curElem ) {
var hitSiblingSection = false;
if ( isHTag( curElem ) ) {
for ( var i = 0; i < curElem.childNodes.length; i++ ) {
if ( curElem.childNodes[i].nodeName == "SPAN"
&& curElem.childNodes[i].getAttribute("class") == "editsection"
&& parseInt( curElem.nodeName.charAt(1) ) <= parseInt( startNode.nodeName.charAt(1) ) )
hitSiblingSection = true;
}
}
else if ( curElem.nodeName == "DIV" && curElem.getAttribute("class") == "printfooter" )
break;
if ( hitSiblingSection )
break;
var nextElem = curElem.nextSibling;
oldContent.appendChild( curElem );
curElem = nextElem;
}
}
else
removeNode( oldContent );
var div = makeDiv( xmlhttp.responseText );
editForm = $("editform");
// change onclick of preview and diff buttons to our function
$("wpPreview").setAttribute( "type", "button" );
$("wpPreview").setAttribute( "onclick", "javascript:getEditData( previewChanged, $('wpPreview') );" );
$("wpDiff").setAttribute( "type", "button" );
$("wpDiff").setAttribute( "onclick", "javascript:getEditData( diffChanged, $('wpDiff') );" );
insertAfter( editForm, startNode );
removeNode( div );
editSec.setAttribute( "oldHref", editSec.getAttribute("href") );
editSec.setAttribute( "href", "javascript:cancelEdit();" );
editSec.innerHTML = "cancel";
}
else
alert("Problem retrieving data - status: "+xmlhttp.status);
}
}
// firefox hack, not sure if this is a problem in other browsers
function encodeURIComponent2( content )
{
// from [http://en.wikipedia.org/wiki/User:Topaz/wputil.js]
content = content.replace(/\<\;/gi, "<");
content = content.replace(/\>\;/gi, ">");
content = content.replace(/\"\;/gi, "\"");
content = content.replace(/\&\;/gi, "&");
return encodeURIComponent( content );
}
// encode differently based on type of form element
function field2Post( node, allowButton )
{
var reqBody = "";
switch ( node.nodeName ) {
case "TEXTAREA":
reqBody += "&"+node.getAttribute("name")+"="+encodeURIComponent2( node.value );
break;
case "INPUT":
var inputType = node.getAttribute("type");
if ( inputType == "checkbox" ) {
if ( node.checked )
reqBody += "&"+node.getAttribute("name")+"=on"
}
else if ( allowButton || (inputType != "submit" && inputType != "button") )
reqBody += "&"+node.getAttribute("name")+"="+encodeURIComponent2( node.value );
break;
case "DIV":
reqBody += form2Post( node, false );
break;
}
return reqBody;
}
// manually encodes a form element for XMLHTTPRequest
function form2Post( node )
{
var reqBody = "";
for ( var i = 0; i < node.childNodes.length; i++ )
reqBody += field2Post( node.childNodes[i], false );
return reqBody;
}
// get preview or diff data
function getEditData( callback, clickedBut )
{
xmlhttpDone = false;
xmlhttp = null; // kludge
var action = editForm.getAttribute("action");
xmlhttp = createXMLHTTP( "POST", "http://en.wikipedia.org"+action, callback, {
body: form2Post( editForm ) + field2Post( clickedBut, true ),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "http://en.wikipedia.org" + action.substring( 0, action.indexOf('&') ) + "&action=edit§ion="+(parseInt(editSec.getAttribute("id").substring(11))+1)
}
} );
}
// callback for preview data
function previewChanged()
{
if ( xmlhttp && xmlhttp.readyState == 4 ) {
if ( xmlhttp.status == 200 ) {
if ( xmlhttpDone )
return;
xmlhttpDone = true;
var div = makeDiv( xmlhttp.responseText );
if ( preview )
removeNode( preview );
preview = $("wikiPreview");
insertAfter( preview, startNode );
removeNode( div );
}
else
alert("Problem retrieving data - status: "+xmlhttp.status);
}
}
// callback for diff data
function diffChanged()
{
if ( xmlhttp && xmlhttp.readyState == 4 ) {
if ( xmlhttp.status == 200 ) {
if ( xmlhttpDone )
return;
xmlhttpDone = true;
var div = makeDiv( xmlhttp.responseText );
if ( preview )
removeNode( preview );
preview = $("wikiDiff");
insertAfter( preview, startNode );
removeNode( div );
}
else
alert("Problem retrieving data - status: "+xmlhttp.status);
}
}
// remove form and preview or diff data
function cancelEdit()
{
if ( preview )
removeNode( preview );
preview = null;
if ( editForm )
removeNode( editForm );
editForm = null;
if ( oldContent ) {
oldContent.setAttribute( "style", "position: static; visibility: visible;" );
insertAfter( oldContent, startNode );
}
oldContent = null;
if ( editSec ) {
editSec.setAttribute( "href", editSec.getAttribute("oldHref") );
editSec.innerHTML = "edit";
}
}
addEventListener( "load", initSecEdit, false );