בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,387
רעדאגירונגען
ק (הגהה) |
(אפדעיט) |
||
| שורה 147: | שורה 147: | ||
{ | { | ||
// notes: at least 2 numbers - avoid chess notation replacement, English links - full link to avoid | | // notes: at least 2 numbers - avoid chess notation replacement, English links - full link to avoid | | ||
from: /( [בלמהוכש])(?:- |)(\[\[[A-Za-z0-9 ]*\]\]|[A-Za-z]|[0-9]{2,}|\[\[[^\[\]]*?\|[A-Za-z0-9])/g, | |||
to: '$1־$2', | to: '$1־$2', | ||
comment: 'מיקוף למספרים ולעז' | comment: 'מיקוף למספרים ולעז' | ||
| שורה 169: | שורה 169: | ||
var self = this, runExcute = true, | var self = this, runExcute = true, | ||
inUseTemplatesRgx = /\{\{אינמיטן ארבעט[ \}\|]/; | inUseTemplatesRgx = /\{\{אינמיטן ארבעט[ \}\|]/; | ||
if (!this.textbox || this.getContents().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.getContents() ) )) { | |||
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(); }); | ||
| שורה 178: | שורה 178: | ||
// 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.getContents()) ) { | |||
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(); }); | ||
| שורה 193: | שורה 193: | ||
this.verifyRun(); | this.verifyRun(); | ||
}, | |||
updateText: function( val, manual ) { | |||
// for non manual changes - update origText | |||
if (!manual && (this.getContents() === 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.getContents().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.getContents() === chectTyTool.origText ) && ( mw.config.get('wgAction') === 'edit') ) | |||
this.onSaveProtection(); | this.onSaveProtection(); | ||
| שורה 229: | שורה 239: | ||
}, | }, | ||
leadSectionFormat: function(execute) { | leadSectionFormat: function(execute) { | ||
var txt = this. | var txt = this.getContents(); | ||
// TODO: is the heuristic good enough or need more explicit for leading section? other langs? | // 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\'\'\')'); | txt = txt.replace(/^(\'{3}.+?\'{3} \(\[*(?:ענגליש|דייטש|פראנצויזיש|אראביש)\]*: )([a-zA-Z ]+)\)/m, '$1\'\'\'$2\'\'\')'); | ||
if (txt === this. | if (txt === this.getContents()) return; // nothing to do. | ||
if (!execute) { | if (!execute) { | ||
| שורה 247: | שורה 257: | ||
}, | }, | ||
decodeExternalLinks: function () { | decodeExternalLinks: function () { | ||
var t = this.getContents(), newTxt = t, | |||
externalLinkRgx = /http[^ \]|]+/g, | externalLinkRgx = /http[^ \]|]+/g, | ||
decodeRgx = /(?:%[0-9a-z]{2}){2,}/ig, | decodeRgx = /(?:%[0-9a-z]{2}){2,}/ig, | ||
| שורה 279: | שורה 289: | ||
}, | }, | ||
defaultSortSuggest: function (execute) { | defaultSortSuggest: function (execute) { | ||
var txt = this.getContents(), | |||
isPerson = false, | isPerson = false, | ||
firstFamilyRgx = /^([^ ]+) ([^ ]+)$/, | firstFamilyRgx = /^([^ ]+) ([^ ]+)$/, | ||
| שורה 299: | שורה 309: | ||
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.getContents(), | |||
newTxt = txt, | newTxt = txt, | ||
self = this, | self = this, | ||
| שורה 339: | שורה 349: | ||
}, | }, | ||
duplicatedCategory: function (execute) { | duplicatedCategory: function (execute) { | ||
var txt = this.getContents(), | |||
newTxt = txt, | newTxt = txt, | ||
categoryRE = /(\[\[(קאַטעגאָריע|קאטעגאריע):.+\]\])(?:$|\n)/g, | categoryRE = /(\[\[(קאַטעגאָריע|קאטעגאריע):.+\]\])(?:$|\n)/g, | ||
| שורה 377: | שורה 387: | ||
}, | }, | ||
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; | ||
| שורה 385: | שורה 394: | ||
onSaveProtection: function () { | onSaveProtection: function () { | ||
$('#wpSave').click(function (e) { | $('#wpSave').click(function (e) { | ||
if (chectTyTool.getContents() === 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) { | ||
| שורה 397: | שורה 406: | ||
} | } | ||
}); | }); | ||
}, | }, | ||
nakedLinks: function () { | nakedLinks: function () { | ||
var t = this.getContents(), | |||
nakeRegex = /\[(http[^ ]+?)\]|\{\{הערה *\| *(?:1 *= *)?(https?:\/\/[^ }|]+)\}\}|<ref(?: [^/>]*)?>(https?:\/\/[^ }|]+?)<\/ref>/g, | nakeRegex = /\[(http[^ ]+?)\]|\{\{הערה *\| *(?:1 *= *)?(https?:\/\/[^ }|]+)\}\}|<ref(?: [^/>]*)?>(https?:\/\/[^ }|]+?)<\/ref>/g, | ||
nakeErrors = [], m, self = this; | nakeErrors = [], m, self = this; | ||
| שורה 460: | שורה 463: | ||
} | } | ||
var template = '{{' + CiteTemplates[d[0].itemType] + '|' + params.join('|') + '}}', | var template = '{{' + CiteTemplates[d[0].itemType] + '|' + params.join('|') + '}}', | ||
wikitext = self.getContents(); | |||
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 + '}}'); | ||
| שורה 469: | שורה 472: | ||
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('הלבשת קישורים עירומים'); | ||
| שורה 484: | שורה 487: | ||
}, | }, | ||
checkExternalLinks: function () { | checkExternalLinks: function () { | ||
var t = this.getContents(), | |||
externalLinksRgx = /== *קישורים חיצוניים *==(?:\n\{\{.+)*((?:\n\*.+|\n\{\{.+\}\})+)/mg, | externalLinksRgx = /== *קישורים חיצוניים *==(?:\n\{\{.+)*((?:\n\*.+|\n\{\{.+\}\})+)/mg, | ||
tplCounterRgx = /\n\* *\{\{([^|]+)/g, | tplCounterRgx = /\n\* *\{\{([^|]+)/g, | ||
| שורה 507: | שורה 510: | ||
this.refsConsistencyCheck(); | this.refsConsistencyCheck(); | ||
this.ibidWarning(); | this.ibidWarning(); | ||
this.wikipediaRefsWarning(); | |||
this.mergeRefs(); | this.mergeRefs(); | ||
this.refDirSuggest(); | this.refDirSuggest(); | ||
| שורה 531: | שורה 535: | ||
}, | }, | ||
build_regexes: function (data, protect) { | build_regexes: function (data, protect) { | ||
if (/\{\{\s*ללא[_ ]בוט\s*\}\}/.test(this.getContents())) { | |||
this.writeMsg('<div>' + mw.msg('checkty-no-replacements') + '</div>', 'info'); | this.writeMsg('<div>' + mw.msg('checkty-no-replacements') + '</div>', 'info'); | ||
return; | return; | ||
| שורה 580: | שורה 584: | ||
}, | }, | ||
process_page: function () { | process_page: function () { | ||
var t = this.getContents(), | |||
skip_ar = [], | skip_ar = [], | ||
actual_replaced = [], // list of actual replcements for summary | actual_replaced = [], // list of actual replcements for summary | ||
| שורה 634: | שורה 638: | ||
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); | ||
| שורה 679: | שורה 683: | ||
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.getContents()) || (redirects[p.title] && chectTyTool.getLinkRegex(redirects[p.title]).exec(chectTyTool.getContents())))) { | |||
disambigs.push(redirects[p.title] || p.title); | disambigs.push(redirects[p.title] || p.title); | ||
} | } | ||
| שורה 695: | שורה 699: | ||
}, | }, | ||
mainArticlesMerge: function () { | mainArticlesMerge: function () { | ||
var origTxt = this.getContents(), txt = origTxt, m; | |||
while (m = /(\{\{(?:הפניה לערך מורחב|ערך מורחב)\|[^=\n]+?\}\}\n){2,}/g.exec(txt)) { | while (m = /(\{\{(?:הפניה לערך מורחב|ערך מורחב)\|[^=\n]+?\}\}\n){2,}/g.exec(txt)) { | ||
| שורה 702: | שורה 706: | ||
txt = txt.replace(m[0], '{{הפניה לערך מורחב|ערכים=[[' + articles.join(']], [[') + ']]}}\n'); | 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.getContents(), newTxt; | |||
// Format autofix | // Format autofix | ||
var specials = [], match; | var specials = [], match; | ||
| שורה 739: | שורה 743: | ||
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 () { | nikudCheck: function () { | ||
var wikitext = chectTyTool. | var wikitext = chectTyTool.getContents(); | ||
if (/[\u0591-\u05BD\u05BF-\u05C7\u05F3\u05F4]/.test(wikitext)) { | if (/[\u0591-\u05BD\u05BF-\u05C7\u05F3\u05F4]/.test(wikitext)) { | ||
nikudInsertMsg = $('<div>', { text: "דער ארטיקל פארמאגט ניקוד " }).append($('<a>', { | nikudInsertMsg = $('<div>', { text: "דער ארטיקל פארמאגט ניקוד " }).append($('<a>', { | ||
| שורה 757: | שורה 755: | ||
}).click(function () { | }).click(function () { | ||
// remove nikud | // remove nikud | ||
chectTyTool. | chectTyTool.getContents() = chectTyTool.getContents().replace(/[\u0591-\u05BD\u05BF-\u05C7\u05F3\u05F4]/g, ''); | ||
chectTyTool.addSummary('אראפגענומען ניקוד'); | chectTyTool.addSummary('אראפגענומען ניקוד'); | ||
return false; | return false; | ||
| שורה 765: | שורה 763: | ||
}, | }, | ||
vavCheck: function () { | vavCheck: function () { | ||
var text = this.getContents(), | |||
vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this; | vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this; | ||
if (!vavRegex.exec(text)) return; | if (!vavRegex.exec(text)) return; | ||
| שורה 846: | שורה 844: | ||
findSentence(); | findSentence(); | ||
function findSentence() { | function findSentence() { | ||
var text = chectTyTool.getContents().substr(offset), | |||
m = text.match(linkRgx); | m = text.match(linkRgx); | ||
if (!m) { | if (!m) { | ||
| שורה 859: | שורה 857: | ||
function resolve() { | function resolve() { | ||
var answer = $(this).text(), | var answer = $(this).text(), | ||
text = chectTyTool.getContents(), | |||
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')); | ||
| שורה 870: | שורה 868: | ||
} | } | ||
function removeLink() { | function removeLink() { | ||
var text = chectTyTool.getContents(), | |||
startLink = text.indexOf('[[' + name, offset), | startLink = text.indexOf('[[' + name, offset), | ||
endLink = text.indexOf(']]', startLink), | endLink = text.indexOf(']]', startLink), | ||
| שורה 877: | שורה 875: | ||
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; | ||
| שורה 891: | שורה 889: | ||
}, | }, | ||
checkGallery: function () { | checkGallery: function () { | ||
var text = this.getContents(), | |||
longGalleryThreshold = 16, | longGalleryThreshold = 16, | ||
galleryRgx = /<gallery.+?\n(\n|.)+?<\/gallery>/mg, | galleryRgx = /<gallery.+?\n(\n|.)+?<\/gallery>/mg, | ||
| שורה 903: | שורה 901: | ||
var fairUsageTemplates = ['מוסטער:שימוש הוגן', 'מוסטער:תמונת חבר כנסת']; | var fairUsageTemplates = ['מוסטער:שימוש הוגן', 'מוסטער:תמונת חבר כנסת']; | ||
if (!data) { | if (!data) { | ||
if (!(/\{\{(ויקישיתוף בשורה|מיזמים)/.test(this.getContents()))) { | |||
$.getJSON('//www.wikidata.org/w/api.php?callback=?', { | $.getJSON('//www.wikidata.org/w/api.php?callback=?', { | ||
languages: 'yi', | languages: 'yi', | ||
| שורה 936: | שורה 934: | ||
} | } | ||
//in case there are no images in page | //in case there are no images in page | ||
if (!(/\[\[(תמונה|קובץ|File|Image):/i.test(this.getContents())) && !(/\| ?תמונה *= *.+jpg/i.test(this.getContents())) ) { | |||
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. | ||
| שורה 942: | שורה 940: | ||
action: 'parse', | action: 'parse', | ||
title: articleName, | title: articleName, | ||
text: this.getContents() | |||
}).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 () { | ||
| שורה 1,034: | שורה 1,032: | ||
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,052: | שורה 1,050: | ||
}, | }, | ||
languageCheck: function (checks) { //style and language check | languageCheck: function (checks) { //style and language check | ||
var txt = this.getContents(); | |||
if (txt.length === 0) return; // nothing to do | if (txt.length === 0) return; // nothing to do | ||
if (checks) { | if (checks) { | ||
| שורה 1,131: | שורה 1,129: | ||
refsConsistencyCheck: function () { | refsConsistencyCheck: function () { | ||
function safeRegexFix(fixRegex, fixReplace, check) { | function safeRegexFix(fixRegex, fixReplace, check) { | ||
var txt = chectTyTool.getContents(), | |||
m; | m; | ||
//remove templates within templates | //remove templates within templates | ||
| שורה 1,148: | שורה 1,146: | ||
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,174: | שורה 1,172: | ||
ibidWarning: function () { | ibidWarning: function () { | ||
var refRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | var refRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | ||
wikitext = this.getContents(), self=this, m; | |||
var checkWarnings = $('<div></div>'); | var checkWarnings = $('<div></div>'); | ||
while (m = refRE.exec(wikitext)) { | while (m = refRE.exec(wikitext)) { | ||
| שורה 1,192: | שורה 1,190: | ||
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.getContents(), 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,227: | שורה 1,225: | ||
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,234: | שורה 1,232: | ||
refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | ||
refTagRE = /<ref>(.+?)<\/ref>/g, | refTagRE = /<ref>(.+?)<\/ref>/g, | ||
wikitext = this.getContents(), m; | |||
while (m = refTemplateRE.exec(wikitext)) { | while (m = refTemplateRE.exec(wikitext)) { | ||
references[m[1]] = references[m[1]] || []; | references[m[1]] = references[m[1]] || []; | ||
| שורה 1,260: | שורה 1,258: | ||
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 = chectTyTool. | var wikitext = chectTyTool.getContents(); | ||
var regex = /{{דעסקריפציע\|[^|}]/; | var regex = /{{דעסקריפציע\|[^|}]/; | ||
// check whether description is empty | // check whether description is empty | ||
| שורה 1,275: | שורה 1,273: | ||
var desc = prompt('שטעלט אריין א שילדערונג מיט געציילטע ווערטער'); | var desc = prompt('שטעלט אריין א שילדערונג מיט געציילטע ווערטער'); | ||
if (desc) { | if (desc) { | ||
chectTyTool. | chectTyTool.getContents() = '{' + '{דעסקריפציע|' + desc + '}}\n' + chectTyTool.getContents(); | ||
chectTyTool.addSummary('צוגעלייגט דעסקריפציע'); | chectTyTool.addSummary('צוגעלייגט דעסקריפציע'); | ||
} | } | ||
| שורה 1,284: | שורה 1,282: | ||
}, | }, | ||
interwikiInsert: function () { | interwikiInsert: function () { | ||
var wikitext = chectTyTool. | var wikitext = chectTyTool.getContents(); | ||
// check whether hebrew is not linked | // check whether hebrew is not linked | ||
if (!wikitext.toLowerCase().includes('[' + '[he:')) { | if (!wikitext.toLowerCase().includes('[' + '[he:')) { | ||
| שורה 1,294: | שורה 1,292: | ||
var inter = prompt('שטעלט אריין דעם נאמען פון ערך אויף המכלול העברי'); | var inter = prompt('שטעלט אריין דעם נאמען פון ערך אויף המכלול העברי'); | ||
if (inter) { | if (inter) { | ||
chectTyTool. | chectTyTool.getContents() += '\n[' + '[he:' + inter + ']]'; | ||
chectTyTool.addSummary('צוגעלייגט אינטערשפראך לינק'); | chectTyTool.addSummary('צוגעלייגט אינטערשפראך לינק'); | ||
} | } | ||
| שורה 1,315: | שורה 1,313: | ||
}, | }, | ||
refDirSuggest: function () { // suggest adding direction for refs | refDirSuggest: function () { // suggest adding direction for refs | ||
var wikitext = this.getContents(), | |||
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,326: | שורה 1,324: | ||
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.getContents(); | |||
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(); | ||
| שורה 1,338: | שורה 1,336: | ||
}, | }, | ||
refSection: function (fix) { | refSection: function (fix) { | ||
var wikitext = this.getContents(), newText = wikitext, self = this, | |||
refRE = /<ref>|\{\{הערה\|/g, | refRE = /<ref>|\{\{הערה\|/g, | ||
refSectionRE = /\{\{רעפערענצן|\{\{הערות[ _]שוליים|<references[ >]/g, | refSectionRE = /\{\{רעפערענצן|\{\{הערות[ _]שוליים|<references[ >]/g, | ||
| שורה 1,350: | שורה 1,348: | ||
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,359: | שורה 1,357: | ||
}, | }, | ||
rawLinks: function () { | rawLinks: function () { | ||
var wikitext = this. | var wikitext = this.getContents().replace(/\[\[רוי:/g, '[['); | ||
if (wikitext != this. | if (wikitext != this.getContents()) { | ||
this.updateText(wikitext); | |||
chectTyTool.addSummary('אראפגענומען דירעקטע רוי לינקס'); | chectTyTool.addSummary('אראפגענומען דירעקטע רוי לינקס'); | ||
} | } | ||
| שורה 1,389: | שורה 1,387: | ||
} | } | ||
} | } | ||
var wikitext = this. | var wikitext = this.getContents().replace(pattern, replaceMatch); | ||
if (wikitext != this. | if (wikitext != this.getContents()) { | ||
this.updateText(wikitext); | |||
chectTyTool.addSummary('פארראכטן רבי לינקס'); | chectTyTool.addSummary('פארראכטן רבי לינקס'); | ||
} | } | ||
| שורה 1,406: | שורה 1,404: | ||
} | } | ||
// 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.getContents(), | |||
overlinkingRgx = /\[\[([^\[\]\|]+?)(?:\]\]|\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\[\[\1(?:\]\]|\|.+?\]\])/g, | overlinkingRgx = /\[\[([^\[\]\|]+?)(?:\]\]|\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\[\[\1(?:\]\]|\|.+?\]\])/g, | ||
m; | m; | ||
| שורה 1,416: | שורה 1,414: | ||
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.getContents(), 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,434: | שורה 1,432: | ||
extractWikidataLabelsSuggestions: function () { | extractWikidataLabelsSuggestions: function () { | ||
var suggestLabelsREen = /(?:\[\[|\|)([א-ת' \-]+?)\]\](?: \('*([a-z][^א-ת]+?)'*\)| *\{\{אנג?\|(.+?)\}\})/gi, | var suggestLabelsREen = /(?:\[\[|\|)([א-ת' \-]+?)\]\](?: \('*([a-z][^א-ת]+?)'*\)| *\{\{אנג?\|(.+?)\}\})/gi, | ||
suggestLabelsREfr = /(?:\[\[|\|)([א-ת' \-]+?)\]\]( *\{\{צרפ?\|(.+?)\}\})/gi, | suggestLabelsREfr = /(?:\[\[|\|)([א-ת' \-]+?)\]\](?: *\{\{צרפ?\|(.+?)\}\})/gi, | ||
langLink = /\{\{קישור שפה\|(?:([א-ת]*)\|)?(?: *2=)? *([^|]+?)\|(?: *3=)? *([א-ת '\-]+?)\}\}/gi, | langLink = /\{\{קישור שפה\|(?:([א-ת]*)\|)?(?: *2=)? *([^|]+?)\|(?: *3=)? *([א-ת '\-]+?)\}\}/gi, | ||
langTable = { 'שפאניש': 'es', 'ענגליש': 'en', 'פראנצויזיש': 'fr', 'דייטש': 'de' }, | langTable = { 'שפאניש': 'es', 'ענגליש': 'en', 'פראנצויזיש': 'fr', 'דייטש': 'de' }, | ||
self = this, | self = this, | ||
text = this.getContents(), | |||
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] || 'ענגליש'); | ||
| שורה 1,575: | שורה 1,573: | ||
// 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.getContents(), replacements = [], m, i; | |||
while (m = numberRangeReNoMinus.exec(wikitext)) { | while (m = numberRangeReNoMinus.exec(wikitext)) { | ||
if (/^קובץ:|בואינג [0-9]|^טעקע:|^file:/.exec(m[1])) continue; // skip wrong suggestion | if (/^קובץ:|בואינג [0-9]|^טעקע:|^file:/.exec(m[1])) continue; // skip wrong suggestion | ||
| שורה 1,592: | שורה 1,590: | ||
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,600: | שורה 1,598: | ||
//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.getContents(), 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,625: | שורה 1,623: | ||
end: nextPlace + toFind.length | end: nextPlace + toFind.length | ||
}); | }); | ||
txtArea.textSelection('scrollToCaretPosition'); | |||
}, | }, | ||
addAuthorityControl: function (v) { | addAuthorityControl: function (v) { | ||
var t = this.getContents(), | |||
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,705: | שורה 1,704: | ||
}, | }, | ||
addAuthorityControlTemplate: function () { | addAuthorityControlTemplate: function () { | ||
var t = this.getContents(), | |||
viafTemplate = /\{\{בקרת זהויות[\}|]/g, | viafTemplate = /\{\{בקרת זהויות[\}|]/g, | ||
acTemplate = '{{' + 'בקרת זהויות}}', | acTemplate = '{{' + 'בקרת זהויות}}', | ||
| שורה 1,714: | שורה 1,713: | ||
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('בקרת זהויות'); | ||
} | } | ||
רעדאגירונגען