אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Gadget-Checkty.js"

אפדעיט
אין תקציר עריכה
(אפדעיט)
שורה 92: שורה 92:
  comment: 'הסרת רווחים מיותרים'
  comment: 'הסרת רווחים מיותרים'
}, { // trim redundant spaces from category links
}, { // trim redundant spaces from category links
  from: /\[\[קטגוריה: */g,
  from: /\[\[קאטעגאריע: */g,
  to: '[[קאטעגאריע:'
  to: '[[קאטעגאריע:'
}],
}],
שורה 318: שורה 318:
  newTxt += '\n' + permutedCats.join('\n');
  newTxt += '\n' + permutedCats.join('\n');
  if (newTxt != txt)
  if (newTxt != txt)
  this.addSummary('הסרת קטגוריה כפולה');
  this.addSummary('הסרת קאטעגאריע כפולה');
  this.updateText(newTxt);
  this.updateText(newTxt);
},
},
שורה 846: שורה 846:
  if (!(/\{\{(ויקישיתוף בשורה|מיזמים)/.test(this.textbox.value))) {
  if (!(/\{\{(ויקישיתוף בשורה|מיזמים)/.test(this.textbox.value))) {
  $.getJSON('//www.wikidata.org/w/api.php?callback=?', {
  $.getJSON('//www.wikidata.org/w/api.php?callback=?', {
  languages: 'he',
  languages: 'yi',
  action: 'wbgetentities',
  action: 'wbgetentities',
  sites: mw.config.get('wgDBname'),
  sites: mw.config.get('wgDBname'),
שורה 1,105: שורה 1,105:
  }).click(function () {
  }).click(function () {
  safeRegexFix(refBefore, '$5$1', false);
  safeRegexFix(refBefore, '$5$1', false);
  chectTyTool.addSummary('אחידות במיקום רעפערענצן');
  chectTyTool.addSummary('איינהייטליכקייט אין רעפערענצן פלאצירונג');
  })).append(' | ').append($('<a>', {
  })).append(' | ').append($('<a>', {
  text: 'לפני',
  text: 'לפני',
שורה 1,111: שורה 1,111:
  }).click(function () {
  }).click(function () {
  safeRegexFix(refAfter, '$2$1', false);
  safeRegexFix(refAfter, '$2$1', false);
  chectTyTool.addSummary('אחידות במיקום רעפערענצן');
  chectTyTool.addSummary('איינהייטליכקייט אין רעפערענצן פלאצירונג');
  })).append(']'), 'alert');
  })).append(']'), 'alert');
  }
  }
שורה 1,141: שורה 1,141:
  }
  }


for (k in references) {
for (k in references) {
if (references[k] > 1) {
if (references[k] > 1) {
var content = new RegExp('<ref name="'+mw.util.escapeRegExp(k)+'">(.+?)</ref>', 'g').exec(wikitext),
var content = new RegExp('<ref name="'+mw.util.escapeRegExp(k)+'">(.+?)</ref>', 'g').exec(wikitext),
shortRef = chectTyTool.named_comment + k + '}}';
shortRef = chectTyTool.named_comment + k + '}}';
i = 0;
i = 0;
if (content)
if (content)
wikitext = wikitext.replace(new RegExp(mw.util.escapeRegExp(content[0]), 'g'), function(m) { return (i++? shortRef : m); });
wikitext = wikitext.replace(new RegExp(mw.util.escapeRegExp(content[0]), 'g'), function(m) { return (i++? shortRef : m); });
mergedRefs.push(k);
mergedRefs.push(k);
}
}
}
}
// merge referecnes with same content but different name
// merge referecnes with same content but different name
for (k in refsContent) {
for (k in refsContent) {
if ($.inArray(k,mergedRefsNames) != -1) continue; // skip name already merged
if ($.inArray(k,mergedRefsNames) != -1) continue; // skip name already merged
for (i in refsContent) {
for (i in refsContent) {
if (k === i) continue; // skip same name
if (k === i) continue; // skip same name
if (refsContent[k].content == refsContent[i].content) { // two refs with same content but different name
if (refsContent[k].content == refsContent[i].content) { // two refs with same content but different name
var oldRefName = new RegExp('<ref name="'+mw.util.escapeRegExp(i)+'" */>', 'g');
var oldRefName = new RegExp('<r' + 'ef name="'+mw.util.escapeRegExp(i)+'" */>', 'g');
mergedRefsNames.push(i);
mergedRefsNames.push(i);
shortRef = chectTyTool.named_comment + k + '}}';
shortRef = chectTyTool.named_comment + k + '}}';
wikitext = wikitext.replace(refsContent[i].text, shortRef);
wikitext = wikitext.replace(refsContent[i].text, shortRef);
wikitext = wikitext.replace(oldRefName, shortRef);
wikitext = wikitext.replace(oldRefName, shortRef);
}
}
}
}
}
}


  if (mergedRefs.length + mergedRefsNames.length) {
  if (mergedRefs.length + mergedRefsNames.length) {
שורה 1,359: שורה 1,359:
  ids: '\x1f' + wikidataIds.join( '\x1f' ),
  ids: '\x1f' + wikidataIds.join( '\x1f' ),
  props: '\x1f' + ['labels', 'sitelinks'].join( '\x1f' ),
  props: '\x1f' + ['labels', 'sitelinks'].join( '\x1f' ),
  languages: '\x1f' + ['he', lang].join( '\x1f' )
  languages: '\x1f' + ['yi', lang].join( '\x1f' )
  }).done(function(d){
  }).done(function(d){
  queries--;
  queries--;
שורה 1,375: שורה 1,375:
  {
  {
  if (/^-/.exec(en)) continue;
  if (/^-/.exec(en)) continue;
  if (data[en].labels && data[en].labels.hasOwnProperty('he')) continue; // already have hebrew label
  if (data[en].labels && data[en].labels.hasOwnProperty('yi')) continue; // already have hebrew label
  found = true;
  found = true;
  var suggestion = suggestions[data[en].sitelinks[langSite].title] || suggestions[redirects[data[en].sitelinks[langSite].title]];
  var suggestion = suggestions[data[en].sitelinks[langSite].title] || suggestions[redirects[data[en].sitelinks[langSite].title]];
שורה 1,384: שורה 1,384:
  target:'_blank'
  target:'_blank'
  }).data({
  }).data({
  'he': suggestion,
  'yi': suggestion,
  'foreignLabel': data[en].sitelinks[langSite].title,
  'foreignLabel': data[en].sitelinks[langSite].title,
  'q': en
  'q': en
  }).click(function(){
  }).click(function(){
  self.wikidataLabelTranslate($(this).data('q'), $(this).data('foreignLabel'), $(this).data('he'));
  self.wikidataLabelTranslate($(this).data('q'), $(this).data('foreignLabel'), $(this).data('yi'));
  return false;
  return false;
  })));
  })));
