בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,716
רעדאגירונגען
אין תקציר עריכה |
(צוריקגעטוישט getContents() צו textbox.value) |
||
| שורה 168: | שורה 168: | ||
var self = this, runExcute = true, | var self = this, runExcute = true, | ||
inUseTemplatesRgx = /\{\{אינמיטן ארבעט[ \}\|]/; | inUseTemplatesRgx = /\{\{אינמיטן ארבעט[ \}\|]/; | ||
if (!this.textbox || this. | 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. | 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(); }); | ||
| שורה 177: | שורה 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. | 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(); }); | ||
| שורה 195: | שורה 195: | ||
updateText: function( val, manual ) { | updateText: function( val, manual ) { | ||
// for non manual changes - update origText | // for non manual changes - update origText | ||
if (!manual && (this. | if (!manual && (this.textbox.value === chectTyTool.origText)) { | ||
chectTyTool.origText = val; | chectTyTool.origText = val; | ||
} | } | ||
| שורה 205: | שורה 205: | ||
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. | 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. | if ( ( chectTyTool.textbox.value === chectTyTool.origText ) && ( mw.config.get('wgAction') === 'edit') ) | ||
this.onSaveProtection(); | this.onSaveProtection(); | ||
| שורה 238: | שורה 238: | ||
}, | }, | ||
leadSectionFormat: function(execute) { | leadSectionFormat: function(execute) { | ||
var txt = this. | var txt = this.textbox.value; | ||
// 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.textbox.value) return; // nothing to do. | ||
if (!execute) { | if (!execute) { | ||
| שורה 256: | שורה 256: | ||
}, | }, | ||
decodeExternalLinks: function () { | decodeExternalLinks: function () { | ||
var t = this. | 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, | ||
| שורה 288: | שורה 288: | ||
}, | }, | ||
defaultSortSuggest: function (execute) { | defaultSortSuggest: function (execute) { | ||
var txt = this. | var txt = this.textbox.value, | ||
isPerson = false, | isPerson = false, | ||
firstFamilyRgx = /^([^ ]+) ([^ ]+)$/, | firstFamilyRgx = /^([^ ]+) ([^ ]+)$/, | ||
| שורה 312: | שורה 312: | ||
}, | }, | ||
categoryOrder: function (execute) { | categoryOrder: function (execute) { | ||
var txt = this. | var txt = this.textbox.value, | ||
newTxt = txt, | newTxt = txt, | ||
self = this, | self = this, | ||
| שורה 348: | שורה 348: | ||
}, | }, | ||
duplicatedCategory: function (execute) { | duplicatedCategory: function (execute) { | ||
var txt = this. | var txt = this.textbox.value, | ||
newTxt = txt, | newTxt = txt, | ||
categoryRE = /(\[\[(קאַטעגאָריע|קאטעגאריע):.+\]\])(?:$|\n)/g, | categoryRE = /(\[\[(קאַטעגאָריע|קאטעגאריע):.+\]\])(?:$|\n)/g, | ||
| שורה 393: | שורה 393: | ||
onSaveProtection: function () { | onSaveProtection: function () { | ||
$('#wpSave').click(function (e) { | $('#wpSave').click(function (e) { | ||
if (chectTyTool. | 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) { | ||
| שורה 407: | שורה 407: | ||
}, | }, | ||
nakedLinks: function () { | nakedLinks: function () { | ||
var t = this. | 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; | ||
| שורה 462: | שורה 462: | ||
} | } | ||
var template = '{{' + CiteTemplates[d[0].itemType] + '|' + params.join('|') + '}}', | var template = '{{' + CiteTemplates[d[0].itemType] + '|' + params.join('|') + '}}', | ||
wikitext = self. | 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 + '}}'); | ||
| שורה 486: | שורה 486: | ||
}, | }, | ||
checkExternalLinks: function () { | checkExternalLinks: function () { | ||
var t = this. | var t = this.textbox.value, | ||
externalLinksRgx = /== *קישורים חיצוניים *==(?:\n\{\{.+)*((?:\n\*.+|\n\{\{.+\}\})+)/mg, | externalLinksRgx = /== *קישורים חיצוניים *==(?:\n\{\{.+)*((?:\n\*.+|\n\{\{.+\}\})+)/mg, | ||
tplCounterRgx = /\n\* *\{\{([^|]+)/g, | tplCounterRgx = /\n\* *\{\{([^|]+)/g, | ||
| שורה 533: | שורה 533: | ||
}, | }, | ||
build_regexes: function (data, protect) { | build_regexes: function (data, protect) { | ||
if (/\{\{\s*ללא[_ ]בוט\s*\}\}/.test(this. | 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; | ||
| שורה 582: | שורה 582: | ||
}, | }, | ||
process_page: function () { | process_page: function () { | ||
var t = this. | 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 | ||
| שורה 681: | שורה 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. | 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); | ||
} | } | ||
| שורה 697: | שורה 697: | ||
}, | }, | ||
mainArticlesMerge: function () { | mainArticlesMerge: function () { | ||
var origTxt = this. | var origTxt = this.textbox.value, txt = origTxt, m; | ||
while (m = /(\{\{(?:הפניה לערך מורחב|הויפט ארטיקל)\|[^=\n]+?\}\}\n){2,}/g.exec(txt)) { | while (m = /(\{\{(?:הפניה לערך מורחב|הויפט ארטיקל)\|[^=\n]+?\}\}\n){2,}/g.exec(txt)) { | ||
| שורה 708: | שורה 708: | ||
}, | }, | ||
formatReplace: function () { | formatReplace: function () { | ||
var txt = this. | var txt = this.textbox.value, newTxt; | ||
// Format autofix | // Format autofix | ||
var specials = [], match; | var specials = [], match; | ||
| שורה 746: | שורה 746: | ||
}, | }, | ||
nikudCheck: function () { | nikudCheck: function () { | ||
var wikitext = chectTyTool. | var wikitext = chectTyTool.textbox.value; | ||
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>', { | ||
| שורה 753: | שורה 753: | ||
}).click(function () { | }).click(function () { | ||
// remove nikud | // remove nikud | ||
chectTyTool. | chectTyTool.textbox.value = chectTyTool.textbox.value.replace(/[\u0591-\u05BD\u05BF-\u05C7\u05F3\u05F4]/g, ''); | ||
chectTyTool.addSummary('אראפגענומען ניקוד'); | chectTyTool.addSummary('אראפגענומען ניקוד'); | ||
return false; | return false; | ||
| שורה 761: | שורה 761: | ||
}, | }, | ||
vavCheck: function () { | vavCheck: function () { | ||
var text = this. | var text = this.textbox.value, | ||
vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this; | vavRegex = /[כלבמשה]\[\[ו[^ו][א-ת ]+\]\]/g, self = this; | ||
if (!vavRegex.exec(text)) return; | if (!vavRegex.exec(text)) return; | ||
| שורה 842: | שורה 842: | ||
findSentence(); | findSentence(); | ||
function findSentence() { | function findSentence() { | ||
var text = chectTyTool. | var text = chectTyTool.textbox.value.substr(offset), | ||
m = text.match(linkRgx); | m = text.match(linkRgx); | ||
if (!m) { | if (!m) { | ||
| שורה 855: | שורה 855: | ||
function resolve() { | function resolve() { | ||
var answer = $(this).text(), | var answer = $(this).text(), | ||
text = chectTyTool. | 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; | ||
| שורה 866: | שורה 866: | ||
} | } | ||
function removeLink() { | function removeLink() { | ||
var text = chectTyTool. | var text = chectTyTool.textbox.value, | ||
startLink = text.indexOf('[[' + name, offset), | startLink = text.indexOf('[[' + name, offset), | ||
endLink = text.indexOf(']]', startLink), | endLink = text.indexOf(']]', startLink), | ||
| שורה 887: | שורה 887: | ||
}, | }, | ||
checkGallery: function () { | checkGallery: function () { | ||
var text = this. | var text = this.textbox.value, | ||
longGalleryThreshold = 16, | longGalleryThreshold = 16, | ||
galleryRgx = /<gallery.+?\n(\n|.)+?<\/gallery>/mg, | galleryRgx = /<gallery.+?\n(\n|.)+?<\/gallery>/mg, | ||
| שורה 899: | שורה 899: | ||
var fairUsageTemplates = ['מוסטער:שימוש הוגן', 'מוסטער:תמונת חבר כנסת']; | var fairUsageTemplates = ['מוסטער:שימוש הוגן', 'מוסטער:תמונת חבר כנסת']; | ||
if (!data) { | if (!data) { | ||
if (!(/\{\{(ויקישיתוף בשורה|מיזמים)/.test(this. | 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', | ||
| שורה 932: | שורה 932: | ||
} | } | ||
//in case there are no images in page | //in case there are no images in page | ||
if (!(/\[\[(תמונה|קובץ|File|Image):/i.test(this. | 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. | ||
| שורה 938: | שורה 938: | ||
action: 'parse', | action: 'parse', | ||
title: articleName, | title: articleName, | ||
text: this. | 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 () { | ||
| שורה 1,048: | שורה 1,048: | ||
}, | }, | ||
languageCheck: function (checks) { //style and language check | languageCheck: function (checks) { //style and language check | ||
var txt = this. | 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,127: | שורה 1,127: | ||
refsConsistencyCheck: function () { | refsConsistencyCheck: function () { | ||
function safeRegexFix(fixRegex, fixReplace, check) { | function safeRegexFix(fixRegex, fixReplace, check) { | ||
var txt = chectTyTool. | var txt = chectTyTool.textbox.value, | ||
m; | m; | ||
//remove templates within templates | //remove templates within templates | ||
| שורה 1,170: | שורה 1,170: | ||
ibidWarning: function () { | ibidWarning: function () { | ||
var refRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | var refRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | ||
wikitext = this. | 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)) { | ||
| שורה 1,188: | שורה 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. | 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,230: | שורה 1,230: | ||
refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | refTemplateRE = /\{\{הערה\|(?! *שם *=)(?:1=)?((?:[^\{\}]|\{\{.*?\}\})+)(?!\|=שם=)\}\}/g, | ||
refTagRE = /<ref>(.+?)<\/ref>/g, | refTagRE = /<ref>(.+?)<\/ref>/g, | ||
wikitext = this. | 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,260: | שורה 1,260: | ||
}, | }, | ||
descriptionInsert: function () { | descriptionInsert: function () { | ||
var wikitext = chectTyTool. | var wikitext = chectTyTool.textbox.value; | ||
var regex = /{{דעסקריפציע\|[^|}]/; | var regex = /{{דעסקריפציע\|[^|}]/; | ||
// check whether description is empty | // check whether description is empty | ||
| שורה 1,280: | שורה 1,280: | ||
}, | }, | ||
interwikiInsert: function () { | interwikiInsert: function () { | ||
var wikitext = chectTyTool. | 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,311: | שורה 1,311: | ||
}, | }, | ||
refDirSuggest: function () { // suggest adding direction for refs | refDirSuggest: function () { // suggest adding direction for refs | ||
var wikitext = this. | 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,322: | שורה 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. | 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.updateText(wikitext, true); | ||
| שורה 1,334: | שורה 1,334: | ||
}, | }, | ||
refSection: function (fix) { | refSection: function (fix) { | ||
var wikitext = this. | var wikitext = this.textbox.value, newText = wikitext, self = this, | ||
refRE = /<ref>|\{\{הערה\|/g, | refRE = /<ref>|\{\{הערה\|/g, | ||
refSectionRE = /\{\{רעפערענצן|\{\{הערות[ _]שוליים|<references[ >]/g, | refSectionRE = /\{\{רעפערענצן|\{\{הערות[ _]שוליים|<references[ >]/g, | ||
| שורה 1,355: | שורה 1,355: | ||
}, | }, | ||
rawLinks: function () { | rawLinks: function () { | ||
var wikitext = this. | var wikitext = this.textbox.value.replace(/\[\[רוי:/g, '[['); | ||
if (wikitext != this. | if (wikitext != this.textbox.value) { | ||
this.updateText(wikitext); | this.updateText(wikitext); | ||
chectTyTool.addSummary('אראפגענומען דירעקטע רוי לינקס'); | chectTyTool.addSummary('אראפגענומען דירעקטע רוי לינקס'); | ||
| שורה 1,385: | שורה 1,385: | ||
} | } | ||
} | } | ||
var wikitext = this. | var wikitext = this.textbox.value.replace(pattern, replaceMatch); | ||
if (wikitext != this. | if (wikitext != this.textbox.value) { | ||
this.updateText(wikitext); | this.updateText(wikitext); | ||
chectTyTool.addSummary('פארראכטן רבי לינקס'); | chectTyTool.addSummary('פארראכטן רבי לינקס'); | ||
| שורה 1,402: | שורה 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. | var wikitext = this.textbox.value, | ||
overlinkingRgx = /\[\[([^\[\]\|]+?)(?:\]\]|\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\[\[\1(?:\]\]|\|.+?\]\])/g, | overlinkingRgx = /\[\[([^\[\]\|]+?)(?:\]\]|\|)[^{}\n]*(?:\{\{[^{]+\}\})?(?:[^{}\n]*)(?:\n\*[^{}\n]*)?\[\[\1(?:\]\]|\|.+?\]\])/g, | ||
m; | m; | ||
| שורה 1,412: | שורה 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. | 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])); | ||
| שורה 1,434: | שורה 1,434: | ||
langTable = { 'שפאניש': 'es', 'ענגליש': 'en', 'פראנצויזיש': 'fr', 'דייטש': 'de' }, | langTable = { 'שפאניש': 'es', 'ענגליש': 'en', 'פראנצויזיש': 'fr', 'דייטש': 'de' }, | ||
self = this, | self = this, | ||
text = this. | text = this.textbox.value, | ||
suggestionsByLang = {}, // lang -> { foreign title -> hebrew label } | suggestionsByLang = {}, // lang -> { foreign title -> hebrew label } | ||
foreignTitles = [], | foreignTitles = [], | ||
| שורה 1,571: | שורה 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. | wikitext = this.textbox.value, 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,597: | שורה 1,597: | ||
//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) { | ||
var content = this. | 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)) { | ||
| שורה 1,624: | שורה 1,624: | ||
}, | }, | ||
addAuthorityControl: function (v) { | addAuthorityControl: function (v) { | ||
var t = this. | var t = this.textbox.value, | ||
acTemplate = /\{\{בקרת זהויות[\}|]/g, | acTemplate = /\{\{בקרת זהויות[\}|]/g, | ||
artsTitle = /== *(?:מ?ספרי[הו]|מ?יצירותי[הו]|מ?חיבורי[הו]|(פרסומים|מאמרים) נבחרים|מ?פרסומי[הו]|פילמוגרפיה.*|(?:מבחר)? (?:כתבי)|דיסקוגרפיה|יצירות) *==/, //cheap hint for art occuption in text | artsTitle = /== *(?:מ?ספרי[הו]|מ?יצירותי[הו]|מ?חיבורי[הו]|(פרסומים|מאמרים) נבחרים|מ?פרסומי[הו]|פילמוגרפיה.*|(?:מבחר)? (?:כתבי)|דיסקוגרפיה|יצירות) *==/, //cheap hint for art occuption in text | ||
| שורה 1,702: | שורה 1,702: | ||
}, | }, | ||
addAuthorityControlTemplate: function () { | addAuthorityControlTemplate: function () { | ||
var t = this. | var t = this.textbox.value, | ||
viafTemplate = /\{\{בקרת זהויות[\}|]/g, | viafTemplate = /\{\{בקרת זהויות[\}|]/g, | ||
acTemplate = '{{' + 'בקרת זהויות}}', | acTemplate = '{{' + 'בקרת זהויות}}', | ||
רעדאגירונגען