Kamel:J*/lib/nulledit.js
aus Kamelopedia, der wüsten Enzyklopädie
Hinweis: Leere nach dem Speichern den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Internet Explorer: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Extras → Internetspuren löschen … → Individuelle Auswahl → Den kompletten Cache löschen
/* * 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]); } );