Wikipedysta:Zwiadowca21/common.js
var citationHelper = {
page: 'Wikipedysta:Kerim44/źródła'
};
importScript('Wikipedysta:Jcubic/citationHelper.js');
// Ulubione
importScript('Wikipedysta:Kaligula/js/Gadget-favorites.js');
importScript('User:Nux/veAutocorrect.js');
importScript('Wikipedysta:Zwiadowca21/wp-sk.js');
importScript('Wikipedysta:Lampak/MyLanguages.js');
var mylangsArray = ["pl", "en", "de"];
// [[Wikipedysta:Dschwen/wikiminiatlas2.js]] - please include this line
document.write('<script type="text/javascript" src="'
+ 'http://pl.wikipedia.org/w/index.php?title=Wikipedysta:Dschwen/wikiminiatlas2.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
var wma_settings =
{
height : 400,
width : 700
}
importScript('Wikipedysta:Beau/skrypty/seen.js');
// Ukrywanie edycji botów na zakładce historii [[Wikipedia:Narzędzia/hideBotsInHistory]]
importScript('Wikipedysta:Matma Rex/hideBotsInHistory v2.js');
// myNotepad – [[User:Vinne2/scripts/myNotepad]]
importScript('Wikipedysta:Vinne2/scripts/myNotepad.js');
// [[m:User:Jon Harald Søby/diffedit.js]]
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript' );
/**
* Prosesize
* Documentation at en.wikipedia.org/wiki/Wikipedia:Prosesize
* Rewrite of [[User:Dr_pda/prosesize.js]].
*/
'use strict';
(function () {
let windowManager;
function loadAndShowDialog() {
mw.loader.using(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api', 'jquery.textSelection'], function () {
defineDialog();
showPageSizeDialog();
});
}
let PageSizeDialog;
function defineDialog() {
if (PageSizeDialog) return;
function Dialog(config) {
Dialog.super.call(this, config);
}
OO.inheritClass(Dialog, OO.ui.ProcessDialog);
Dialog.static.name = 'PageSizeDialog';
Dialog.static.title = 'Rozmiar strony';
Dialog.static.actions = [
{ action: 'close', label: 'Zamknij', flags: ['safe', 'primary'] }
];
Dialog.prototype.initialize = function () {
Dialog.super.prototype.initialize.call(this);
this.content = new OO.ui.PanelLayout({ padded: true, expanded: false });
this.content.$element.css({
'max-height': '400px',
'overflow-y': 'auto',
'font-size': '14px',
'padding': '10px'
});
this.$body.append(this.content.$element);
this.$element.addClass('prosesize-dialog');
};
Dialog.prototype.getSetupProcess = function () {
return Dialog.super.prototype.getSetupProcess.call(this).next(() => {
const statsContent = calculateStatistics();
this.content.$element.empty().append(statsContent);
});
};
Dialog.prototype.getActionProcess = function (action) {
const dialog = this;
if (action === 'close') {
return new OO.ui.Process(function () {
resetHighlighting();
dialog.close({ action: 'close' });
});
}
return Dialog.super.prototype.getActionProcess.call(this, action);
};
Dialog.prototype.getTeardownProcess = function (data) {
const dialog = this;
return Dialog.super.prototype.getTeardownProcess.call(this, data).first(function () {
resetHighlighting();
});
};
PageSizeDialog = Dialog;
}
function showPageSizeDialog() {
if (!windowManager) {
windowManager = new OO.ui.WindowManager();
$(document.body).append(windowManager.$element);
}
const dialog = new PageSizeDialog({ size: 'large' });
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
}
$.when($.ready).then(function () {
if (mw.config.get('wgCanonicalSpecialPageName')) return;
const portletLink = mw.util.addPortletLink(
'p-tb',
'#',
'Rozmiar strony',
't-page-size',
'Oblicz rozmiar strony i rozmiar tekstu'
);
$(portletLink).on('click', function (e) {
e.preventDefault();
if (window.ve && ve.init && ve.init.target && ve.init.target.active) {
mw.notify('Prosesize nie działa z edytorem wizualnym.');
} else {
loadAndShowDialog();
}
});
});
function calculateStatistics() {
const parserOutput = $('.mw-parser-output');
if (parserOutput.length === 0) {
return $('<div>').text('Nie znaleziono zawartości.');
}
resetHighlighting();
let proseSize = 0;
let proseSizeHtml = 0;
let refmarkSize = 0;
let refmarkSizeHtml = 0;
let wordCount = 0;
let refSize = 0;
let refSizeHtml = 0;
parserOutput.children('p').each(function () {
$(this).addClass('prosesize-highlight');
proseSize += getLength(this);
proseSizeHtml += this.innerHTML.length;
refmarkSize += getRefMarkLength(this, false);
refmarkSizeHtml += getRefMarkLength(this, true);
wordCount += this.innerHTML.replace(/(<([^>]+)>)/ig, '').split(/\s+/).filter(Boolean).length;
});
parserOutput.find('ol.references').each(function () {
refSize = getLength(this);
refSizeHtml = this.innerHTML.length;
});
const list = $('<div>').append(
sizeElement('total-size', 'Rozmiar dokumentu HTML: ', 'https://upload.wikimedia.org/wikipedia/commons/1/16/OOjs_UI_icon_article-ltr-progressive.svg', 'Ładowanie...'),
sizeElement('wiki-size', 'Rozmiar wiki-tekstu: ', 'https://upload.wikimedia.org/wikipedia/commons/8/8f/OOjs_UI_icon_wikiText-progressive.svg', 'Ładowanie...'),
sizeElement('prose-size-html', 'Rozmiar tekstu (wraz z kodem HTML): ', 'https://upload.wikimedia.org/wikipedia/commons/f/f4/OOjs_UI_icon_viewDetails-ltr-progressive.svg', proseSizeHtml - refmarkSizeHtml),
sizeElement('ref-size-html', 'Przypisy (wraz z kodem HTML): ', 'https://upload.wikimedia.org/wikipedia/commons/f/fb/OOjs_UI_icon_references-ltr-progressive.svg', refSizeHtml + refmarkSizeHtml),
sizeElement('prose-size', 'Rozmiar tekstu (czysty tekst): ', 'https://upload.wikimedia.org/wikipedia/commons/3/30/OOjs_UI_icon_highlight-progressive.svg', proseSize - refmarkSize, ' (' + wordCount + ' słów)'),
sizeElement('ref-size', 'Przypisy (czysty tekst): ', 'https://upload.wikimedia.org/wikipedia/commons/0/02/OOjs_UI_icon_reference-progressive.svg', refSize + refmarkSize)
);
getFileSize(list);
getRevisionSize(list);
return list;
}
function resetHighlighting() {
$('.mw-parser-output').children('p').removeClass('prosesize-highlight');
}
function getFileSize(container) {
if (mw.config.get('wgAction') !== 'submit') {
$.get(location).then(function (result) {
container.find('#total-size').html('<b>' + sizeFormatter(result.length) + '</b>');
});
}
}
function getRevisionSize(container) {
const Api = new mw.Api();
function appendResult(size) {
container.find('#wiki-size').html('<b>' + sizeFormatter(size) + '</b>');
}
if (mw.config.get('wgAction') === 'submit') {
appendResult($('#wpTextbox1').textSelection('getContents').length);
} else if (mw.config.get('wgIsArticle')) {
Api.get({
action: 'query',
prop: 'revisions',
rvprop: 'size',
revids: mw.config.get('wgRevisionId'),
formatversion: 2
}).then(function (result) {
appendResult(result.query.pages[0].revisions[0].size);
});
}
}
function sizeFormatter(size) {
const nbsp = "\xA0";
if (size > 10240) {
return (Math.round(size / 1024) + nbsp + 'kB');
} else {
return (size + nbsp + 'B');
}
}
function sizeElement(id, text, imgUrl, size, extraText) {
const iconImg = $('<img>').attr('src', imgUrl).css({
'width': '20px',
'height': '20px',
'margin-right': '8px',
'vertical-align': 'middle'
});
return $('<div>')
.css({ 'margin-bottom': '8px', 'display': 'flex', 'align-items': 'center', 'gap': '10px' })
.append(
iconImg,
$('<span>').text(text + ' '),
$('<span>').prop('id', id).html('<b>' + sizeFormatter(size) + (extraText || '') + '</b>')
);
}
function getLength(node) {
let textLength = 0;
for (let i = 0; i < node.childNodes.length; i++) {
const child = node.childNodes[i];
if (child.nodeType === Node.TEXT_NODE) {
textLength += child.nodeValue.length;
} else if (
child.nodeType === Node.ELEMENT_NODE &&
(child.id === 'coordinates' || child.className.indexOf('emplate') !== -1)
) {
child.className += ' prosesize-special-template';
} else {
textLength += getLength(child);
}
}
return textLength;
}
function getRefMarkLength(node, includeHtml) {
let textLength = 0;
for (let i = 0; i < node.childNodes.length; i++) {
const child = node.childNodes[i];
if (child.nodeType === Node.ELEMENT_NODE && child.className === 'reference') {
textLength += includeHtml ? child.innerHTML.length : getLength(child);
}
}
return textLength;
}
mw.util.addCSS(`
.prosesize-highlight {
background-color: #ffff99;
}
`);
})();
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.