מדיה ויקי: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) +')((?![^\\[\\{]*[\\]\\}]).*)', ' | this.contextRgx = new RegExp('(.*[^\\[])(' + mw.RegExp.escape(titleNoBrackets) +')((?![^\\[\\{]*[\\]\\}]).*)', 'ig'); | ||
this.contextRgxLink = new RegExp('(.*\\[\\[)([^\\]]+?)\\|(' + mw.RegExp.escape(titleNoBrackets) +')(\\]\\].*)', ' | 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. | QuickEditorDialog.prototype.nextMatch = function ( ) { | ||
var m, contextPre, contextPost, contextInner, contextInnerOld, newContext; | var m, contextPre, contextPost, contextInner, contextInnerOld, newContext, context; | ||
this. | this.matchI++; | ||
if (this.searchData.pageids.length <= this.pageI) | if (this.searchData.pageids.length <= this.pageI) { | ||
return this.nextPage(); | |||
} | } | ||
var page = this.searchData.pages[this.searchData.pageids[this.pageI]], | var page = this.searchData.pages[this.searchData.pageids[this.pageI]], | ||
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 ( | |||
if (!m) return this.nextPage(); | |||
context = m[0]; | |||
contextPre = m[1]; | |||
newContext = contextPre+contextInner+contextPost; | |||
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.curPage = page.title; | |||
} | this.text = pagecontent.replace(context, newContext) | ||
this.timestamp = page.revisions[0].timestamp; | |||
} | |||
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(); | |||
} | } | ||