Benutzer:J*/lib/nulledit.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
(AZ: Die Seite wurde neu angelegt.)
 
K (Schützte „Kamel:J*/lib/nulledit.js“ ([edit=sysop] (unbeschränkt) [move=sysop] (unbeschränkt) [protect=sysop] (unbeschränkt)))
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 4: Zeile 4:
 
  * do nulledits to a page or members of a category
 
  * do nulledits to a page or members of a category
 
  */
 
  */
 
+
 
+
function pageNulledit(page)
+
function pageNulledit(page,notify)
 +
{
 +
    getNulleditTokens([page],notify);
 +
}
 +
 +
function multipageNulledit(pages,notify)
 
{
 
{
      
+
     getNulleditTokens(pages,notify);
 
}
 
}
 
+
function categoryNulledit(category,cont)
+
function categoryNulledit(category,notify,cont)
 
{
 
{
    if(!cont)
+
if(!cont)
        cont = "";
+
cont = "";
 
+
    jQuery.ajax({
+
jQuery.ajax({
        url: "/api.php",
+
url: "/api.php",
        data: {
+
data: {
            action: "query",
+
action: "query",
            list: "categorymembers",
+
list: "categorymembers",
            cmtitle: category,
+
cmtitle: category,
            format: "xml",
+
format: "xml",
            cmcontinue: cont
+
cmcontinue: cont
        },
+
},
        context: {category: category},
+
context: {category: category, notify: notify},
        dataType: "xml",
+
dataType: "xml",
        success: parseCategoryNulleditMembers
+
success: parseCategoryNulleditMembers
    });
+
});
 
}
 
}
 
+
 
function parseCategoryNulleditMembers(xml)
 
function parseCategoryNulleditMembers(xml)
 
{
 
{
    var $xml = jQuery(xml);
+
var $xml = jQuery(xml);
    var category = this.category;
+
var category = this.category;
 
+
    var $members = $xml.find("api query categorymembers cm")
+
var $members = $xml.find("api query categorymembers cm");
 +
 +
        var titles = [];
 +
$members.each( function () {
 +
$this = jQuery(this);
 +
title = $this.attr("title");
 +
titles.push(title);
 +
});
 +
        multipageNulledit(titles,this.notify);
 +
 +
var cont = $xml.find("query-continue categorymembers").attr("cmcontinue");
 +
if (cont)
 +
window.setTimeout(function () {categoryNulledit(category,this.notify,cont)}, 10000);
 +
}
 +
 +
function getNulleditTokens(pages,notify)
 +
{
 +
var titlearray = [];
 +
for(var i=0; i<pages.length; i++)
 +
{
 +
titlearray.push(pages[i]);
 +
}
 +
var titlestring = titlearray.join("|");
  
    $members.each( function () {
+
         notify("Bereite Nulledits vor.",titlearray.length);
         $this = jQuery(this);
+
        title = $this.attr("title");
+
jQuery.ajax({
        console.log(title);
+
url: "/api.php",
    });
+
data: {
 
+
action: "query",
    var cont = $xml.find("query-continue categorymembers").attr("cmcontinue");
+
prop: "info",
    if (cont)
+
intoken: "edit",
        window.setTimeout(function () {categoryNulledit(category,cont)}, 2000);
+
titles: titlestring,
 +
format: "xml"
 +
},
 +
dataType: "xml",
 +
context: {notify: notify},
 +
success: parseNulleditTokens
 +
});
 +
 
}
 
}
 
+
function getNulleditTokens(pages)
+
function parseNulleditTokens(xml)
 
{
 
{
    action=query&prop=info&intoken=edit&titles=Hauptseite
+
var $xml = jQuery(xml);
 +
        var context = this;
 +
$xml.find("api query pages page").each( function () {
 +
var $this = jQuery(this);
 +
                var token = $this.attr("edittoken");
 +
                if(token)
 +
                {
 +
                        context.notify("Führe Nulledit für "+$this.attr("title")+" durch.", 0);
 +
        doNulledit($this.attr("title"),token,context.notify);
 +
                }
 +
                else
 +
                        context.notify("Kein valides Token für "+ $this.attr("title"), -1);
 +
})
 
}
 
}
 
