var current_edit_index = -1; var friend_box_cnt = 1; var friend_box_cnt_max = 5; //clone 3rd row and put to box_extra function initPanel(){ current_edit_index = 1; } //called by flash object function upload_finish( filename ){ //alert("shit: " + filename); var param_full = filename + ',' + 'http://images.pvideo.com.hk/upload/focus/200905_mtr/'; //alert(param_full); updatePageIcons(param_full); } function showImgPersistent(id, url) { id = id.replace(/'/g, ''); url = url.replace(/'/g, ''); var reload = false; var img = document.getElementById(id); if(img){ var persist = false; if(img.src != url){ reload = true; persist = true; } else if(img.complete && img.width==0){ //reload reload = true; persist = true; } else if(!img.complete){ persist = true; } if(reload){ img.style.display = 'none'; img.src = url; } if(persist){ setTimeout('showImgPersistent(\'' +id +'\', \''+url +'\');', 500); } else{ img.style.display = ''; } } } function updatePageIcons(data){ var a = data.split(','); var imgId = a[0]; var url = a[1]; // alert("wait a few second"); //set image var t = document.getElementById('uploaded_pict_' +current_edit_index); //$("#uploaded_pict_" +current_edit_index); //t.src = url + imgId + '.jpg'; var new_src = url + imgId + '.jpg'; //t.src = new_src; //showImgPersistent('uploaded_pict_' +current_edit_index, new_src); //set hidden field $("#img_ul_"+current_edit_index).attr('value', imgId); //$("#box_edit_" + current_edit_index).css({'height':'1px'}); $("#box_fd" + current_edit_index).css({'height':'180px'}); showImgPersistent('uploaded_pict_' +current_edit_index, new_src); //hide panel hideEditorPanel(true); } function hideEditorPanel(hide){ var editor_holder = document.getElementById('box_editor_panel_holder'); var editor = document.getElementById('box_editor_panel'); //editor.style.border = '1px solid green'; if (editor){ if(hide){ //$("#box_editor_panel").hide(); //editor.style.display = 'none'; //editor.style.height = '1px'; editor.style.visibility = 'hidden'; editor.style.height = '0px'; editor_holder.style.visibility = 'hidden'; editor_holder.style.height = '0px'; //editor_holder.style.height = '1px'; //editor_holder.style.overflow = 'hidden'; //editor.style.display = 'none'; }else{ //$("#box_editor_panel").show(); //editor.style.display = 'block'; //editor.style.height = '476px'; //editor.style.display = ''; //editor_holder.style.overflow = ''; //editor_holder.style.height = '486px'; editor_holder.style.height = '590px'; editor_holder.style.visibility = 'visible'; editor.style.height = '590px'; editor.style.visibility = 'visible'; } } } function hideListItem(){ for(i=1; i<=friend_box_cnt; i++){ //$("#box_edit_" + i).css({'height':'1px'}); $("#box_fd" + i).css({'height':'180px'}); } } function jq_moveTo(id){ //alert(id + ' ' + current_edit_index); //$("#box_editor_panel_holder").css({'display':'none'}); //$("#box_edit_" + current_edit_index).css({'height':'1px'}); $("#box_fd" + current_edit_index).css({'height':'180px'}); //hideListItem(); //$("#box_edit_" + id).css({'height':'490px'}); $("#box_fd" + id).css({'height':'800px'}); $("#box_editor_panel_holder").css({'left':'0px', 'top':(id * 180)+'px' }); /* var tar = document.getElementById("box_edit_" + id); var src = document.getElementById("box_editor_panel_holder"); if(tar){ tar.style.height = 476; src.style.top = (id * 100); } */ hideEditorPanel(false); current_edit_index = id; /* if(id != current_edit_index){ //add to new position var cloned = $("#box_editor_panel").clone(true); cloned.appendTo("#box_edit_" + id); //delete itself $("#box_edit_" + current_edit_index).empty(); } current_edit_index = id; //clear panel clearActionPanel(); //show panel hideEditorPanel(false); */ } function jq_plusMore(){ if (friend_box_cnt >= friend_box_cnt_max){ } else{ var row_html = $("#box_fd1").html(); row_html = row_html.replace(/1號/gi, ""+(friend_box_cnt+1)+"號"); row_html = row_html.replace(/jq_moveTo\(1\)/gi, "jq_moveTo(" +(friend_box_cnt+1) +")"); row_html = row_html.replace(/uploaded_pict_1/gi, "uploaded_pict_" +(friend_box_cnt+1) +""); //row_html = row_html.replace(/name_en_3/gi, "name_en_" +(friend_box_cnt+1) +""); row_html = row_html.replace(/selected_language_1/gi, "selected_language_" +(friend_box_cnt+1) +""); row_html = row_html.replace(/name_receiver_1/gi, "name_receiver_" +(friend_box_cnt+1) +""); row_html = row_html.replace(/email_1/gi, "email_" +(friend_box_cnt+1) +""); row_html = row_html.replace(/msg_1/gi, "msg_" +(friend_box_cnt+1) +""); row_html = row_html.replace(/img_ul_1/gi, "img_ul_" +(friend_box_cnt+1) +""); row_html = row_html.replace(/salutation_1/gi, "salutation_" +(friend_box_cnt+1) +""); // row_html = '