שורה 1,500: שורה 1,500:
  acTemplate = /\{\{בקרת זהויות[\}|]/g,
  acTemplate = /\{\{בקרת זהויות[\}|]/g,
  artsTitle = /== *(?:מ?ספרי[הו]|מ?יצירותי[הו]|מ?חיבורי[הו]|מאמרים נבחרים|פילמוגרפיה.*|(?:מבחר)? (?:כתבי)|דיסקוגרפיה|יצירות) *==/, //cheap hint for art occuption in text
  artsTitle = /== *(?:מ?ספרי[הו]|מ?יצירותי[הו]|מ?חיבורי[הו]|מאמרים נבחרים|פילמוגרפיה.*|(?:מבחר)? (?:כתבי)|דיסקוגרפיה|יצירות) *==/, //cheap hint for art occuption in text
  artsCategory = /\[\[קטגוריה:(מוזיקאיות|מוזיקאים|זמרות|זמרים|סופרים|סופרות|משוררים|משוררות|מתרגמים|ציירות|ציירים|במאי|רבנים|רבניות)(?!.+\*)/; //cheap hint for art occuption in category
  artsCategory = /\[\[קאטעגאריע:(מוזיקאיות|מוזיקאנטן|זמרות|זינגערס|שרייבערס|סופרות|משוררים|משוררות|מתרגמים|ציירות|ציירים|במאי|רבנים|רבניות)(?!.+\*)/; //cheap hint for art occuption in category
  if ( acTemplate.exec( t ) ) return; // AC already exist
  if ( acTemplate.exec( t ) ) return; // AC already exist
  if ( !artsTitle.exec( t ) && !artsCategory.exec( t ) ) return; // no hint will have authority control
  if ( !artsTitle.exec( t ) && !artsCategory.exec( t ) ) return; // no hint will have authority control
  this.getWikidataApi().get({
  this.getWikidataApi().get({
  action: 'wbgetentities',
  action: 'wbgetentities',
  languages: 'he',
  languages: 'yi',
  sites: mw.config.get('wgDBname'),
  sites: mw.config.get('wgDBname'),
  titles: mw.config.get('wgPageName'),
  titles: mw.config.get('wgPageName'),
שורה 1,580: שורה 1,580:
  newText;
  newText;
  if ( viafTemplate.exec( t ) ) return; // viaf already exist
  if ( viafTemplate.exec( t ) ) return; // viaf already exist
  newText = t.replace(/{{קצרמר/, acTemplate + '\n{{קצרמר'); // before stub
  newText = t.replace(/{{שטומף/, acTemplate + '\n{{שטומף'); // before stub
  if (newText == t) newText = t.replace(/{{מיון רגיל:/, acTemplate + '\n{{מיון רגיל:'); //before default sort
  if (newText == t) newText = t.replace(/{{מיון רגיל:/, acTemplate + '\n{{מיון רגיל:'); //before default sort
  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.textbox.value = newText;
  this.textbox.value = newText;
שורה 1,591: שורה 1,591:
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) + 1) $(document).ready(function () {
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) + 1) $(document).ready(function () {
chectTyTool.origText = $('#wpTextbox1').val();
chectTyTool.origText = $('#wpTextbox1').val();
var checktyBtn = new OO.ui.ButtonInputWidget({ label: 'בדיקה', title: 'טשעקטי - געצייג צו בודק זיין פארשידענע אפטע פראבלעמען', accessKey: (window.checkToolKey || 'e'), id:'btnCheckTool' });
var checktyBtn = new OO.ui.ButtonInputWidget({ label: 'בדיקה', title: 'טשעקטי - געצייג צו בודק זיין אפטע פראבלעמען', accessKey: (window.checkToolKey || 'e'), id:'btnCheckTool' });
checktyBtn.$button.updateTooltipAccessKeys();
checktyBtn.$button.updateTooltipAccessKeys();
$('#wpPreviewWidget').after(checktyBtn.$element.click(chectTyTool.run));
$('#wpPreviewWidget').after(checktyBtn.$element.click(chectTyTool.run));
});
});