מדיה ויקי:Gadget-Checkty.js: הבדלים בין גרסאות בדף

קפיצה לניווט קפיצה לחיפוש
עדכון מויקיפדיה: https://he.wikipedia.org/wiki/%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-Checkty.js
אין תקציר עריכה
(עדכון מויקיפדיה: https://he.wikipedia.org/wiki/%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-Checkty.js)
תגית: ביטול
שורה 47: שורה 47:
'checkty-language-check': 'בערך זה מופיע הביטוי "$1". ',
'checkty-language-check': 'בערך זה מופיע הביטוי "$1". ',
'checkty-wrong-use-discussion': 'דף זה עשוי להיות דף דיונים. אין לערוך תגובות של עורכים אחרים והשימוש בבדיקה של דף כזה אינו מומלץ. האם ברצונך להפעיל את הכלי למרות זאת?',
'checkty-wrong-use-discussion': 'דף זה עשוי להיות דף דיונים. אין לערוך תגובות של עורכים אחרים והשימוש בבדיקה של דף כזה אינו מומלץ. האם ברצונך להפעיל את הכלי למרות זאת?',
'checkty-vav-warning': 'כאשר ו עיצורית מופיעה באמצע מילה נהוג להכפילה. ייתכן שיש מופעים שדורשים תיקון.'
'checkty-vav-warning': 'כאשר ו עיצורית מופיעה באמצע מילה נהוג להכפילה. ייתכן שיש מופעים שדורשים תיקון.',
'checkty-inuse-warning': 'הדף כולל תבנית בעבודה. אנא הימנעו מעריכה של ערך בעבודה כאשר משתמשים אחרים עובדים עליו במקביל. האם ברצונכם להפעיל בדיקה אוטומטית בכל זאת?'
});
});


