Neidio i'r cynnwys

MediaWici:Gadget-uploadtools.js

Oddi ar Wicipedia

Nodyn: Ar ôl cyhoeddi, efallai y bydd rhaid i chi fynd heibio celc eich porwr er mwyn gweld y newidiadau.

  • Firefox / Safari: Pwyswch Shift wrth glicio Adnewyddu / Reload, neu bwyswch naill ai Ctrl-F5 neu Ctrl-R (⌘-R ar Mac);
  • Google Chrome: Pwyswch Ctrl-Shift-R (⌘-Shift-R ar Mac)
  • Edge: Pwyswch Ctrl wrth glicio Adnewyddu / Refresh, neu bwyswch Ctrl-F5.
/**
  * Ermöglicht eine Vorschau der Beschreibung auf [[Spezial:Hochladen]]
  * siehe auch [[phab:T4537]]
  * wird in [[MediaWiki:Common.js]] eingebunden
  * Code von [[Benutzer:Schnark]]
  * <nowiki>
  */
 $( function() {
  var $editbox = $( '#wpUploadDescription' );
  if ( $editbox.length !== 1 ) {
     return; // exits silently if not exactly one #wpUploadDescription is found
  }
  var parseAsSummary; // Fallunterscheidung für Vorschaufunktion
  if ( mw.util.getParamValue( 'wpForReUpload' ) !== '1' ) { // Kein Upload von neuer Dateiversion?
     parseAsSummary = false; // bei Upload der ersten Dateiversion wird eingegebener Text auf der Seite erscheinen
  } else {
     parseAsSummary = true; // bei Upload von neuer Dateiversion wird eingegebener Text nur im Log erscheinen
  }

  if ( false ) {
     return;
  }
  var previewText = 'Vorschau';
  if ( $( '#mw-description-preview' ).length === 0 ) {
     $( '#mw-htmlform-description' ).before( $( mw.html.element( 'div', { id: 'mw-description-preview' } ) ) );
  }
  $( 'input[name="wpUpload"]' ).after( $( mw.html.element( 'input', {
   value: previewText,
   type: 'button',
   id: 'wpPreview',
   title: previewText,
   accesskey: 'p'
  })).click( function() {
    if ( typeof wikEd !== 'undefined' && wikEd.useWikEd ) { // if WikEd is active
       wikEd.UpdateTextarea(); // transfer WikEd to $editbox
    }
    var param = {action: 'parse',
                 title: 'Datei:' + ( $( '#wpDestFile' ).val() || 'Beispiel.jpg' ), //Titel, Datei:Beispiel.jpg als Standard
                 prop: 'text',
                 pst: '',
                 format: 'json'};
    param[ parseAsSummary ? 'summary' : 'text' ] = $editbox.val(); //Inhalt des Eingabefeldes entweder als Kommentar oder als Text parsen
    $.getJSON( mw.util.wikiScript( 'api' ), param, function ( json ) {
       var content = parseAsSummary ? 'parsedsummary' : 'text'; //Geparster Inhalt entweder in parsedsummary oder in text
       if ( !json || !json.parse || !json.parse[content] || !json.parse[content]['*'] ) {
          return;
       }
       var html = '<p><strong>' + previewText + ':</strong></p><div>' + json.parse[content]['*'] + '</div>';
       $( '#mw-description-preview' ).html( html );
    }); //getJSON
  })); //click
  $( '#t-print a' ).removeAttr( 'accesskey' ); // T58786
  $( '#t-print a, #wpPreview' ).updateTooltipAccessKeys();
 }); //ready
//</nowiki>