var old_selected_index = 0; var current_selected_index = old_selected_index; var max_records = 300; var max_record_per_page = 20; var record_height = 30; var default_iframe_height = 130; var arr_profile_field = new Array(); var str_profile; str_profile = ""; var arr_old_pd_list = new Array(); function construct_native_pd_list(ARGV_checksum, ARGV_key, ARGV_order, ARGV_type, ARGV_flag, ARGV_name, ARGV_work_phone, ARGV_home_phone, ARGV_mobile_phone, ARGV_ring_tone_id) { this.CHECKSUM = ARGV_checksum; this.KEY = ARGV_key; this.ORDER = ARGV_order; this.TYPES = ARGV_type; this.FLAG = ARGV_flag; this.NAME = ARGV_name; this.WORK_PHONE = ARGV_work_phone; this.HOME_PHONE = ARGV_home_phone; this.MOBILE_PHONE = ARGV_mobile_phone; this.RING_TOME_ID = ARGV_ring_tone_id; } function construct_pd_list(ARGV_index, ARGV_name, ARGV_work_phone, ARGV_cell_phone, ARGV_home_phone, ARGV_ring_tone, ARGV_key) { this.INDEX = ARGV_index; this.NAME = ARGV_name; this.WORK_PHONE = ARGV_work_phone; this.CELL_PHONE = ARGV_cell_phone; this.HOME_PHONE = ARGV_home_phone; this.RING_TONE = ARGV_ring_tone; this.KEY = ARGV_key; } function fn_pd_list_info() { var i; var len_old_pd_profile; var current_page = 1; var total_page; var start_record ; var end_record; var obj_iframe = parent.document.getElementById("iframe_personal_directory_list"); if(obj_iframe == null) { alert("error: fn_pd_list_info"); return; } fn_parse_native_pd_list_data(); len_old_pd_profile = arr_old_pd_list.length; top.document.frm_personal_directory.bt_add_personal_directory.disabled = (len_old_pd_profile == max_records) ? true : false; if(len_old_pd_profile) { start_record = (current_page - 1) * max_record_per_page; end_record = len_old_pd_profile > (current_page * max_record_per_page) ? current_page * max_record_per_page : len_old_pd_profile; total_page = Math.ceil(len_old_pd_profile / max_record_per_page); if(len_old_pd_profile > 1) { obj_iframe.height = parseInt(obj_iframe.height) + (record_height * (end_record - 1)); } for(i = start_record; i < end_record; i++) { fn_show_pd_list(i, current_page); } }else{ fn_show_pd_list(-1, current_page); top.document.frm_personal_directory.bt_remove_personal_directory.disabled = true; top.frames[3].document.getElementById("chk_select_pd_list_all").disabled = true; } if(total_page != 1) { fn_show_pd_page_index(total_page, current_page); } current_selected_index = current_page; } function fn_parse_native_pd_list_data() { var arr_profiles; var arr_profile_field_tmp; var profile_amount; var i; if(str_profile.length == 0) { return; } arr_profiles = str_profile.split(rec_sep_ptn); arr_profiles.length = (arr_profiles.length > max_records)? max_records : arr_profiles.length; profile_amount = arr_profiles.length; for(i = 0; i < profile_amount; i++) { arr_profile_field_tmp = arr_profiles[i].split(fld_sep_ptn); arr_profile_field[i] = new construct_native_pd_list(arr_profile_field_tmp[0], arr_profile_field_tmp[1], arr_profile_field_tmp[2], arr_profile_field_tmp[3], arr_profile_field_tmp[4], arr_profile_field_tmp[5], arr_profile_field_tmp[6], arr_profile_field_tmp[7], arr_profile_field_tmp[8], arr_profile_field_tmp[9],arr_profile_field_tmp[10], arr_profile_field_tmp[11], arr_profile_field_tmp[12], arr_profile_field_tmp[13], arr_profile_field_tmp[14], arr_profile_field_tmp[15], arr_profile_field_tmp[16], arr_profile_field_tmp[17]); fn_set_pd_list_array(i, arr_profile_field[i]); } } function fn_set_pd_list_array(ARGV_index, ARGV_profile_field) { arr_old_pd_list[ARGV_index] = new construct_pd_list(ARGV_index, ARGV_profile_field.NAME, ARGV_profile_field.WORK_PHONE, ARGV_profile_field.MOBILE_PHONE, ARGV_profile_field.HOME_PHONE, ARGV_profile_field.RING_TOME_ID, ARGV_profile_field.KEY); } function fn_show_pd_list(ARGV_record_ind, ARGV_current_page) { var table_tbody = document.getElementById("tb_pd_list").getElementsByTagName("tbody")[0]; var table_tbody_tr = document.createElement("tr"); var arr_table_tbody_tr_td = new Array(); var chk_select_pd_list = document.createElement("input"); var img_edit_pd_list = document.createElement("img"); var img_quick_dial_pd_list = document.createElement("img"); var i; var j; var k; var arr_width = new Array("5%", "5%", "20%", "15%", "15%", "15%", "10%", "10%", "5%"); var no_content = "---"; table_tbody_tr.setAttribute("id", "tr" + ARGV_record_ind); for(i = 0; i < arr_width.length; i++) { arr_table_tbody_tr_td[i] = document.createElement("td"); arr_table_tbody_tr_td[i].setAttribute("id", "td" + i); arr_table_tbody_tr_td[i].setAttribute("align", "center"); arr_table_tbody_tr_td[i].setAttribute("width", arr_width[i]); arr_table_tbody_tr_td[i].setAttribute("height", 26); if((i == 0) || (i == (arr_width.length - 1))) { continue; }else{ arr_table_tbody_tr_td[i].className = "tbl_cnt"; } } if(ARGV_record_ind != -1) { chk_select_pd_list.setAttribute("type", "checkbox"); chk_select_pd_list.setAttribute("id", "chk_select_pd_list" + ARGV_record_ind); chk_select_pd_list.setAttribute("name", "chk_sel_pd_list"); chk_select_pd_list.setAttribute("value", ARGV_record_ind); chk_select_pd_list.onclick = function(){fn_chk_sgl_item(document.frm_pd_list, this, 'chk_sel_pd_list_all')}; img_edit_pd_list.setAttribute("id", "img_edit_pd_list" + ARGV_record_ind); img_edit_pd_list.setAttribute("src", "image/UI_edit.jpg"); img_edit_pd_list.onclick = function(){fn_edit_contact_page(obj_page.add_contact, arr_old_pd_list[ARGV_record_ind])}; img_quick_dial_pd_list.setAttribute("id" ,"img_quick_dial_pd_list" + ARGV_record_ind); img_quick_dial_pd_list.setAttribute("src", "image/UI_dial.jpg"); img_quick_dial_pd_list.onclick = function(){fn_add_to_quick_dial(ARGV_record_ind)}; arr_table_tbody_tr_td[1].appendChild(chk_select_pd_list); arr_table_tbody_tr_td[2].innerHTML = arr_old_pd_list[ARGV_record_ind].NAME; arr_table_tbody_tr_td[3].innerHTML = arr_old_pd_list[ARGV_record_ind].WORK_PHONE == "NULL" ? "---" : arr_old_pd_list[ARGV_record_ind].WORK_PHONE; arr_table_tbody_tr_td[4].innerHTML = arr_old_pd_list[ARGV_record_ind].CELL_PHONE == "NULL" ? "---" : arr_old_pd_list[ARGV_record_ind].CELL_PHONE; arr_table_tbody_tr_td[5].innerHTML = arr_old_pd_list[ARGV_record_ind].HOME_PHONE == "NULL" ? "---" : arr_old_pd_list[ARGV_record_ind].HOME_PHONE; arr_table_tbody_tr_td[6].appendChild(img_edit_pd_list); arr_table_tbody_tr_td[7].appendChild(img_quick_dial_pd_list); }else{ for(j = 1; j < (arr_width.length - 1); j++) { arr_table_tbody_tr_td[j].innerHTML = no_content; } } for(k = 0; k < arr_width.length; k++) { table_tbody_tr.appendChild(arr_table_tbody_tr_td[k]); } table_tbody.appendChild(table_tbody_tr); } function fn_edit_contact_page(ARGV_page_name, ARGV_edit_list) { fn_sw_pop_pg(); fn_show_contact_fields(ARGV_edit_list) } function fn_show_contact_fields(ARGV_edit_list_data) { var select_index; var dest_form = top.document.getElementById("load_webpage").contentWindow.document.frm_add_contact; var dest_submit_form = top.document.getElementById("load_webpage").contentWindow.document.frm_hidden_add_contact; dest_form.txt_contact_name.value = ARGV_edit_list_data.NAME; dest_form.txt_work_phone.value = ARGV_edit_list_data.WORK_PHONE == "NULL" ? "" : ARGV_edit_list_data.WORK_PHONE; dest_form.txt_cell_phone.value = ARGV_edit_list_data.CELL_PHONE == "NULL" ? "" : ARGV_edit_list_data.CELL_PHONE; dest_form.txt_home_phone.value = ARGV_edit_list_data.HOME_PHONE == "NULL" ? "" : ARGV_edit_list_data.HOME_PHONE; dest_form.sl_ring_tone.selectedIndex = parseInt(ARGV_edit_list_data.RING_TONE); dest_submit_form.hdn_contact_key.value = ARGV_edit_list_data.KEY; } function fn_show_pd_page_index(ARGV_total_page, ARGV_current_page) { var table_tbody; var table_tbody_tr; var arr_table_tbody_tr_td = new Array(); var arr_width = new Array((100 - (3 * ARGV_total_page) - (10 + 5 + 5 + 10 + 10)) + "%", "10%", "5%", "3%", "5%", "10%", "10%"); var columns; var i; var k; table_tbody = document.getElementById("tb_pd_page").getElementsByTagName("tbody")[0]; if(table_tbody == null) { alert("error: fn_show_pd_page_index"); return; } table_tbody_tr = document.createElement("tr"); table_tbody_tr.setAttribute("id", "tb_pd_page_tr1"); columns = 6 + ARGV_total_page; old_selected_index = ARGV_current_page; for(i = 0; i < columns; i++) { arr_table_tbody_tr_td[i] = document.createElement("td"); arr_table_tbody_tr_td[i].setAttribute("id", "tb_pd_page_tr1_td" + i); if((i == 0) || (i == 1)) { arr_table_tbody_tr_td[i].setAttribute("width", arr_width[i]); }else if((i == 2) || (i == columns - 3)){ arr_table_tbody_tr_td[i].setAttribute("width", arr_width[i]); }else if(i == columns - 2){ arr_table_tbody_tr_td[i].setAttribute("width", arr_width[arr_width.length - 2]); arr_table_tbody_tr_td[i].innerHTML = "" + obj_btn.next_page + ""; }else if(i == columns - 1){ arr_table_tbody_tr_td[i].setAttribute("width", arr_width[arr_width.length - 1]); }else{ arr_table_tbody_tr_td[i].setAttribute("width", arr_width[3]); if(i == ARGV_current_page + 2) { arr_table_tbody_tr_td[i].innerHTML = "" + (i - 2) + ""; }else{ arr_table_tbody_tr_td[i].innerHTML = "" + (i - 2) + ""; } } } for(k = 0; k < (ARGV_total_page + arr_width.length - 1); k++) { table_tbody_tr.appendChild(arr_table_tbody_tr_td[k]); } table_tbody.appendChild(table_tbody_tr); } function fn_change_page(ARGV_total_page, ARGV_page_index) { fn_clean_up_old_pd_records(ARGV_total_page, ARGV_page_index); fn_show_new_pd_records(ARGV_total_page, ARGV_page_index); fn_show_new_index(ARGV_total_page, ARGV_page_index); current_selected_index = ARGV_page_index; if(top.window.frz_pab) { top.window.fn_frz_entry_pab(document.frm_pd_list, ARGV_page_index) } } function fn_show_new_pd_records(ARGV_total_page, ARGV_page_index) { var start_record; var end_record; var obj_iframe = parent.document.getElementById("iframe_personal_directory_list"); if(obj_iframe == null) { alert("error: fn_show_new_pd_records"); return; } obj_iframe.height = default_iframe_height; start_record = (ARGV_page_index - 1) * max_record_per_page; if(ARGV_page_index == ARGV_total_page) { end_record = arr_old_pd_list.length; obj_iframe.height = parseInt(obj_iframe.height) + (record_height * ((end_record % max_record_per_page) ? (end_record % max_record_per_page) : max_record_per_page)); }else{ end_record = ARGV_page_index * max_record_per_page; obj_iframe.height = parseInt(obj_iframe.height) + (record_height * (max_record_per_page - 1)); } for(i = start_record; i < end_record; i++) { fn_show_pd_list(i, ARGV_page_index); } } function fn_clean_up_old_pd_records(ARGV_total_page, ARGV_page_index) { var table_tbody = document.getElementById("tb_pd_list").getElementsByTagName("tbody")[0]; var table_tbody_tr; var i; var start_record; var end_record; if(table_tbody == null) { alert("error: fn_clean_up_old_pd_records"); return; } start_record = (old_selected_index - 1) * max_record_per_page; if(old_selected_index == ARGV_total_page) { end_record = arr_old_pd_list.length; }else{ end_record = old_selected_index * max_record_per_page; } for(i = start_record; i < end_record; i++) { table_tbody_tr = eval("document.getElementById(\"tr" + i + "\")"); if(table_tbody_tr != null) { table_tbody.removeChild(table_tbody_tr); } } if(top.frames[3].document.frm_pd_list.chk_sel_pd_list_all.checked) { top.frames[3].document.frm_pd_list.chk_sel_pd_list_all.checked = false; } } function fn_show_new_index(ARGV_total_page, ARGV_page_index) { var table_tbody_tr_td_prev; var table_tbody_tr_td_next; var table_tbody_tr_td_index; var table_tbody_tr_td_old_index; table_tbody_tr_td_prev = document.getElementById("tb_pd_page_tr1_td1"); if(table_tbody_tr_td_prev == null) { alert("error: fn_show_new_index"); return; } table_tbody_tr_td_next = eval("document.getElementById(\"tb_pd_page_tr1_td" + (ARGV_total_page + 4) +"\")"); if(table_tbody_tr_td_next == null) { alert("error: fn_show_new_index"); return; } table_tbody_tr_td_index = eval("document.getElementById(\"tb_pd_page_tr1_td" + (ARGV_page_index + 2) +"\")"); if(table_tbody_tr_td_index == null) { alert("error: fn_show_new_index"); return; } table_tbody_tr_td_old_index = eval("document.getElementById(\"tb_pd_page_tr1_td" + (old_selected_index + 2) +"\")"); if(table_tbody_tr_td_old_index == null) { alert("error: fn_show_new_index"); return; } table_tbody_tr_td_old_index.innerHTML = "" + old_selected_index + ""; table_tbody_tr_td_index.innerHTML = "" + ARGV_page_index + ""; old_selected_index = ARGV_page_index; if(ARGV_page_index == 1) { table_tbody_tr_td_prev.innerHTML = ""; table_tbody_tr_td_next.innerHTML = "" + obj_btn.next_page + ""; }else if(ARGV_page_index == ARGV_total_page){ table_tbody_tr_td_prev.innerHTML = "" + obj_btn.prev_page + ""; table_tbody_tr_td_next.innerHTML = ""; }else{ table_tbody_tr_td_prev.innerHTML = "" + obj_btn.prev_page + ""; table_tbody_tr_td_next.innerHTML = "" + obj_btn.next_page + ""; } }