www/common/select_color.jsp

Code
Comments
Other
Rev Date Author Line
2733 16 Oct 06 nicklas 1 <%-- $Id$
2733 16 Oct 06 nicklas 2   ------------------------------------------------------------------
3675 16 Aug 07 jari 3   Copyright (C) 2006 Nicklas Nordborg
2733 16 Oct 06 nicklas 4
2733 16 Oct 06 nicklas 5   This file is part of BASE - BioArray Software Environment.
2733 16 Oct 06 nicklas 6   Available at http://base.thep.lu.se/
2733 16 Oct 06 nicklas 7
2733 16 Oct 06 nicklas 8   BASE is free software; you can redistribute it and/or
2733 16 Oct 06 nicklas 9   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 10   as published by the Free Software Foundation; either version 3
2733 16 Oct 06 nicklas 11   of the License, or (at your option) any later version.
2733 16 Oct 06 nicklas 12
2733 16 Oct 06 nicklas 13   BASE is distributed in the hope that it will be useful,
2733 16 Oct 06 nicklas 14   but WITHOUT ANY WARRANTY; without even the implied warranty of
2733 16 Oct 06 nicklas 15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2733 16 Oct 06 nicklas 16   GNU General Public License for more details.
2733 16 Oct 06 nicklas 17
2733 16 Oct 06 nicklas 18   You should have received a copy of the GNU General Public License
4510 11 Sep 08 jari 19   along with BASE. If not, see <http://www.gnu.org/licenses/>.
2733 16 Oct 06 nicklas 20   ------------------------------------------------------------------
2733 16 Oct 06 nicklas 21
2733 16 Oct 06 nicklas 22   A window for selecting a color interactively from a color chart.
2733 16 Oct 06 nicklas 23
2733 16 Oct 06 nicklas 24   @param title The title of the input field on the parent form
2733 16 Oct 06 nicklas 25   @param form The name of the form where the input field is located
2733 16 Oct 06 nicklas 26   @param input The name of the input field containing the current color value
2733 16 Oct 06 nicklas 27   @param callback A javascript function to call to set the new color in the
2733 16 Oct 06 nicklas 28     opener's form (optional, if not specified the color is just saved back to
2733 16 Oct 06 nicklas 29     the original form)
2733 16 Oct 06 nicklas 30
2733 16 Oct 06 nicklas 31   @author Nicklas
2733 16 Oct 06 nicklas 32   @version 2.0
2733 16 Oct 06 nicklas 33 --%>
5426 24 Sep 10 nicklas 34 <%@ page pageEncoding="UTF-8" session="false"
2753 20 Oct 06 nicklas 35   import="net.sf.basedb.util.Values"
2733 16 Oct 06 nicklas 36   import="java.util.Date"
2733 16 Oct 06 nicklas 37 %>
2733 16 Oct 06 nicklas 38 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
2733 16 Oct 06 nicklas 39 <%
2733 16 Oct 06 nicklas 40   String title = request.getParameter("title");
6187 29 Oct 12 nicklas 41   String textarea = request.getParameter("textarea");
2733 16 Oct 06 nicklas 42 %>
2733 16 Oct 06 nicklas 43 <base:page type="popup" title="<%=title%>">
6187 29 Oct 12 nicklas 44 <base:head scripts="~select_color.js">
5911 15 Dec 11 nicklas 45   <style>
5911 15 Dec 11 nicklas 46   .colorchart
5911 15 Dec 11 nicklas 47   {
5911 15 Dec 11 nicklas 48     width: 100%; 
5911 15 Dec 11 nicklas 49     height: 100%;
5911 15 Dec 11 nicklas 50   }
5911 15 Dec 11 nicklas 51   
5911 15 Dec 11 nicklas 52   .colorchart td
5911 15 Dec 11 nicklas 53   {
5911 15 Dec 11 nicklas 54     border: 1px solid #000000;
5911 15 Dec 11 nicklas 55   }
5911 15 Dec 11 nicklas 56
6097 03 Sep 12 nicklas 57   .colorchart td:hover, .colorchart td:focus
5911 15 Dec 11 nicklas 58   {
5911 15 Dec 11 nicklas 59     cursor: pointer;
5911 15 Dec 11 nicklas 60     outline: 1px solid #FFFFFF;
5911 15 Dec 11 nicklas 61   }
5911 15 Dec 11 nicklas 62   </style>
2733 16 Oct 06 nicklas 63 </base:head>
6187 29 Oct 12 nicklas 64 <base:body>
5911 15 Dec 11 nicklas 65   <h1><%=title%><base:help helpid="colorchart.selectcolor" /></h1>
6187 29 Oct 12 nicklas 66   
6187 29 Oct 12 nicklas 67   <div id="page-data" class="datacontainer"
6187 29 Oct 12 nicklas 68     data-textarea="<%=textarea%>"
6187 29 Oct 12 nicklas 69   ></div>
6187 29 Oct 12 nicklas 70   
6187 29 Oct 12 nicklas 71   
2733 16 Oct 06 nicklas 72   <form name="color">
6607 19 Nov 14 nicklas 73   <div class="content bg-filled-50 bottomborder">
6607 19 Nov 14 nicklas 74     <div class="absolutefull" style="bottom: 2.5em;">
5911 15 Dec 11 nicklas 75     <table class="colorchart">
2733 16 Oct 06 nicklas 76     <%
5911 15 Dec 11 nicklas 77     int red = 0;
5911 15 Dec 11 nicklas 78     int green = 0;
5911 15 Dec 11 nicklas 79     int blue = 0;
6097 03 Sep 12 nicklas 80     int x = 0;
6097 03 Sep 12 nicklas 81     int y = 0;
5911 15 Dec 11 nicklas 82     while (red < 16 && green < 16 && blue < 16)
2733 16 Oct 06 nicklas 83     {
2733 16 Oct 06 nicklas 84       String r = Integer.toHexString(red).toUpperCase();
5911 15 Dec 11 nicklas 85       String g = Integer.toHexString(green).toUpperCase();
5911 15 Dec 11 nicklas 86       String b = Integer.toHexString(blue).toUpperCase();
6187 29 Oct 12 nicklas 87       String full = r+r+g+g+b+b;
6097 03 Sep 12 nicklas 88       if (x == 0)
2733 16 Oct 06 nicklas 89       {
5911 15 Dec 11 nicklas 90         %>
5911 15 Dec 11 nicklas 91         <tr>
5911 15 Dec 11 nicklas 92         <%
5911 15 Dec 11 nicklas 93       }
5911 15 Dec 11 nicklas 94       %>
6187 29 Oct 12 nicklas 95       <td style="background: #<%=full%>;" 
6187 29 Oct 12 nicklas 96         title="#<%=full%>"
6097 03 Sep 12 nicklas 97         id="x<%=x%>y<%=y%>"
6187 29 Oct 12 nicklas 98         data-red="<%=r+r%>" data-green="<%=g+g%>" data-blue="<%=b+b%>"
6187 29 Oct 12 nicklas 99         data-x="<%=x%>" data-y="<%=y%>"
6097 03 Sep 12 nicklas 100         tabindex="0"
5911 15 Dec 11 nicklas 101         ><div></div></td>
5911 15 Dec 11 nicklas 102       <%
6097 03 Sep 12 nicklas 103       x++;
6097 03 Sep 12 nicklas 104       if (x == 18)
5911 15 Dec 11 nicklas 105       {
6097 03 Sep 12 nicklas 106         x = 0;
6097 03 Sep 12 nicklas 107         y++;
5911 15 Dec 11 nicklas 108         %>
5911 15 Dec 11 nicklas 109         </tr>
5911 15 Dec 11 nicklas 110         <%
5911 15 Dec 11 nicklas 111       }
5911 15 Dec 11 nicklas 112       red += 3;
5911 15 Dec 11 nicklas 113       if (red == 18)
5911 15 Dec 11 nicklas 114       {
5911 15 Dec 11 nicklas 115         red = 0;
5911 15 Dec 11 nicklas 116         green += 3;
5911 15 Dec 11 nicklas 117         if (green == 9)
2733 16 Oct 06 nicklas 118         {
5911 15 Dec 11 nicklas 119           green = 0;
5911 15 Dec 11 nicklas 120           blue += 3;
5911 15 Dec 11 nicklas 121           if (blue == 18)
2733 16 Oct 06 nicklas 122           {
5911 15 Dec 11 nicklas 123             blue = 0;
5911 15 Dec 11 nicklas 124             green = 9;
2733 16 Oct 06 nicklas 125           }
2733 16 Oct 06 nicklas 126         }
5911 15 Dec 11 nicklas 127         else if (green == 18)
5911 15 Dec 11 nicklas 128         {
5911 15 Dec 11 nicklas 129           green = 9;
5911 15 Dec 11 nicklas 130           blue += 3;
5911 15 Dec 11 nicklas 131         }
2733 16 Oct 06 nicklas 132       }
2733 16 Oct 06 nicklas 133     }
2733 16 Oct 06 nicklas 134     %>
2733 16 Oct 06 nicklas 135     </table>
5911 15 Dec 11 nicklas 136     </div>
5911 15 Dec 11 nicklas 137     
6607 19 Nov 14 nicklas 138     <div class="absolutefull" style="top: auto; height: 2.5em;">
5911 15 Dec 11 nicklas 139     <table style="margin: auto; height: 100%; border-spacing: 2px;" >
2733 16 Oct 06 nicklas 140     <tr>
5911 15 Dec 11 nicklas 141       <th>Red</th>
5911 15 Dec 11 nicklas 142       <td><input class="text" type="text" name="red" value="" size="2" maxlength="2" title="Red color value in hexadecimal"></td>
2733 16 Oct 06 nicklas 143
5911 15 Dec 11 nicklas 144       <th>Green</th>
5911 15 Dec 11 nicklas 145       <td><input class="text" type="text" name="green" value="" size="2" maxlength="2" title="Green color value in hexadecimal"></td>
2733 16 Oct 06 nicklas 146
5911 15 Dec 11 nicklas 147       <th>Blue</th>
5911 15 Dec 11 nicklas 148       <td><input class="text" type="text" name="blue" value="" size="2" maxlength="2" title="Blue color value in hexadecimal"></td>
2733 16 Oct 06 nicklas 149     </tr>
2733 16 Oct 06 nicklas 150     </table>
5911 15 Dec 11 nicklas 151     </div>
2733 16 Oct 06 nicklas 152
2733 16 Oct 06 nicklas 153   </div>
2733 16 Oct 06 nicklas 154   </form>
5911 15 Dec 11 nicklas 155   
5911 15 Dec 11 nicklas 156   <base:buttongroup subclass="dialogbuttons">
6187 29 Oct 12 nicklas 157     <base:button id="btnSave" title="Ok" />
6187 29 Oct 12 nicklas 158     <base:button id="close" title="Cancel" />
5911 15 Dec 11 nicklas 159   </base:buttongroup>
5911 15 Dec 11 nicklas 160   
2733 16 Oct 06 nicklas 161 </base:body>
2733 16 Oct 06 nicklas 162 </base:page>