מדיה ויקי:Gadget-quickLinker.js: הבדלים בין גרסאות בדף
מאין תקציר עריכה |
מאין תקציר עריכה |
||
| שורה 21: | שורה 21: | ||
'qlinker-invoke': 'הוספת בזק של קישורים', | 'qlinker-invoke': 'הוספת בזק של קישורים', | ||
'qlinker-sidelink': 'הוספת קישורים', | 'qlinker-sidelink': 'הוספת קישורים', | ||
'qlinker-no-results': 'לא נמצאו תוצאות' | 'qlinker-no-results': 'לא נמצאו תוצאות', | ||
'qlinker-confirm-masslink': 'לדף זה יש כבר הרבה קישורים, ונדרשת זהירות בהוספת הקישורים. האם נחוצים קישורים נוספים?' | |||
}); | }); | ||
break; | break; | ||
| שורה 34: | שורה 35: | ||
'qlinker-invoke': 'Quickly add links', | 'qlinker-invoke': 'Quickly add links', | ||
'qlinker-sidelink': 'Add links', | 'qlinker-sidelink': 'Add links', | ||
'qlinker-no-results': 'No results found' | 'qlinker-no-results': 'No results found', | ||
'qlinker-confirm-masslink': 'This page already has many links. Are you sure?' | |||
}); | }); | ||
break; | break; | ||
| שורה 40: | שורה 42: | ||
function createQuickEditorDialog(searchRes){ | 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) +')((?![^\\[\\{]*[\\]\\}]).*)', 'i'); | ||
| שורה 47: | שורה 49: | ||
this.searchData = null; | this.searchData = null; | ||
this.curPage = null; | this.curPage = null; | ||
this.safeMode = safeMode; | |||
this.skipsCounter = 0; | |||
QuickEditorDialog.super.call( this, config ); | QuickEditorDialog.super.call( this, config ); | ||
} | } | ||
| שורה 92: | שורה 96: | ||
case 'skipOne': | case 'skipOne': | ||
return new OO.ui.Process( function () { | return new OO.ui.Process( function () { | ||
dialog.skipsCounter++; | |||
dialog.nextPage(); | dialog.nextPage(); | ||
}, this ); | }, this ); | ||
| שורה 120: | שורה 125: | ||
}); | }); | ||
} | } | ||
this.nextPage(); | var self = this; | ||
if(this.safeMode) setTimeout(function(){ self.nextPage(); }, 5000/(self.skipsCounter+1)); | |||
else self.nextPage(); | |||
}; | }; | ||
| שורה 200: | שורה 207: | ||
addLinksWizard.click(function(e){ | addLinksWizard.click(function(e){ | ||
searchLinksApi().done(function( | protectedSearchQuery(); | ||
if ( | e.preventDefault(); | ||
if (! | }); | ||
return addLinksWizard; | |||
} | |||
function protectedSearchQuery() | |||
{ | |||
var api = new mw.Api(); | |||
api.get( { | |||
action: 'query', | |||
prop: 'linkshere', | |||
lhlimit: 500, | |||
titles: mw.config.get('wgPageName'), | |||
indexpageids: 1 | |||
}).done(function(d) { | |||
var isValid = true, safeMode = false; | |||
if(d.query && d.query.pages && d.query.pages[d.query.pageids[0]] && d.query.pages[d.query.pageids[0]].linkshere && d.query.pages[d.query.pageids[0]].linkshere.length > 100) | |||
{ | |||
isValid = confirm(mw.msg('qlinker-confirm-masslink')); | |||
safeMode = true; | |||
} | |||
if (!isValid) return; | |||
searchLinksApi().done(function(q){ | |||
if (q.error) mw.notify(q.error.info); | |||
if (!q.query || !q.query.pageids || q.query.pageids.length<=1) { | |||
mw.notify(mw.msg('qlinker-no-results')); | mw.notify(mw.msg('qlinker-no-results')); | ||
return; | return; | ||
} | } | ||
mw.loader.using('oojs-ui-windows', function() { createQuickEditorDialog( | mw.loader.using('oojs-ui-windows', function() { createQuickEditorDialog(q, safeMode) } ); | ||
}); | }); | ||
}) | |||
}) | |||
} | } | ||
function searchLinksApi() | function searchLinksApi() { | ||
{ | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
return api.get( { | return api.get( { | ||
| שורה 232: | שורה 258: | ||
}); | }); | ||
} | } | ||
else | else { | ||
{ | |||
createAddLinksButton(); | createAddLinksButton(); | ||
} | } | ||
}); | }); | ||