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

קפיצה לניווט קפיצה לחיפוש
עדכון
אין תקציר עריכה
(עדכון)
שורה 29: שורה 29:
// 'checkty-empty-parameters-summary': 'ניקוי קוד',
// 'checkty-empty-parameters-summary': 'ניקוי קוד',
'checkty-main-articles-merge-summary': 'מיזוג הפניות לערכים מורחבים',
'checkty-main-articles-merge-summary': 'מיזוג הפניות לערכים מורחבים',
'checkty-missing-ref-section-add': 'נמצאו הערות שוליים בערך אך לא פרק מתאים. מומלץ להוסיף את הפרק לערך, וניתן להוסיף אותו אוטומטית במקום המשוער לכך.',
'checkty-missing-ref-section-added': 'פרק הערות שוליים הוסף.',
'checkty-missing-ref-section-autofix': 'הוספה אוטומטית',
'checkty-please-position-caret' : 'אנא מקמו את הסמן במקום בו יש להוסיף ',
'checkty-please-position-caret' : 'אנא מקמו את הסמן במקום בו יש להוסיף ',
'checkty-ref-dir-fix' : 'תיקון כיווניות להערת שוליים',
'checkty-ref-dir-fix' : 'תיקון כיווניות להערת שוליים',
שורה 83: שורה 86:
to: '[[$1$2]]',
to: '[[$1$2]]',
comment: 'פישוט קישור'
comment: 'פישוט קישור'
}, { // trim begining from redundant spaces
}, { // trim beginning from redundant spaces
from: /^\s+/g,
from: /^\s+/g,
to: '',
to: '',
comment: 'הסרת רווחים מיותרים'
comment: 'הסרת רווחים מיותרים'
}, { // trim redundant spaces from category links
from: /\[\[קטגוריה: */g,
to: '[[קטגוריה:'
}],
}],
formatReplacesConfig: [{
formatReplacesConfig: [{ // piped link has identical text before and after the pipe
from: /\[\[(.*?)\|\1([a-zא-ת]*)\]\]/g,
from: /\[\[(.*?)\|\1([.,a-zא-ת]*)\]\]/g,
to: '[[$1]]$2'
to: '[[$1]]$2'
}, {
}, {
שורה 124: שורה 130:
from: /,\]\]/g,
from: /,\]\]/g,
to: ']],'
to: ']],'
},
{ // section between two headings without content
from: /\n==[^=\n]+?==\n*(\n==[^=\n]+?==\n)/g,
to: '$1',
comment: 'הסרת כותרות ריקות'
}],
}],
regexes: [],
regexes: [],
שורה 398: שורה 409:
this.mergeRefs();
this.mergeRefs();
this.refDirSuggest();
this.refDirSuggest();
if (!this.isSection) {
this.refSection();
}
},
},
writeMsg: function (msg, icon) {
writeMsg: function (msg, icon) {
שורה 635: שורה 649:
vavCheck: function () {
vavCheck: function () {
var text = this.textbox.value,
var text = this.textbox.value,
vavRegex = /ה\[\[ו[^ו][א-ת ]+\]\]/g, self = this;
vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this;
if (!vavRegex.exec( text )) return;
if (!vavRegex.exec( text )) return;
var vavWarning = $('<div>').text( mw.msg( 'checkty-vav-warning' ) ).append(this.createSearchLink(vavRegex));
var vavWarning = $('<div>').text( mw.msg( 'checkty-vav-warning' ) ).append(this.createSearchLink(vavRegex));
שורה 1,069: שורה 1,083:
if (k === i) continue; // skip same name
if (k === i) continue; // skip same name
if (refsContent[k].content == refsContent[i].content) { // two refs with same content but different name
if (refsContent[k].content == refsContent[i].content) { // two refs with same content but different name
var oldRefName = new RegExp('<ref name="'+mw.util.escapeRegExp(i)+'" */>', 'g');
mergedRefsNames.push(i);
mergedRefsNames.push(i);
shortRef = chectTyTool.named_comment + k + '}}';
shortRef = chectTyTool.named_comment + k + '}}';
wikitext = wikitext.replace(refsContent[i].text, shortRef);
wikitext = wikitext.replace(refsContent[i].text, shortRef);
// TODO: possibly need to replace short refs of the other name
wikitext = wikitext.replace(oldRefName, shortRef);
}
}
}
}
שורה 1,151: שורה 1,166:
var searchRef = this.createSearchLink(m[1]);
var searchRef = this.createSearchLink(m[1]);
this.writeMsg($('<div>').append(['נמצאה הערת שוליים ללא הגדרת כיווניות "'+m[1]+'" [',searchRef, '&nbsp;-&nbsp;', fixRefDirLink, ']']), 'alert');
this.writeMsg($('<div>').append(['נמצאה הערת שוליים ללא הגדרת כיווניות "'+m[1]+'" [',searchRef, '&nbsp;-&nbsp;', fixRefDirLink, ']']), 'alert');
}
},
refSection: function(fix) {
var wikitext = this.textbox.value, newText = wikitext, self = this,
refRE = /<ref>|\{\{הערה\|/g,
refSectionRE = /\{\{הערות[ _]שוליים|<references[ >]/g,
hasRef = refRE.exec(wikitext) != null,
hasRefSection  = refSectionRE.exec(wikitext) != null;
if (hasRefSection) return; //not missing
if (!hasRef) return; // not needed
if (fix) { //  fix only when when explictly asked
var autoRefSection = '\n== הערות שוליים ==\n{{הערות שוליים}}\n'
var lastItems = [/(\n{{בקרת זהויות)/, /(\n{{קצרמר)/,/\n({{הבהרה (?:רפואית|הלכתית|משפטית))/,/(\n{{מיון רגיל:)/, /(\n\[\[קטגוריה:)/];
for (var i=0; (i < lastItems.length) && (wikitext == newText); i++ )  newText = wikitext.replace(lastItems[i], autoRefSection + '$1');
if ( wikitext === newText ) newText = wikitext + autoRefSection;
this.textbox.value = newText;
this.addSummary('פרק הערות שוליים');
this.writeMsg($('<div>'+mw.msg( 'checkty-missing-ref-section-added' )+'</div>'), 'info');
} else {
this.writeMsg($('<div>'+mw.msg( 'checkty-missing-ref-section-add' )+'</div>').append($('<a href="#">'+mw.msg( 'checkty-missing-ref-section-autofix' )+'</a>').click(function(){ self.refSection(true); return false; })), 'info');
}
}
},
},

תפריט ניווט