משתמש:Yonidebest/monobook.js/quickdelete.js

מתוך ויקיפדיה, האנציקלופדיה החופשית

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
// From [[en:User:Lupin/autoedit.js]], translated by [[user:ערן]], edited by [[User:Yonidebest]]

// String constants
ns_text = "חסר מקור";
ns_tooltip = "סמן תמונה זו כחסרה מקור";
nl_text = "חסר רישיון";
nl_tooltip = "סמן תמונה זו כחסרה פרטי רישיון";
nsl_text = "חסר מקור ורישיון";
nsl_tooltip = "סמן תמונה זו כחסרה מקור ופרטי רישיון";
c_text = "ויקישיתוף";
c_tooltip = "הודע למשתמש על ויקישיתוף";
p_text = "שימוש אישי";
p_tooltip = "סמן תמונה זו כשימוש אישי";
v_text = "אומת";
v_tooltip = "סמן תמונה זו כמאומתת";
dns_text = "מחק: אין מקור";
dns_tooltip = "מחק מכיוון שאין מקור";
dnl_text = "מחק: אין רישיון";
dnl_tooltip = "מחק מכיוון שאין רישיון תקף";
dc_text = "מחק: ויקישיתוף";
dc_tooltip = "מחק מכיוון שהתמונה נמצאת בוויקישיתוף";
dnu_text = "מחק: לא בשימוש";
dnu_tooltip = "מחק מכיוון שהתמונה לא נמצאת בשימוש";
dr_text = "מחק עם סיבה";
dr_tooltip = "מחק עם סיבה חדשה";

// Site info
scriptPath = "/w/index.php";

function openWindow(url) {
  var res = window.open(url, '_blank');
  if (!res) alert("openWindow: window.open() returned null");
}

function getUploader() {
  // Get uploader from first point in the list under "File history"
  // Uploader is stored in second A tag in UL tag under "File history"
  // Returns title of user page (without name space) in URL form
  var el = document.getElementById('filehistory')
  if (!el) {
    alert("תקלה: לא נמצאה היסטורית העלאה ... משימה נכשלה");
    return null;
  }
  while (el.nextSibling) {
    el = el.nextSibling;
    if (el.tagName && el.tagName.toLowerCase() == 'ul') 
      break;
  }
  if (!el) {
    alert("תקלה: לא הצלחתי למצוא רשימת מעלים ... נטשתי אותך, ביי!");
    return null;
  }
  var lis = el.getElementsByTagName('li');
  if (lis && lis.length == 1) {
    var li = lis[0];
  } else {
    var answer = prompt('Which version (1 - top one, a - buttom one)?', '');
    if (!answer) answer = '1';
    if (answer == 'a') {
      var li = lis[lis.length - 1];
    } else {
      var li = lis[answer - 1];
    }
  }
  if (!li) {
    alert("לא הצלחתי למצוא את הפריט הדרוש לי ברשימה ... הפסקתי את המשימה");
    return null;
  }
  var as = li.getElementsByTagName('a');

  var re1 = new RegExp('Blockip/(.*)$');
  var m;
  for (var k=0; k<as.length; k++) {
     m = re1.exec(as[k].title);
     if (m) return m[1];
  }
  alert("תקלה: לא נמצא מעלה ... משימה נכשלה");
  return null;
}

// Function that help idenfity what action must be taken
function mnx_mark(imagepage_fakeaction, usertalk_fakeaction) {

  if (usertalk_fakeaction == 'warn' ) {
    var pagename = encodeURIComponent(mw.config.get('wgPageName'));
    var uploader = getUploader();
 
    if (!uploader) return;
    // Open new window for the user page
    openWindow(scriptPath + '?title=User_talk:' + uploader + '&action=edit&fakeaction=' + usertalk_fakeaction + '&target=' + pagename + '&template_type=' + imagepage_fakeaction);
  }
  if (imagepage_fakeaction != 'dns_temp' &&
      imagepage_fakeaction != 'dnl_temp' &&
      imagepage_fakeaction != 'dc_temp' &&
      imagepage_fakeaction != 'dnu_temp' && 
      imagepage_fakeaction != 'dr_temp' ) {
    var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
    document.location = editlk + '&fakeaction=' + imagepage_fakeaction;
  } else { // delete requests
    /* sysop
    var dellk = document.getElementById('ca-delete').getElementsByTagName('a')[0].href;
    document.location = dellk + '&fakeaction=' + imagepage_fakeaction;
    */
    // no sysop
    var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
    document.location = editlk + '&fakeaction=' + imagepage_fakeaction;
  }
}

