מדיה ויקי:Gadget-Checkty.js – הבדלי גרסאות
חלוקת קונטרסים (שיחה | תרומות) אין תקציר עריכה |
אין תקציר עריכה |
||
| (44 גרסאות ביניים של משתמש אחר אחד אינן מוצגות) | |||
| שורה 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': 'הערות לבדיקה:', | ||
| שורה 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' : 'תיקון כיווניות להערת שוליים', | ||
| שורה 43: | שורה 46: | ||
'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': 'כאשר ו עיצורית מופיעה באמצע מילה נהוג להכפילה. ייתכן שיש מופעים שדורשים תיקון.', | |||
'checkty-inuse-warning': 'הדף כולל תבנית בעבודה. אנא הימנעו מעריכה של ערך בעבודה כאשר משתמשים אחרים עובדים עליו במקביל. האם ברצונכם להפעיל בדיקה אוטומטית בכל זאת?' | |||
}); | }); | ||
| שורה 49: | שורה 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 | 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)'); | ||
| שורה 75: | שורה 80: | ||
to: "", | to: "", | ||
comment: 'הסרת תווים בלתי נראים' | comment: 'הסרת תווים בלתי נראים' | ||
}, { | }, { // trim spaces in end of line | ||
from: / +$/mg, | from: / +$/mg, | ||
to: '' | to: '' | ||
| שורה 82: | שורה 87: | ||
to: '[[$1$2]]', | to: '[[$1$2]]', | ||
comment: 'פישוט קישור' | comment: 'פישוט קישור' | ||
}, { // trim | }, { // 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' | ||
}, { | }, { | ||
| שורה 123: | שורה 131: | ||
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: [], | ||
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) { | ||
| שורה 133: | שורה 164: | ||
var t = $('#wpTextbox1'); | var t = $('#wpTextbox1'); | ||
this.textbox = t.length ? t[0] : null; | this.textbox = t.length ? t[0] : null; | ||
this.verifyRun(); | |||
}, | |||
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); | ||
| שורה 153: | שורה 182: | ||
} | } | ||
this.languageCheck(); | this.languageCheck(); | ||
this.vavCheck(); | |||
this.expandWikidata(); | this.expandWikidata(); | ||
}, | }, | ||
| שורה 232: | שורה 262: | ||
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(/אישים במאה ה-|אישים שחיו במאה ה-| | if (/אישים במאה ה-|אישים שחיו במאה ה-|רבנים במאה ה-/.exec(a)) return 1; if(/אישים במאה ה-|אישים שחיו במאה ה-|רבנים במאה ה-/.exec(b)) return -1; | ||
return a>=b; | return a>=b; | ||
}); | }); | ||
| שורה 296: | שורה 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[ | 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 | ||
| שורה 350: | שורה 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 ( | 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 | ||
| שורה 396: | שורה 429: | ||
this.mergeRefs(); | this.mergeRefs(); | ||
this.refDirSuggest(); | this.refDirSuggest(); | ||
if (!this.isSection) { | |||
this.refSection(); | |||
} | |||
}, | }, | ||
writeMsg: function (msg, icon) { | writeMsg: function (msg, icon) { | ||
| שורה 561: | שורה 597: | ||
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: | שורה 615: | ||
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: | שורה 666: | ||
// }).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 () { | ||
| שורה 802: | שורה 847: | ||
text: this.textbox.value | text: this.textbox.value | ||
} ).done( function( data ) { | } ).done( function( data ) { | ||
if ( data && data.parse && data.parse.text && $( data.parse.text['*'] ).find( 'a.image | if ( data && data.parse && data.parse.text && $( data.parse.text['*'] ).find( 'a.image img' ).filter(function() { | ||
var width = $(this).attr('width'); | var width = $(this).attr('width'); | ||
if (isNaN(width)) width = $(this).width(); | if (isNaN(width)) width = $(this).width(); | ||
| שורה 809: | שורה 854: | ||
} ).length === 0 ) { | } ).length === 0 ) { | ||
var fistURL = that.fistURL({ | var fistURL = that.fistURL({ | ||
s: articleName | |||
}); | }); | ||
var msg = $('<div>', { | var msg = $('<div>', { | ||
text: 'בדף זה אין תמונות. ניתן לחפש תמונות | text: 'בדף זה אין תמונות. ניתן לחפש תמונות באתר חב"ד אינפו. ' | ||
}).append($('<a>', { | }).append($('<a>', { | ||
href: decodeURI(fistURL), | href: decodeURI(fistURL), | ||
| שורה 902: | שורה 946: | ||
}, | }, | ||
fistURL: function (p) { | fistURL: function (p) { | ||
return 'https://chabad.info/? | return 'https://chabad.info/?' + $.param(p).replaceAll('_', '+'); | ||
}, | }, | ||
languageCheck: function (checks) { //style and language check | languageCheck: function (checks) { //style and language check | ||
| שורה 950: | שורה 994: | ||
var splittedWarn = genrealWarningWords[i].split("//"); | var splittedWarn = genrealWarningWords[i].split("//"); | ||
if ( splittedWarn.length !== 2 ) continue; | if ( splittedWarn.length !== 2 ) continue; | ||
checks.push({ | try { | ||
checks.push({ | |||
'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,034: | שורה 1,087: | ||
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,104: | ||
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 | |||
var oldRefName = new RegExp('<ref name="'+mw.util.escapeRegExp(i)+'" */>', 'g'); | |||
mergedRefsNames.push(i); | |||
shortRef = chectTyTool.named_comment + k + '}}'; | |||
wikitext = wikitext.replace(refsContent[i].text, shortRef); | |||
wikitext = wikitext.replace(oldRefName, shortRef); | |||
} | |||
} | |||
} | |||
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,059: | שורה 1,129: | ||
mergeRefsWithoutName: function() { // merge refs with same content | mergeRefsWithoutName: function() { // merge refs with same content | ||
var references = {},// a dictionary where key is the ref content and the value is list of uses | var references = {},// a dictionary where key is the ref content and the value is list of uses | ||
refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | |||
refTagRE = /<ref>(.+?)<\/ref>/g, | |||
wikitext = this.textbox.value, m; | wikitext = this.textbox.value, m; | ||
while ( m = | while ( m = refTemplateRE.exec( wikitext ) ){ | ||
references[m[1]] = references[m[1]] || []; | |||
references[m[1]].push(m[0]); | |||
} | |||
while ( m = refTagRE.exec( wikitext ) ){ | |||
references[m[1]] = references[m[1]] || []; | references[m[1]] = references[m[1]] || []; | ||
references[m[1]].push(m[0]); | references[m[1]].push(m[0]); | ||
| שורה 1,119: | שורה 1,194: | ||
var searchRef = this.createSearchLink(m[1]); | var searchRef = this.createSearchLink(m[1]); | ||
this.writeMsg($('<div>').append(['נמצאה הערת שוליים ללא הגדרת כיווניות "'+m[1]+'" [',searchRef, ' - ', fixRefDirLink, ']']), 'alert'); | this.writeMsg($('<div>').append(['נמצאה הערת שוליים ללא הגדרת כיווניות "'+m[1]+'" [',searchRef, ' - ', 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' | |||
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'); | |||
} | } | ||
}, | }, | ||
| שורה 1,136: | שורה 1,232: | ||
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,253: | ||
}, | }, | ||
getWikidataApi: function(callback) { | getWikidataApi: function(callback) { | ||
return new mw.ForeignApi( ' | return new mw.ForeignApi( 'https://www.wikidata.org/w/api.php' ); | ||
}, | }, | ||
extractWikidataLabelsSuggestions: function() { | extractWikidataLabelsSuggestions: function() { | ||
| שורה 1,236: | שורה 1,334: | ||
translations.append($('<li>').append($('<a>', { | translations.append($('<li>').append($('<a>', { | ||
href: ' | 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,422: | ||
} | } | ||
}, | }, | ||
//original version from | //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,454: | ||
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 | ||
| שורה 1,433: | שורה 1,531: | ||
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(/{{קצרמר/, ' | newText = t.replace(/{{קצרמר/, acTemplate + '\n{{קצרמר'); // before stub | ||
if (newText == t) newText = t.replace(/{{מיון רגיל:/, ' | if (newText == t) newText = t.replace(/{{מיון רגיל:/, acTemplate + '\n{{מיון רגיל:'); //before default sort | ||
if (newText == t) newText = t.replace(/\[\[קטגוריה:/, ' | if (newText == t) newText = t.replace(/\[\[קטגוריה:/, acTemplate + '\n[[קטגוריה:'); // before categories | ||
if (newText == t) newText = t + | if (newText == t) newText = t + '\n' + acTemplate; | ||
this.textbox.value = newText; | this.textbox.value = newText; | ||
this.addSummary('בקרת זהויות'); | this.addSummary('בקרת זהויות'); | ||