מדיה ויקי:Gadget-ExtendedFileOptions.js
קפיצה לניווט
קפיצה לחיפוש
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload), או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh), או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
if ( mw.config.get('wgNamespaceNumber') === 6 ) $( function() { function deleteCommonsDuplicate(newName) { var api = new mw.Api(); mw.notify('כל השימושים בקובץ הוסרו'); if ( mw.config.get('wgUserGroups').indexOf('sysop') > -1) { api.postWithToken('edit', { action: 'delete', title: mw.config.get('wgPageName'), reason: '[[וק:וש|הקובץ נמצא בוויקישיתוף]]: [[:File:' + newName + ']]' }); } else { api.postWithToken('edit', { action: 'edit', title: 'ויקיפדיה:בקשות ממפעילים', section: 1, summary: '[[:' + mw.config.get('wgPageName') + ']] - [[וק:וש|הקובץ נמצא בוויקישיתוף]]: [[:File:' + newName + ']]' , appendtext: '\n* {{בקשת מחיקה|' + mw.config.get('wgPageName') + '|קיים קובץ זהה בוויקישיתוף: [[:File:' + newName + ']]}} ~~'+'~~', tags: 'ניטור_תמונות' }).done(function(d) { if (d && d.edit && d.edit.result == 'Success') mw.notify('נוספה בקשה בבקשות ממפעילים'); }); } } if($('#ca-history').length === 0) return; /* Replace image uses with commons copy or similar file */ function replaceFile(newName) { var rgxFrom = new RegExp(': *' + /.+?:(.+)/.exec(mw.config.get('wgPageName'))[1].replace(/_/g, '[ _]')), process = new $.Deferred(), api = new mw.Api(), requiredReplacements = $('.mw-imagepage-linkstoimage a').length; mw.notify('מחליף ל' + newName); process.progress(function(){ requiredReplacements--; if (requiredReplacements === 0) deleteCommonsDuplicate(newName); }); if ($('.mw-imagepage-linkstoimage a').length === 0) { deleteCommonsDuplicate(newName); } else { $('.mw-imagepage-linkstoimage a').each(function(){ var page = $(this).attr('title'); api.get({action:'parse', page: page, prop: 'wikitext'}).done(function(d){ var oldText = d.parse.wikitext['*']; var newText = d.parse.wikitext['*'].replace(rgxFrom, ':' + newName); if(oldText!=newText) { api.postWithToken('edit', {action:'edit', summary: '[['+mw.config.get('wgPageName') + ']] => [[:קובץ:' + newName +']]', text: newText, title: page, tags: 'ניטור_תמונות' }).done(function(){ mw.notify('הקובץ הוחלף ב'+page); process.notify(); }); } else { //process.notify(); mw.notify('הקובץ לא הוחלף ב'+page); } }); }); } } function safeReplaceFile(filename) { var api = new mw.Api(); api.get({action: 'query', titles: 'File:' + filename, prop: 'imageinfo', indexpageids: 1}).done(function(d) { if ( d.query.pages["-1"] && d.query.pages["-1"].imagerepository === 'shared' ) { replaceFile(filename); } else if ( d.query.pageids.length === 1 && d.query.pageids[0] != -1) { mw.notify('קיים עותק מקומי של הקובץ'); } else { mw.notify('הקובץ לא קיים. נא לבדוק ידנית.'); } }); } function replaceToCommons(){ var api = new mw.Api(), newName; if ($('.mw-imagepage-duplicates a').length === 1 ) { newName = /.+?:(.+)/.exec($('.mw-imagepage-duplicates a').text())[1].replace('_', ' '); replaceFile(newName); } else { newName = prompt("שם התמונה להחלפה"); newName = newName.replace(/File:|קובץ:|תמונה:/,'').replace('_', ' '); safeReplaceFile(newName); } } function addTemplateAndNotifyUser(reason, template) { var imgTemplate = '{' + '{ס:תמונה בעייתית|' + reason + '}}', user = $.unique($('#mw-imagepage-section-filehistory .mw-userlink').map(function(){return $(this).text()})).toArray(); reason = prompt('סיבה', reason); if (!reason) return; if (user.length != 1) { user = prompt('שם מעלה התמונה'); // in past the default was user.join(', ') but this can confuse if (!user) return; } else { user = user[0]; } if ( user.indexOf(mw.config.get('wgFormattedNamespaces')[2]) === -1 ) user = mw.config.get('wgFormattedNamespaces')[3] +':' +user ; else user='שיחת ' + user; var api = new mw.Api(); api.postWithToken('edit', { action: 'edit', title: mw.config.get('wgPageName'), summary: 'תמונה בעייתית - ' + reason , appendtext: '\n' + imgTemplate, tags: 'ניטור_תמונות' }).done(function(d) { if (d && d.edit && d.edit.result != 'Success') mw.notify('אירעה שגיאה'); else { var userNotice = new mw.Api(); userNotice.postWithToken('edit', { action: 'edit', title: user, section: 'new', sectiontitle: '[[:' + mw.config.get('wgPageName').replace(/_/g, " ") + ']]', text: '{{' + template + '}}\n~~' + '~~', tags: 'ניטור_תמונות' }).done(function(dd) { window.location.reload(true); }); } }); } /* common messages for handling files*/ var imageTemplate = [ { buttonText: 'החלפה לתמונה מוויקישיתוף', id: 't-commons-replace', alt: 'החלפה בתמונה מוויקישיתוף', func: replaceToCommons }, { buttonText: 'חסר אישור OTRS', id: 't-OTRS-missing', alt: 'המשתמש העלה תמונה שמישהו אחר יצר', func: function() { addTemplateAndNotifyUser('נדרש אישור OTRS', 'אישור OTRS'); } }, { buttonText: 'תמונה חסרת רישיון', id: 't-license-missing', alt: 'לתמונה לא ניתן רישיון', func: function() { addTemplateAndNotifyUser('נדרשת תבניות רישיון', 'תמונה ללא רישיון'); } }, { buttonText: 'תמונה מוגנת', id: 't-copyvio', alt: 'התמונה נמצאה במקור חיצוני ולא ברור שמעלה התמונה הוא הבעלים שלה', func: function() { addTemplateAndNotifyUser('התמונה כבר קיימת ברשת/נראה שלא נוצרה על ידי מעלה הקובץ', 'תמונה מוגנת'); } }, { buttonText: 'שימוש הוגן לא תקין', id: 't-unfairuse', alt: 'הקובץ מוגדר כשימוש הוגן אך אינו שימוש הוגן', func: function() { addTemplateAndNotifyUser('נראה כי התמונה אינה בשימוש הוגן', 'תמונה חופשית'); } }, { buttonText: 'שימוש חופשי שצריך הוגן', id: 't-unfreeuse', alt: 'תמונה שהועלתה כשימוש חופשי אבל נראית כתמונת שימוש הוגן', func: function() { addTemplateAndNotifyUser('נראה כי התמונה אינה תמונה חופשית', 'תמונה בשימוש הוגן'); } }, { buttonText: 'שימוש הוגן ללא מקור', id: 't-source-missing', alt: 'התמונה מוגדרת כשימוש הוגן אך חסר לה מקור', func: function() { addTemplateAndNotifyUser('חסר מקור', 'תמונה בשימוש הוגן ללא מקור'); } } ]; if (window.imageTemplateExt) imageTemplate = imageTemplate.concat(window.imageTemplateExt); for(var i=0;i<imageTemplate.length;i++) $(mw.util.addPortletLink('p-tb', '#', imageTemplate[i].buttonText, imageTemplate[i].id, imageTemplate[i].alt, null, '#t-whatlinkshere')).click(imageTemplate[i].func); });