+
function parseNulleditTokens(xml)
+
function doNulledit(page,token,notify)
 
{
 
{
 
+
jQuery.ajax({
 +
url: "/api.php",
 +
type: "POST",
 +
data: {
 +
action: "edit",
 +
appendtext: "",
 +
token: token,
 +
title: page,
 +
nocreate: "1",
 +
format: "xml"
 +
},
 +
dataType: "xml",
 +
context: {notify: notify},
 +
success: reportNulledit
 +
});
 
}
 
}
  
function doNulledit(page,token)
+
function reportNulledit(xml)
 
{
 
{
 
+
this.notify("Ok.",-1);
 
}
 
}
 
+
//categoryNulledit("Kategorie:Commons: Kamel");
+
//var count = 0
getNulleditTokens(["Hauptseite","Test"]);
+
//pageNulledit(wgPageName, function (a,b) { count += b; console.log([a,count]); } );
 +
//categoryNulledit(wgPageName, function (a,b) { count += b; console.log([a,count]); } );

Aktuelle Version vom 25. November 2010, 08:59 Uhr

/*
 * libnulledit
 *
 * do nulledits to a page or members of a category
 */
 
 
function pageNulledit(page,notify)
{
    getNulleditTokens([page],notify);
}
 
function multipageNulledit(pages,notify)
{
    getNulleditTokens(pages,notify);
}
 
function categoryNulledit(category,notify,cont)
{
	if(!cont)
		cont = "";
 
	jQuery.ajax({
		url: "/api.php",
		data: {
			action: "query",
			list: "categorymembers",
			cmtitle: category,
			format: "xml",
			cmcontinue: cont
		},
		context: {category: category, notify: notify},
		dataType: "xml",
		success: parseCategoryNulleditMembers
	});
}
 
function parseCategoryNulleditMembers(xml)
{
	var $xml = jQuery(xml);
	var category = this.category;
 
	var $members = $xml.find("api query categorymembers cm");
 
        var titles = [];
	$members.each( function () {
		$this = jQuery(this);
		title = $this.attr("title");
		titles.push(title);
	});
        multipageNulledit(titles,this.notify);
 
	var cont = $xml.find("query-continue categorymembers").attr("cmcontinue");
	if (cont)
		window.setTimeout(function () {categoryNulledit(category,this.notify,cont)}, 10000);
}
 
function getNulleditTokens(pages,notify)
{
	var titlearray = [];
	for(var i=0; i<pages.length; i++)
	{
		titlearray.push(pages[i]);
	}
	var titlestring = titlearray.join("|");

        notify("Bereite Nulledits vor.",titlearray.length);
 
	jQuery.ajax({
		url: "/api.php",
		data: {
			action: "query",
			prop: "info",
			intoken: "edit",
			titles: titlestring,
			format: "xml"
		},
		dataType: "xml",
		context: {notify: notify},	
		success: parseNulleditTokens
});
 
}
 
function parseNulleditTokens(xml)
{
	var $xml = jQuery(xml);
        var context = this;
	$xml.find("api query pages page").each( function () {
		var $this = jQuery(this);
                var token = $this.attr("edittoken");
                if(token)
                {
                        context.notify("Führe Nulledit für "+$this.attr("title")+" durch.", 0);
		        doNulledit($this.attr("title"),token,context.notify);
                }
                else
                        context.notify("Kein valides Token für "+ $this.attr("title"), -1);
	})
}
 
function doNulledit(page,token,notify)
{
	jQuery.ajax({
		url: "/api.php",
		type: "POST",
		data: {
			action: "edit",
			appendtext: "",
			token: token,
			title: page,
			nocreate: "1",
			format: "xml"
		},
		dataType: "xml",
		context: {notify: notify},
		success: reportNulledit
	});
}

function reportNulledit(xml)
{
	this.notify("Ok.",-1);
}
 
//var count = 0
//pageNulledit(wgPageName, function (a,b) { count += b; console.log([a,count]); } );
//categoryNulledit(wgPageName, function (a,b) { count += b; console.log([a,count]); } );