use strict;return sub{my $this = shift;my $C = $this->{C};$this->out("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title>Links Directory Category Editor</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n</head>\n<body>\n\n");$C->{EditorId} = "LinkdirCatsEditor$C->{INPUT}{linkdir_id}";$this->out("");$C->{EditorBaseURL} = "/action/Jin/Linkdir/Web/cats_editor.html?linkdir_id=$C->{INPUT}{linkdir_id}";$this->out("\n<script>\n\nfunction InsertNew()\n{\n	var CatsList = document.getElementById(\'CatsList\');\n	\n	var title = prompt(\'Please enter a title of a new category:\', \'\');\n	\n	if( title == undefined ){return;}\n	\n	if( title.search(/,/) != -1 ){alert(\'Category name cannot include commas\'); return; }\n	\n	title = title.replace(/^\\s+/, \'\');\n	title = title.replace(/\\s+\$/, \'\');\n	\n	if( title == \'\' ){alert(\'The title of a category cannot be empty\'); return; }\n	\n	jinAjaxLoadContent(\'$C->{EditorId}\', \'$C->{EditorBaseURL}&do=new&title=\' + escape(title)\n		+ \'&pos=\' + CatsList.selectedIndex\n	);\n}\n\nfunction Rename()\n{\n	var CatsList = document.getElementById(\'CatsList\');\n	\n	if( CatsList.selectedIndex < 0 ){ alert(\'Please select a category in the list\'); return; }\n	\n	var title = prompt(\'Please enter a new title for category \' + CatsList.options[CatsList.selectedIndex].text + \':\', CatsList.options[CatsList.selectedIndex].text);\n	\n	if( title == undefined ){return;}\n	\n	if( title.search(/,/) != -1 ){alert(\'Category name cannot include commas\'); return; }\n	\n	title = title.replace(/^\\s+/, \'\');\n	title = title.replace(/\\s+\$/, \'\');\n	\n	if( title == \'\' ){alert(\'The title of a category cannot be empty\'); return; }\n	\n	jinAjaxLoadContent(\'$C->{EditorId}\', \'$C->{EditorBaseURL}&do=rename&title=\' + escape(title)\n		+ \'&pos=\' + CatsList.selectedIndex\n	);\n} \n\nfunction Move(dir)\n{\n	var CatsList = document.getElementById(\'CatsList\');\n	\n	if( CatsList.selectedIndex < 0 ){ alert(\'Please select a category in the list\'); return; }\n	\n	var newpos = (dir == \'up\' ? CatsList.selectedIndex - 1 : CatsList.selectedIndex + 1);\n	\n	jinAjaxLoadContent(\'$C->{EditorId}\', \'$C->{EditorBaseURL}&do=swop\' \n		+ \'&newpos=\' + (newpos < 0 || newpos > CatsList.options.length - 1 ? -1 : newpos)\n		+ \'&pos=\' + CatsList.selectedIndex\n	);\n}\n\nfunction Delete()\n{\n	var CatsList = document.getElementById(\'CatsList\');\n	\n	if( CatsList.selectedIndex < 0 ){ alert(\'Please select categories in the list\'); return; }\n	\n	var selTitle = new Array(), selPos = new Array();\n	\n	for(n = 0; n < CatsList.options.length; n++)\n	{\n		if( ! CatsList.options[n].selected ){continue;}\n		\n		selTitle.push(CatsList.options[n].text);\n		selPos.push(n);\n	}\n	\n	if( ! confirm(\'Are you sure you want to delete \' \n		+ ( selTitle.length > 1 ? \'categories\' : \'category\' ) \n		+ \': \' + selTitle.join(\', \') + \'?\' ) \n	){return;}\n	\n	jinAjaxLoadContent(\'$C->{EditorId}\', \'$C->{EditorBaseURL}&do=del&pos=\' + CatsList.selectedIndex + \'&selpos=\' + selPos.join(\',\'));\n}\n\nfunction SelectCategory(pos)\n{\n	var CatsList = document.getElementById(\'CatsList\');\n	CatsList.selectedIndex = pos;\n}\n\nSelectCategory($C->{pos});\n\n</script>\n\n\n<input type=\"hidden\" name=\"categories\" value=\"\">\n\n<table class=\'atkEditorRight\'>\n<tr>\n	<td valign=\"top\">\n		<select id=\"CatsList\" multiple size=\"$C->{Size}\">\n");my $in = $C->{Cats};my $loop = ref($in) eq "ARRAY" ? $in : ref($in) eq "CODE" ? &{$in} : [];$C->{ITERATION}{i} = -1;for my $f (@$loop) {$C->{ITERATION}{i}++;$C->{i} = $f;$this->out("				<option>$C->{i}</option>\n");}$this->out("		</select>\n	</td>\n	<td valign=\"top\">\n		<table class=\"atkEditorRight\">\n			<tr>\n				<td>Edit:</td>\n				<td><nobr>\n					<input type=\"button\" class=\"\"btn btn-primary\"\" onClick=\"InsertNew()\" value=\"Insert new\">\n					<input type=\"button\" class=\"\"btn btn-primary\"\" onClick=\"Rename()\" value=\"Rename\">\n					<input type=\"button\" class=\"\"btn btn-primary\"\" onClick=\"Delete()\" value=\"Delete\">\n				</nobr></td>\n			</tr>\n			<tr>\n				<td>Move:</td>\n				<td>\n					<input type=\"button\" class=\"\"btn btn-primary\"\" onClick=\"Move(\'up\')\" value=\"Up\">\n					<input type=\"button\" class=\"\"btn btn-primary\"\" onClick=\"Move(\'down\')\" value=\"Down\">\n				</td>\n			</tr>\n		</table>\n");if ( $C->{Error} ) {$this->out("			<div style=\"color:red\">* $C->{Error}</div>\n");}$this->out("	</td>\n</tr>\n</table>\n\n</body>\n</html>\n");}