Потребител:ShadeOfGrey/Gadget-Advisor.js и Потребител:Ted Masters/Test 3.js: Разлика между страниците

(Разлики между страниците)
Изтрито е съдържание Добавено е съдържание
мРедакция без резюме
 
Редакция без резюме
 
Ред 22:
// originally from https://en.wikipedia.org/wiki/User:GregU/dashes.js
// checkPat1, checkPat2, checkTags, checkFileName default to true
ct.doNotFix = function (s, m, checkPat1, checkPat2, checkTags, checkFileName, ignoreTemplates) {
var pos = m.start;
var pat = /\[\[[^|\]]*$|\{\{[^|}]*$|[:\/%][^\s|>]+$|<[^>]*$|#\w*expr:.*$/i;
if (checkPat1 !== false && s.substring(pos - 260, pos + 1).search(pat) >= 0)
return true; // it's a link, so don't change it
 
var pat2 = /\{\{\s*(друг[ои] значени[ея]|основна|main|към|от пренасочване|категория|anchor|cite|citation|цитат2?|c?quote|is[sb]n|lang[i2]?|sfn|hrf|harv)((?!\{\{|\}\})[^\s\S]|\{\{(?:(?!\{\{|\}\})[\s\S]|\{\{(?:(?!\{\{|\}\})[\s\S]|\{\{(?:(?!\{\{|\}\})[\s\S])*\}\})*\}\})*\}\})*$/i;
if (checkPat2 !== false && s.substringslice(pos - 2600, pos + 1).search(pat2) >= 0)
return true; // likely a specific template (with up to 3 levels of template // likely templates with page-namenesting)
 
if (checkTags !== false) {
var nextTagPos = s.slice(pos).search(/<\/?(chem|math|pre|code|tt|source|syntaxhighlight|timeline|graph|mapframe|maplink|poem|blockquote|q|i|ref)\b/i);
if (nextTagPos >= 0 && s.charAt(pos + nextTagPos + 1) == '/')
return true; // skip math/chem equations, source code, timelines, graphs, maps, ref content, content in citation tags
return true; // don't break a <math> equation, or source code
}
}
 
if (ignoreTemplates !== false) {
var openingPos = s.substring(Math.max(0, pos - 500), pos + 1).search(/{{\s*?(друг[ои] значени[ея]|основна|main|към|от пренасочване|категория|anchor|cite|webarchive|citation|цитат2?|quote|is[sb]n|lang[i2]?|sfn|hrf|harv)\s*?([^{}]*|{{([^{}]*|{{([^{}]*|{{[^{}]*}})[^{}]*}})*}})*/i); // Find open template tag (that is not closed) preceding the match.
 
if (openingPos >=0) {
return true;
}
}
 
if (checkFileName !== false && s.slice(pos).search(/^[^|{}[\]<>\n]*\.([a-z]{3,4}\s*([|}\n]|\{\{!\}))/i) >= 0)
return true; // it's a file name parameter
};
 
Line 260 ⟶ 252:
// If we are editing a section, we have to be tolerant to the first heading's level
var isSection = editform &&
editform['.wpSection'] != null &&
editform['.wpSection'].value != '';
for (var i = 0; i < a.length; i++) {
var m = a[i];
Line 319 ⟶ 311:
for (var i = 0; i < a.length; i++) {
var m = a[i];
var sstr = m[1].replace(/[^0-9Xx]+/g, '').toUpperCase(); // remove all non-digits
if (sstr.length !== 10 && sstr.length !== 13) {
b.push({
start: m.start,
Line 327 ⟶ 319:
description: 'Трябва да е дълъг 10 или 13 цифри',
help: 'ISBN номерата трябва да са дълги 10 или 13 цифри. '
+ 'Този се състои от ' + sstr.length + ' цифри:<br><kbd>' + m[1] + '</kbd>'
});
continue;
}
var isNew = (sstr.length === 13); // old (10 digits) or new (13 digits)
var xIndex = sstr.indexOf('X');
if (xIndex !== -1 && (xIndex !== 9 || isNew)) {
b.push({
Line 346 ⟶ 338:
var computedChecksum = 0;
var modulus = isNew ? 10 : 11;
for (var j = sstr.length - 2; j >= 0; j--) {
var digit = sstr.charCodeAt(j) - 48; // 48 is the ASCII code of '0'
var quotient = isNew
? ((j & 1) ? 3 : 1) // the new way: 1 for even, 3 for odd
Line 354 ⟶ 346:
}
computedChecksum = (modulus - computedChecksum) % modulus;
var c = sstr.charCodeAt(sstr.length - 1) - 48;
var actualChecksum = (c < 0 || 9 < c) ? 10 : c;
if (computedChecksum === actualChecksum) {
Line 602 ⟶ 594:
var char = decodeURI(urlEncoded);
return (char.length == 1 ? char : urlEncoded);
};
 
var re = /(https?:\/\/[^\/ ]+\/)(((?![ \n\|\]\}><]).)*)/g;
Line 667 ⟶ 659:
return b;
});
 
window.ct = ct;