User:A930913/vada/vada.js

importScript("User:A930913/vada/diffview.js"); window.vada={};

window.vada.process=new Worker("/w/index.php?title=User:A930913/vada/vadaprocess.js&action=raw&ctype=text/javascript"); window.vada.process.onmessage=function(msg){ //if(typeof console!="undefined")console.log(msg.data); //debugger; data=JSON.parse(msg.data); if((dot=data.func.indexOf("."))>=0){ var func=window.vada[data.func.substr(0,dot)]; data.func=data.func.slice(dot+1); while((dot=data.func.indexOf("."))+1){ func=func[data.func.substr(0,dot)]; data.func=data.func.slice(dot+1); }		func=func[data.func]; } else { var func=window.vada.dom[data.func]; }	func(data.params); } window.vada.process.onerror=function(e){if(typeof console!="undefined")console.log("Error:",e);} //window.vada.process.postMessage;//vada, activate! window.vada.call=function(func,params){ window.vada.process.postMessage(JSON.stringify({"func":func,"params":params})); }

window.vada.dom={}; window.vada.dom._removeChildren=function(elem){ while(elem.lastChild)elem.removeChild(elem.lastChild); } window.vada.dom.queue={}; window.vada.dom.queue.redraw=function(params){ var frag=document.createDocumentFragment; for(var i=0;i<params.elements.length;i++){ (function(elem){			var d=document.createElement("div");			d.textContent=elem.text;			d.setAttribute("alt",elem.text);			d.setAttribute("title",elem.text);			d.setAttribute("class",elem.classes);			d.setAttribute("style",elem.style);			for(n in elem.data){				d.setAttribute("data-"+n,elem.data[n]);			}			d.onclick=function{window.vada.call(elem.callback,elem.params);}			frag.appendChild(d);		})(params.elements[i]); }	window.vada.dom._removeChildren(document.querySelector("#sidebar")); document.querySelector("#sidebar").appendChild(frag); } window.vada.dom.queue.builder={}; window.vada.dom.queue.builder.redraw=function(params){ window.vada.dom._removeChildren(document.querySelector("#qbsource")); for(var i=0;i<params.elements.length;i++){ (function(elem){			var o=$(document.createElement("option"));			o.text(elem.text);			o.data("input",elem.input);			o.data("callback",elem.callback);			$("#qbsource").append(o);		})(params.elements[i]); }	$("#qbsource").trigger("change"); } window.vada.dom.queue.builder.visible=function(params){ $("#sidebar").toggleClass("qb",params.visible); $("#queuebuilder").toggleClass("qb",params.visible); } window.vada.dom.queue.next=function{ $("#sidebar").children[0].click; } window.vada.dom.log=function(params){ if(typeof console!="undefined")console.log(params.text); } window.vada.dom.diff={}; window.vada.dom.diff.loadleft=function(params){ window.vada.dom.diff.lefttext=params.text; window.vada.dom.diff.leftid=params.revid; window.vada.dom.diff.leftheader=params.header; } window.vada.dom.diff.loadright=function(params){ window.vada.dom.diff.righttext=params.text; window.vada.dom.diff.rightid=params.revid; window.vada.dom.diff.rightheader=params.header; $("#editbox").val(params.text); $("#editbox").trigger("change"); } window.vada.dom.diff.redraw=function{ $("#diffcontainer").html(diffview({"baseTextName":window.vada.dom.diff.leftheader,"newTextName":window.vada.dom.diff.rightheader,"baseTextLines":window.vada.dom.diff.lefttext,"newTextLines":window.vada.dom.diff.righttext,"inline":false,"contextSize":1})[0]); } window.vada.dom.page=function(params){ $("#pagename").val(params.page); } window.vada.dom.user=function(params){ $("#username").val(params.user); } window.vada.dom.history=function(params){ var historybar=$(" "); var isprev=false; for(var i=0;i<params.history.length;i++){ with({hs:params.history[i]}){ var item=$(" "); item.html(" "); item.addClass(hs.classes); item.click(function{window.vada.call(hs.callback,hs.params);}); var hover=" "+hs.user+" "+hs.timestamp+" "+hs.sizediff+" "+hs.tags+" "+hs.comment+" "; item.append(hover); historybar.append(item); }	}	$("#history").html(historybar); } window.vada.dom.contributions=function(params){ var contributionsbar=$(" "); for(var i=0;i<params.contributions.length;i++){ var ct=params.contributions[i]; var item=$(" "); item.html(" "); item.addClass(ct.classes); /*with({c:ct}){ item.click(function{				loadrev({diff:c["diff"],user:contribs["user"],title:c['title']});			}); }*/		var hover=" "+ct.title+" "+ct.timestamp+" "+ct.sizediff+" "+ct.tags+" "+ct.comment+" "; item.append(hover); contributionsbar.append(item); }	$("#contributions").html(contributionsbar); } window.vada.dom.editbox={}; window.vada.dom.editbox.visible=function(params){ $("#editwrap").toggleClass("eb",params.visible); $("#diffcontainer").toggleClass("eb",params.visible); } window.vada.dom.editbox.setText=function(params){ $("#editbox").val(params.text); $("#editbox").trigger("change"); } window.vada.dom.summarybox={}; window.vada.dom.summarybox.setText=function(params){ $("#summarybox").val(params.text); $("#summarybox").trigger("change"); } window.vada.dom.minorbox={}; window.vada.dom.minorbox.set=function(params){ $("#minor").prop('checked',params.checked); //$("#minor").trigger('click'); } window.vada.dom.setExtraInfo=function(params){ $("#extrainfo").html(params.text); } window.vada.dom.menu={}; window.vada.dom.menu.redraw=function(params){ $("#menu").html(window.vada.dom.menu.render(params)); } window.vada.dom.menu.render=function(params){ var menu = $(""); for (var i = 0; i < params.menu.length; i++) { var item = params.menu[i]; var me = $(" "); if (item["image"]) { var img = $(" "); img.attr("src", item["image"]).attr("alt", item["text"]).attr("title", item["text"]); img.on('dragstart', function (event) {				event.preventDefault;			}); me.html(img); } else { me.html(item["text"]); }		with({				itm: item,				m: me			}) { m.click(function(evt){				if(!m.hasClass("menu-disabled"))					window.vada.call(itm["callback"],itm["params"]);			}); if (item["shortcut"]) { $(window).keyup(function (e) {					if (e.keyCode == itm["shortcut"].toUpperCase.charCodeAt) m.trigger("click");				}); };		}		var li = $(""); li.html(me); me = li; if (item["children"].length) me.append(window.vada.dom.menu.render({menu:item["children"]})); menu.append(me); }	return menu; } window.vada.heartbeat={}; window.vada.heartbeat.beating=true; window.vada.heartbeat.step=0; window.vada.heartbeat.ping=function{ if(window.vada.heartbeat.beating){ window.vada.heartbeat.beating=false; window.vada.call("heartbeat.ping",{}); } else { $("#menu ul li:first span img")[0].src="//tools.wmflabs.org/cluestuff/vada/vadalogos"+window.vada.heartbeat.step++%4+".png"; } } window.vada.heartbeat.pong=function(params){ window.vada.heartbeat.beating=true; } window.vada.heartbeat.timer=setInterval(window.vada.heartbeat.ping,1000); window.vada.plugins={}; window.vada.loadPlugin=function(plugin){ window.vada.plugins[plugin.about.namespace]=plugin; window.vada.call("loadPlugin",{plugin:plugin}); } $("link[rel='stylesheet']").remove; var css=document.createElement("link"); css.setAttribute("rel","stylesheet"); css.setAttribute("href","//tools.wmflabs.org/cluestuff/wave/style.css"); document.head.appendChild(css); document.body.innerHTML='\ \		 \			 Queue Builder \ Source:  \   \ Build Queue \ Filter \ \		 \			 \			 \				 \				 \				\ \ \			 \		 \		 \			\		 \		 \			 \			 \				 Summary: \ \					\ \				 \					 Minor: \ \ \			 \		 \		 \			 X \ Remove  from top bottom \ Remove titles matching not matching  (case insensitive ) \ Sort alphabetically \ \ '; $("#editbox").on("keyup change",function{	window.vada.dom.diff.righttext=this.value;	window.vada.dom.diff.redraw;	window.vada.call("dom.editbox.change",{text:this.value}); }); $("#summarybox").on("keyup change",function{	window.vada.call("dom.summarybox.change",{text:this.value}); }); $("#minor").on("click",function{	window.vada.call("dom.minorbox.change",{checked:$("#minor").prop('checked')}); }); $("#pagename").keypress(function(e){	if(e.which==13){		window.vada.call("events.trigger",{event:"pagename",page:this.value});	} }); $("#username").keypress(function(e){	if(e.which==13){		window.vada.call("events.trigger",{event:"username",user:this.value});	} }); $("#qbsource").change(function{	var o=$("#queuebuilder select option:selected");	if($(o).data("input")){		$("#qblbl").text($(o).data("input")+": ");		$("#qbinput").prop("disabled",false);	}else{		$("#qblbl").text("");		$("#qbinput").prop("disabled",true);	} }); $("#queuebuilder button:first").on("click",function{	var o=$("#queuebuilder select option:selected");	window.vada.call(o.data("callback"),{input:$("#qbinput").val}); }); $("#queuebuilder button:last").on("click",function{	$("#filterwindow").toggleClass("show"); }); $("#closefilterwindow").on("click",function{	$("#filterwindow").toggleClass("show",false); }); $("#trimtop").on("click",function{	window.vada.call("dom.queue.filters.trimtop",{value:$("#trimno").val}); }); $("#trimbottom").on("click",function{	window.vada.call("dom.queue.filters.trimbottom",{value:$("#trimno").val}); }); $("#rmtitlematch").on("click",function{	window.vada.call("dom.queue.filters.regexremove",{re:$("#rmre").val,case:$("#rmrecase").prop('checked')}); }); $("#rmtitlenotmatch").on("click",function{	window.vada.call("dom.queue.filters.regexonly",{re:$("#rmre").val,case:$("#rmrecase").prop('checked')}); }); $("#sortab").on("click",function{	window.vada.call("dom.queue.filters.sortab",{}); }); window.vada.call("api._edittoken",{token:mw.user.tokens.get("editToken")}); window.vada.call("events.trigger",{event:"load"}); importScript("User:A930913/vada/plugin/store.js"); importScript("Special:MyPage/vada.js");