_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:Theleekycauldron/Scripts/PSHAW/protocols/hook mover.js

This article will address the topic of User:Theleekycauldron/Scripts/PSHAW/protocols/hook mover.js, which has captured the attention of researchers, experts and the general public. User:Theleekycauldron/Scripts/PSHAW/protocols/hook mover.js is a topic that has sparked interest due to its relevance in today's society, its implications in different areas and its impact on people's daily lives. Along these lines, different aspects related to User:Theleekycauldron/Scripts/PSHAW/protocols/hook mover.js will be explored, addressing its origin, evolution, characteristics, consequences and possible solutions. In addition, recent studies, expert opinions and experiences related to User:Theleekycauldron/Scripts/PSHAW/protocols/hook mover.js will be presented, with the aim of providing a comprehensive and enriching vision on this topic.
/*<nowiki>
Copyright (c) 2023 theleekycauldron

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
$.when(
	mw.loader.using('ext.gadget.morebits'),
	$.ready
).then(async function() {
	console.log("ready!");
	if (mw.config.get('wgPageName').includes("Template:Did_you_know_nominations/")) {
		$(mw.util.addPortletLink(window.DYKH_portlet || 'p-cactions', '#', 'Promote (PSHAW)', 'dyk-portlet', 'Close nomination')).click(promote);
	}
});

promote = async function (e) {
	origin = new Prep(mw.config.get('wgPageName'));
	//nomtext = nomtext.replaceAll(/<s>.*?<\/s>/g,"");
	e.preventDefault();
	var Window = new Morebits.simpleWindow(900, 800);
	Window.setTitle("The prep set's half-assed workbench (PSHAW)");
	Window.addFooterLink("DYK promoter's rules", "Wikipedia:Did you know/Prep builder instructions");
	var form = new Morebits.quickForm();
	
	//prep and queue selection
	
	form.append({type: 'select',name: 'area',label: 'Transport hook to:',list: });
	form.append({type: 'number',name: 'pqid',label: 'Prep/queue number:',min: 1,max: 7,step: 1})
	
	// render
	let result;
	function show(){
		result = form.render();
		Window.setContent(result);
		Window.display();
	}
	
	show();
	
	// load up the prep/queue
	
	let firstLoad = true;
	
	form.append({type: 'button',name: 'load', label: 'Load prep/queue', event: load});
	
	async function load(){
		console.log("howdy :)");
		let pagename = result.area.value+result.pqid.value;
		
		let nextpreppage = await get_pages("Template:Did you know/Queue/NextPrep","user|content",null,"older");
		await nextpreppage;
		let nextpreptext = nextpreppage.revisions.slots.main.content;
		let previousprep = (parseInt(nextpreptext-2)%7+1).toString();
		
		let dolastprepmessage = previousprep == result.pqid.value;
		
		console.log(form);
		form.root.childs.data.disabled = true; //disable button
		show(); //reload while button is being disabled
		if (firstLoad){ //these should only be done once
			form.append({type: 'div', name: 'hooktopromote', label: '<b>Hook to move: </b>'})
			form.append({type: 'radio', name: 'nomhooks', list: });
			form.append({type: 'div', name: 'preppagename', label: "<b>]</b>"})
			form.append({type: 'radio', name: 'prephooks', label: 'Hooks:', list: });
		} else { //update prepnum
			form.root.childs.data.label = "<b>]</b>";
		}
		
		prep = new Prep(pagename);
		await prep.initialize();
		
		form.root.childs.data.list = prep.morebits();
		console.log(origin.hooks);
		form.root.childs.data.list = origin.morebits();
		
		if (firstLoad){
			form.append({type: 'div', name: 'lastprepmessage', label: ""});
			form.append({type: 'button', name: 'submit', label: 'submit!', event: function l(){evaluate(e, result)}});
		}
		
		form.root.childs.data.label = (dolastprepmessage)?"<i>This appears to be the bottom prep set – per ], try to leave the image slot, quirky slot, and at least two middle slots open for bumps and replacements!</i>":"";
		
		firstLoad = false;
		form.root.childs.data.disabled = false; //re-enable button
		show();
	}
	show();
	
	evaluate = async function (e, result){
		console.log(result)
		let slotnum = JSON.parse(result.prephooks.value).id;
		if (slotnum == ""){
			alert("Which slot is this hook going in?");
			return;
		}
		
		let hook = JSON.parse(result.nomhooks.value);
		if (hook.content == ""){
			alert("You gotta pick a hook!");
			return
		}
		
		if (imgfile==""){ //scrub ''(pictured)'' from hook if no image
			hook.content = hook.content.replace(/''\(.*?\)''/,"");
		}
		
		form.root.childs = ;
		
		form.append({type: 'div', name: 'Promoting hook', label: 'pulling from ]... '})
		form.append({type: 'div', name: 'Closing nomination', label: 'moving to ]... '})
		
		show();
		
		if (prep.hooks.text != "... that ..."){
			origin.addHook(prep.hooks,result.nomhooks.value,)
		}
		
		prep.addHook(hook,slotnum,prep.file);
		prep.assemble()
		nomination.hat("yes",prep.title);
		
		await prep.save("pulling hook from ]").done(function(data){
			form.root.childs.data.label += 'done! :)';
			console.log(form.root.childs);
			show();
		});
	
		await origin.save("moving hook to ]").done(function(data){
			console.log(data)
			form.root.childs.data.label += 'done! :)';
			show();
			location.reload(true);
		});
	}
	
}
// </nowiki>