שורה 53: שורה 54:
try {
try {
// proper spacing around , and . using negative lookahead and lookbehind (ES2018) to acronyms (b.b.c)
// proper spacing around , and . using negative lookahead and lookbehind (ES2018) to acronyms (b.b.c)
return new RegExp('(?<!\\.[א-ת]*)([א-ת]\\]?\\]?) ?([,\\.]) ?(?=[א-ת]?\\[?\\[?[א-ת]{3})(?![א-ת]*\\.[א-ת])','g');
return new RegExp('(?<!\\.[א-ת]*)([א-ת]\\]?\\]?"?) ?([,\\.]) ?(?=[א-ת]?\\[?\\[?[א-ת]{3})(?![א-ת]*\\.[א-ת])','g');
} catch(e) {
} catch(e) {
console.log('Checkty - browser doesnt support negative lookhead or lookbehind (ES2018)');
console.log('Checkty - browser doesnt support negative lookhead or lookbehind (ES2018)');
שורה 79: שורה 80:
to: "",
to: "",
comment: 'הסרת תווים בלתי נראים'
comment: 'הסרת תווים בלתי נראים'
}, {
}, { // trim spaces in end of line
from: / +$/mg,
from: / +$/mg,
to: ''
to: ''
שורה 138: שורה 139:
regexes: [],
regexes: [],
ignoreRegexes: [],
ignoreRegexes: [],
verifyRun: function () {
var self = this, runExcute = true,
inUseTemplatesRgx = /\{\{בעבודה[ \}\|]/;
if (!this.textbox || this.textbox.value.length === 0) return;
// this tool is not indented to be used in discussion pages
if ( mw.config.get('wgNamespaceNumber') % 2 == 1 || ( mw.config.get('wgNamespaceNumber') != 0  &&  /\(IST\)/.exec(this.textbox.value ) )) {
runExcute = false;
OO.ui.confirm(mw.msg('checkty-wrong-use-discussion')).done( function( confirmed ) { if ( confirmed ) self.execute(); });
}
// this tool is not intended to be used while other people are working on the same page
if( inUseTemplatesRgx.exec(this.textbox.value) ) {
runExcute = false;
OO.ui.confirm( mw.msg( 'checkty-inuse-warning' ) ).done( function( confirmed ) { if ( confirmed ) self.execute(); });
}
if (runExcute) this.execute();
},
run: function () {
run: function () {
if (this != chectTyTool) {
if (this != chectTyTool) {
שורה 145: שורה 164:
var t = $('#wpTextbox1');
var t = $('#wpTextbox1');
this.textbox = t.length ? t[0] : null;
this.textbox = t.length ? t[0] : null;
if (!this.textbox || this.textbox.value.length === 0) return;


// this tool is not indented to be used in discussion pages
this.verifyRun();
if ( mw.config.get('wgNamespaceNumber') % 2 == 1 || ( mw.config.get('wgNamespaceNumber') != 0  &&  /\(IST\)/.exec(this.textbox.value ) )) {
},
if (!prompt(mw.msg('checkty-wrong-use-discussion'))) return;
execute: function() {
}
// indication that skippable replacements should be ignored in the page
// indication that skippable replacements should be ignored in the page
this.skipCheckty = this.textbox.value.match(/{{ללא[_ ]בוט\|\s*צ'קטי\s*}}/g);
this.skipCheckty = this.textbox.value.match(/{{ללא[_ ]בוט\|\s*צ'קטי\s*}}/g);
שורה 309: שורה 326:
nakedLinks: function() {
nakedLinks: function() {
var t = this.textbox.value,
var t = this.textbox.value,
nakeRegex=/\[(http[^ ]+?)\]|\{\{הערה *\| *(?:1 *= *)?(https?:\/\/[^ }|]+)\}\}/g,
nakeRegex=/\[(http[^ ]+?)\]|\{\{הערה *\| *(?:1 *= *)?(https?:\/\/[^ }|]+)\}\}|<ref(?: [^/>]*)?>(https?:\/\/[^ }|]+?)<\/ref>/g,
nakeErrors=[], m, self= this;
nakeErrors=[], m, self= this;
while (m = nakeRegex.exec(t)) {
while (m = nakeRegex.exec(t)) {
var nakedUrl = m[1] || m[2],
var nakedUrl = m[1] || m[2] || m[3],
fixNakedLink = $( '<a href="#">' + mw.msg( 'checkty-naked-link-fix' )+'</a>' ).data( { 'search': nakedUrl, 'inRef': m[2] }).click( function ( e ) {  
fixNakedLink = $( '<a href="#">' + mw.msg( 'checkty-naked-link-fix' )+'</a>' ).data( { 'search': nakedUrl, 'inRefTemplate': m[2], 'inRef': m[3] }).click( function ( e ) {  
var searchUrl = $(this).data( 'search' ),
var searchUrl = $(this).data( 'search' ),
inRef = $(this).data('inRef'),
inRef = $(this).data('inRef'),
inRefTemplate = $(this).data('inRefTemplate'),
citoidTemplatesPromise = new mw.Api().loadMessagesIfMissing( [ 'citoid-template-type-map.json' ] );
citoidTemplatesPromise = new mw.Api().loadMessagesIfMissing( [ 'citoid-template-type-map.json' ] );
        // Common case: pasting a URI into this field. Citoid expects
        // Common case: pasting a URI into this field. Citoid expects
שורה 363: שורה 381:
var template = '{{'+CiteTemplates[d[0].itemType]+'|' + params.join('|')+'}}',
var template = '{{'+CiteTemplates[d[0].itemType]+'|' + params.join('|')+'}}',
wikitext = self.textbox.value;
wikitext = self.textbox.value;
if ( inRef ) {
if ( inRefTemplate ) {
wikitext = wikitext.replace(new RegExp('\\{\\{הערה *\\| *(?:1 *= *)?'+mw.util.escapeRegExp(searchUrl)+'\\}\\}', 'g'), '{{הערה|' + template + '}}');
wikitext = wikitext.replace(new RegExp('\\{\\{הערה *\\| *(?:1 *= *)?'+mw.util.escapeRegExp(searchUrl)+'\\}\\}', 'g'), '{{הערה|' + template + '}}');
} else if ( inRef ) {
wikitext = wikitext.replace(new RegExp('(<ref[^>]*>)'+mw.util.escapeRegExp(searchUrl)+'(</ref>)', 'g'), '$1' + template + '$2');
} else {
} else {
// this is more context sensitive - sometimes we may or may not want to wrap with ref
// this is more context sensitive - sometimes we may or may not want to wrap with ref
שורה 834: שורה 854:
} ).length === 0 ) {
} ).length === 0 ) {
var fistURL = that.fistURL({
var fistURL = that.fistURL({
datatype: 'articles',
data: articleName
});
});
var msg = $('<div>', {
var msg = $('<div>', {
שורה 973: שורה 995:
var splittedWarn = genrealWarningWords[i].split("//");
var splittedWarn = genrealWarningWords[i].split("//");
if ( splittedWarn.length !== 2 ) continue;
if ( splittedWarn.length !== 2 ) continue;
checks.push({
try {
'test': new RegExp( splittedWarn[0], 'i' ),
checks.push({
'remark': splittedWarn[1]
'test': new RegExp( splittedWarn[0], 'i' ),
});
'remark': splittedWarn[1]
});
}
catch(e)
{
/* negative lookbehind and similar advanced regex
will be skipped in browser which don't support it */
console.log('Skippted automatic check ' + i );
console.log(splittedWarn);
}
}
}
chectTyTool.languageCheck(checks);
chectTyTool.languageCheck(checks);
שורה 1,501: שורה 1,532:
var t = this.textbox.value,
var t = this.textbox.value,
viafTemplate = /\{\{בקרת זהויות[\}|]/g,
viafTemplate = /\{\{בקרת זהויות[\}|]/g,
acTemplate = '{{' + 'בקרת זהויות}}',
newText;
newText;
if ( viafTemplate.exec( t ) ) return; // viaf already exist
if ( viafTemplate.exec( t ) ) return; // viaf already exist
newText = t.replace(/{{קצרמר/, '{{בקרת זהויות}}\n{{קצרמר'); // before stub
newText = t.replace(/{{קצרמר/, acTemplate + '\n{{קצרמר'); // before stub
if (newText == t) newText = t.replace(/{{מיון רגיל:/, '{{בקרת זהויות}}\n{{מיון רגיל:'); //before default sort
if (newText == t) newText = t.replace(/{{מיון רגיל:/, acTemplate + '\n{{מיון רגיל:'); //before default sort
if (newText == t) newText = t.replace(/\[\[קטגוריה:/, '{{בקרת זהויות}}\n[[קטגוריה:'); // before categories
if (newText == t) newText = t.replace(/\[\[קטגוריה:/, acTemplate + '\n[[קטגוריה:'); // before categories
if (newText == t) newText = t += '\n{{בקרת זהויות}}';
if (newText == t) newText = t + '\n' + acTemplate;
this.textbox.value = newText;
this.textbox.value = newText;
this.addSummary('בקרת זהויות');
this.addSummary('בקרת זהויות');

תפריט ניווט