/*******************************************************************************
Description : GENERAL Script
Last Modified : 2003/04/14
*******************************************************************************/
/*******************************************************************************
USER_MENU script
*******************************************************************************/
function user_menu(id, name, email, url) {
// user menu layer
var obj = document.all["id_user_menu"];
// 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 += " ";
// id or name
if(id != "") {
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
} else {
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
}
// email
if(email != "") {
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
}
// url
if(url != "" && url != "http://" && url != "HTTP://") {
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
}
// memo and personal info
if(id != "") {
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
text += " ";
text += " | ";
text += "  | ";
text += " | ";
text += " | ";
text += " ";
}
text += " ";
text += " | ";
text += "
";
text += " ";
text += "  | ";
text += "
";
text += "
";
obj.innerHTML = text;
obj.style.visibility = "visible";
}
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/search_" + field + ".gif";
obj_field.value = 0;
} else {
document.all["s_"+field+"_chk"].src = PATH_SKIN + "images/search_" + field + "-1.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
*******************************************************************************/
// comment write
function write_comment(idx) {
var obj = document.all["id_comment"];
comment_form.article_idx.value = idx;
obj.style.posLeft = event.x - 250 + document.body.scrollLeft;
obj.style.posTop = event.y + document.body.scrollTop;
obj.style.visibility = "visible";
}
function hide_comment() {
comment_form.article_idx.value = "";
document.all["id_comment"].style.visibility = "hidden";
}
function add_comment() {
var idx = comment_form.article_idx.value;
if(document.all["comment_name"].value == "") {
alert("À̸§À» ½á ÁÖ¼¼¿ä");
document.all["comment_name"].focus();
return;
}
if(MEMBER_IDX == 0) {
// ·Î±×ÀÎÇÑ °æ¿ì´Â ºñ¹Ð¹øÈ£¸¦ ¹ÞÁö¾ÊÀ½.
if(document.all["comment_pwd"].value == "") {
alert("ºñ¹Ð¹øÈ£À» ½á ÁÖ¼¼¿ä");
document.all["comment_pwd"].focus();
return;
}
}
if(document.all["comment_content"].value == "") {
alert("³»¿ëÀ» ½á ÁÖ¼¼¿ä");
document.all["comment_content"].focus();
return;
}
comment_form.action = "ttboard.cgi?act=add_comment" + QUERY_DB + "&idx=" + idx;
comment_form.submit();
}
function show_comment_pwd(article_idx, comment_idx) {
if(MEMBER_IDX == 0) {
// before login
var obj = document.all["id_comment_pwd"];
if(article_idx != 0 && comment_idx != 0) {
comment_form.del_pwd.value = "";
comment_form.article_idx.value = article_idx;
comment_form.comment_idx.value = comment_idx;
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 = article_idx;
comment_form.comment_idx.value = comment_idx;
del_comment();
event.returnValue = false;
}
}
function hide_comment_pwd() {
document.all["id_comment_pwd"].style.visibility = "hidden";
}
function del_comment() {
var pwd = comment_form.del_pwd.value;
hide_comment_pwd();
comment_form.action = "ttboard.cgi?act=del_comment" + QUERY_DB + "&pwd=" + pwd;
comment_form.submit();
}
/*******************************************************************************
WRITE script
*******************************************************************************/
function verify_data() {
// check name
if(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(write_form.title.value == "") {
alert("Á¦¸ñÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
write_form.title.focus();
return;
}
// check content
if(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
}
}
// 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);
// link1
resize_object_width("link1", 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 = 2; 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(!document.all["id_link" + i]) continue;
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 == "del_comment") del_comment();
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 flag = 0;
// check 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;
}
flag = 1;
}
}
if(!flag) {
alert("ÀÐÀ» °Ô½Ã¹°À» ¼±ÅÃÇØÁֽʽÿÀ.");
return;
}
list_form.action = "ttboard.cgi?act=multi_read" + QUERY;
list_form.submit();
}
function multi_delete() {
var flag = 0;
// check index
for(var i = 1; i <= ARTICLE_ROWS; i++) {
var obj = document.all["check" + i];
if(obj && obj.value != 0) flag = 1;
}
if(!flag) {
alert("»èÁ¦ÇÒ °Ô½Ã¹°À» ¼±ÅÃÇØÁֽʽÿÀ.");
return;
}
list_form.action = "ttboard.cgi?act=multi_del" + QUERY + "&page=" + PAGE_CUR_PAGE;
list_form.submit();
}
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 + "&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");
}
function view_image(idx,imgpath) {
url = "ttboard.cgi?act=popup" + QUERY_DB + "&object=popupimage&idx=" + idx + "&imgpath=" + imgpath;
viewWin = window.open(url,'', 'width=500, height=400, scrollbars=yes, resizable=yes');
}