מדיה ויקי: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)
שורה 6: שורה 6:
'checkty-wikilink-in-extlink': 'בערך קיים קישור פנימי בתוך קישור חיצוני. רצוי לבטל את הקישור הפנימי או לצמצם את המסגרת של הקישור החיצוני',
'checkty-wikilink-in-extlink': 'בערך קיים קישור פנימי בתוך קישור חיצוני. רצוי לבטל את הקישור הפנימי או לצמצם את המסגרת של הקישור החיצוני',
'checkty-long-list': 'רשימה ארוכה - נראה כי בערך רשימה של מעל 20 פריטים. כדאי לשקול לפצלה לשני טורים באמצעות <a href="' + (new mw.Title('תבנית:טורים')).getUrl() + '">תבנית:טורים</a>',
'checkty-long-list': 'רשימה ארוכה - נראה כי בערך רשימה של מעל 20 פריטים. כדאי לשקול לפצלה לשני טורים באמצעות <a href="' + (new mw.Title('תבנית:טורים')).getUrl() + '">תבנית:טורים</a>',
'checkty-long-gallery': 'גלריה ארוכה - הערך מכיל גלריה ארוכה. מומלץ לשקול צמצום שלה או העברה לתבנית נפרדת.',
'checkty-long-gallery': 'גלריה ארוכה - הערך מכיל גלריה ארוכה. מומלץ לשקול צמצום שלה או העברה לתבנית נפדרת.',
'checkty-waiting-disambig-query': 'ממתין לרשימת פירושונים מהשרת...',
'checkty-waiting-disambig-query': 'ממתין לרשימת פירושונים מהשרת...',
'checkty-warnings-title': 'הערות לבדיקה:',
'checkty-warnings-title': 'הערות לבדיקה:',
שורה 43: שורה 43:
'checkty-defaultsort-suggest': 'בערך לא מוגדר מיון רגיל. בערכים העוסקים באישים נהוג למיין לפי שם משפחה. ',
'checkty-defaultsort-suggest': 'בערך לא מוגדר מיון רגיל. בערכים העוסקים באישים נהוג למיין לפי שם משפחה. ',
'checkty-language-check': 'בערך זה מופיע הביטוי "$1". ',
'checkty-language-check': 'בערך זה מופיע הביטוי "$1". ',
'checkty-wrong-use-discussion': 'דף זה עשוי להיות דף דיונים. אין לערוך תגובות של עורכים אחרים והשימוש בבדיקה של דף כזה אינו מומלץ. האם ברצונך להפעיל את הכלי למרות זאת?'
'checkty-wrong-use-discussion': 'דף זה עשוי להיות דף דיונים. אין לערוך תגובות של עורכים אחרים והשימוש בבדיקה של דף כזה אינו מומלץ. האם ברצונך להפעיל את הכלי למרות זאת?',
'checkty-vav-warning': 'כאשר ו עיצורית מופיעה באמצע מילה נהוג להכפילה. ייתכן שיש מופעים שדורשים תיקון.'
});
});


