בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,387
רעדאגירונגען
(גענוג געווען מיט 'לא ניתן להחיל את התגית "צ'קטי" ידנית') |
(פעלט שויניש אויס) |
||
| (44 מיטלסטע ווערסיעס פון 3 באַניצער נישט געוויזן.) | |||
| שורה 1: | שורה 1: | ||
// הוספת כפתור "בדיקה" שמבצע החלפות נפוצות של בוט ההחלפות וכן מתריע על בעיות סגנון ועיצוב שונות | // הוספת כפתור "בדיקה" שמבצע החלפות נפוצות של בוט ההחלפות וכן מתריע על בעיות סגנון ועיצוב שונות | ||
// לעזרה ראו [[mediawiki:Gadget-Checkty.js/הוראות]] | // לעזרה ראו [[mediawiki:Gadget-Checkty.js/הוראות]] | ||
mw.messages.set({ | mw.messages.set({ | ||
| שורה 15: | שורה 14: | ||
'checkty-disambig-success': 'לינקס צו באדייטן - די בדיקה איז סוקסעספול פארענדיגט.', | 'checkty-disambig-success': 'לינקס צו באדייטן - די בדיקה איז סוקסעספול פארענדיגט.', | ||
'checkty-disambig-links-title': 'די לעצטע אפגעהיטענע ווערסיע פארבינדט צו באדייטן בלעטער. ביטע פאררעכט די לינקס צו די בלעטער: ', | 'checkty-disambig-links-title': 'די לעצטע אפגעהיטענע ווערסיע פארבינדט צו באדייטן בלעטער. ביטע פאררעכט די לינקס צו די בלעטער: ', | ||
'checkty-page-doesnt-exist': ' ( | 'checkty-page-doesnt-exist': ' (בלאַט עקזיסטירט נאכנישט)', | ||
'checkty-dismabig-dialog-title': 'באדייטן פאררעכטונג', | 'checkty-dismabig-dialog-title': 'באדייטן פאררעכטונג', | ||
'checkty-remove-link': 'הסרת קישור', | 'checkty-remove-link': 'הסרת קישור', | ||
| שורה 35: | שורה 34: | ||
'checkty-ref-dir-fix': 'תיקון כיווניות להערת שוליים', | 'checkty-ref-dir-fix': 'תיקון כיווניות להערת שוליים', | ||
'checkty-ref-merge': 'צונויפגיסן רעפערענצן', | 'checkty-ref-merge': 'צונויפגיסן רעפערענצן', | ||
'checkty-naked-link-found': 'געטראפן נאקעטע | 'checkty-naked-link-found': 'געטראפן נאקעטע דרויסנדיגע לינק: $1', | ||
'checkty-naked-link-fix': 'פארריכטן', | 'checkty-naked-link-fix': 'פארריכטן', | ||
'checkty-broken-link': 'חשש פון א צעבראכן לינק: ', | 'checkty-broken-link': 'חשש פון א צעבראכן לינק: ', | ||
| שורה 45: | שורה 44: | ||
'checkty-category-sort': 'ניתן למיין את הקטגוריות בדף על פי סדר אלפביתי ', | 'checkty-category-sort': 'ניתן למיין את הקטגוריות בדף על פי סדר אלפביתי ', | ||
'checkty-defaultsort-suggest': 'דער ארטיקל האט נישט אנגעשטעלט דיפאלט סארטיר. ארטיקלען וואס באהאנדלען מענטשן סארטירט מען לויט פאמיליע נאמען. ', | 'checkty-defaultsort-suggest': 'דער ארטיקל האט נישט אנגעשטעלט דיפאלט סארטיר. ארטיקלען וואס באהאנדלען מענטשן סארטירט מען לויט פאמיליע נאמען. ', | ||
'checkty-bold-orig-lang-suggest': 'נהוג להדגיש את השם בשפת המקור אך נראה שחסרה הדגשה מתאימה בערך.', | |||
'checkty-language-check': 'אין דעם ארטיקל געפינט זיך דער אויסדרוק "$1". ', | 'checkty-language-check': 'אין דעם ארטיקל געפינט זיך דער אויסדרוק "$1". ', | ||
'checkty-wrong-use-discussion': 'דף זה עשוי להיות דף דיונים. אין לערוך תגובות של עורכים אחרים והשימוש בבדיקה של דף כזה אינו מומלץ. האם ברצונך להפעיל את הכלי למרות זאת?', | 'checkty-wrong-use-discussion': 'דף זה עשוי להיות דף דיונים. אין לערוך תגובות של עורכים אחרים והשימוש בבדיקה של דף כזה אינו מומלץ. האם ברצונך להפעיל את הכלי למרות זאת?', | ||
| שורה 98: | שורה 98: | ||
from: /\[\[(קאטעגאריע|קאַטעגאָריע): */g, | from: /\[\[(קאטעגאריע|קאַטעגאָריע): */g, | ||
to: '[[קאַטעגאָריע:' | to: '[[קאַטעגאָריע:' | ||
}, { // remove explicit self links | |||
from: new RegExp('\\[\\[' + mw.util.escapeRegExp(mw.config.get('wgTitle')) + '\\]\\]', 'g'), | |||
to: mw.config.get('wgTitle'), | |||
comment: 'אראפגענומען דירעקטע זעלבסט לינק' | |||
}], | }], | ||
formatReplacesConfig: [{ // piped link has identical text before and after the pipe | formatReplacesConfig: [{ // piped link has identical text before and after the pipe | ||
| שורה 141: | שורה 145: | ||
}, | }, | ||
{ | { | ||
from: /([ | // notes: at least 2 numbers - avoid chess notation replacement, English links - full link to avoid | | ||
to: '$1־$2' | from: /( [בלמהוכש])(?:- |)(\[\[[A-Za-z0-9 ]*\]\]|[A-Za-z]|[0-9]{2,}|\[\[[^\[\]]*?\|[A-Za-z0-9])/g, | ||
to: '$1־$2', | |||
comment: 'מיקוף למספרים ולעז' | |||
}, | }, | ||
{ // move , suffix outside links | { // move , suffix outside links | ||
| שורה 162: | שורה 168: | ||
var self = this, runExcute = true, | var self = this, runExcute = true, | ||
inUseTemplatesRgx = /\{\{אינמיטן ארבעט[ \}\|]/; | inUseTemplatesRgx = /\{\{אינמיטן ארבעט[ \}\|]/; | ||
if (!this.textbox || this.textbox.value.length === 0) return; | |||
// this tool is not indented to be used in discussion pages | // 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; | runExcute = false; | ||
OO.ui.confirm(mw.msg('checkty-wrong-use-discussion')).done(function (confirmed) { if (confirmed) self.execute(); }); | OO.ui.confirm(mw.msg('checkty-wrong-use-discussion')).done(function (confirmed) { if (confirmed) self.execute(); }); | ||
| שורה 171: | שורה 177: | ||
// this tool is not intended to be used while other people are working on the same page | // 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; | runExcute = false; | ||
OO.ui.confirm(mw.msg('checkty-inuse-warning')).done(function (confirmed) { if (confirmed) self.execute(); }); | OO.ui.confirm(mw.msg('checkty-inuse-warning')).done(function (confirmed) { if (confirmed) self.execute(); }); | ||
| שורה 186: | שורה 192: | ||
this.verifyRun(); | this.verifyRun(); | ||
}, | |||
updateText: function( val, manual ) { | |||
// for non manual changes - update origText | |||
if (!manual && (this.textbox.value === chectTyTool.origText)) { | |||
chectTyTool.origText = val; | |||
} | |||
$(this.textbox).textSelection( 'setContents', val ); | |||
}, | |||
getContents: function( ) { | |||
return $(this.textbox).textSelection( 'getContents' ); | |||
}, | |||
execute: function () { | 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); | |||
if (!($('#checktyResults').length)) $('.editButtons').after('<div id="checktyResults"><div class="checktyResultsTitle">' + mw.msg('checkty-warnings-title') + '</div></div>'); | if (!($('#checktyResults').length)) $('.editButtons').after('<div id="checktyResults"><div class="checktyResultsTitle">' + mw.msg('checkty-warnings-title') + '</div></div>'); | ||
//first call to remote functions than to local | //first call to remote functions than to local | ||
if ( ( chectTyTool.textbox.value === chectTyTool.origText ) && ( mw.config.get('wgAction') === 'edit') ) | |||
this.onSaveProtection(); | this.onSaveProtection(); | ||
this.linkChecks(); | |||
this.formatChecks(); | this.formatChecks(); | ||
if (!this.isSection) { | if (!this.isSection) { | ||
this.articleOrgChecks(); | this.articleOrgChecks(); | ||
| שורה 202: | שורה 218: | ||
} | } | ||
this.languageCheck(); | this.languageCheck(); | ||
if (window.checkNikud) { | |||
this.nikudCheck(); | |||
} | |||
this.vavCheck(); | this.vavCheck(); | ||
this.expandWikidata(); | this.expandWikidata(); | ||
| שורה 207: | שורה 226: | ||
}, | }, | ||
formatChecks: function () { | formatChecks: function () { | ||
if (!this.isSection) { | |||
this.build_regexes(); | this.build_regexes(); | ||
this.leadSectionFormat(false); | |||
} | |||
this.formatReplace(); | this.formatReplace(); | ||
this.decodeExternalLinks(); | this.decodeExternalLinks(); | ||
| שורה 215: | שורה 236: | ||
this.mainArticlesMerge(); | this.mainArticlesMerge(); | ||
this.numberRangeDash(false); | this.numberRangeDash(false); | ||
}, | |||
leadSectionFormat: function(execute) { | |||
var txt = this.textbox.value; | |||
// TODO: is the heuristic good enough or need more explicit for leading section? other langs? | |||
txt = txt.replace(/^(\'{3}.+?\'{3} \(\[*(?:ענגליש|דייטש|פראנצויזיש|אראביש)\]*: )([a-zA-Z ]+)\)/m, '$1\'\'\'$2\'\'\')'); | |||
if (txt === this.textbox.value) return; // nothing to do. | |||
if (!execute) { | |||
var suggestBoldOrigLang = $('<div>', { text: mw.msg('checkty-bold-orig-lang-suggest') }).append($('<a>', { | |||
href: '#', | |||
text: 'הדגשת שם בשפת המקור', | |||
}).click(function(){ chectTyTool.leadSectionFormat(true); return false;})); | |||
this.writeMsg(suggestBoldOrigLang, 'info'); | |||
} else { | |||
this.addSummary('הדגשת שם בשפת המקור'); | |||
this.updateText(txt); | |||
} | |||
}, | |||
decodeExternalLinks: function () { | decodeExternalLinks: function () { | ||
var t = this.textbox.value, newTxt = t, | |||
externalLinkRgx = /http[^ \]|]+/g, | externalLinkRgx = /http[^ \]|]+/g, | ||
decodeRgx = /(?:%[0-9a-z]{2}){2,}/ig, | decodeRgx = /(?:%[0-9a-z]{2}){2,}/ig, | ||
| שורה 249: | שורה 288: | ||
}, | }, | ||
defaultSortSuggest: function (execute) { | defaultSortSuggest: function (execute) { | ||
var txt = this.textbox.value, | |||
isPerson = false, | isPerson = false, | ||
firstFamilyRgx = /^([^ ]+) ([^ ]+)$/, | firstFamilyRgx = /^([^ ]+) ([^ ]+)$/, | ||
| שורה 269: | שורה 308: | ||
txt = txt.replace(/\[\[(קאַטעגאָריע|קאטעגאריע)/, '{{DEFAULTSORT:' + name[2] + ', ' + name[1] + '}}\n[[קאַטעגאָריע'); | txt = txt.replace(/\[\[(קאַטעגאָריע|קאטעגאריע)/, '{{DEFAULTSORT:' + name[2] + ', ' + name[1] + '}}\n[[קאַטעגאָריע'); | ||
this.addSummary('DEFAULTSORT'); | this.addSummary('DEFAULTSORT'); | ||
this.updateText(txt, true); | |||
} | } | ||
}, | }, | ||
categoryOrder: function (execute) { | categoryOrder: function (execute) { | ||
var txt = this.textbox.value, | |||
newTxt = txt, | newTxt = txt, | ||
self = this, | self = this, | ||
| שורה 309: | שורה 348: | ||
}, | }, | ||
duplicatedCategory: function (execute) { | duplicatedCategory: function (execute) { | ||
var txt = this.textbox.value, | |||
newTxt = txt, | newTxt = txt, | ||
categoryRE = /(\[\[(קאַטעגאָריע|קאטעגאריע):.+\]\])(?:$|\n)/g, | categoryRE = /(\[\[(קאַטעגאָריע|קאטעגאריע):.+\]\])(?:$|\n)/g, | ||
| שורה 333: | שורה 372: | ||
this.rawLinks(); | this.rawLinks(); | ||
} | } | ||
this.rabbiLinks(); | |||
this.overlinkify(); | this.overlinkify(); | ||
this.nakedLinks(); | this.nakedLinks(); | ||
| שורה 346: | שורה 386: | ||
}, | }, | ||
createSearchLink: function (v) { | createSearchLink: function (v) { | ||
return searchLink = $('<a href="#">'+mw.msg( 'checkty-search' )+'</a>').data({'search': v}).click(function(e){ | |||
chectTyTool.highlightString($(this).data('search')); e.preventDefault(); | |||
}); | }); | ||
return searchLink; | return searchLink; | ||
| שורה 354: | שורה 393: | ||
onSaveProtection: function () { | onSaveProtection: function () { | ||
$('#wpSave').click(function (e) { | $('#wpSave').click(function (e) { | ||
if (chectTyTool.textbox.value === chectTyTool.origText) { | |||
OO.ui.confirm(mw.msg('checkty-nonsense-edit')).done(function (confirmed) { | OO.ui.confirm(mw.msg('checkty-nonsense-edit')).done(function (confirmed) { | ||
if (confirmed) { | if (confirmed) { | ||
| שורה 366: | שורה 405: | ||
} | } | ||
}); | }); | ||
}, | }, | ||
nakedLinks: function () { | nakedLinks: function () { | ||
var t = this.textbox.value, | |||
nakeRegex = /\[(http[^ ]+?)\]|\{\{הערה *\| *(?:1 *= *)?(https?:\/\/[^ }|]+)\}\}|<ref(?: [^/>]*)?>(https?:\/\/[^ }|]+?)<\/ref>/g, | nakeRegex = /\[(http[^ ]+?)\]|\{\{הערה *\| *(?:1 *= *)?(https?:\/\/[^ }|]+)\}\}|<ref(?: [^/>]*)?>(https?:\/\/[^ }|]+?)<\/ref>/g, | ||
nakeErrors = [], m, self = this; | nakeErrors = [], m, self = this; | ||
| שורה 429: | שורה 462: | ||
} | } | ||
var template = '{{' + CiteTemplates[d[0].itemType] + '|' + params.join('|') + '}}', | var template = '{{' + CiteTemplates[d[0].itemType] + '|' + params.join('|') + '}}', | ||
wikitext = self.textbox.value; | |||
if (inRefTemplate) { | 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 + '}}'); | ||
| שורה 438: | שורה 471: | ||
wikitext = wikitext.replace(new RegExp('\\[' + mw.util.escapeRegExp(searchUrl) + '\\]', 'g'), template); | wikitext = wikitext.replace(new RegExp('\\[' + mw.util.escapeRegExp(searchUrl) + '\\]', 'g'), template); | ||
} | } | ||
self.updateText(wikitext, true); | |||
self.writeMsg($('<div>').append(mw.msg('checkty-naked-link-fixed', searchUrl, template)).append(self.createSearchLink(template))); | self.writeMsg($('<div>').append(mw.msg('checkty-naked-link-fixed', searchUrl, template)).append(self.createSearchLink(template))); | ||
chectTyTool.addSummary('הלבשת קישורים עירומים'); | chectTyTool.addSummary('הלבשת קישורים עירומים'); | ||
| שורה 453: | שורה 486: | ||
}, | }, | ||
checkExternalLinks: function () { | checkExternalLinks: function () { | ||
var t = this.textbox.value, | |||
externalLinksRgx = /== *קישורים חיצוניים *==(?:\n\{\{.+)*((?:\n\*.+|\n\{\{.+\}\})+)/mg, | externalLinksRgx = /== *קישורים חיצוניים *==(?:\n\{\{.+)*((?:\n\*.+|\n\{\{.+\}\})+)/mg, | ||
tplCounterRgx = /\n\* *\{\{([^|]+)/g, | tplCounterRgx = /\n\* *\{\{([^|]+)/g, | ||
| שורה 500: | שורה 533: | ||
}, | }, | ||
build_regexes: function (data, protect) { | build_regexes: function (data, protect) { | ||
if (/\{\{\s*ללא[_ ]בוט\s*\}\}/.test(this.textbox.value)) { | |||
this.writeMsg('<div>' + mw.msg('checkty-no-replacements') + '</div>', 'info'); | this.writeMsg('<div>' + mw.msg('checkty-no-replacements') + '</div>', 'info'); | ||
return; | return; | ||
| שורה 549: | שורה 582: | ||
}, | }, | ||
process_page: function () { | process_page: function () { | ||
var t = this.textbox.value, | |||
skip_ar = [], | skip_ar = [], | ||
actual_replaced = [], // list of actual replcements for summary | actual_replaced = [], // list of actual replcements for summary | ||
| שורה 574: | שורה 607: | ||
} | } | ||
while (true) { //extract inner links, inner templates and inner params - we don't want to sptit those. | while (true) { //extract inner links, inner templates and inner params - we don't want to sptit those. | ||
match = t.match(/(\{\{[^\{\}]*\}\}|(\n|\[\[)(?:File|קובץ|תמונה| | match = t.match(/(\{\{[^\{\}]*\}\}|(\n|\[\[)(?:File|קובץ|תמונה|בילד|טעקע):.*?[\|\n]|\[\[[a-z]{2,3}:[^\[\]]+\]\]|[^\[\0]\[[^\{\}\[]*\])/); | ||
if ((!match || !match.length) && this.ignoreRegexes.length) match = t.match(ignoreRegex); | if ((!match || !match.length) && this.ignoreRegexes.length) match = t.match(ignoreRegex); | ||
if (!match || !match.length) break; | if (!match || !match.length) break; | ||
| שורה 603: | שורה 636: | ||
match = t.match(/\0(\d+)\0/); | match = t.match(/\0(\d+)\0/); | ||
if (!match || !match.length) break; | if (!match || !match.length) break; | ||
t = t.replace(match[0], specials[parseInt(match[1], 10) - 1].replace('$','$$$$')); | |||
} | } | ||
this.updateText(t); | this.updateText(t); | ||
| שורה 648: | שורה 681: | ||
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) || (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); | ||
} | } | ||
| שורה 664: | שורה 697: | ||
}, | }, | ||
mainArticlesMerge: function () { | mainArticlesMerge: function () { | ||
var origTxt = this.textbox.value, txt = origTxt, m; | |||
while (m = /(\{\{(?:הפניה לערך מורחב| | while (m = /(\{\{(?:הפניה לערך מורחב|הויפט ארטיקל)\|[^=\n]+?\}\}\n){2,}/g.exec(txt)) { | ||
var articles = [], expArticleRE = /\{\{(?:הפניה לערך מורחב| | 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], '{{ | txt = txt.replace(m[0], '{{הויפט ארטיקל|ערכים=[[' + articles.join(']], [[') + ']]}}\n'); | ||
} | } | ||
this.updateText(txt, true); | |||
if (origTxt != txt) chectTyTool.addSummary(mw.msg('checkty-main-articles-merge-summary')); | if (origTxt != txt) chectTyTool.addSummary(mw.msg('checkty-main-articles-merge-summary')); | ||
}, | }, | ||
formatReplace: function () { | formatReplace: function () { | ||
var txt = this.textbox.value, newTxt; | |||
// Format autofix | // Format autofix | ||
var specials = [], match; | var specials = [], match; | ||
| שורה 708: | שורה 741: | ||
match = txt.match(/\0(\d+)\0/); | match = txt.match(/\0(\d+)\0/); | ||
if (!match || !match.length) break; | if (!match || !match.length) break; | ||
txt = txt.replace(match[0], specials[parseInt(match[1], 10) - 1].replace('$','$$$$')); | |||
} | } | ||
this.updateText(txt); | this.updateText(txt); | ||
// | }, | ||
nikudCheck: function () { | |||
var wikitext = chectTyTool.textbox.value; | |||
if (/[\u0591-\u05BD\u05BF-\u05C7\u05F3\u05F4]/.test(wikitext)) { | |||
nikudInsertMsg = $('<div>', { text: "דער ארטיקל פארמאגט ניקוד " }).append($('<a>', { | |||
href: '#', | |||
text: 'אראפנעמען', | |||
}).click(function () { | |||
// remove nikud | |||
chectTyTool.textbox.value = chectTyTool.textbox.value.replace(/[\u0591-\u05BD\u05BF-\u05C7\u05F3\u05F4]/g, ''); | |||
chectTyTool.addSummary('אראפגענומען ניקוד'); | |||
return false; | |||
})); | |||
chectTyTool.writeMsg(nikudInsertMsg, 'info'); | |||
} | |||
}, | }, | ||
vavCheck: function () { | vavCheck: function () { | ||
var text = this.textbox.value, | |||
vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this; | vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this; | ||
if (!vavRegex.exec(text)) return; | if (!vavRegex.exec(text)) return; | ||
| שורה 784: | שורה 826: | ||
h = a.href; | h = a.href; | ||
if (h.indexOf('#') + 1) anchor = decodeURI(h.substr(h.indexOf('#')).replace(/\./g, '%').replace(/_/g, ' ')); | if (h.indexOf('#') + 1) anchor = decodeURI(h.substr(h.indexOf('#')).replace(/\./g, '%').replace(/_/g, ' ')); | ||
$(a).text(a.title.replace(mw.msg('checkty-page-doesnt-exist'), "") + anchor); | $(a).text(a.title.replace(" (רוי)", "").replace(mw.msg('checkty-page-doesnt-exist'), "") + anchor); | ||
a.title = storeTitle; | a.title = storeTitle; | ||
} | } | ||
| שורה 800: | שורה 842: | ||
findSentence(); | findSentence(); | ||
function findSentence() { | function findSentence() { | ||
var text = chectTyTool.textbox.value.substr(offset), | |||
m = text.match(linkRgx); | m = text.match(linkRgx); | ||
if (!m) { | if (!m) { | ||
| שורה 813: | שורה 855: | ||
function resolve() { | function resolve() { | ||
var answer = $(this).text(), | var answer = $(this).text(), | ||
text = chectTyTool.textbox.value, | |||
startLink = text.indexOf('[[' + name, offset); | startLink = text.indexOf('[[' + name, offset); | ||
if (text.charAt(startLink + 2 + name.length) != '|') answer += '|' + name; | if (text.charAt(startLink + 2 + name.length) != '|') answer += '|' + name; | ||
offset += answer.length + 2; | offset += answer.length + 2; | ||
text = text.substr(0, startLink + 2) + answer + text.substr(startLink + 2 + name.length); | text = text.substr(0, startLink + 2) + answer + text.substr(startLink + 2 + name.length); | ||
chectTyTool.updateText(text, true); | |||
findSentence(); | findSentence(); | ||
chectTyTool.addSummary(mw.msg('checkty-dismabig-fix-summary')); | chectTyTool.addSummary(mw.msg('checkty-dismabig-fix-summary')); | ||
| שורה 824: | שורה 866: | ||
} | } | ||
function removeLink() { | function removeLink() { | ||
var text = chectTyTool.textbox.value, | |||
startLink = text.indexOf('[[' + name, offset), | startLink = text.indexOf('[[' + name, offset), | ||
endLink = text.indexOf(']]', startLink), | endLink = text.indexOf(']]', startLink), | ||
| שורה 831: | שורה 873: | ||
offset += (endLink - startLink) + linkText.length; | offset += (endLink - startLink) + linkText.length; | ||
text = text.substr(0, startLink) + linkText + text.substr(endLink + 2); | text = text.substr(0, startLink) + linkText + text.substr(endLink + 2); | ||
chectTyTool.updateText(text, true); | |||
findSentence(); | findSentence(); | ||
return false; | return false; | ||
| שורה 845: | שורה 887: | ||
}, | }, | ||
checkGallery: function () { | checkGallery: function () { | ||
var text = this.textbox.value, | |||
longGalleryThreshold = 16, | longGalleryThreshold = 16, | ||
galleryRgx = /<gallery.+?\n(\n|.)+?<\/gallery>/mg, | galleryRgx = /<gallery.+?\n(\n|.)+?<\/gallery>/mg, | ||
| שורה 857: | שורה 899: | ||
var fairUsageTemplates = ['מוסטער:שימוש הוגן', 'מוסטער:תמונת חבר כנסת']; | var fairUsageTemplates = ['מוסטער:שימוש הוגן', 'מוסטער:תמונת חבר כנסת']; | ||
if (!data) { | if (!data) { | ||
if (!(/\{\{(ויקישיתוף בשורה|מיזמים)/.test(this.textbox.value))) { | |||
$.getJSON('//www.wikidata.org/w/api.php?callback=?', { | $.getJSON('//www.wikidata.org/w/api.php?callback=?', { | ||
languages: 'yi', | languages: 'yi', | ||
| שורה 890: | שורה 932: | ||
} | } | ||
//in case there are no images in page | //in case there are no images in page | ||
if (!(/\[\[(תמונה|קובץ|File|Image):/i.test(this.textbox.value)) && !(/\| ?תמונה *= *.+jpg/i.test(this.textbox.value)) ) { | |||
var articleName = mw.config.get('wgPageName'); | var articleName = mw.config.get('wgPageName'); | ||
var that = this; // we want to use "this" in the done method of the api call. | var that = this; // we want to use "this" in the done method of the api call. | ||
| שורה 896: | שורה 938: | ||
action: 'parse', | action: 'parse', | ||
title: articleName, | title: articleName, | ||
text: this.textbox.value | |||
}).done(function (data) { | }).done(function (data) { | ||
if (data && data.parse && data.parse.text && $(data.parse.text['*']).find('a.image img').filter(function () { | if (data && data.parse && data.parse.text && $(data.parse.text['*']).find('a.image img').filter(function () { | ||
| שורה 988: | שורה 1,030: | ||
var isInInfobox = new RegExp('=\s*\\[\\[(?:file|image|קובץ|תמונה):' + imgName.replace(' ', '[ _]') + '[^\\]]*?\]\]', 'i'); | var isInInfobox = new RegExp('=\s*\\[\\[(?:file|image|קובץ|תמונה):' + imgName.replace(' ', '[ _]') + '[^\\]]*?\]\]', 'i'); | ||
if (isInInfobox.test(t.val())) { | if (isInInfobox.test(t.val())) { | ||
chectTyTool.updateText(t.val().replace(matches[0], matches[0] + '{{'+mw.msg('checkty-fairuse-img-replace-template')+'}}'), true); | |||
chectTyTool.addSummary('{{' + mw.msg('checkty-fairuse-img-replace-template') + '}}'); | chectTyTool.addSummary('{{' + mw.msg('checkty-fairuse-img-replace-template') + '}}'); | ||
} | } | ||
| שורה 1,006: | שורה 1,048: | ||
}, | }, | ||
languageCheck: function (checks) { //style and language check | languageCheck: function (checks) { //style and language check | ||
var txt = this.textbox.value; | |||
if (txt.length === 0) return; // nothing to do | if (txt.length === 0) return; // nothing to do | ||
if (checks) { | if (checks) { | ||
| שורה 1,046: | שורה 1,088: | ||
}).done(function (data) { | }).done(function (data) { | ||
if (!(data && data.parse && data.parse.wikitext)) return; | if (!(data && data.parse && data.parse.wikitext)) return; | ||
var DictionaryText = data.parse.wikitext['*'].split('-----')[1] | var DictionaryText = data.parse.wikitext['*'].split('-----')[1]; | ||
var genrealWarningWords = DictionaryText.split('\n*'); | var genrealWarningWords = DictionaryText.split('\n*'); | ||
var checks = []; | var checks = []; | ||
| שורה 1,085: | שורה 1,127: | ||
refsConsistencyCheck: function () { | refsConsistencyCheck: function () { | ||
function safeRegexFix(fixRegex, fixReplace, check) { | function safeRegexFix(fixRegex, fixReplace, check) { | ||
var txt = chectTyTool.textbox.value, | |||
m; | m; | ||
//remove templates within templates | //remove templates within templates | ||
| שורה 1,102: | שורה 1,144: | ||
txt = txt.replace(fixRegex, fixReplace); | txt = txt.replace(fixRegex, fixReplace); | ||
while (m = specials.pop()) txt = txt.replace('\0' + specials.length + '\0', m); | while (m = specials.pop()) txt = txt.replace('\0' + specials.length + '\0', m); | ||
chectTyTool.updateText(txt, true); | |||
} | } | ||
} | } | ||
| שורה 1,128: | שורה 1,170: | ||
ibidWarning: function () { | ibidWarning: function () { | ||
var refRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | var refRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | ||
wikitext = this.textbox.value, self=this, m; | |||
var checkWarnings = $('<div></div>'); | var checkWarnings = $('<div></div>'); | ||
while (m = refRE.exec(wikitext)) { | while (m = refRE.exec(wikitext)) { | ||
if (/^שם[ .,]|^שם$/.test(m[1]) || /\bibid(?![^a-z])/i.test(m[1])) { | if (/^שם[ .,]|^שם$/.test(m[1]) || /\bibid(?![^a-z])/i.test(m[1]) || /^דארט[ .,]|^דארט$/.test(m[1])) { | ||
checkWarnings.append(this.createSearchLink(m[0])); | checkWarnings.append(this.createSearchLink(m[0])); | ||
checkWarnings.append(' - נמצאה הערת שוליים המפנה להערה הקודמת בצורה של שם. יש להחליף לציון מקור מדויק. ראו עוד: <a href="' + mw.util.getUrl('המכלול:רעפערענצן') + '">המכלול:רעפערענצן</a><br/>'); | checkWarnings.append(' - נמצאה הערת שוליים המפנה להערה הקודמת בצורה של שם. יש להחליף לציון מקור מדויק. ראו עוד: <a href="' + mw.util.getUrl('המכלול:רעפערענצן') + '">המכלול:רעפערענצן</a><br/>'); | ||
| שורה 1,146: | שורה 1,188: | ||
refsContent = {},// a dictionary where key is the ref name and value is the content | 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 = [], 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; | ||
| שורה 1,181: | שורה 1,223: | ||
if (mergedRefsNames.length) this.writeMsg($('<div>').text('מיזוג הערות עם שמות שונים: ' + mergedRefsNames.join(', '))); | if (mergedRefsNames.length) this.writeMsg($('<div>').text('מיזוג הערות עם שמות שונים: ' + mergedRefsNames.join(', '))); | ||
this.addSummary('מיזוג הערות אוטומטי'); | this.addSummary('מיזוג הערות אוטומטי'); | ||
this.updateText(wikitext); | |||
} | } | ||
}, | }, | ||
| שורה 1,188: | שורה 1,230: | ||
refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | ||
refTagRE = /<ref>(.+?)<\/ref>/g, | refTagRE = /<ref>(.+?)<\/ref>/g, | ||
wikitext = this.textbox.value, m; | |||
while (m = refTemplateRE.exec(wikitext)) { | while (m = refTemplateRE.exec(wikitext)) { | ||
references[m[1]] = references[m[1]] || []; | references[m[1]] = references[m[1]] || []; | ||
| שורה 1,214: | שורה 1,256: | ||
this.addSummary(mw.msg('checkty-ref-merge')); // addSummary will only add it once | this.addSummary(mw.msg('checkty-ref-merge')); // addSummary will only add it once | ||
} | } | ||
this.updateText(wikitext); | |||
} | } | ||
}, | }, | ||
descriptionInsert: function () { | descriptionInsert: function () { | ||
var wikitext = | var wikitext = chectTyTool.textbox.value; | ||
var regex = /{{דעסקריפציע\|[^|}]/; | var regex = /{{דעסקריפציע\|[^|}]/; | ||
// check whether description is empty | // check whether description is empty | ||
| שורה 1,229: | שורה 1,271: | ||
var desc = prompt('שטעלט אריין א שילדערונג מיט געציילטע ווערטער'); | var desc = prompt('שטעלט אריין א שילדערונג מיט געציילטע ווערטער'); | ||
if (desc) { | if (desc) { | ||
chectTyTool.textbox.value = '{' + '{דעסקריפציע|' + desc + '}}\n' + | chectTyTool.textbox.value = '{' + '{דעסקריפציע|' + desc + '}}\n' + chectTyTool.textbox.value; | ||
chectTyTool.addSummary('צוגעלייגט דעסקריפציע'); | chectTyTool.addSummary('צוגעלייגט דעסקריפציע'); | ||
} | } | ||
| שורה 1,238: | שורה 1,280: | ||
}, | }, | ||
interwikiInsert: function () { | interwikiInsert: function () { | ||
var wikitext = | var wikitext = chectTyTool.textbox.value; | ||
// check whether hebrew is not linked | // check whether hebrew is not linked | ||
if (!wikitext.toLowerCase().includes('[' + '[he:')) { | if (!wikitext.toLowerCase().includes('[' + '[he:')) { | ||
| שורה 1,246: | שורה 1,288: | ||
}).click(function () { | }).click(function () { | ||
// insert interlink | // insert interlink | ||
var inter = prompt('שטעלט אריין דעם נאמען פון ערך אויף המכלול העברי'); | |||
if (inter) { | |||
chectTyTool.textbox.value += '\n[' + '[he:' + inter + ']]'; | |||
chectTyTool.addSummary('צוגעלייגט אינטערשפראך לינק'); | |||
} | |||
return false; | return false; | ||
})); | })); | ||
| שורה 1,258: | שורה 1,300: | ||
titleOrderCheck: function () { | titleOrderCheck: function () { | ||
// validates the titles order is consistent | // validates the titles order is consistent | ||
var orderedTitles = ['זעט אויך', 'ליינט מער', ' | var orderedTitles = ['זעט אויך', 'ליינט מער', 'דרויסנדיגע לינקס', 'רעפערענצן'], | ||
isSorted = 1, | isSorted = 1, | ||
titles = $('#wpTextbox1').val().match('==\\s*' + orderedTitles.join('|') + '\\s*==', 'g'), i, indexes; | titles = $('#wpTextbox1').val().match('==\\s*' + orderedTitles.join('|') + '\\s*==', 'g'), i, indexes; | ||
| שורה 1,269: | שורה 1,311: | ||
}, | }, | ||
refDirSuggest: function () { // suggest adding direction for refs | refDirSuggest: function () { // suggest adding direction for refs | ||
var wikitext = this.textbox.value, | |||
defaultDir = (/{{רעפערענצן *\| *יישור *= *שמאל}}/.exec(wikitext)) ? 'ltr' : 'rtl', | defaultDir = (/{{רעפערענצן *\| *יישור *= *שמאל}}/.exec(wikitext)) ? 'ltr' : 'rtl', | ||
ltrRefRegex = /\{\{הערה\|(?:שם ?=[^|]*\|)?(?:1= *)?(?! *\[?https?:\/\/[^ ]+\]? *\}\})( *\[?[a-z][^א-ת\u0600-\u06FF{|]+?)\}\}/ig, | ltrRefRegex = /\{\{הערה\|(?:שם ?=[^|]*\|)?(?:1= *)?(?! *\[?https?:\/\/[^ ]+\]? *\}\})( *\[?[a-z][^א-ת\u0600-\u06FF{|]+?)\}\}/ig, | ||
| שורה 1,280: | שורה 1,322: | ||
var fixRefDirLink = $('<a href="#">' + mw.msg('checkty-ref-dir-fix') + '</a>').data({ 'search': m[0] }).click(function (e) { | var fixRefDirLink = $('<a href="#">' + mw.msg('checkty-ref-dir-fix') + '</a>').data({ 'search': m[0] }).click(function (e) { | ||
var specificRefRgx = new RegExp('\\[\\[(' + mw.util.escapeRegExp($(this).data('search')) + ')(\\]\\]|\\|).+\\[\\[\\1(\\]\\]|\\|.+?\\]\\])', 'g'), | var specificRefRgx = new RegExp('\\[\\[(' + mw.util.escapeRegExp($(this).data('search')) + ')(\\]\\]|\\|).+\\[\\[\\1(\\]\\]|\\|.+?\\]\\])', 'g'), | ||
wikitext = chectTyTool.textbox.value; | |||
wikitext = wikitext.replace($(this).data('search'), $(this).data('search').replace('}}', '|כיוון=' + uncommonDir + '}}')); | wikitext = wikitext.replace($(this).data('search'), $(this).data('search').replace('}}', '|כיוון=' + uncommonDir + '}}')); | ||
chectTyTool.updateText(wikitext, true); | |||
chectTyTool.addSummary(mw.msg('checkty-ref-dir-fix')); | chectTyTool.addSummary(mw.msg('checkty-ref-dir-fix')); | ||
e.preventDefault(); | e.preventDefault(); | ||
}); | }); | ||
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) { | refSection: function (fix) { | ||
var wikitext = this.textbox.value, newText = wikitext, self = this, | |||
refRE = /<ref>|\{\{הערה\|/g, | refRE = /<ref>|\{\{הערה\|/g, | ||
refSectionRE = /\{\{רעפערענצן|\{\{הערות[ _]שוליים|<references[ >]/g, | refSectionRE = /\{\{רעפערענצן|\{\{הערות[ _]שוליים|<references[ >]/g, | ||
| שורה 1,304: | שורה 1,346: | ||
for (var i = 0; (i < lastItems.length) && (wikitext == newText); i++) newText = wikitext.replace(lastItems[i], autoRefSection + '$1'); | for (var i = 0; (i < lastItems.length) && (wikitext == newText); i++) newText = wikitext.replace(lastItems[i], autoRefSection + '$1'); | ||
if (wikitext === newText) newText = wikitext + autoRefSection; | if (wikitext === newText) newText = wikitext + autoRefSection; | ||
this.updateText(newText, true); | |||
this.addSummary('רעפערענצן אפטיילונג'); | this.addSummary('רעפערענצן אפטיילונג'); | ||
this.writeMsg($('<div>' + mw.msg('checkty-missing-ref-section-added') + '</div>'), 'info'); | this.writeMsg($('<div>' + mw.msg('checkty-missing-ref-section-added') + '</div>'), 'info'); | ||
| שורה 1,313: | שורה 1,355: | ||
}, | }, | ||
rawLinks: function () { | rawLinks: function () { | ||
var wikitext = this.textbox.value. | var wikitext = this.textbox.value.replace(/\[\[רוי:/g, '[['); | ||
if (wikitext != this.textbox.value) { | if (wikitext != this.textbox.value) { | ||
this.updateText(wikitext); | |||
chectTyTool.addSummary('אראפגענומען דירעקטע רוי לינקס'); | chectTyTool.addSummary('אראפגענומען דירעקטע רוי לינקס'); | ||
} | |||
}, | |||
rabbiLinks: function () { | |||
// Check if the second part equals the concatenation of the first and third parts | |||
// רבי [[רבי שלמה|שלמה]] = [[רבי שלמה]] | |||
// Define the regular expression pattern with the global flag | |||
var pattern = /(\S+)\s*\[\[([^\]]+\|[^\]]+)\]\]/g; | |||
// Define a function to be used as a replacement | |||
function replaceMatch(match, precedingWord, enclosedString) { | |||
var parts = enclosedString.split('|'); | |||
var validPrefixes = ['רבי', 'הרב', 'הר"ר', 'ר\'']; | |||
// Check if the parts are equivalent | |||
if (parts[0] === 'רבי ' + parts[1] || parts[0] === 'הרב ' + parts[1]) { | |||
if (validPrefixes.includes(precedingWord)) { | |||
// Delete redundant title before link | |||
return '[[' + parts[0] + ']]'; | |||
} else { | |||
// Word before is something else | |||
return precedingWord + ' [[' + parts[0] + ']]'; | |||
} | |||
} else { | |||
// If not, return the original match | |||
return match; | |||
} | |||
} | |||
var wikitext = this.textbox.value.replace(pattern, replaceMatch); | |||
if (wikitext != this.textbox.value) { | |||
this.updateText(wikitext); | |||
chectTyTool.addSummary('פארראכטן רבי לינקס'); | |||
} | } | ||
}, | }, | ||
| שורה 1,330: | שורה 1,402: | ||
} | } | ||
// using [^{}\n] as a quick hack to counting links within templates | // using [^{}\n] as a quick hack to counting links within templates | ||
var wikitext = this.textbox.value, | |||
overlinkingRgx = /\[\[([^\[\]\|]+?)(?:\]\]|\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\[\[\1(?:\]\]|\|.+?\]\])/g, | overlinkingRgx = /\[\[([^\[\]\|]+?)(?:\]\]|\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\[\[\1(?:\]\]|\|.+?\]\])/g, | ||
m; | m; | ||
| שורה 1,340: | שורה 1,412: | ||
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'); | ||
var wikitext = chectTyTool.textbox.value, m; | |||
while (m = specificOverlinkingRgx.exec(wikitext)) { | while (m = specificOverlinkingRgx.exec(wikitext)) { | ||
wikitext = wikitext.replace(m[0], removeOverlink(m[0], m[1])); | wikitext = wikitext.replace(m[0], removeOverlink(m[0], m[1])); | ||
} | } | ||
chectTyTool.updateText(wikitext); | |||
chectTyTool.addSummary('אראפגענומען איבריגע לינקס'); | chectTyTool.addSummary('אראפגענומען איבריגע לינקס'); | ||
e.preventDefault(); | e.preventDefault(); | ||
| שורה 1,358: | שורה 1,430: | ||
extractWikidataLabelsSuggestions: function () { | extractWikidataLabelsSuggestions: function () { | ||
var suggestLabelsREen = /(?:\[\[|\|)([א-ת' \-]+?)\]\](?: \('*([a-z][^א-ת]+?)'*\)| *\{\{אנג?\|(.+?)\}\})/gi, | var suggestLabelsREen = /(?:\[\[|\|)([א-ת' \-]+?)\]\](?: \('*([a-z][^א-ת]+?)'*\)| *\{\{אנג?\|(.+?)\}\})/gi, | ||
suggestLabelsREfr = /(?:\[\[|\|)([א-ת' \-]+?)\]\](?: *\{\{צרפ?\|(.+?)\}\})/gi, | |||
langLink = /\{\{קישור שפה\|(?:([א-ת]*)\|)?(?: *2=)? *([^|]+?)\|(?: *3=)? *([א-ת '\-]+?)\}\}/gi, | langLink = /\{\{קישור שפה\|(?:([א-ת]*)\|)?(?: *2=)? *([^|]+?)\|(?: *3=)? *([א-ת '\-]+?)\}\}/gi, | ||
langTable = { 'שפאניש': 'es', 'ענגליש': 'en', 'פראנצויזיש': 'fr', 'דייטש': 'de' }, | |||
self = this, | self = this, | ||
text = this.textbox.value, | |||
suggestionsByLang = {}, // lang -> { foreign title -> hebrew label } | suggestionsByLang = {}, // lang -> { foreign title -> hebrew label } | ||
foreignTitles = [], | foreignTitles = [], | ||
m, lang, suggestions; | m, lang, suggestions; | ||
suggestionsByLang = { 'en' : {}, 'fr': {} }; | |||
// populate suggestions | // populate suggestions | ||
while (m = suggestLabelsREen.exec(text)) suggestionsByLang['en'][m[2] || m[3]] = (m[1] || ' | while (m = suggestLabelsREen.exec(text)) suggestionsByLang['en'][m[2] || m[3]] = (m[1] || 'ענגליש'); | ||
while (m = suggestLabelsREfr.exec(text)) suggestionsByLang['fr'][m[2] || m[3]] = (m[1]||'צרפתית'); | |||
while (m = langLink.exec(text)) { | while (m = langLink.exec(text)) { | ||
if (!m[1]) m[1] = ' | if (!m[1]) m[1] = 'ענגליש' | ||
if (!langTable.hasOwnProperty(m[1])) { | if (!langTable.hasOwnProperty(m[1])) { | ||
console.log('wikidataLabelsSuggested: Missing lang: ' + m[1]); | console.log('wikidataLabelsSuggested: Missing lang: ' + m[1]); | ||
| שורה 1,497: | שורה 1,571: | ||
// replace minus => dash foreach x-y s.t x<y and swap y and x otherwise. prefix/suffix requirement in regex to make sure it is within sentence | // replace minus => dash foreach x-y s.t x<y and swap y and x otherwise. prefix/suffix requirement in regex to make sure it is within sentence | ||
var numberRangeReNoMinus = /([^|\n]*[א-ת]+'?[-\ ]*)((?:\[\[|\()?[0-9]+(?:\]\])?)-((?:\[\[)?[0-9]+)((?:\]\]|\))?[.:,]?(?:[ \|]|\n)(?!לפנה"ס))/g, | var numberRangeReNoMinus = /([^|\n]*[א-ת]+'?[-\ ]*)((?:\[\[|\()?[0-9]+(?:\]\])?)-((?:\[\[)?[0-9]+)((?:\]\]|\))?[.:,]?(?:[ \|]|\n)(?!לפנה"ס))/g, | ||
wikitext = this.textbox.value, replacements = [], m, i; | |||
while (m = numberRangeReNoMinus.exec(wikitext)) { | while (m = numberRangeReNoMinus.exec(wikitext)) { | ||
if (/^קובץ:|בואינג [0-9]/.exec(m[1])) continue; // skip wrong suggestion | if (/^קובץ:|בואינג [0-9]|^טעקע:|^file:/.exec(m[1])) continue; // skip wrong suggestion | ||
// note - in replacement we dont include the prefix/suffix to make consistent replacement | // note - in replacement we dont include the prefix/suffix to make consistent replacement | ||
if (parseInt(m[2].replace(/[^0-9]/g, '')) < parseInt(m[3].replace(/[^0-9]/g, ''))) { | if (parseInt(m[2].replace(/[^0-9]/g, '')) < parseInt(m[3].replace(/[^0-9]/g, ''))) { | ||
| שורה 1,514: | שורה 1,588: | ||
wikitext = wikitext.replace(new RegExp(mw.util.escapeRegExp(replacements[i][0]), 'g'), replacements[i][1]); | wikitext = wikitext.replace(new RegExp(mw.util.escapeRegExp(replacements[i][0]), 'g'), replacements[i][1]); | ||
} | } | ||
this.updateText(wikitext); | |||
this.addSummary('קו מפריד בטווח מספרים'); | this.addSummary('קו מפריד בטווח מספרים'); | ||
} else { | } else { | ||
| שורה 1,522: | שורה 1,596: | ||
//original version from http://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) { | |||
var content = this.textbox.value, txtArea = $(this.textbox); | |||
// cast to string if this is regex | // cast to string if this is regex | ||
if (RegExp.prototype.isPrototypeOf(toFind)) { | if (RegExp.prototype.isPrototypeOf(toFind)) { | ||
toFind = toFind.exec(content); | |||
if (!toFind) return; | if (!toFind) return; | ||
toFind = toFind[0]; | toFind = toFind[0]; | ||
} | } | ||
var nextPlace = content.indexOf(toFind, txtArea.textSelection('getCaretPosition') + 1); | |||
if (nextPlace === -1) nextPlace = content.indexOf(toFind); //start from begining | |||
if (nextPlace === -1) return; //not found... nothing to do | if (nextPlace === -1) return; //not found... nothing to do | ||
var origText = content; | |||
txtArea.val(origText.substring(0, nextPlace)); | txtArea.val(origText.substring(0, nextPlace)); | ||
txtArea.focus(); | txtArea.focus(); | ||
| שורה 1,547: | שורה 1,621: | ||
end: nextPlace + toFind.length | end: nextPlace + toFind.length | ||
}); | }); | ||
txtArea.textSelection('scrollToCaretPosition'); | |||
}, | }, | ||
addAuthorityControl: function (v) { | addAuthorityControl: function (v) { | ||
var t = this.textbox.value, | |||
acTemplate = /\{\{בקרת זהויות[\}|]/g, | acTemplate = /\{\{בקרת זהויות[\}|]/g, | ||
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 | ||
| שורה 1,627: | שורה 1,702: | ||
}, | }, | ||
addAuthorityControlTemplate: function () { | addAuthorityControlTemplate: function () { | ||
var t = this.textbox.value, | |||
viafTemplate = /\{\{בקרת זהויות[\}|]/g, | viafTemplate = /\{\{בקרת זהויות[\}|]/g, | ||
acTemplate = '{{' + 'בקרת זהויות}}', | acTemplate = '{{' + 'בקרת זהויות}}', | ||
| שורה 1,636: | שורה 1,711: | ||
if (newText == t) newText = t.replace(/\[\[קאטעגאריע:/, acTemplate + '\n[[קאטעגאריע:'); // before categories | if (newText == t) newText = t.replace(/\[\[קאטעגאריע:/, acTemplate + '\n[[קאטעגאריע:'); // before categories | ||
if (newText == t) newText = t + '\n' + acTemplate; | if (newText == t) newText = t + '\n' + acTemplate; | ||
this.updateText(newText, true); | |||
this.addSummary('בקרת זהויות'); | this.addSummary('בקרת זהויות'); | ||
} | } | ||
רעדאגירונגען