Changeset 14405 for greenstone3


Ignore:
Timestamp:
2007-09-03T13:44:54+12:00 (17 years ago)
Author:
qq6
Message:

added javascript for getting <collection>-collection-editor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/web/interfaces/default/transform/authen.xsl

    r14357 r14405  
    2424      <xsl:call-template name="pageHead" />
    2525      <xsl:call-template name="addGroup" />
    26       <xsl:call-template name="loadGroup" />
    27       <xsl:call-template name="trans" />
    28       <body onLoad="loadGroup()" >
     26      <body>
    2927    <div id="globalwrapper">
    3028      <xsl:variable name="authen_service" select="/page/pageRequest/paramList/param[@name='s']/@value"/>
     
    375373      <tr>
    376374    <td bgcolor="#eeeeee"><xsl:value-of select="@umun"/></td>
    377     <td bgcolor="#eeeeee"><xsl:value-of select="@umas"/></td>
    378     <td bgcolor="#eeeeee"><xsl:value-of select="@umgp"/></td>
     375    <td id="status" bgcolor="#eeeeee">
     376        <script type="text/javascript">
     377          <xsl:text disable-output-escaping="yes">
     378        var status="</xsl:text><xsl:value-of select="@umas"/><xsl:text disable-output-escaping="yes">";
     379        if (status=="true"){
     380           document.getElementById("status").innerHTML="enabled";
     381        }
     382        if (status=="false"){
     383           document.getElementById("status").innerHTML="disabled";
     384        }
     385          </xsl:text>       
     386        </script>
     387      </td>
     388    <td id="group" bgcolor="#eeeeee">
     389         <script type="text/javascript">
     390          <xsl:text disable-output-escaping="yes">
     391        var groups="</xsl:text><xsl:value-of select="@umgp"/><xsl:text disable-output-escaping="yes">";
     392        var split_groups= groups.split(",");
     393        var new_groups="";
     394        for (j=0; j &lt; split_groups.length ; j++){
     395                   new_groups+=split_groups[j]+" &lt;br /&gt; ";
     396           }
     397          document.getElementById('group').innerHTML=new_groups;
     398          </xsl:text>       
     399        </script>
     400      </td>
    379401    <td bgcolor="#eeeeee"><xsl:value-of select="@umc"/></td>
    380402    <td bgcolor="#eeeeee">
     
    397419    </tr>
    398420       </xsl:for-each>
    399     </table><script type="text/javascript"><xsl:text disable-output-escaping="yes">trans();</xsl:text></script>
     421    </table>
    400422  </xsl:template>
    401423
     
    485507    <input type='hidden' name='s1.pw' value='{$pw_s}'/>
    486508   
    487     <table align="left"><tr><td>
     509    <table align="left" ><tr><td>
    488510          <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.username')"/></td><td><input type="text" name="s1.umun" size="15" value="{$umun_s}"/></td><td><font color="gray"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.username_describe')"/></font></td></tr>
    489511      <tr><td>
     
    509531      <tr>
    510532        <td></td>
    511         <td  align="right"> <select name="groups" size="0">
    512           </select></td><td><input type="button" name="addGroupButton" value="add" onClick="addGroup()"/></td>
     533        <td  align="right"> <select id="groups" size="0">
     534        <script type="text/javascript">
     535            <xsl:text disable-output-escaping="yes">
     536            var group_arr=Array("administrator","all-collections-editor","personal-collections-editor");
     537            var group_string=document.getElementById("group").value;
     538            var split_group_string=group_string.split(",");
     539            var find=0;
     540            for (i=0; i &lt; group_arr.length; i++){
     541                 find=0;
     542                 for (j=0; j &lt; group_arr.length; j++){
     543                    if (split_group_string[j]==group_arr[i]){
     544                       find=1;
     545                            }
     546                 }
     547                     if (find==0){
     548                     op = document.createElement('option');
     549                     op.innerHTML = group_arr[i];
     550                     op.setAttribute("value", group_arr[i]);
     551                     document.getElementById("groups").appendChild(op);
     552                         }
     553                }
     554           
     555          </xsl:text>       
     556        </script>
     557          </select></td><td><input type="button" name="addGroupButton" value="add" onClick="addGroup('groups')"/></td>
     558      </tr>
     559      <tr>
     560        <td></td>
     561        <td  align="right">
     562          <select  id="collects" size="0">
     563        <xsl:for-each select="/page/pageResponse/collectionList/collection">
     564          <script type="text/javascript">
     565            <xsl:text disable-output-escaping="yes">
     566              var group="</xsl:text><xsl:value-of select="@name"/>-collection-editor<xsl:text disable-output-escaping="yes">";
     567              var group_string=document.getElementById("group").value;
     568              var split_group_string=group_string.split(",");
     569              var find=0;
     570              for (i=0; i &lt; split_group_string.length; i++){
     571                  if (split_group_string[i]==group){
     572                      find=1;
     573                  }
     574              }
     575              if (find==0){
     576                  op = document.createElement('option');
     577                  op.innerHTML = group;
     578                  op.setAttribute("value", group);
     579                  document.getElementById("collects").appendChild(op);
     580              }
     581            </xsl:text>     
     582          </script>
     583         </xsl:for-each>
     584          </select>
     585        </td>
     586        <td><input type="button" name="addGroupButton" value="add" onClick="addGroup('collects')"/></td>
    513587      </tr>
    514588      <tr><td>
     
    534608    <script type="text/javascript">
    535609      <xsl:text disable-output-escaping="yes">
    536     function addGroup(){
     610    function addGroup(g){
    537611        var itemSelected;
    538612        var splitGroup;
     
    540614
    541615    if (document.getElementById("editForm")!=null){
    542         itemSelected=document.getElementById("editForm").groups.options.selectedIndex;
    543         if (document.getElementById("group").value==""){
    544             document.getElementById("group").value=document.getElementById("group").value+document.getElementById("editForm").groups.options[itemSelected].text;
    545         }else{
    546             splitGroup=document.getElementById("group").value.split(",");
    547             for (var i=0; i &lt; splitGroup.length; i++){
    548                if (splitGroup[i]==document.getElementById("editForm").groups.options[itemSelected].text){
    549                   alert(document.getElementById("editForm").groups.options[itemSelected].text + " has been added.");
    550                   groupExit=1;
    551                   break;
     616        //itemSelected=document.getElementById("editForm").groups.options.selectedIndex;
     617        itemSelected=document.getElementById(g).options.selectedIndex;
     618        if (document.getElementById(g).options[itemSelected].text!=""){
     619           if (document.getElementById("group").value==""){
     620               document.getElementById("group").value=document.getElementById("group").value+document.getElementById(g).options[itemSelected].text;
     621           }else{
     622               splitGroup=document.getElementById("group").value.split(",");
     623               for (var i=0; i &lt; splitGroup.length; i++){
     624                  if (splitGroup[i]==document.getElementById(g).options[itemSelected].text){
     625                      alert(document.getElementById(g).options[itemSelected].text + " has been added.");
     626                      groupExit=1;
     627                      break;
     628                  }
    552629               }
    553             }
    554             if (groupExit!=1) {
    555                document.getElementById("group").value=document.getElementById("group").value+","+document.getElementById("editForm").groups.options[itemSelected].text;
    556             }
    557         }
    558         document.getElementById("editForm").groups.options[itemSelected]=new Option("",itemSelected);
    559     }
    560     }
    561       </xsl:text>
    562     </script>   
    563   </xsl:template>
    564 
    565 <!-- loadGroup() javascript -->
    566   <xsl:template name="loadGroup">
    567     <script type="text/javascript">
    568       <xsl:text disable-output-escaping="yes">
    569     function loadGroup(){
    570       // three constant group "administrator","all-collections-editor","personal-collections-editor"
    571 
    572     var group_arr=Array("administrator","all-collections-editor","personal-collections-editor");
    573     var find;
    574    
    575     if (document.getElementById("editForm")!=null){
    576        document.getElementById("editForm").groups.length=3;
    577        if (document.getElementById("group").value=="") {
    578           for (i=0; i &lt; 3;i++){
    579           document.getElementById("editForm").groups.options[i]=new Option(group_arr[i],i);
    580           }
    581        }else{
    582          var group_string=document.getElementById("group").value;
    583          var split_group_string=group_string.split(",");
    584          for (i=0; i &lt; 3; i++){
    585             find=0
    586             for (j=0; j &lt; split_group_string.length ; j++){
    587               if (split_group_string[j]==group_arr[i]){
    588                      find=1;
    589                      //break;
    590                   }
    591             }
    592             if (find==0){
    593                    document.getElementById("editForm").groups.options[i]=new Option(group_arr[i],i);
    594                 }
    595          }
    596       }
    597     }
    598     }
    599       </xsl:text>
    600     </script>   
    601   </xsl:template>
    602 
    603 <!-- trans() javascript translates "true" to enable, "false" to "disable", splits groups into lines-->
    604   <xsl:template name="trans">
    605     <script type="text/javascript">
    606       <xsl:text disable-output-escaping="yes">
    607     function trans(){
    608       // trnasform "true" to "enabled", "false" to "disabled" for 'account status', and split one line of groups into several lines
    609        if (document.getElementById('mainTable')!=null){
    610        var num= document.getElementById('mainTable').getElementsByTagName('tr').length;
    611        for (i=1; i &lt; num; i++){
    612            if (document.getElementById('mainTable').getElementsByTagName('tr')[i].cells[1].innerHTML=="true"){
    613                    document.getElementById('mainTable').getElementsByTagName('tr')[i].cells[1].innerHTML="enabled";
     630               if (groupExit!=1) {
     631                  document.getElementById("group").value=document.getElementById("group").value+","+document.getElementById(g).options[itemSelected].text;
     632               }
    614633           }
    615            if (document.getElementById('mainTable').getElementsByTagName('tr')[i].cells[1].innerHTML=="false"){
    616                    document.getElementById('mainTable').getElementsByTagName('tr')[i].cells[1].innerHTML="disabled";
    617            }
    618           var groups=document.getElementById('mainTable').getElementsByTagName('tr')[i].cells[2].innerHTML;
    619           var split_groups= groups.split(",");
    620           var new_groups="";
    621           for (j=0; j &lt; split_groups.length ; j++){
    622                    new_groups+=split_groups[j]+" &lt;br /&gt; ";
    623            }
    624           document.getElementById('mainTable').getElementsByTagName('tr')[i].cells[2].innerHTML=new_groups;
     634           document.getElementById(g).options[itemSelected]=new Option("",itemSelected);
    625635       }
    626636    }
Note: See TracChangeset for help on using the changeset viewer.