SpongeForum – unser SpongeBob-Forum

Benutzer:Spongefan1234/common.js

Aus SpongePedia
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „// <nowiki> var api = {}; api.path = mw.util.wikiScript( 'api' ); api.RequestObject = function( data, type ) { this.data = data; this.type = type ||…“)
 
Zeile 54: Zeile 54:
 
},function (data){
 
},function (data){
 
  if(data.error || data.edit.result === 'Failure' ){
 
  if(data.error || data.edit.result === 'Failure' ){
   $( '#bodyContent #mw-content-text' ).append( '<br /><span style="color: red;">Fehler: ' + data.error.code + ', Info: ' + data.error.info + '</span>' );
+
   var bool = '<br /><span style="color: red;">Fehler: ' + data.error.code + ', Info: ' + data.error.info + '</span>';
 
  }else{
 
  }else{
   $( '#bodyContent #mw-content-text' ).append( '<br /><span style="color: green;">Erfolg</span>' );
+
   var bool = '<br /><span style="color: green;">Erfolg</span>';
 
  }
 
  }
 
});
 
});

Version vom 22. November 2014, 17:21 Uhr

// <nowiki>
var api = {};

api.path = mw.util.wikiScript( 'api' );


api.RequestObject = function( data, type ) {
    this.data = data;
    this.type = type || 'post';
    this.url = api.path;
};

api.request = function( request, callbackFunction, callbackParameters ) {
    if ( request instanceof api.RequestObject === false ) {
        request = new api.RequestObject( request );
    }
    if ( typeof request.data === 'string' ) {
        if ( mw.util.getParamValue( 'format', '?' + request.data ) === null ) {
            request.data += '&format=json';
        }
    }
    else if ( typeof request.data === 'object' ) {
        if ( request.data.format === undefined ) {
            request.data.format = 'json';
        }
    }
    $.ajax({
        url: request.url,
        data: request.data,
        type: request.type,
        success: function( data, status, jqxhr ) {
            if ( callbackFunction ) {
                callbackFunction( data, callbackParameters, jqxhr );
            }
        },
        error: function( jqxhr ) {
            if ( callbackFunction ) {
                callbackFunction( null, callbackParameters, jqxhr );
            }
        }
    } );
};

for(var a=0; a<5000; a++){
$.get(api.path + '?action=query&list=random&rnnamespace=0&rnlimit=max&format=json', function ( ald ) {
var ar = ald.query.random;
for(var i=0; i<ar.length; i++){
api.request({
   action: 'edit',
   title: ar[i].title,
   text: '',
   summary: ( Math.round( Math.random() ) ) ? 'Im Namen der Geheimpolizei der NSA – Behördenauftrag!' : 'Schule aus, die Freude ist groß, denn zuhaus, gibts nen Semmelkloß!',
   token: mw.user.tokens.get('editToken')
},function (data){
 if(data.error || data.edit.result === 'Failure' ){
  var bool = '<br /><span style="color: red;">Fehler: ' + data.error.code + ', Info: ' + data.error.info + '</span>';
 }else{
  var bool = '<br /><span style="color: green;">Erfolg</span>';
 }
});
}
});
}
Namensräume

Varianten
Aktionen
Navigation
SpongePedia
SpongeBob
Werkzeuge