⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selcolor.js

📁 类似xici的一个交流社区网站,jsp+mssql2000(sp4)开发,内含存储过程,作业等
💻 JS
字号:

var defBGColors = new Array('#6699EE', '#FFFF33', '#FFCC33', '#FF9933', '#996633', '#FFCCCC', '#FF9999', '#FF6666', '#FF3333', '#99FF66', '#33CC33', '#339933', '#336633', '#66CCFF', '#3399FF', '#3366FF', '#333399', '#FFFFFF','#E0E0E0', '#CCCCCC', '#999999', '#666666', '#333333', '#000000');
var defColors = new Array('#6699EE', '#FFFF33', '#FFCC33', '#FF9933', '#996633', '#FFCCCC', '#FF9999', '#FF6666', '#FF3333', '#FF0000','#99FF66', '#33CC33', '#339933', '#336633', '#66CCFF', '#3399FF', '#3366FF','#0000FF', '#333399', '#800080','#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000');

function colorPicker(name, color, mode)
{
	var df = mode ? defColors : defBGColors;
	var i, c;
	if(color=="")color=df[0];
	color = color.toUpperCase();
	document.write('<input type="hidden" name="'+name+'" id="'+name+'" value="'+color+'"><select style="background-color:'+color+';" id="cp_'+name+'" onchange="document.getElementById(\''+name+'\').value = fmtColor(this.style.backgroundColor = this.options[this.selectedIndex].style.backgroundColor);">');
	for(i = 0; i < df.length; i ++)
	{
		c = df[i].toUpperCase();
		if(c==color)
		{
			document.write('<option style="color:'+c+';background-color:'+c+';" selected>   </option>');
			color='';
		}else document.write('<option style="color:'+c+';background-color:'+c+';">   </option>');
	}

	document.write('</select><a href="javascript:openDialog(\'/board/page_admin/selcolor.html\', 320, 285, \''+name+'\');"><img src="/board/images/icon_patt.gif" width="17" height="17" border="0" hspace="3" align="absmiddle"></a>');
}

function cpSetColor(name, color)
{
	var colorList = document.getElementById("cp_" + name);
	var colorItems = colorList.options;
	var i;

	color = color.toUpperCase();

	for(i = 0; i < colorItems.length; i ++)
		if(colorItems[i].text == color)
		{
			colorList.selectedIndex = i;
			colorList.onchange();
			return;	
		}

	i --;
	colorList.selectedIndex = i;
	colorItems[i].style.backgroundColor = color;
	colorList.onchange();
}

function cpGetColor(name)
{
	return document.getElementById(name).value;
}

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 fmtColor(c)
{
	c = c.toUpperCase();
	if(c.indexOf("RGB(")==0)
	{
		c = c.substring(4,c.length-1)
		var ns = c.split(',');

		c = "#" + ToHex(ns[0]) + ToHex(ns[1]) + ToHex(ns[2]);
	}
	return c;
}

function openDialog(url, width, height, args) {
		var x, y;
		openWindowArgs = args;
		x = parseInt(screen.width / 2.0) - (width / 2.0);
		y = parseInt(screen.height / 2.0) - (height / 2.0);

			var features = "resizable:no;scroll:no;status:yes;center:yes;help:no;dialogWidth:"
				+ width + "px;dialogHeight:" + height + "px;";

			window.showModalDialog(url, window, features);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -