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

📄 adminsettings.js

📁 论坛BBS
💻 JS
📖 第 1 页 / 共 2 页
字号:
// End select.js
///////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////
// writeSelect.js This file is part of the DHTML Select to give X browser support. There is no need
// to edit this unless you want to mess with select
///////////////////////////////////////////////////////////////////////////////////////////////////
function writeSelectBox(matrix, id, size, onchange, css) {
	var d = window.document;

	// The NN part has been remove
	var s = createIEString(matrix, id, size, onchange, css);
	document.write(s);
}

function createIEString(matrix, id, size, onchange, css) {
	var str = "";
	// Span startTag	
		str += '<span class="select"';
		if (size == null)
			size = 1;
		str += ' size="' + size + '"';	
		if (id != null)
			str += ' id="' + id + '"';
		if (onchange != null)
			str += ' onchange="' + onchange + '"';
		if (css != null)
			str += ' style="' + css + '"';
		str += '>\n';
	
	// Table Tag
		str += '<table class="selectTable" cellspacing="0" cellpadding="0"\n';
		str += ' onclick="toggleDropDown(this.parentElement)">\n';
		str += '<tr>\n';
		str += '<td class="selected">&nbsp;</td>\n';
		str += '<td align="CENTER" valign="MIDDLE" class="Button"\n';
		str += ' onmousedown="this.style.border=\'2 inset buttonhighlight\'"\n';
		str += ' onmouseup="this.style.border=\'2 outset buttonhighlight\'">\n';
		str += '<span style="position: relative; left: 0; top: -2; width: 100%;">6</span></td>\n';
		str += '</tr>\n';
		str += '</table>\n';
		
	// DropDown startTag
		str += '<div class="dropDown" onclick="optionClick()" onmouseover="optionOver()" onmouseout="optionOut()">\n';
		
		for (var i=0; i<matrix.length; i++) {
			html     = matrix[i].html;
			value    = matrix[i].value;
			css      = matrix[i].css;
			selected = matrix[i].selected;
			
		// Write option starttag
			str += '<div class="option"';
			if (value != null)
				str += ' value="' + value + '"';
			if (css != null)
				str += ' style="' + css + '"';
			if (selected != null)
				str += ' selected';
			str += '>\n';
			
		// Write HTML contents
			str += html;
		// Write end tag
			str += '</div>\n';
		}
	
	//DropDown endtag
		str += '</div>\n';
		
	// Span endTag
		str += '</span>\n';
		
	return str;
}

