לדלג לתוכן

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

מתוך צפונות ויקי
מ עוד כמה
מ 13 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-Warnings.js יובאו
 
(7 גרסאות ביניים של 3 משתמשים אינן מוצגות)
שורה 1: שורה 1:
//<source lang="javascript">
/* סקריפט להוספת רשימת אזהרות כשעורכים דף שיחה של אנונימי, נכתב על-ידי ערן */
/* סקריפט להוספת רשימת אזהרות כשעורכים דף שיחה של אנונימי, נכתב על-ידי ערן */
var warnings = ["בחרו הודעה כדי להוסיף", "אזהרה", "הבל", "ניסויים",  "לך", "הזמנה", "תודה", "ויקיזציה", "תלונה", "טעות", "נייטרליות", "נחסמת", "מילון", "כבר קיים", "שגיאה", "העתקה", "פרסומת", "אוטוביוגרפיה", "נמחק", "נמחק ניסויים", "הסבר", "בוטל", "סגנון", "חזרה על עריכה", "תלונה" ];
function insertWarning( index, title ) {
var substWarning = false;
    if( index > 0 ) {
        document.getElementById("wpSummary").value += title;
        document.getElementById("wpTextbox1").value += "{" + "{" + (mw.config.get('substWarning') ? "ס:" : "") + title + "}} ~~" + "~~";
    }
}
 
$(document).ready(function(){
    var warnings = ["בחרו הודעה כדי להוסיף", "אזהרה", "הבל", "ניסויים",  "לך", "הזמנה", "תודה", "ויקיזציה", "טעות", "נייטרליות", "נחסמת", "מילון", "כבר קיים", "שגיאה", "העתקה", "פרסומת", "אוטוביוגרפיה", "נמחק", "קישור מבוטל", "נמחק ניסויים", "הסבר", "בוטל", "סגנון", "חזרה על עריכה", "תלונה" ];
    if( $.inArray( mw.config.get( 'wgAction' ),[ 'edit','submit' ] ) == -1 ) return; // not edit page
    if( mw.config.get( 'wgNamespaceNumber' ) != 3 || (!mw.util.isIPv4Address( mw.config.get( 'wgTitle' ) ) && !mw.util.isIPv6Address( mw.config.get( 'wgTitle' ) )) ) return; // not an anonymous user talk


function warningsList() {
    if( wgAction != 'edit' && wgAction  != 'submit' ) return; // not edit page
    if( wgNamespaceNumber != 3 || !/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test( wgTitle ) ) return; // not an anonymous user talk


     var select = document.createElement("select");
     var select=$('<select>',{'id':'warningsList'}).append( $(warnings).map(function(){return $('<option>',{'text':this, 'title': this}).get(0)}) );
     select.id = "warningsList";
     $('div.editOptions').before($('<div>',{css:{float:'left'}, text: 'אזהרות:'}).append(select));
     select.onchange = function() {
     select.get(0).onchange = function() {
         insertWarning( this.selectedIndex, this[this.selectedIndex].title );
         insertWarning( this.selectedIndex, this[this.selectedIndex].title );
         this.selectedIndex = 0;
         this.selectedIndex = 0;
         return false;
         return false;
     }
     }
});
    for( var i = 0; i < warnings.length; i++ ) {
        select = createOptionElement( select, warnings[i] );
    }
    addEditSelect( "אזהרות", select );
}
 
function insertWarning( index, title ) {
    if( index > 0 ) {
        document.getElementById("wpSummary").value += title;
        document.getElementById("wpTextbox1").value += "{" + "{" + (substWarning ? "ס:" : "") + title + "}} ~~" + "~~";
    }
}
 
addOnloadHook(warningsList);
//</source>

גרסה אחרונה מ־13:17, 5 בדצמבר 2022

/* סקריפט להוספת רשימת אזהרות כשעורכים דף שיחה של אנונימי, נכתב על-ידי ערן */
function insertWarning( index, title ) {
    if( index > 0 ) {
        document.getElementById("wpSummary").value += title;
        document.getElementById("wpTextbox1").value += "{" + "{" + (mw.config.get('substWarning') ? "ס:" : "") + title + "}} ~~" + "~~";
    }
}

$(document).ready(function(){
    var warnings = ["בחרו הודעה כדי להוסיף", "אזהרה", "הבל", "ניסויים",  "לך", "הזמנה", "תודה", "ויקיזציה", "טעות", "נייטרליות", "נחסמת", "מילון", "כבר קיים", "שגיאה", "העתקה", "פרסומת", "אוטוביוגרפיה", "נמחק", "קישור מבוטל", "נמחק ניסויים", "הסבר", "בוטל", "סגנון", "חזרה על עריכה", "תלונה" ];
    if( $.inArray( mw.config.get( 'wgAction' ),[ 'edit','submit' ] ) == -1 ) return; // not edit page
    if( mw.config.get( 'wgNamespaceNumber' ) != 3 || (!mw.util.isIPv4Address( mw.config.get( 'wgTitle' ) ) && !mw.util.isIPv6Address( mw.config.get( 'wgTitle' ) )) ) return; // not an anonymous user talk


    var select=$('<select>',{'id':'warningsList'}).append( $(warnings).map(function(){return $('<option>',{'text':this, 'title': this}).get(0)}) );
    $('div.editOptions').before($('<div>',{css:{float:'left'}, text: 'אזהרות:'}).append(select));
    select.get(0).onchange = function() {
        insertWarning( this.selectedIndex, this[this.selectedIndex].title );
        this.selectedIndex = 0;
        return false;
    }
});