מדיה ויקי:Gadget-quickLinker.js: הבדלים בין גרסאות בדף

מ thanks to User:Yamaha5 (fawiki)
מאין תקציר עריכה
שורה 19: שורה 19:
'qlinker-save-continue': 'שמירה',
'qlinker-save-continue': 'שמירה',
'qlinker-skip': 'דילוג לדף הבא',
'qlinker-skip': 'דילוג לדף הבא',
'qlinker-skip-match': 'דילוג למופע הבא',
'qlinker-invoke': 'הוספת בזק של קישורים',
'qlinker-invoke': 'הוספת בזק של קישורים',
'qlinker-sidelink': 'הוספת קישורים',
'qlinker-sidelink': 'הוספת קישורים',
שורה 33: שורה 34:
'qlinker-save-continue': 'Save',
'qlinker-save-continue': 'Save',
'qlinker-skip': 'Skip page',
'qlinker-skip': 'Skip page',
'qlinker-skip-match': 'Skip to next match',
'qlinker-invoke': 'Quickly add links',
'qlinker-invoke': 'Quickly add links',
'qlinker-sidelink': 'Add links',
'qlinker-sidelink': 'Add links',
שורה 44: שורה 46:
function createQuickEditorDialog(searchRes, safeMode){
function createQuickEditorDialog(searchRes, safeMode){
function QuickEditorDialog( config ) {
function QuickEditorDialog( config ) {
  this.contextRgx = new RegExp('(.*[^\\[])(' + mw.RegExp.escape(titleNoBrackets) +')((?![^\\[\\{]*[\\]\\}]).*)', 'i');
  this.contextRgx = new RegExp('(.*[^\\[])(' + mw.RegExp.escape(titleNoBrackets) +')((?![^\\[\\{]*[\\]\\}]).*)', 'ig');
  this.contextRgxLink = new RegExp('(.*\\[\\[)([^\\]]+?)\\|(' + mw.RegExp.escape(titleNoBrackets) +')(\\]\\].*)', 'i');
  this.contextRgxLink = new RegExp('(.*\\[\\[)([^\\]]+?)\\|(' + mw.RegExp.escape(titleNoBrackets) +')(\\]\\].*)', 'ig');
  this.pageI = -1;
  this.pageI = -1;
  this.matchI = 0;
  this.searchData = null;
  this.searchData = null;
  this.curPage = null;
  this.curPage = null;
שורה 65: שורה 68:
  { action: 'saveContinue', label: mw.msg('qlinker-save-continue'), flags: [ 'other', 'constructive' ] },
  { action: 'saveContinue', label: mw.msg('qlinker-save-continue'), flags: [ 'other', 'constructive' ] },
  { action: 'skipOne', label: mw.msg('qlinker-skip'), flags: [ 'other', 'progressive' ] },
  { action: 'skipOne', label: mw.msg('qlinker-skip'), flags: [ 'other', 'progressive' ] },
  { action: 'skipMatch', label: mw.msg('qlinker-skip-match'), flags: [ 'other', 'progressive' ] },
  { label: mw.msg('qlinker-cancel'), flags: 'safe' }
  { label: mw.msg('qlinker-cancel'), flags: 'safe' }
];
];
שורה 101: שורה 105:
  dialog.skipsCounter++;
  dialog.skipsCounter++;
  dialog.nextPage();
  dialog.nextPage();
}, this );
case 'skipMatch':
return new OO.ui.Process( function () {
  dialog.skipsCounter++;
  dialog.nextMatch();
}, this );
}, this );
case 'saveContinue':
case 'saveContinue':
שורה 134: שורה 143:
};
};


QuickEditorDialog.prototype.nextPage = function ( ) {
QuickEditorDialog.prototype.nextMatch = function ( ) {
var m, contextPre, contextPost, contextInner, contextInnerOld, newContext;
var m, contextPre, contextPost, contextInner, contextInnerOld, newContext, context;
this.pageI++;
this.matchI++;
if (this.searchData.pageids.length <= this.pageI)
if (this.searchData.pageids.length <= this.pageI) {
{
return this.nextPage();
if(this.curPage === null) {
this.content.$element.html('<h1><a target="_blank" href="/wiki/Special:Search/'+encodeURI('"' + titleNoBrackets +'" -linksto:"'+mw.config.get('wgPageName') + '"')+'">'+mw.msg('qlinker-no-results')+'</a></h1>');
this.actions.setAbilities( {
saveContinue: false, skipOne: false
} );
} else {
this.close();
}
return;
}
}
var page = this.searchData.pages[this.searchData.pageids[this.pageI]],
var page = this.searchData.pages[this.searchData.pageids[this.pageI]],
pagecontent = page.revisions[0]['*'];
pagecontent = page.revisions[0]['*'];
if (page.title == mw.config.get('wgTitle')) {
return this.nextPage();
}


if (m = this.contextRgx.exec(pagecontent)) {
if (m = this.contextRgx.exec(pagecontent)) {
שורה 169: שורה 173:
}
}
}
}
if ((page.title!=mw.config.get('wgTitle')) && m) {
 
var context = m[0];
if (!m) return this.nextPage();
contextPre = m[1];
 
newContext = contextPre+contextInner+contextPost;
context = m[0];
this.content.$element.html('<h1><a href="/wiki/'+encodeURI(page.title)+'" target="_blank">'+page.title+'</a></h1><p>'+contextPre+contextInnerOld+'<b>'+contextInner+'</b>'+contextPost+'</p>');
contextPre = m[1];
this.curPage = page.title;
newContext = contextPre+contextInner+contextPost;
this.text = pagecontent.replace(context, newContext)
this.content.$element.html('<h1><a href="/wiki/'+encodeURI(page.title)+'" target="_blank">'+page.title+'</a></h1><p>'+contextPre+contextInnerOld+'<b>'+contextInner+'</b>'+contextPost+'</p>');
this.timestamp = page.revisions[0].timestamp;
this.curPage = page.title;
}
this.text = pagecontent.replace(context, newContext)
else {
this.timestamp = page.revisions[0].timestamp;
this.nextPage();
}
 
QuickEditorDialog.prototype.nextPage = function ( ) {
var m, contextPre, contextPost, contextInner, contextInnerOld, newContext;
this.pageI++;
this.matchI = 0;
if (this.searchData.pageids.length <= this.pageI)
{
if(this.curPage === null) {
this.content.$element.html('<h1><a target="_blank" href="/wiki/Special:Search/'+encodeURI('"' + titleNoBrackets +'" -linksto:"'+mw.config.get('wgPageName') + '"')+'">'+mw.msg('qlinker-no-results')+'</a></h1>');
this.actions.setAbilities( {
saveContinue: false, skipOne: false
} );
} else {
this.close();
}
return;
}
}
this.nextMatch();
}
}