Location: PHPKode > projects > NetLink > netlink_os/egap/link.php
<?php
###########################
#Rotide Egap v1.5
#Created/Revised: 02242005
#Creator: Kyle M. Perkins
###########################
session_start();
if (!isset($_SESSION['login']))
 {include("index.php");
 exit();}
?>

<head>
<title>
Rekam Knil&copy; - Rotide Egap
</title>
<style type='text/css'>
.spacer{
  font-weight: bold;
}
#sel_text{
  width: 100%;
  color: #333;
}
</style>
<script type='text/javascript'>
function alert_call(){
  var link_text=window.opener.window.getSelection();
  if (link_text!=""){
    document.getElementById("sel_text").value=link_text;
    document.getElementById("sel_text").disabled=true;
    document.getElementById("sel_text").style.background='#ccc';
  }
  PRE_ID="";
}
function load_link(){
  link_to=document.getElementById("link_to").value;
  if (link_to=="url")
    document.getElementById("link").innerHTML="http://<input type='text' id='url_link' style='width: 93%;'></input>";
  else if (link_to=="mail")
    document.getElementById("link").innerHTML="E-Mail Address:<input type='text' id='mail_link' style='width: 82%;'></input>";
  else{
    document.getElementById("link").innerHTML="<?php include('file_list.php'); ?>";
    preview();
  }
}
function create_link(){
  
  text=document.getElementById("sel_text").value;
  if (document.getElementById("link_to").value=="url"){
    address=document.getElementById("url_link").value;
    code="<a href='http://"+address+"'>"+text+"</a>";
  }
  else if (document.getElementById("link_to").value=="mail"){
    address=document.getElementById("mail_link").value;
    code="<a href='mailto:"+address+"'>"+text+"</a>";
  }
  else{
    file=document.getElementById("file_name").value;
    file=file.replace(" ","%20");
    code="<a href='http://netlink.kaibasoftware.com/Users/<?php echo $login;?>/"+file+"'>"+text+"</a>";   
  }
  string=window.opener.window.getSelection();
  
  //alert("DOCUMENT:\n\""+document.getElementById("sel_text").value+"\"\n\nSTRING:\n\""+string+"\"")
  
  opener_code = new String(window.opener.document.getElementById("preview").innerHTML);
  if (document.getElementById("sel_text").value==string){
    //alert("DISABLED");
    //alert("Selection:\n\""+string+"\"\nCode:\n\""+code+"\"");
    //alert("Opener_code1:\n"+opener_code);
    link_text=opener_code.replace(window.opener.window.getSelection(), code);
    //alert("Opener_code2:\n"+link_text);
  
    window.opener.document.getElementById("preview").innerHTML=link_text;
    window.opener.document.getElementById("egap_b_code").value=link_text;
    //alert(window.opener.document.getElementById("preview").innerHTML);
   }
  else{
    //alert("ELSE");
    window.opener.document.getElementById("preview").innerHTML+=code;
    window.opener.document.getElementById("egap_b_code").value=window.opener.document.getElementById("preview").innerHTML;
  }
  window.opener.document.getElementById("saved").innerHTML="<span style='color: #CC0000;'>Not Saved</span>"
  window.close();
}
function preview(){
  file=document.getElementById("file_name").value;
  document.getElementById("preview").innerHTML="<a href='http://netlink.kaibasoftware.com/Users/<?php echo $login;?>/"+file+"' class='under' target='_blank'>Preview "+file+"</a>";
}
</script>
</head>

<body onload='alert_call(), load_link();'>
<link media="screen" type="text/css" rel="stylesheet"  href="../main.css" />
<div align='center'>
<img src='pix/rekam.png' alt=''/><br/>
c/o R<small>OTIDE</small> E<small>GAP</small>
</div>
<br/>
<form method='post' action='javascript:create_link();'>
  <div style='font-size: 10pt;'>
    Link Text:<br/>
    <input type='text' id='sel_text'>
    </input>
    <br/>
    
    Link to:
    <br/>
    <select id='link_to' onchange='javascript:load_link();'>
      <option value='url'>Web Address</option>
      <option value='mail'>E-Mail</option>
      <option value='myfile'>My Own File</option>
    </select>
    <div id='link'>
    </div>
  </div>
    <div align='center'>
      <input type='submit' value='Make Link' style='font-weight: bold'/>&nbsp;&nbsp;&nbsp;<button onclick='javascript:window.close()'>Close</button>
    </div>
  </div>
</form>
Return current item: NetLink