function Option(html, value, css, selected) {
	this.html = html;
	this.value = value;
	this.css = css;
	this.selected = selected;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// end writeSelect.js
///////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////
// This is the specific code for the settings window. The customisation part is at the top
// of this document (except formatting of the option element, see directly below)
///////////////////////////////////////////////////////////////////////////////////////////////////

// If you want to change the layout inside the Selectbox edit here
function formatOption(img, name, descr) {
	return "<img src='" + img + "' class='groupIcon'><b>" + name + "</b><br>" + descr;
}

initAdminSettings();

function initAdminSettings() {
	window.onload = initAdminSettingsOnload;
	document.onclick = hideShownDropDowns;
}

function initAdminSettingsOnload() {
	initSelectBoxes();
	serverLoadSelect();
}

var optionArray = new Array();	//This is used when creating the select in the html file
optionArray[0] = new Option(
"<div style='height:42'>" + loadingMessage + "</div>",
'|:||:||:|');

function populateInputs(value) {
	var a = value.split("|:|");
	
	nameInp.value = a[1];
	descrInp.value = a[2];
	imgInp.value = a[3];
	fileInp.value = a[0];
}

function highlightOver() {
	var el = window.event.srcElement;
	if (el.tagName == "INPUT" || el.tagName == "BUTTON") {
		el.style.borderWidth = 2;
		el.style.padding     = 0;
	}
	
	el = getReal(el,"className","dropDown");
	if (el.className == "dropDown") {
		el.style.borderWidth = 2;
		el.style.padding     = 0;
	}
}

function highlightOut() {
	var el = window.event.srcElement;
	if (el.tagName == "INPUT" || el.tagName == "BUTTON") {
		el.style.borderWidth = 1;
		el.style.padding     = 1;
	}
	el = getReal(el,"className","dropDown");
	if (el.className == "dropDown") {
		el.style.borderWidth = 1;
		el.style.padding     = 1;
	}
}

if (ie5) {
	document.onmouseover = highlightOver;
	document.onmouseout = highlightOut;
}

function createNewGroup() {
	var o = groupSelect.options;
	
	for (var i=0; i<o.length; i++) {
		if (fileInp.value == o[i].value.split("|:|")[0]) {
			alert(createNewGroupError);
			return;
		}
	}
	
	var str = cgiFile + "?action=newgroup";

	str += "&group=" + fileInp.value;
	str += "&name=" + escape(nameInp.value);
	str += "&description=" + escape(descrInp.value);
	str += "&image=" + escape(imgInp.value);

	openWithPassword(str);
}

function updateGroup() {
	var str = cgiFile + "?action=updategroup";

	str += "&group=" + fileInp.value;	
	str += "&name=" + escape(nameInp.value);
	str += "&description=" + escape(descrInp.value);
	str += "&image=" + escape(imgInp.value);

	openWithPassword(str);
}

function removeGroup() {
	var str = cgiFile + "?action=removegroup"
	
	str += "&group=" + fileInp.value;
	
	openWithPassword(str);
}

function updatePassword() {
	if (npwd1.value != npwd2.value)
		alert(updatePasswordError);
	else {
		var str = cgiFile + "?action=updatepassword";
	
		str += "&old=" + escape(opwd.value);	
		str += "&new1=" + escape(npwd1.value);
		str += "&new2=" + escape(npwd2.value);
	
		openWithPassword(str);
	}
}

function serverLoadSelect() {
	var str = cgiFile + "?action=loadselect"
	disableAll();
	document.frames[0].location = str;
}

var disableTimer;

function disableAll() {
	var inps = document.all.tags("INPUT");
	var btns = document.all.tags("BUTTON");
	
	for (var i=0; i<inps.length; i++)
		inps[i].disabled = true;
		
	for (var i=0; i<btns.length; i++)
		btns[i].disabled = true;
		
	disableDiv.style.display = "block";
	disableTimer = window.setTimeout("responseTimeout()", responseTimeLimit);
}

function enableAll() {
	var inps = document.all.tags("INPUT");
	var btns = document.all.tags("BUTTON");
	
	for (var i=0; i<inps.length; i++)
		inps[i].disabled = false;
		
	for (var i=0; i<btns.length; i++)
		btns[i].disabled = false;

	disableDiv.style.display = "none";
	window.clearTimeout(disableTimer);
}


function responseTimeout() {
	alert(responseTimeoutError);
	enableAll();
}


function createNewGroupResponse(success, group, name, descr, img, errorMsg) {
	if (!success)
		alert(errorString + errorMsg);
	else {
		var o = document.createElement("OPTION");
		o.text = formatOption(img, name, descr);
		o.value = group + "|:|" + name + "|:|" + descr + "|:|" + img;
		groupSelect.add(o);
	}
	enableAll();
}

function updateGroupResponse(success, group, name, descr, img, errorMsg) {
	if (!success)
		alert(errorMsg);
	else {
		var o = groupSelect.options;
	
		for (var i=0; i<o.length; i++) {
			if (group == o[i].value.split("|:|")[0]) {
				groupSelect.remove(i);
				break;
			}
		}
			
		var o = document.createElement("OPTION");
		o.text = formatOption(img, unescape(name), unescape(descr));
		o.value = group + "|:|" + unescape(name) + "|:|" + unescape(descr) + "|:|" + unescape(img);
		groupSelect.add(o);
	}
	enableAll();
}

function removeGroupResponse(success, group, errorMsg) {
	if (!success)
		alert(errorString + errorMsg);
	else {
		var o = groupSelect.options;
	
		for (var i=0; i<o.length; i++) {
			if (group == o[i].value.split("|:|")[0]) {
				groupSelect.remove(i);
				break;
			}
		}
	}
	enableAll();
}

function updatePasswordResponse(success, errorMsg) {
	if (success)
		alert(updatePasswordSuccessMessage);
	else
		alert(errorString + errorMsg);
	
	enableAll();
}


function updateSelectOption(group,data) {
	var d = data.split("|:|");
	var o = groupSelect.options;
	
	for (var i=0; i<o.length; i++) {
		if (o[i].value.split("|:|")[0] == d[0]) {
			o[i].innerHTML = formatOption(d[3], d[1], d[2]);
			o[i].value = data;
			if (o[i].selected)
				populateInputs(data);
			break;
		}
	}
}

function openWithPassword(str) {
	var top = opener.parent;
	var pwd;
	
	if (top != null && top.treeframe != null)
		pwd = top.treeframe.document.body.password;
	else {
		alert(contactError);
		return;
	}
		
	if  (pwd == null || pwd == "") {
		alert(contactPassError);
		return;
	}
	
	str += "&pwd=" + pwd;
	
	document.frames["com"].location = str;
	disableAll();
}

function loadSelect(success, data, errorMsg) {
	if (!success)
		alert("Error!\n" + errorMsg);
	else {
		groupSelect.remove(0);

		for (var i=0; i<data.length; i++) {
			
			var o = document.createElement("OPTION");
			o.text = formatOption(data[i][3], unescape(data[i][1]), unescape(data[i][2]));
			o.value = data[i][0] + "|:|" + unescape(data[i][1]) + "|:|" + unescape(data[i][2]) + "|:|" + data[i][3];
			
			groupSelect.add(o);
		}
	}
	enableAll();
}

⌨️ 快捷键说明

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