Location: PHPKode > scripts > Bioloide > botlane/setup.php
<?php
session_start(); 
include_once("authorize.php");	
$registered = false;
if(file_exists($users))
{
   $registered= authorize($_SESSION["login"], $_SESSION["password"]);
}
if(!$registered)
{
  echo "Must be called from the main program (index.php)<br>";
  echo "This message may be displayed if the registration process failed, too.<br>";
  $host  = $_SERVER['HTTP_HOST'];
  $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
  die("<br><a href=\"index.php\">index.php</a>");
}  

$tablist = file("tabs-list.txt");
$toolist = array();
foreach($tablist as $line)
{
  $pos = strpos($line,",");
  $k = substr($line, 0, $pos);
  $v = substr($line, $pos + 1);
  $toolist[$k] = $v; 
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Setup</title>
<meta name="robots" content="none" />
<link type="text/css" href="script.css" rel="stylesheet">

<script type="text/javascript" src="anaa.js"></script>
<script type="text/javascript">

	function setTool()
	{
		var selected = document.configure.toolist.selectedIndex;
		var title = document.configure.toolist[selected].text;
		var value = document.configure.toolist[selected].value;

		document.getElementById("selname").innerHTML = "Delete " + title;
		document.configure.title.value = title;
		document.configure.url.value = value;
	}

	function cleartool()
	{
		document.configure.title.value="";
		document.configure.url.value="";
	}

	function addtool()
	{
		var tools = document.forms[0].toolist;

		var title = document.configure.title.value;
		var url = document.configure.url.value;

		var size = tools.options.length;
		tools.options[size] = new Option(title);
		tools.options[size].value = url;

		dispsize(0);

	}

	function deltool()
	{
		var tools = document.forms[0].toolist;
		var selected = tools.selectedIndex;
		var size = tools.options.length;

		var titles = new Array();
		var urls = new Array();

		for(i = 0; i < size; i++)
		{
			if(i == selected)  continue;
			titles.push(tools.options[i].text);
			urls.push(tools.options[i].value);
		}

		size--;
		for(i = 0; i < size; i++)
		{
			tools.options[i].text = titles[i];
			tools.options[i].value = urls[i];
		}

		tools.options[size].text = "<deleted>";
		tools.options[size].value = "";

		dispsize(size);
	}

	function moveup()
	{
		var tools = document.forms[0].toolist;
		var i = tools.selectedIndex;

		if(i == 0) return; // can't move

		var title = tools.options[i-1].text;
		var url = tools.options[i-1].value;
		tools.options[i-1].text = tools.options[i].text;
		tools.options[i-1].value = tools.options[i].value;
		tools.options[i].text = title;
		tools.options[i].value = url;

	}




	function dispsize(forcesize)
	{
		var tools = document.forms[0].toolist;
		var size = tools.options.length;
		if(forcesize > 0) size = forcesize;
		var ts = document.getElementById("toolsize");
		ts.innerHTML = size;

	}

  function info(element, res)
  {
	element.form.action = "index.php";
	element.form.submit()
  }

function TabWrite(data, fun, element)
{ 
	var xhr = AACreate();

	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			if(fun != null) fun(element, xhr.responseText);
		}
	}; 
	xhr.open("POST", "tabs-save.php", true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send(data); 
} 

	function savelist(element)
	{
		var title = "";
		var url = "";
		var data = "";

		var tools = document.forms[0].toolist;
		var size = tools.options.length;

		for(i = 0; i < size; i++)
		{
			title =tools.options[i].text;
			if(title == "") continue;
			if(title == "<deleted>") continue;

			url = tools.options[i].value;
			if(url == "") continue;
			
			if(data != "") data +="&";
			data += "tab" + String(i) + "=" + title + "," + url;
		}    	 
	
	 //alert(data);
	 TabWrite(data, info, element);
 		
	}
	
	function cancelall(element)
	{
	   element.form.action = "index.php";
  	 element.form.submit();
  }
	
	
	

window.onload=dispsize;

</script>


</head>

<body>
<div id="content">
<h1>Bot Lane - Configure</h1>
<p>Setting up the list of tools to include in tabs</p>
<p>There are <span id="toolsize"></span> tools in tabs. </p>
<br />

<fieldset>
<legend>Interface to List of Tabs </legend>

<br />

<form id="configure" name="configure" method="post" action="">

  <table width="743" border="0" cellspacing="0" cellpadding="8">
    <tr>
      <td width="223" rowspan="2">
        <div align="center">
          <select name="toolist" if="toolist"  style="width:180px" multiple onchange="setTool();" title="List of tabs and related tools">
          
<?php

reset($toolist);
while($url = current($toolist))
{
  $title = key($toolist);
  echo '<option value="'.$url.'">'.$title.'</option>\n';
  next($toolist);
}

?>          
          
          </select>
        </div></td>
<td width="488">

  <table width="467" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td width="134" rowspan="2"><input type="button" name="add"  style="width:120px" value="Add a Tool" onclick="addtool()" title="Create a new tab in the tab panel" />
        <br />
    </td>
      <td width="319">Label  
        <input name="title" type="text" id="title"  value="" size="24" title="Type a label for the tab" />
        <input type="button" name="clear" value="X"  onclick="cleartool()" title="Clear label and url fields" /></td>
    </tr>
    <tr>
      <td>URL 
        <input name="url" type="text" id="url" size="40" title="Type the filename of the tool" /></td>
    </tr>
  </table>
 

</td>
    </tr>
    <tr>
      <td>
        <table width="468" border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td width="460"><input type="button" name="del"  style="width:120px" value="Delete Selected" onclick="deltool()" title="Remove the selected tool from the tabpanel" />
              <span name="selname" id="selname" style="margin-left:16px" title="Label of the tab to remove">Nothing selected</span></td>
            </tr>
        </table>
        <br />
        <table width="468" border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td width="460"><input type="button" name="del2"  style="width:120px" value=" Selected Up" onclick="moveup()" title="Remove the selected tool from the tabpanel" />
                <span name="selname" id="selname" style="margin-left:16px" title="Move up the selected name">Move up selected</span></td>
          </tr>
        </table></td>
    </tr>
  </table>
<br />
  <p>
    <div align="center">
      <input type="button" name="SubmitSave" value="Save and Restart Bot Lane" title="Save the list in a file to be used by the tabpanel" onclick="savelist(this)" />
      <input type="button" name="SubmitCancel" value="Cancel - Return to Bot Lane " title="Cancel any change and load the tabpanel" onclick="cancelall(this)" />
    </div>
  </p>

</form>

<p><br /></p>
 </fieldset>


</div>
<div id="footer">
(c) 2009 Scriptol.com
</div>
</body>
</html>
Return current item: Bioloide