// Add template to image description page
function mnx_addTemplate(template) {
  var comment = "תמונה חשודה";
  if (template == 'ns_temp') template = 'ס:תמונה חשודה|סיבה=חסר מקור'; //no source
  if (template == 'nl_temp') template = 'ס:תמונה חשודה|סיבה=חסר רישיון'; //no license
  if (template == 'nsl_temp') template = 'ס:תמונה חשודה|סיבה=חסר מקור ורישיון'; //no source and license
  if (template == 'c_temp') { //commons
    template = 'העברה לוויקישיתוף';
    comment = 'העברה לוויקישיתוף';
  }
  if (template == 'v_temp') { //verified
    template = 'אומת';
    comment = 'אומת';
  }
  if (template == 'p_temp') { //private
    template = 'תמונה לשימוש אישי}}{{אומת';
    comment = 'שימוש אישי';
  }
  var txt = '{{' + template + '}}';
  document.editform.wpTextbox1.value += '\n' + txt;
  document.editform.wpSummary.value = comment;
  document.editform.wpSave.click();
}

// delete image
function mnx_deleteImage(reason) {
/* sysop
  if (reason == 'dns_temp') reason = 'אין מקור';
  if (reason == 'dnl_temp') reason = 'אין רישיון תקף';
  if (reason == 'dc_temp') reason = 'התמונה הועברה לוויקישיתוף / הוחלפה בתמונה בוויקישיתוף';
  if (reason == 'dnu_temp') reason = 'לא בשימוש';
  document.getElementById('deleteconfirm').wpReason.value = reason;
  document.getElementById('deleteconfirm').submit();
*/
  // no sysop
  if (reason == 'dns_temp') reason = 'אין מקור';
  if (reason == 'dnl_temp') reason = 'אין רישיון תקף';
  if (reason == 'dc_temp') reason = 'התמונה הועברה לוויקישיתוף / הוחלפה בתמונה בוויקישיתוף';
  if (reason == 'dnu_temp') reason = 'לא בשימוש';
  if (reason == 'dr_temp') reason = prompt('Reason?', '');
  var txt = '{{' + 'מחק|' + reason + '}}';
  document.editform.wpTextbox1.value += '\n' + txt;
  document.editform.wpSummary.value = reason;
  document.editform.wpSave.click();
}

// Add warning template to uploader's talk page
function mnx_addUserWarningTemplate(imagetarget, template_type) {
  var imageName = imagetarget.substring(6,imagetarget.length);
  var txt = '==[[:תמונה:' + imageName + '|' + imageName + ']]==\n';
  var comment = '';
  if (template_type == 'ns_temp') { // source
     txt += 'במסגרת הטיפול בתמונות בעייתיות ב[[וק:מה|מיזם התמונות]], שמתי לב כי העלית את התמונה הנ"ל שלא בהתאם להנחיות הברורות המופיעות ב[[מיוחד:Upload|דף העלאת קובץ לשרת]] ובדפי העזרה בנושא תמונות. אנא פעל על פי ה\'\'\'[[משתמש:Yonidebest/מקור|הנחיות בדף זה]]\'\'\', אחרת התמונה עלולה להימחק בשבוע הקרוב. בהמשך לשיחה זו אני לרשותך לשם מתן מידע ועזרה. לחלופין, ניתן ואף רצוי לפנות ל[[ויקיפדיה:דלפק ייעוץ|דלפק הייעוץ]] שכן שם יש סיכוי טוב יותר לקבל תשובה מהירה יותר. ';
     comment = 'חסר מקור';
  }
  if (template_type == 'nl_temp') { // license
     txt += 'במסגרת הטיפול בתמונות בעייתיות ב[[וק:מה|מיזם התמונות]], שמתי לב כי העלית את התמונה הנ"ל שלא בהתאם להנחיות הברורות המופיעות ב[[מיוחד:Upload|דף העלאת קובץ לשרת]] ובדפי העזרה בנושא תמונות. אנא פעל על פי ה\'\'\'[[משתמש:Yonidebest/רישיון|הנחיות בדף זה]]\'\'\', אחרת התמונה עלולה להימחק בשבוע הקרוב. בהמשך לשיחה זו אני לרשותך לשם מתן מידע ועזרה. לחלופין, ניתן ואף רצוי לפנות ל[[ויקיפדיה:דלפק ייעוץ|דלפק הייעוץ]] שכן שם יש סיכוי טוב יותר לקבל תשובה מהירה יותר. ';
     comment = 'חסר רישיון';
  }
  if (template_type == 'nsl_temp') { // source and license
     txt += 'במסגרת הטיפול בתמונות בעייתיות ב[[וק:מה|מיזם התמונות]], שמתי לב כי העלית את התמונה הנ"ל שלא בהתאם להנחיות הברורות המופיעות ב[[מיוחד:Upload|דף העלאת קובץ לשרת]] ובדפי העזרה בנושא תמונות. אנא פעל על פי ה\'\'\'[[משתמש:Yonidebest/מקור ורישיון|הנחיות בדף זה]]\'\'\', אחרת התמונה עלולה להימחק בשבוע הקרוב. בהמשך לשיחה זו אני לרשותך לשם מתן מידע ועזרה. לחלופין, ניתן ואף רצוי לפנות ל[[ויקיפדיה:דלפק ייעוץ|דלפק הייעוץ]] שכן שם יש סיכוי טוב יותר לקבל תשובה מהירה יותר. ';
     comment = 'חסר מקור ורישיון';
  }
  if (template_type == 'c_temp') { // commons
     txt += 'במסגרת הטיפול בתמונות חופשיות ב[[וק:מה|מיזם התמונות]], ברצוני להזכיר לך כי תמונות חופשיות מומלץ להעלות ל[[ויקישיתוף|וויקישיתוף]]. תודה, ';
     comment = 'ויקישיתוף';
  }
  document.editform.wpTextbox1.value += '\n' + txt + '~~' + '~~\n';
  document.editform.wpSummary.value = comment;
  document.editform.wpSave.click();
}

