Difference between revisions of "Physics307L:People/Weiss"

From OpenWetWare
Jump to: navigation, search
(New page: <html> <script type="text/javascript"> String.prototype.capitalize = function(){ return this.replace(/\w+/g, function(a){ return a.charAt(0).toUpperCase() + a.substr(1).toLowe...)
 
m (Reverted edits by David J Weiss (Talk) to last version by Bill Flanagan)
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
<OneClick />
 
<html>
 
<html>
<script type="text/javascript">
 
String.prototype.capitalize = function(){
 
    return this.replace(/\w+/g, function(a){
 
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
 
    });
 
};
 
function getArgs() {
 
    var args = new Object();
 
    var query = location.search.substring(1);  // Get query string.
 
    var pairs = query.split(",");              // Break at comma.
 
    for(var i = 0; i < pairs.length; i++) {
 
var pos = pairs[i].indexOf('=');      // Look for "name=value".
 
if (pos == -1) continue;              // If not found, skip.
 
var argname = pairs[i].substring(0,pos);  // Extract the name.
 
var value = pairs[i].substring(pos+1); // Extract the value.
 
args[argname] = unescape(value);          // Store as a property.
 
    }
 
    return args;                              // Return the object.
 
}
 
function isLoggedIn(){
 
  if (wgUserName == null){
 
    return false;
 
  }
 
  return true;
 
}
 
function changeDisplayById(id,val){
 
  if (document.getElementById){
 
    var nodeObj = document.getElementById(id);
 
    var display='none';
 
    if (val == 'on'){
 
      display = 'table-row';
 
    } 
 
    nodeObj.style.display = display;
 
  }
 
}
 
function EntryCheck(){
 
if (!document.forms.OneClick.Project.value){
 
  alert('Project must be specified');
 
  return false;
 
}
 
var opt = document.forms.OneClick.Type.selectedIndex;
 
var type = document.forms.OneClick.Type.options[opt];
 
switch (type.value){
 
  case 'IGEM':
 
    if (!document.forms.OneClick.Institution.value){
 
      alert('Institution must be specified');
 
      return false;
 
    }
 
    break;
 
  case 'USER':
 
    break;
 
  default:
 
  case 'LAB':
 
    if (!document.forms.OneClick.Lab.value){
 
      alert('Lab name must be specified');
 
      return false;
 
    }
 
    break;
 
}
 
return true;
 
}
 
function MakePageName(){
 
  var igem = 'IGEM';
 
  var user = 'User';
 
  var notebook = 'Notebook';
 
  var igemYear = '2008';
 
  var project = document.forms.OneClick.Project.value;
 
  var inst = document.forms.OneClick.Institution.value;
 
  var lab = document.forms.OneClick.Lab.value;
 
  if (project){
 
    project = project.capitalize();
 
  }
 
  document.forms.OneClick.Username.value = wgUserName;
 
  var opt = document.forms.OneClick.Type.selectedIndex;
 
  var type = document.forms.OneClick.Type.options[opt];
 
  var url = '';
 
  switch (type.value){
 
    case 'IGEM':
 
      changeDisplayById('LabRow','off');
 
      changeDisplayById('ProjectRow','on');
 
      changeDisplayById('InstitutionRow','on');
 
      if (inst.length == 0 || project.length == 0)
 
        url= '';
 
      else
 
        url = igem+':'+inst+'/'+igemYear+'/'+notebook+'/'+project;
 
      break;
 
    case 'USER':
 
      changeDisplayById('LabRow','off');
 
      changeDisplayById('ProjectRow','on');
 
      changeDisplayById('InstitutionRow','off');
 
      if (project.length == 0)
 
        url= '';
 
      else
 
        url = user+':'+wgUserName+'/'+ notebook+'/'+project;
 
      break;
 
    case 'LAB':
 
      changeDisplayById('LabRow','on');
 
      changeDisplayById('ProjectRow','on');
 
      changeDisplayById('InstitutionRow','off');
 
      if (lab.length == 0 || project.length == 0)
 
        url= '';
 
      else
 
        url = lab +':'+notebook+'/'+project;
 
      break;
 
  }
 
  return url;
 
}
 
function ShowURL(){
 
    if (!isLoggedIn()){
 
      alert ('You must be logged in to create a new Notebook.');
 
      window.location = "/wiki/Special:Userlogin&returnto=Help:Notebook/One_Click_Setup";
 
    }
 
    var currentURL = MakePageName();
 
    document.getElementById('DisplayURL').innerHTML=currentURL;
 
    return true;
 
}
 
function loadMessage(){
 
  var args = getArgs();
 
  if (args.Message){
 
    changeDisplayById('form_body','off');
 
    var nodeObj = document.getElementById('message_body');
 
    nodeObj.style.verticalAlign='middle';
 
    nodeObj.style.width='600px';
 
    nodeObj.style.height='120px';
 
    if (args.Error == null){
 
      nodeObj.style.backgroundColor='#e5edc8';
 
      nodeObj.innerHTML=
 
        "<img src='/images/f/f8/Owwnotebook_icon.png' style='float: left;' " +
 
          "  alt='Owwnotebook_icon.png' /><br />"+
 
        "<span style=\"font-size: 20px; font-weight: bold;\">Success!</span><br />"+args.Message;
 
    }else{
 
      nodeObj.style.backgroundColor='#e0bcc1';
 
      nodeObj.innerHTML=
 
        "<img src='/images/f/f8/Owwnotebook_icon.png' style='float: left;' " +
 
        "  alt='Owwnotebook_icon.png' /><br />"+
 
        "<span style=\"font-size: 20px; font-weight: bold;\">Error</span><br />"+args.Message;
 
    }
 
    return true;
 
  }
 
  return false;
 
}
 
</script>
 
 
<div id="form_body" class="forms_body">
 
<div id="form_body" class="forms_body">
 
<form action="/um/um_process_oneclick.php" name="OneClick"  
 
<form action="/um/um_process_oneclick.php" name="OneClick"  
 
     id="OneClick" onsubmit="return EntryCheck();" method="POST">
 
     id="OneClick" onsubmit="return EntryCheck();" method="POST">
 
<input type="hidden" name="Username" value="" />
 
<input type="hidden" name="Username" value="" />
 +
<input type="hidden" name="CurrentURL" value="" />
 
<table class="forms_table" width="100%" border="0" cellpadding="5" cellspacing="0">
 
<table class="forms_table" width="100%" border="0" cellpadding="5" cellspacing="0">
 
   <tr>
 
   <tr>
Line 159: Line 19:
 
         <option value="LAB">Lab</option>
 
         <option value="LAB">Lab</option>
 
       </select>
 
       </select>
 +
 
       <div class="forms_style1">
 
       <div class="forms_style1">
 
       Select the type of notebook to be created.<br />
 
       Select the type of notebook to be created.<br />
Line 166: Line 27:
 
       </div>
 
       </div>
 
     </td>
 
     </td>
 +
<td valign="top" align="right" width="250px">
 +
<a href="http://openwetware.org/wiki/Help:Notebook">What's an OpenWetWare Lab Notebook?</a>
 +
</td>
 
   </tr>
 
   </tr>
 
   <tr id='ProjectRow'>
 
   <tr id='ProjectRow'>
Line 214: Line 78:
 
     </td>
 
     </td>
 
     <td valign="top" align="left">
 
     <td valign="top" align="left">
       <span class="forms_style1"><span id="DisplayURL"></span><br />
+
       <span class="forms_style1"><span id="DisplayURL" style="color:#336699; background-color:#D3DCE5; text-decoration:underline; padding:4px;"></span><br />
       This is the full OWW page of the notebook to be created.</span><span onclick="ShowURL()"> Update</span>
+
       This is the full OWW page of the notebook to be created. </span><span onclick="ShowURL()" style="border:#CCCCCC 1px solid; padding:2px; background-color:#EEEEEE;">Update</span>
 
     </td>
 
     </td>
 
   </tr>
 
   </tr>
Line 238: Line 102:
 
}
 
}
 
</script>
 
</script>
 +
</html>
 +
[[category:OWWLabNotebookV1]]

Latest revision as of 14:41, 4 September 2009

<OneClick /> <html> <div id="form_body" class="forms_body"> <form action="/um/um_process_oneclick.php" name="OneClick"

   id="OneClick" onsubmit="return EntryCheck();" method="POST">

<input type="hidden" name="Username" value="" /> <input type="hidden" name="CurrentURL" value="" /> <table class="forms_table" width="100%" border="0" cellpadding="5" cellspacing="0">

 <tr>
   <td class="forms_style2">
     <span class="forms_label">
       Notebook Type:
     </span>
   </td>
   <td valign="top" align="left">
     <select name="Type" onchange='ShowURL();' id="Type">
       <option value="IGEM">IGEM</option>
       <option value="USER">User</option>
       <option value="LAB">Lab</option>
     </select>
     <div class="forms_style1">
     Select the type of notebook to be created.<br />
     IGEM: Create a notebook used to support an IGEM project<br />
     User: Create a notebook which will be rooted in your user page<br />
     Lab: Create a notebook for your lab<br />
     </div>
   </td>

<td valign="top" align="right" width="250px"> <a href="http://openwetware.org/wiki/Help:Notebook">What's an OpenWetWare Lab Notebook?</a> </td>

 </tr>
 <tr id='ProjectRow'>
   <td class="forms_style2">
     <span class="forms_label">Project Name: </span>
   </td>
   <td valign="top" align="left">
     <span class="forms_style1">
     <input type="text" name="Project" onclick="ShowURL();" onblur="ShowURL();" value="" class="forms_format" size="30"/>
     <br />
     Enter the name of the project this notebook is being created for. 
     All notebooks must have a project name</span>
   </td>
 </tr>
 <tr id='InstitutionRow'>
   <td class="forms_style2">
     <span class="forms_label">
       University/Institute: 
     </span>
   </td>
   <td valign="top" align="left">
     <span class="forms_style1">
     <input type="text" onblur="ShowURL();" onclick="ShowURL();" size="30" class="forms_format" name="Institution" /><br />
     Please enter the name of your IGEM Team. 
     If your team has not been registered, do so before creating a notebook
     </span>
   </td>
 </tr>
 <tr id='LabRow'>
   <td class="forms_style2">
     <span class="forms_label">
       Lab Name: 
     </span>
   </td>
   <td valign="top" align="left">
     <span class="forms_style1">
     <input type="text" onblur="ShowURL();" onclick="ShowURL();" size="30" class="forms_format" name="Lab" /><br />
     Please enter the name of your Lab. 
     If your Lab's main pages has not been created, do so before creating a notebook
     </span>
   </td>
 </tr>
 <tr>
   <td class="forms_style2">
     <span class="forms_label">
       Page Name: 
     </span>
   </td>
   <td valign="top" align="left">
     <span class="forms_style1"><span id="DisplayURL" style="color:#336699; background-color:#D3DCE5; text-decoration:underline; padding:4px;"></span><br />
     This is the full OWW page of the notebook to be created. </span><span onclick="ShowURL()" style="border:#CCCCCC 1px solid; padding:2px; background-color:#EEEEEE;">Update</span>
   </td>
 </tr>
 <tr>
   <td align="left">&nbsp;</td>
   <td align="left">
     <input type="submit" class="forms_button" name="OneClickSubmit" value="Submit!" />
   </td>
 </tr>
 <tr id='MessageRow'>
   <td colspan=2 class="forms_style2">
     <span class="forms_style1"><span id="Message"></span></span>
   </td>
 </tr>

</table> </form> </div> <div id="message_body"></div> <script type="text/javascript"> if (!loadMessage()){

 ShowURL();

} </script> </html>