You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
klintersrv/editor/dialog/selcolor.htm

433 lines
18 KiB

<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript src="dialog.js"></script>
<link href='dialog.css' type='text/css' rel='stylesheet'>
<script language=javascript>
var sAction = URLParams['action'] ;
var sTitle = "";
var color = "" ;
var oSelection;
var oControl;
var sRangeType;
switch (sAction) {
case "forecolor":
sTitle = "字体前景色";
oSelection = dialogArguments.eWebEditor.document.selection.createRange();
color = oSelection.queryCommandValue("ForeColor");
if (color) color = N2Color(color);
break;
case "backcolor":
sTitle = "字体背景色";
oSelection = dialogArguments.eWebEditor.document.selection.createRange();
color = oSelection.queryCommandValue("BackColor");
if (color) color = N2Color(color);
break;
case "bgcolor":
sTitle = "对象背景色";
oSelection = dialogArguments.eWebEditor.document.selection.createRange();
sRangeType = dialogArguments.eWebEditor.document.selection.type;
if (sRangeType == "Control") {
oControl = GetControl(oSelection, "TABLE");
}else{
oControl = GetParent(oSelection.parentElement());
}
if (oControl) {
switch(oControl.tagName){
case "TD":
sTitle += " - 单元格";
break;
case "TR":
case "TH":
sTitle += " - 表格行";
break;
default:
sTitle += " - 表格";
break;
}
color = oControl.bgColor;
}else{
sTitle += " - 网页";
}
break;
default:
if (URLParams['color']){
color = decodeURIComponent(URLParams['color']) ;
}
break;
}
document.write("<TITLE>颜色选择(" + sTitle + ")</TITLE>");
if (!color) color = "#000000";
function GetParent(obj){
while(obj!=null && obj.tagName!="TD" && obj.tagName!="TR" && obj.tagName!="TH" && obj.tagName!="TABLE")
obj=obj.parentElement;
return obj;
}
function GetControl(obj, sTag){
obj=obj.item(0);
if (obj.tagName==sTag){
return obj;
}
return null;
}
function N2Color(s_Color){
s_Color = s_Color.toString(16);
switch (s_Color.length) {
case 1:
s_Color = "0" + s_Color + "0000";
break;
case 2:
s_Color = s_Color + "0000";
break;
case 3:
s_Color = s_Color.substring(1,3) + "0" + s_Color.substring(0,1) + "00" ;
break;
case 4:
s_Color = s_Color.substring(2,4) + s_Color.substring(0,2) + "00" ;
break;
case 5:
s_Color = s_Color.substring(3,5) + s_Color.substring(1,3) + "0" + s_Color.substring(0,1) ;
break;
case 6:
s_Color = s_Color.substring(4,6) + s_Color.substring(2,4) + s_Color.substring(0,2) ;
break;
default:
s_Color = "";
}
return '#' + s_Color;
}
function InitDocument(){
ShowColor.bgColor = color;
RGB.innerHTML = color;
SelColor.value = color;
var s_BoxID = "cbox_" + color.substr(1);
var o_Box = document.all(s_BoxID);
if (o_Box){
BoxClick(o_Box);
}
adjustDialog();
}
var SelRGB = color;
var DrRGB = '';
var SelGRAY = '120';
var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
function ToHex(n) {
var h, l;
n = Math.round(n);
l = n % 16;
h = Math.floor((n / 16)) % 16;
return (hexch[h] + hexch[l]);
}
function DoColor(c, l){
var r, g, b;
r = '0x' + c.substring(1, 3);
g = '0x' + c.substring(3, 5);
b = '0x' + c.substring(5, 7);
if(l > 120){
l = l - 120;
r = (r * (120 - l) + 255 * l) / 120;
g = (g * (120 - l) + 255 * l) / 120;
b = (b * (120 - l) + 255 * l) / 120;
}else{
r = (r * l) / 120;
g = (g * l) / 120;
b = (b * l) / 120;
}
return '#' + ToHex(r) + ToHex(g) + ToHex(b);
}
function EndColor(){
var i;
if(DrRGB != SelRGB){
DrRGB = SelRGB;
for(i = 0; i <= 30; i ++)
GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 8);
}
var s_Color = DoColor(RGB.innerText, GRAY.innerText);
SelColor.value = s_Color
ShowColor.bgColor = s_Color;
var s_BoxID = "cbox_" + s_Color.substr(1);
var o_Box = document.all(s_BoxID);
if (o_Box){
BoxClick(o_Box, true);
}else{
if (s_CurrBoxID){
document.all(s_CurrBoxID).className = "boxNormal";
s_CurrBoxID = ""
}
}
}
var s_CurrBoxID = "";
function BoxMouseOut(obj){
if (obj.id==s_CurrBoxID){
obj.className = "boxSelected";
}else{
obj.className = "boxNormal";
}
}
function BoxMouseOver(obj){
if (obj.id==s_CurrBoxID){
obj.className = "boxSelected";
}else{
obj.className = "boxOver";
}
}
function BoxClick(obj, notSel){
if (obj.id==s_CurrBoxID){
return;
}else{
if (s_CurrBoxID){
document.all(s_CurrBoxID).className = "boxNormal";
}
s_CurrBoxID = obj.id;
obj.className = "boxSelected";
var s_Color = "#" + s_CurrBoxID.substr(5);
if (!notSel){
SelRGB = s_Color;
}
SelColor.value = s_Color;
ShowColor.bgColor = SelColor.value;
}
}
</SCRIPT>
<SCRIPT event=onclick for=ColorTable language=JavaScript>
SelRGB = event.srcElement.bgColor;
EndColor();
</SCRIPT>
<SCRIPT event=onmouseover for=ColorTable language=JavaScript>
RGB.innerText = event.srcElement.bgColor;
EndColor();
</SCRIPT>
<SCRIPT event=onmouseout for=ColorTable language=JavaScript>
RGB.innerText = SelRGB;
EndColor();
</SCRIPT>
<SCRIPT event=onclick for=GrayTable language=JavaScript>
SelGRAY = event.srcElement.title;
EndColor();
</SCRIPT>
<SCRIPT event=onmouseover for=GrayTable language=JavaScript>
GRAY.innerText = event.srcElement.title;
EndColor();
</SCRIPT>
<SCRIPT event=onmouseout for=GrayTable language=JavaScript>
GRAY.innerText = SelGRAY;
EndColor();
</SCRIPT>
<SCRIPT event=onclick for=Ok language=JavaScript>
color = SelColor.value;
if (!IsColor(color)){
alert("无效的颜色值!");
return;
}
switch (sAction) {
case "forecolor":
dialogArguments.format('ForeColor', color) ;
window.returnValue = null;
break;
case "backcolor":
dialogArguments.format('BackColor', color) ;
window.returnValue = null;
break;
case "bgcolor":
if (oControl){
oControl.bgColor = color;
}else{
dialogArguments.setHTML("<table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%'><tr><td valign=top bgcolor='"+color+"'>"+dialogArguments.getHTML()+"</td></tr></table>", true);
}
window.returnValue = null;
break;
default:
window.returnValue = color;
break;
}
window.close();
</SCRIPT>
<style>
.boxNormal {border:1px solid #d4d0c8}
.boxOver {border-width:1px;border-color:#ffffff #000000 #000000 #ffffff;border-style:solid}
.boxSelected {border-width:1px;border-color:#000000 #ffffff #ffffff #000000;border-style:inset}
</style>
</HEAD>
<BODY onload="InitDocument()">
<table border=0 cellpadding=0 cellspacing=5 id=tabDialogSize><tr><td>
<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr valign=top>
<td>
<table border=0 cellpadding=0 cellspacing=10><tr><td>
<table id= border=0 cellpadding=3 cellspacing=0>
<tr>
<td id="cbox_000000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#000000"></td>
<td id="cbox_993300" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#993300"></td>
<td id="cbox_333300" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#333300"></td>
<td id="cbox_003300" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#003300"></td>
<td id="cbox_003366" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#003366"></td>
</tr>
<tr>
<td id="cbox_000080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#000080"></td>
<td id="cbox_333399" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#333399"></td>
<td id="cbox_333333" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#333333"></td>
<td id="cbox_800000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#800000"></td>
<td id="cbox_FF6600" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF6600"></td>
</tr>
<tr>
<td id="cbox_808000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#808000"></td>
<td id="cbox_008000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#008000"></td>
<td id="cbox_008080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#008080"></td>
<td id="cbox_0000FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#0000FF"></td>
<td id="cbox_666699" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#666699"></td>
</tr>
<tr>
<td id="cbox_808080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#808080"></td>
<td id="cbox_FF0000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF0000"></td>
<td id="cbox_FF9900" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF9900"></td>
<td id="cbox_99CC00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#99CC00"></td>
<td id="cbox_339966" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#339966"></td>
</tr>
<tr>
<td id="cbox_33CCCC" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#33CCCC"></td>
<td id="cbox_3366FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#3366FF"></td>
<td id="cbox_800080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#800080"></td>
<td id="cbox_999999" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#999999"></td>
<td id="cbox_FF00FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF00FF"></td>
</tr>
<tr>
<td id="cbox_FFCC00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFCC00"></td>
<td id="cbox_FFFF00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFFF00"></td>
<td id="cbox_00FF00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#00FF00"></td>
<td id="cbox_00FFFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#00FFFF"></td>
<td id="cbox_00CCFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#00CCFF"></td>
</tr>
<tr>
<td id="cbox_993366" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#993366"></td>
<td id="cbox_C0C0C0" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#C0C0C0"></td>
<td id="cbox_FF99CC" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF99CC"></td>
<td id="cbox_FFCC99" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFCC99"></td>
<td id="cbox_FFFF99" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFFF99"></td>
</tr>
<tr>
<td id="cbox_CCFFCC" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#CCFFCC"></td>
<td id="cbox_CCFFFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#CCFFFF"></td>
<td id="cbox_99CCFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#99CCFF"></td>
<td id="cbox_CC99FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#CC99FF"></td>
<td id="cbox_FFFFFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFFFFF"></td>
</tr>
</table>
</td></tr></table>
</td>
<td>
<TABLE border=0 cellPadding=0 cellSpacing=10 align=center>
<TR>
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 id=ColorTable style="CURSOR: hand">
<SCRIPT language=JavaScript>
function wc(r, g, b, n){
r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15;
g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15;
b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15;
document.write('<TD BGCOLOR=#' + ToHex(r) + ToHex(g) + ToHex(b) + ' height=8 width=8></TD>');
}
var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);
for(i = 0; i < 16; i ++){
document.write('<TR>');
for(j = 0; j < 30; j ++){
n1 = j % 5;
n2 = Math.floor(j / 5) * 3;
n3 = n2 + 3;
wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)),
(cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)),
(cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i);
}
document.writeln('</TR>');
}
</SCRIPT>
</TABLE>
</TD>
<TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 id=GrayTable style="CURSOR: hand">
<SCRIPT language=JavaScript>
for(i = 255; i >= 0; i -= 8.5)
document.write('<TR BGCOLOR=#' + ToHex(i) + ToHex(i) + ToHex(i) + '><TD TITLE=' + Math.floor(i * 16 / 17) + ' height=4 width=20></TD></TR>');
</SCRIPT>
</TABLE>
</TD>
</TR>
</TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=10 align=center>
<TR>
<TD noWrap align=middle rowSpan=2>选中色彩
<TABLE border=1 cellPadding=0 cellSpacing=0 height=30 id=ShowColor width=40 bgcolor=""><TBODY><TR><TD></TD></TR></TBODY></TABLE>
</TD>
<TD noWrap rowSpan=2>基色: <SPAN id=RGB></SPAN><BR>亮度: <SPAN id=GRAY>120</SPAN><BR>代码: <INPUT id=SelColor size=7 value=""></TD>
<TD><input id=Ok type=submit value="确定"></TD>
</TR>
<TR>
<TD noWrap><input type=BUTTON onclick="window.close();" value="取消"></TD>
</TR>
</TABLE>
</td>
</tr></table>
</td></tr></table>
</BODY></HTML>