function mnx_onload() {
  if (wgNamespaceNumber == 6) { // image name space
    addLink('p-tb', 'javascript:mnx_mark(\'ns_temp\', \'warn\')', ns_text, 'mark-no-source', ns_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'nl_temp\', \'warn\')', nl_text, 'mark-no-license', nl_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'nsl_temp\', \'warn\')', nsl_text, 'mark-no-license-source', nsl_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'c_temp\', \'warn\')', c_text, 'mark-commons', c_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'v_temp\', \'no_warn\')', v_text, 'mark-verified', v_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'p_temp\', \'no_warn\')', p_text, 'mark-private', p_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'dnl_temp\', \'no_warn\')', dnl_text, 'delete-no-license', dnl_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'dns_temp\', \'no_warn\')', dns_text, 'delete-no-source', dns_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'dc_temp\', \'no_warn\')', dc_text, 'delete-commons', dc_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'dnu_temp\', \'no_warn\')', dnu_text, 'delete-no-use', dnu_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'dr_temp\', \'no_warn\')', dr_text, 'delete-reason', dr_tooltip, null, null);
  }
  var fakeaction = getParamValue('fakeaction');
  var template_type = getParamValue('template_type');   // Fetch what template to add

  if (fakeaction == 'ns_temp'){ // מקור
    mnx_addTemplate('ns_temp');
  }
  if (fakeaction == 'nsl_temp'){ // מקור ורישיון
    mnx_addTemplate('nsl_temp');
  }
  if (fakeaction == 'nl_temp'){ // רישיון
    mnx_addTemplate('nl_temp');
  }
  if (fakeaction == 'v_temp'){ // אומת
    mnx_addTemplate('v_temp');
  }
  if (fakeaction == 'p_temp'){ // שימוש אישי
    mnx_addTemplate('p_temp');
  }
  if (fakeaction == 'c_temp'){ // ויקישיתוף
    mnx_addTemplate('c_temp');
  }
  if (fakeaction == 'dc_temp'){ // מחק ויקישיתוף
    mnx_deleteImage('dc_temp');
  }
  if (fakeaction == 'dnl_temp'){ // מחק רישיון
    mnx_deleteImage('dnl_temp');
  }
  if (fakeaction == 'dns_temp'){ // מחק מקור
    mnx_deleteImage('dns_temp');
  }
  if (fakeaction == 'dnu_temp'){ // מחק לא בשימוש
    mnx_deleteImage('dnu_temp');
  }
  if (fakeaction == 'dr_temp'){ // מחק עם סיבה
    mnx_deleteImage('dr_temp');
  }
  if (fakeaction == 'warn') {
   mnx_addUserWarningTemplate(decodeURIComponent(getParamValue('target')), template_type);
  }
}

$(mnx_onload);