שורה 49: שורה 50:
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 /(?<!\.[א-ת]*)([א-ת]\]?\]?) ?([,\.]) ?(?=[א-ת]?\[?\[?[א-ת]{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)');
שורה 153: שורה 154:
}
}
this.languageCheck();
this.languageCheck();
this.vavCheck();
this.expandWikidata();
this.expandWikidata();
},
},
שורה 232: שורה 234:
if (/נפטרים ב-|נפטרות|שנפטרו/.exec(a)) return 1; if(/נפטרים ב-|נפטרות|שנפטרו/.exec(b)) return -1;
if (/נפטרים ב-|נפטרות|שנפטרו/.exec(a)) return 1; if(/נפטרים ב-|נפטרות|שנפטרו/.exec(b)) return -1;
if (/(ילידי|ילידות|שנולדו).*[0-9]/.exec(a)) return 1; if(/(ילידי|ילידות|שנולדו).*[0-9]/.exec(b)) return -1;
if (/(ילידי|ילידות|שנולדו).*[0-9]/.exec(a)) return 1; if(/(ילידי|ילידות|שנולדו).*[0-9]/.exec(b)) return -1;
if (/אישים במאה ה-|אישים שחיו במאה ה-|רבנים במאה ה-/.exec(a)) return 1; if(/אישים במאה ה-|אישים שחיו במאה ה-|אפיפיורים במאה ה-/.exec(b)) return -1;
if (/אישים במאה ה-|אישים שחיו במאה ה-|רבנים במאה ה-/.exec(a)) return 1; if(/אישים במאה ה-|אישים שחיו במאה ה-|רבנים במאה ה-/.exec(b)) return -1;
return a>=b;
return a>=b;
});
});
שורה 452: שורה 454:
} else {
} else {
var replceQuery = $.ajax({
var replceQuery = $.ajax({
url: mw.util.getUrl( (window.replaceListPage || 'חב&quot;דפדיה:בוט/רשימת החלפות'), { action: 'raw', ctype: 'text/x-wiki' } ),
url: mw.util.getUrl( (window.replaceListPage || 'חב"דפדיה:בוט/רשימת החלפות'), { action: 'raw', ctype: 'text/x-wiki' } ),
dataType: 'html'
dataType: 'html'
}), protectQuery = $.ajax({
}), protectQuery = $.ajax({
url: mw.util.getUrl( 'חב&quot;דפדיה:בוט/דפים חריגים', { action: 'raw', ctype: 'text/x-wiki' } ),
url: mw.util.getUrl( 'חב"דפדיה:בוט/דפים חריגים', { action: 'raw', ctype: 'text/x-wiki' } ),
dataType: 'html'
dataType: 'html'
});
});
שורה 561: שורה 563:
isDisambigPage = p.pageprops && p.title != mw.config.get('wgTitle') + mw.msg( 'checkty-disambig-suffix' );
isDisambigPage = p.pageprops && p.title != mw.config.get('wgTitle') + mw.msg( 'checkty-disambig-suffix' );
//list only real disambig links
//list only real disambig links
if (isDisambigPage && chectTyTool.getLinkRegex(p.title).exec(chectTyTool.textbox.value)) {
if (isDisambigPage && (chectTyTool.getLinkRegex(p.title).exec(chectTyTool.textbox.value) || (redirects[p.title] && chectTyTool.getLinkRegex(redirects[p.title]).exec(chectTyTool.textbox.value)))) {
disambigs.push(redirects[p.title] || p.title);
disambigs.push(redirects[p.title] || p.title);
}
}
שורה 579: שורה 581:
var origTxt = this.textbox.value, txt = this.textbox.value, m;
var origTxt = this.textbox.value, txt = this.textbox.value, m;
while (m = /(\{\{(?:הפניה לערך מורחב|ערך מורחב)\|[^=]+?\}\}\n){2,}/g.exec(txt)) {
while (m = /(\{\{(?:הפניה לערך מורחב|ערך מורחב)\|[^=\n]+?\}\}\n){2,}/g.exec(txt)) {
var articles = [], expArticleRE = /\{\{(?:הפניה לערך מורחב|ערך מורחב)\|([^=]+?)\}\}/g;
var articles = [], expArticleRE = /\{\{(?:הפניה לערך מורחב|ערך מורחב)\|([^=\n]+?)\}\}/g;
while (ma = expArticleRE.exec(m[0])) articles.push(ma[1]);
while (ma = expArticleRE.exec(m[0])) articles.push(ma[1]);
txt = txt.replace(m[0], '{{הפניה לערך מורחב|ערכים=[['+articles.join(']], [[')+']]}}\n');
txt = txt.replace(m[0], '{{הפניה לערך מורחב|ערכים=[['+articles.join(']], [[')+']]}}\n');
שורה 630: שורה 632:
// }).click(function(){ $('#wpTextbox1').val($('#wpTextbox1').val().replace(emptyParametersRgx, '')); chectTyTool.addSummary( mw.msg( 'checkty-empty-parameters-summary' ) ); return false; }));
// }).click(function(){ $('#wpTextbox1').val($('#wpTextbox1').val().replace(emptyParametersRgx, '')); chectTyTool.addSummary( mw.msg( 'checkty-empty-parameters-summary' ) ); return false; }));
// this.writeMsg(emptyParametersMsg, 'info');
// this.writeMsg(emptyParametersMsg, 'info');
},
vavCheck: function () {
var text = this.textbox.value,
vavRegex = /ה\[\[ו[^ו][א-ת ]+\]\]/g, self = this;
if (!vavRegex.exec( text )) return;
var vavWarning = $('<div>').text( mw.msg( 'checkty-vav-warning' ) ).append(this.createSearchLink(vavRegex));
// TODO: add semi-automatic fix option?
chectTyTool.writeMsg(vavWarning);
},
},
disambigCheck: function () {
disambigCheck: function () {
שורה 902: שורה 913:
},
},
fistURL: function (p) {
fistURL: function (p) {
return 'https://chabad.info/?s=' + $.param(p);
return 'https://tools.wmflabs.org/fist/fist.php?doit=1&language=he&project=wikipedia&params[catdepth]=&params[random]=&params[startat]=&params[ll_max]=5&params[free_only]=1&params[commons_max]=5&params[flickr_max]=5&params[include_flickr_id]=1&params[flickr_new_name_from_article]=1&params[picasa_max]=5&params[wts_max]=5&params[gimp_max]=&params[esp_max]=5&params[geograph_max]=5&params[geograph_max_de]=5&params[geograph_max_channel-islands]=5&params[freemages_max]=5&params[forarticles]=all&params[lessthan_images]=&params[default_thumbnail_size]=250&params[jpeg]=1&params[png]=1&params[gif]=1&params[svg]=1&params[output_format]=out_html&params[min_width]=80&params[min_height]=80&params[ab_max]=5&sources[languagelinks]=1&sources[commons]=1&sources[flickr]=1&' + $.param(p);
},
},
languageCheck: function (checks) { //style and language check
languageCheck: function (checks) { //style and language check
שורה 1,034: שורה 1,045:
autoMergeRefs: function() { // merge refs with same content and same name
autoMergeRefs: function() { // merge refs with same content and same name
var references = {},// a dictionary where key is the ref name and value is count
var references = {},// a dictionary where key is the ref name and value is count
refsContent = {},// a dictionary where key is the ref name and value is the content
refReEn = /<ref name="([^"]+?)">(.+?)<\/ref>/g,
refReEn = /<ref name="([^"]+?)">(.+?)<\/ref>/g,
wikitext = this.textbox.value, mergedRefs = [], m, k, i;
wikitext = this.textbox.value, mergedRefs = [], mergedRefsNames = [], m, k, i;
while ( m = refReEn.exec( wikitext ) ){
while ( m = refReEn.exec( wikitext ) ){
references[m[1]] = (references[m[1]] || 0) + 1;
references[m[1]] = (references[m[1]] || 0) + 1;
refsContent[m[1]] = { content: m[2], text: m[0] };
}
}


שורה 1,049: שורה 1,062:
mergedRefs.push(k);
mergedRefs.push(k);
}
}
}
}
if (mergedRefs.length) {
// merge referecnes with same content but different name
this.writeMsg( $('<div>').text('מיזוג הערות: ' + mergedRefs.join(', ')) );
for (k in refsContent) {
if ($.inArray(k,mergedRefsNames) != -1) continue; // skip name already merged
for (i in refsContent) {
if (k === i) continue; // skip same name
if (refsContent[k].content == refsContent[i].content) { // two refs with same content but different name
mergedRefsNames.push(i);
shortRef = chectTyTool.named_comment + k + '}}';
wikitext = wikitext.replace(refsContent[i].text, shortRef);
// TODO: possibly need to replace short refs of the other name
}
}
}
 
if (mergedRefs.length + mergedRefsNames.length) {
if (mergedRefs.length) this.writeMsg( $('<div>').text('מיזוג הערות: ' + mergedRefs.join(', ')) );
if (mergedRefsNames.length) this.writeMsg( $('<div>').text('מיזוג הערות עם שמות שונים: ' + mergedRefsNames.join(', ')) );
this.addSummary( 'מיזוג הערות אוטומטי' );
this.addSummary( 'מיזוג הערות אוטומטי' );
this.textbox.value = wikitext;
this.textbox.value = wikitext;
שורה 1,136: שורה 1,163:
m;
m;
while ( m = overlinkingRgx.exec(wikitext) )
while ( m = overlinkingRgx.exec(wikitext) ) {
{
if (/(?:File|קובץ|תמונה|מדיה):.+/.test(m[1])) {
continue; // skip files
}
var removeLink = $('<a href="#">'+mw.msg( 'checkty-remove-link' )+'</a>').data({'search': m[1]}).click(function(e){  
var removeLink = $('<a href="#">'+mw.msg( 'checkty-remove-link' )+'</a>').data({'search': m[1]}).click(function(e){  
var specificOverlinkingRgx = new RegExp('\\[\\[('+$(this).data('search')+')(\\]\\]|\\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\\[\\[\\1(\\]\\]|\\|.+?\\]\\])', 'g');
var specificOverlinkingRgx = new RegExp('\\[\\[('+$(this).data('search')+')(\\]\\]|\\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\\[\\[\\1(\\]\\]|\\|.+?\\]\\])', 'g');
שורה 1,155: שורה 1,184:
},
},
getWikidataApi: function(callback) {
getWikidataApi: function(callback) {
return new mw.ForeignApi( 'ttps://www.wikidata.org/w/api.php' );
return new mw.ForeignApi( 'https://www.wikidata.org/w/api.php' );
},
},
extractWikidataLabelsSuggestions: function() {
extractWikidataLabelsSuggestions: function() {
שורה 1,236: שורה 1,265:
translations.append($('<li>').append($('<a>', {
translations.append($('<li>').append($('<a>', {
href: 'ttps://www.wikidata.org/wiki/'+en,
href: 'https://www.wikidata.org/wiki/'+en,
text: en + ' ('+data[en].labels[lang].value+')',
text: en + ' ('+data[en].labels[lang].value+')',
target:'_blank'
target:'_blank'
שורה 1,324: שורה 1,353:
}
}
},
},
//original version from ttp://code.google.com/p/proveit-js/source/browse/ProveIt_Wikipedia.js#384
//original version from http://code.google.com/p/proveit-js/source/browse/ProveIt_Wikipedia.js#384
//thanks to Georgia Tech Research Corporation. Atlanta, GA 30332-0415
//thanks to Georgia Tech Research Corporation. Atlanta, GA 30332-0415
highlightString: function (toFind) {
highlightString: function (toFind) {
שורה 1,356: שורה 1,385:
acTemplate = /\{\{בקרת זהויות[\}|]/g,
acTemplate = /\{\{בקרת זהויות[\}|]/g,
artsTitle = /== *(?:מ?ספרי[הו]|מ?יצירותי[הו]|מ?חיבורי[הו]|מאמרים נבחרים|פילמוגרפיה.*|(?:מבחר)? (?:כתבי)|דיסקוגרפיה|יצירות) *==/, //cheap hint for art occuption in text
artsTitle = /== *(?:מ?ספרי[הו]|מ?יצירותי[הו]|מ?חיבורי[הו]|מאמרים נבחרים|פילמוגרפיה.*|(?:מבחר)? (?:כתבי)|דיסקוגרפיה|יצירות) *==/, //cheap hint for art occuption in text
artsCategory = /\[\[קטגוריה:(מוזיקאיות|מוזיקאים|זמרות|זמרים|סופרים|סופרות|ציירות|ציירים|במאי|רבנים|רבניות)(?!.+\*)/; //cheap hint for art occuption in category
artsCategory = /\[\[קטגוריה:(מוזיקאיות|מוזיקאים|זמרות|זמרים|סופרים|סופרות|מתרגמים|ציירות|ציירים|במאי|רבנים|רבניות)(?!.+\*)/; //cheap hint for art occuption in category
if ( acTemplate.exec( t ) ) return; // AC already exist
if ( acTemplate.exec( t ) ) return; // AC already exist
if ( !artsTitle.exec( t ) && !artsCategory.exec( t ) ) return; // no hint will have authority control
if ( !artsTitle.exec( t ) && !artsCategory.exec( t ) ) return; // no hint will have authority control

תפריט ניווט