/*******************************************************************************
Description : GENERAL Script
Last Modified : 2003.05.10
*******************************************************************************/
function isblank(str) {
var re = /( || )/g;
if(str.replace(re, "") == "") return true;
return false;
}
/*******************************************************************************
CHECKBOX script
*******************************************************************************/
function check_option() {
// check option layer
var obj = document.all["id_checkbox"];
// set position
obj.style.posLeft = event.x + document.body.scrollLeft;
obj.style.posTop = event.y + document.body.scrollTop;
obj.style.visibility = "visible";
}
function show_check_option() {
document.all["id_checkbox"].style.visibility = "visible";
}
function hide_check_option() {
document.all["id_checkbox"].style.visibility = "hidden";
}
function select_all() {
for(var i = 1; i <= ARTICLE_ROWS; i++) {
var obj = document.all["check" + i];
if(obj) {
obj.value = document.all["article" + i + "_idx"].value;
document.all["check_img" + i].src = PATH_SKIN + "images/chkbox_on.gif";
}
}
hide_check_option();
}
function cancel_all() {
for(var i = 1; i <= ARTICLE_ROWS; i++) {
var obj = document.all["check" + i];
if(document.all["check" + i]) {
obj.value = 0;
document.all["check_img" + i].src = PATH_SKIN + "images/chkbox_off.gif";
}
}
hide_check_option();
}
function reverse_chk() {
for(var i = 1; i <= ARTICLE_ROWS; i++) {
if(document.all["check" + i]) set_check(i);
}
hide_check_option();
}
function set_check(row_num) {
var obj = document.all["check" + row_num];
var idx = document.all["article" + row_num + "_idx"].value;
if(obj.value == idx) {
obj.value = 0;
document.all["check_img" + row_num].src = PATH_SKIN + "images/chkbox_off.gif";
} else {
obj.value = idx;
document.all["check_img" + row_num].src = PATH_SKIN + "images/chkbox_on.gif";
}
}
/*******************************************************************************
PREVIEW script
*******************************************************************************/
function preview(content) {
var obj = document.all["id_preview"];
// check content
if(content == "") {
obj.innerHTML = "";
return;
}
var text = "";
text = "
"
text += " ";
text += " ";
text += " ";
text += " ";
text += "  | ";
text += " ";
text += " ";
text += " ";
text += " ";
text += "  | ";
text += " ";
text += "  | ";
text += "  | ";
text += " ";
text += " ";
text += " | ";
text += " " + content + " | ";
text += " | ";
text += " ";
text += " ";
text += "  | ";
text += " | ";
text += "  | ";
text += " ";
text += " ";
text += " | ";
text += "
";
text += "
";
obj.innerHTML = text;
move_preview();
obj.style.visibility = "visible";
}
function move_preview() {
var obj = document.all["id_preview"];
if(obj.innerHTML != "") {
obj.style.posLeft = event.x - 40 + document.body.scrollLeft;
obj.style.posTop = event.y + 10 + document.body.scrollTop;
}
}
function hide_preview() {
document.all["id_preview"].style.visibility = "hidden";
}
/*******************************************************************************
USER_MENU script
*******************************************************************************/
function user_menu(id, name, email, url) {
// user menu layer
var obj = document.all["id_user_menu"];
if(obj.style.visibility == "hidden") {
// set position
obj.style.posLeft = event.x + document.body.scrollLeft;
obj.style.posTop = event.y + document.body.scrollTop;
var text = "";
text += "";
text += "";
text += " ";
text += " ";
text += " ";
text += " ";
text += "  | ";
text += "  | ";
text += "  | ";
text += " ";
text += " ";
text += " | ";
text += " ";
text += " ";
// id or name
text += " ";
text += " | ";
if(id != "") {
text += "  | ";
text += " Search | ";
} else {
text += "  | ";
text += " Search | ";
}
text += " | ";
text += " ";
// email
if(email != "") {
text += " ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += "  | ";
text += " Mail | ";
text += " | ";
text += " ";
}
// url
if(url != "" && url != "http://" && url != "HTTP://") {
text += " ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += "  | ";
text += " Home | ";
text += " | ";
text += " ";
}
// memo and personal info
if(id != "") {
text += " ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += "  | ";
text += " Memo | ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += "  | ";
text += " Info | ";
text += " | ";
text += " ";
}
text += " ";
text += " | ";
text += " | ";
text += " ";
text += " ";
text += "  | ";
text += " | ";
text += "  | ";
text += " ";
text += " ";
text += " | ";
text += "
";
text += "
";
obj.innerHTML = text;
obj.style.visibility = "visible";
} else {
hide_user_menu();
}
}
function show_user_menu() {
document.all["id_user_menu"].style.visibility = "visible";
}
function hide_user_menu() {
document.all["id_user_menu"].style.visibility = "hidden";
}
function search_by_id(id) {
location.href = "ttboard.cgi?act=list" + QUERY_DB + "&s_mode=def&s_id=1&s_key=" + id;
hide_user_menu();
}
function search_by_name(name) {
location.href = "ttboard.cgi?act=list" + QUERY_DB + "&s_mode=def&s_name=1&s_key=" + name;
hide_user_menu();
}
function send_mail(email) {
if(email == "") return;
location.href = "mailto:" + email;
}
function ttmailer(email) {
if(email == "") return;
window.open("ttmailer.cgi?act=write&to="+email, "", "width=320, height=350, resizable=1, scrollbars=1");
}
function open_url(url) {
if(url == "") return;
window.open(url, "", "");
}
function user_info(id) {
profile(id, 1, "");
}
/*******************************************************************************
SEARCH script
*******************************************************************************/
function set_search(field) {
var obj_field = document.all["s_"+field];
if(obj_field.value == 1) {
document.all["s_"+field+"_chk"].src = PATH_SKIN + "images/chkbox_off.gif";
obj_field.value = 0;
} else {
document.all["s_"+field+"_chk"].src = PATH_SKIN + "images/chkbox_on.gif";
obj_field.value = 1;
}
}
function set_search_num() {
var total_num = SEARCH_TOTAL_COUNT;
var search_num = search_form.s_num.value;
if(search_num != '') {
if(search_num > total_num) {
search_num = total_num;
search_form.s_num.value = total_num;
}
// show search field
for(var i = 1; i <= total_num; i++) {
if(i <= search_num)
document.all["id_search" + i].style.display = "block";
else
document.all["id_search" + i].style.display = "none";
}
}
}
function show_adv_search() {
document.all["id_default_search"].style.display = "none";
document.all["id_adv_search"].style.display = "block";
}
function show_default_search() {
document.all["id_default_search"].style.display = "block";
document.all["id_adv_search"].style.display = "none";
}
function search(mode) {
if(mode == "default") {
if(search_form.s_id.value == 0 && search_form.s_name.value == 0
&& search_form.s_title.value == 0 && search_form.s_content.value == 0) {
alert("°Ë»öÇÒ Çʵ带 ¼±ÅÃÇØ ÁֽʽÿÀ.");
return;
} else if(search_form.s_key.value == "") {
alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.");
search_form.s_key.focus();
return;
}
search_form.action = "ttboard.cgi?act=list" + QUERY_DB + "&s_mode=def";
} else if(mode == "advanced") {
// check search key
for(var i = 1; i <= search_form.s_num.value; i++) {
var obj = document.all["s_key" + i];
if(obj.value == "") {
alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.");
obj.focus();
return;
}
}
search_form.action = "ttboard.cgi?act=list" + QUERY_DB + "&s_mode=adv";
}
search_form.submit();
}
/*******************************************************************************
COMMENT script
*******************************************************************************/
function cmt_add(aidx) {
var name = document.all["cmt"+aidx+"_name"];
var pwd = document.all["cmt"+aidx+"_pwd"];
var content = document.all["cmt"+aidx+"_content"];
// check name.
if(isblank(name.value)) {
alert("À̸§À» ½á ÁÖ¼¼¿ä");
name.focus();
return;
}
// check password.
if(MEMBER_IDX == 0) {
// ·Î±×ÀÎÇÑ °æ¿ì´Â ºñ¹Ð¹øÈ£¸¦ ¹ÞÁö¾ÊÀ½.
if(document.all["cmt"+aidx+"_pwd"].value == "") {
alert("ºñ¹Ð¹øÈ£À» ½á ÁÖ¼¼¿ä");
document.all["cmt"+aidx+"_pwd"].focus();
return;
}
}
// check content.
if(isblank(content.value)) {
alert("³»¿ëÀ» ½á ÁÖ¼¼¿ä");
content.focus();
return;
}
// set value.
comment_form.comment_name.value = name.value;
if(MEMBER_IDX == 0) comment_form.comment_pwd.value = pwd.value;
comment_form.comment_content.value = content.value;
// submit form.
comment_form.action = "ttboard.cgi?act=add_comment" + QUERY_DB + "&idx=" + aidx;
comment_form.submit();
}
function cmt_del() {
// hide password layer.
cmt_hide_pwd();
// submit form.
comment_form.action = "ttboard.cgi?act=del_comment" + QUERY_DB
+ "&pwd=" + comment_form.del_pwd.value;
comment_form.submit();
}
function cmt_mdel(aidx) {
var obj = document.all["cmt"+aidx+"_idx"];
if(!obj) return;
// article index
comment_form.article_idx.value = aidx;
// comment index
var cmt_idx = comment_form.comment_idx;
cmt_idx.value = "";
if(obj.length) {
// more than two objects
for(var i = 0; i < obj.length; i++) {
if(obj[i].checked == true) {
if(cmt_idx.value != "") cmt_idx.value += ",";
cmt_idx.value += obj[i].value;
}
}
} else {
// only one object
cmt_idx.value = obj.value;
}
comment_form.action = "ttboard.cgi?act=del_comment" + QUERY_DB;
comment_form.submit();
}
function cmt_show_pwd(aidx, cidx) {
if(MEMBER_IDX == 0) {
// before login
var obj = document.all["div_cmt_pwd"];
if(aidx != 0 && cidx != 0) {
comment_form.del_pwd.value = "";
comment_form.article_idx.value = aidx;
comment_form.comment_idx.value = cidx;
obj.style.posLeft = event.x - 170 + document.body.scrollLeft;
obj.style.posTop = event.y + document.body.scrollTop;
}
obj.style.visibility = "visible";
comment_form.del_pwd.focus();
} else {
// after login
comment_form.del_pwd.value = "";
comment_form.article_idx.value = aidx;
comment_form.comment_idx.value = cidx;
cmt_del();
event.returnValue = false;
}
}
function cmt_hide_pwd() {
document.all["div_cmt_pwd"].style.visibility = "hidden";
}
/*******************************************************************************
WRITE script
*******************************************************************************/
function verify_data() {
// check name.
if(isblank(write_form.name.value)) {
alert("À̸§À» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
write_form.name.focus();
return;
}
// check email.
if(write_form.email.value != "") {
if(!check_email(write_form.email.value)) {
alert("À̸ÞÀÏ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
write_form.email.focus();
return;
}
}
// check password.
if(WRITE_MODE != "modify" && MEMBER_IDX == 0) {
if(write_form.pwd && write_form.pwd.value == "") {
alert("ÆÐ½º¿öµå¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
write_form.pwd.focus();
return;
}
}
// check title.
if(isblank(write_form.title.value)) {
alert("Á¦¸ñÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
write_form.title.focus();
return;
}
// check content.
if(isblank(write_form.content.value)) {
alert("³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
write_form.content.focus();
return;
}
// check category.
if(write_form.cate_idx) {
// use categoy
if(CATEGORY_WRITE_METHOD == 0) {
// essential field
if(write_form.cate_idx.value == "") {
alert("Ä«Å×°í¸®¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä.");
return;
}
} else if(CATEGORY_WRITE_METHOD == 1) {
// alert message
if(write_form.cate_idx.value == 0) {
var bYes = confirm("Ä«Å×°í¸®¸¦ ¼±ÅÃÇÏÁö ¾ÊÀ¸¼Ì½À´Ï´Ù.\nÀúÀåÇϽðڽÀ´Ï±î?");
if(!bYes) return;
}
} else if(CATEGORY_WRITE_METHOD == 2) {
// no action
}
}
//check url.
if(write_form.url.value=="http://")
write_form.url.value = "";
// set content info.
if(write_form.content_width)
write_form.content_width.value = parseInt(document.all['content'].style.width);
if(write_form.content_height)
write_form.content_height.value = parseInt(document.all['content'].style.height);
write_form.submit();
}
// resize
function resize_content_width(width) {
var obj, total_count;
// url
resize_object_width("url", width, CONTENT_WIDTH);
// title
resize_object_width("title", width, CONTENT_WIDTH);
// content
resize_object_width("content", width, CONTENT_WIDTH);
// file
obj = document.all['file_num'];
if(obj) {
total_count = obj.options[obj.length-1].value;
for(var i = 1; i <= total_count; i++) {
resize_object_width("file"+i, width, FILE_WIDTH);
}
}
// link
obj = document.all['link_num'];
if(obj) {
total_count = obj.options[obj.length-1].value;
for(var i = 1; i <= total_count; i++) {
resize_object_width("link"+i, width, FILE_WIDTH);
}
}
}
function resize_object_width(obj, width, min_width) {
if(document.all[obj]) {
var obj_width = parseInt(document.all[obj].style.width);
if(obj_width + width >= min_width)
document.all[obj].style.width = obj_width + width;
}
}
function resize_content_height(height) {
if(document.all["content"]) {
var obj_height = parseInt(document.all['content'].style.height);
if(obj_height + height >= CONTENT_HEIGHT)
document.all['content'].style.height = obj_height + height;
}
}
// file & link
function show_file() {
var obj = write_form.file_num;
var file_num = obj.options[obj.selectedIndex].value;
var total_file = obj.options[obj.length-1].value;
for(var i = 1; i <= total_file; i++) {
var obj_file = document.all["id_file" + i];
var obj_info = document.all["id_file" + i + "_info"];
if(i <= file_num) {
obj_file.style.display = 'block';
if(obj_info) obj_info.style.display = 'block';
} else {
obj_file.style.display = 'none';
if(obj_info) obj_info.style.display = 'none';
}
}
}
function show_link() {
var obj = write_form.link_num;
var link_num = obj.options[obj.selectedIndex].value;
var total_link = obj.options[obj.length-1].value;
for(var i = 1; i <= total_link; i++) {
if(i <= link_num)
document.all["id_link" + i].style.display = 'block';
else
document.all["id_link" + i].style.display = 'none';
}
}
function add_var(id, idx) {
if(id == 'link') {
write_form.all["content"].value += "{LINK:" + idx + "}";
} else if(id == 'file') {
write_form.all["content"].value += "{FILE:" + idx + "}";;
}
}
/*******************************************************************************
ACTION script
*******************************************************************************/
// rollover bgcolor.
function rollover(obj, color) {
if(!obj) return false;
obj.style.backgroundColor = color;
}
function check_enter(id) {
if(event.keyCode == 13) {
if(id == "search") search('default');
else if(id == "jump_page") jump_to();
else if(id == "search_num") set_search_num();
else if(id == "cmt_del") cmt_del();
event.returnValue = false;
}
}
function read_article(idx) {
if(LIST_TITLE_ON_CLICK == 0) {
location.href = "ttboard.cgi?act=read" + QUERY + "&page=" + PAGE_CUR_PAGE + "&idx=" + idx;
} else if(LIST_TITLE_ON_CLICK == 1) {
window.open("ttboard.cgi?act=popup" + QUERY + "&page=" + PAGE_CUR_PAGE + "&idx=" + idx,
"", "width="+LIST_POPUP_WIDTH+", height="+LIST_POPUP_HEIGHT+", scrollbars=1, resizable=1");
} else if(LIST_TITLE_ON_CLICK == 2) {
window.open("ttboard.cgi?act=read" + QUERY + "&page=" + PAGE_CUR_PAGE + "&idx=" + idx,
"", "width="+LIST_POPUP_WIDTH+", height="+LIST_POPUP_HEIGHT+", scrollbars=1, resizable=1");
}
}
function multi_read() {
var idx = "";
// make index.
for(var i = 1; i <= ARTICLE_ROWS; i++) {
var obj = document.all["check" + i];
if(obj && obj.value != 0) {
// check secret article
if(document.all["article" + i + "_secret"].value == 1) {
alert("ºñ¹Ð °Ô½Ã¹°Àº ´ÙÁßÀб⸦ ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
return;
}
if(idx != "") idx += ",";
idx += obj.value;
}
}
if(idx == "") {
alert("ÀÐÀ» °Ô½Ã¹°À» ¼±ÅÃÇØÁֽʽÿÀ.");
return;
}
location.href = "ttboard.cgi?act=multi_read&idx=" + idx + QUERY;
}
function article_manage() {
var idx = "";
// make index.
for(var i = 1; i <= ARTICLE_ROWS; i++) {
var obj = document.all["check" + i];
if(obj && obj.value != 0) {
if(idx != "") idx += ",";
idx += obj.value;
}
}
if(idx == "") {
alert("°Ô½Ã¹°À» ¼±ÅÃÇØÁÖ¼¼¿ä.");
return;
}
var url = "ttadmin.cgi?act=article_manage_list&bid="+DB+"&idx="+idx;
window.open(url, "", "width=450, height=160, resizable=1");
}
function reply_article(idx) {
hform.action = "ttboard.cgi?act=reply" + QUERY + "&idx=" + idx;
hform.submit();
}
function modify_article(idx) {
hform.action = "ttboard.cgi?act=modify" + QUERY + "&idx=" + idx;
hform.submit();
}
function delete_article(idx) {
if(confirm("°Ô½Ã¹°À» »èÁ¦ÇϽðڽÀ´Ï±î?")) {
hform.action = "ttboard.cgi?act=delete" + QUERY + "&idx=" + idx;
hform.submit();
}
}
function recommend(idx) {
location.href = "ttboard.cgi?act=recommend" + QUERY_DB + "&idx="+idx;
}
function jump_to() {
var obj = document.all["jump_page"];
var page = obj.value;
var last_page = document.all["last_page"].value;
if(!check_number(page)) {
alert("page¿¡´Â ¼ýÀÚ¸¸ ¾²½Ç ¼ö ÀÖ½À´Ï´Ù.");
obj.value = "";
obj.focus();
return;
}
if(page != "") {
if(parseInt(page) < 1) {
alert("ÆäÀÌÁö´Â 1º¸´Ù Ä¿¾ßÇÕ´Ï´Ù.");
obj.value = "";
obj.focus();
return;
} else if(parseInt(page) > parseInt(last_page)) {
alert(page + " ÆäÀÌÁö´Â Á¸ÀçÇÏÁö ¾Ê´Â ÆäÀÌÁöÀÔ´Ï´Ù.");
obj.value = "";
obj.focus();
return;
} else {
location.href = "ttboard.cgi?act=list" + QUERY_DB + "&page="+page;
}
}
}
function whois(ip) {
// check ip.
if(ip == "") return;
var left = (screen.width - 520) / 2;
var top = (screen.height - 500) / 3;
window.open("ttadmin.cgi?act=whois&ip="+ip, "",
"width=520, height=500, left="+left+", top="+top+", scrollbars=1, resizable=1");
}