var CMyhome = Class.create(); CMyhome.prototype = { initialize: function(member_uid,myhome_uid,is_owner) { this.member_uid = member_uid; this.myhome_uid = myhome_uid; this.is_owner = is_owner; this.now_page = 1; // this.now_writing = false; this.handle_as_eff = null; //로그인 상태이면 정기적으로 새로운 쪽지 확인 if(this.member_uid) { } }, addbox_show: function(tar) { if(!this.is_owner || this.now_writing) return; el = $('addbox_'+tar); bel = $('addselector'); $('writebox_type').value=tar; Effect.BlindUp(bel,{duration:0.3, afterFinish:(function(){ Effect.BlindDown(el,{duration:0.5}); }).bind(this)}); }, addbox_linkchk: function(el) { if(el.value=='http://') { el.value=''; } }, addbox_hide: function() { if(!this.is_owner || this.now_writing) return; tar = $('writebox_type').value; if(!tar) return; el = $('addbox_'+tar); bel = $('addselector'); $('writebox_type').value=''; Effect.BlindUp(el,{duration:0.5, afterFinish:(function(){ Effect.BlindDown(bel,{duration:0.3}); }).bind(this)}); }, onfocus_replybox: function(el) { if(this.member_uid==0||!this.member_uid) { el.readOnly=true; member.showPop(); return; } else { } }, onblue_replybox: function(el) { }, chkmsg_writebox: function(msg_el) { counter_el = $('writebox').select('.counter')[0]; dcounter = 250-msg_el.value.bytes(); if(dcounter<0) counter_el.addClassName('counter_over'); else counter_el.removeClassName('counter_over'); counter_el.update(dcounter); }, visible_reply:function(view_uid) { el = $('storylist').select('.story_box_'+view_uid)[0]; el.select('.inputbut')[0].hide(); el.select('.inputarea')[0].show(); el.select('.reply_msg')[0].focus(); }, submit_reply: function(tar) { el = $(tar).select('.reply_msg')[0]; el.value = el.value.trim(); if(el.value.bytes()<1) { alert('내용을 입력해주세요'); el.focus(); return false; } if(el.value.bytes()>250) { alert('250자 내외의 내용만 입력 가능합니다'); el.focus(); return false; } //로딩표시 el.readOnly = true; el.addClassName('reply_msg_loading'); //등록 var rowTemplate = new Template("story_uid=#{story_uid}&msg=#{msg}"); param = rowTemplate.evaluate({ story_uid : $(tar).select('.story_uid')[0].value, msg : encodeURIComponent(el.value) }); this.xmlRequest = new Ajax.Request( '/inc/ajax/myhome/add_story_reply.html', { method: 'post', parameters: param, onComplete: (function(t) { jv = t.responseText.evalJSON(); el_reply = $('storylist').select('.story_box_'+jv.story_uid*-1+' .reply_box .list')[0]; el_reply.insert(jv['html']); el_reply.removeClassName('list_empty'); el_new = el_reply.select('.row_'+jv.reply_uid)[0]; //로딩표시 제거 el.readOnly = false; el.removeClassName('reply_msg_loading'); new Effect.Pulsate(el_new,{pulses: 3,duration:1.5,afterFinish:(function(){ }).bind(this)}); }).bind(this) }); //폼 초기화 el.value = ''; return false; }, submit_story: function(f) { wbox_el = $('writebox'); msg_el = wbox_el.select('.message')[0]; msg_el.value = msg_el.value.trim(); f.link_href.value = f.link_href.value.trim(); add_type = $('writebox_type').value; if(msg_el.value.length==0) { alert('내용을 입력해주세요'); msg_el.focus(); return false; } if(msg_el.value.bytes()>250) { alert('250자 내외의 내용만 입력 가능합니다'); msg_el.focus(); return false; } if(add_type=='link'&&f.link_href.value.is_mixshlink()) { alert('믹시 내부링크는 첨부할 수 없습니다.'); f.link_href.focus(); return false; } this.now_writing = true; msg_el.readOnly = true; wbox_el.addClassName('writebox_ready'); wbox_el.select('.butreg')[0].hide(); wbox_el.select('.butreg_loading')[0].show(); switch(add_type) { case 'photo': wbox_el.select('.photo_file')[0].readOnly = true; break; case 'link': wbox_el.select('.link_href')[0].readOnly = true; break; default: //this.handle_as_eff = Effect.BlindUp($('addselector'),{duration:0.3, afterFinish:(function(){}).bind(this)}); //$('addselector').hide(); break; } }, complete_writebox: function(story_uid,trackback) { this.now_writing = false; wbox_el = $('writebox'); msg_el = wbox_el.select('.message')[0]; msg_el.readOnly = false; wbox_el.removeClassName('writebox_ready'); wbox_el.select('.butreg_loading')[0].hide(); wbox_el.select('.butreg')[0].show(); //추가 관련 add_type = $('writebox_type').value; switch(add_type) { case 'photo': wbox_el.select('.photo_file')[0].readOnly = false; /* Effect.BlindUp($('addbox_photo'),{duration:0.3, afterFinish:(function(){ Effect.BlindDown($('addselector'),{duration:0.3, afterFinish:(function(){}).bind(this)}); }).bind(this)}); */ $('addbox_photo').hide(); $('addselector').show(); break; case 'link': wbox_el.select('.link_href')[0].readOnly = false; /* Effect.BlindUp($('addbox_link'),{duration:0.3, afterFinish:(function(){ Effect.BlindDown($('addselector'),{duration:0.3, afterFinish:(function(){}).bind(this)}); }).bind(this)}); */ $('addbox_link').hide(); $('addselector').show(); break; default: if($('addselector').visible()) { //this.handle_as_eff.cancel(); } else { //Effect.BlindDown($('addselector'),{duration:0.3, afterFinish:(function(){}).bind(this)}); $('addselector').show(); } break; } //변수 초기화 msg_el.update(''); $('writebox_form').reset(); msg_el.focus(); //마지막에 등록된 게시물 로딩 param =''; this.xmlRequest = new Ajax.Request( '/inc/ajax/myhome/get_mylast_story.html', { method: 'get', parameters: param, onComplete: (function(t) { jv = t.responseText.evalJSON(); $('storylist').update(jv['html']+$('storylist').innerHTML); el = $('storylist').select('.story_box_'+(jv['story_uid']*-1)+' .inner_box')[0]; //el_date = el.select('.tsdate .date')[0].hide(); if(trackback) { el.select('.contents')[0].insert("
"); //alert(trackback); } new Effect.Pulsate(el,{pulses: 3,duration:1.5,afterFinish:(function(){ //el_date.show(); }).bind(this)}); }).bind(this) }); }, send_trackback: function(type,uid,trackback) { el = $('storylist').select('.story_box_'+(uid*-1)+' .inner_box')[0]; if(type=='close') { t_el = el.select('.trackback')[0]; new Effect.Fade(t_el,{duration:0.5}); } else //send { if(type=='send') { t_el = el.select('.trackback')[0]; t_el.select('.buts')[0].update(''); t_el.select('.buts')[0].addClassName('loading'); msg_el = t_el.select('.tinfo')[0]; msg_el.update('트랙백을 전송하고 있습니다'); } var rowTemplate = new Template("uid=#{story_uid}&trackback=#{trackback}"); param = rowTemplate.evaluate({ story_uid : uid*-1, trackback: trackback }); this.xmlRequest = new Ajax.Request( '/inc/ajax/myhome/send_trackback.html', { method: 'post', parameters: param, onComplete: (function(t) { switch(t.responseText) { case "1": msg_el.update('전송이 완료되었습니다'); break; case "0": case "-1": case "-2": msg_el.update('처리중 문제가 발생했습니다.'); break; case "-3": msg_el.update('트랙백이 정상적으로 전송되지 못했습니다.'); break; } if(t_el) { t_el.select('.buts')[0].removeClassName('loading'); new Effect.Fade(t_el,{delay:1, duration:0.5}); } }).bind(this) }); } }, delete_story: function(uid) { if(!confirm('정말 삭제하시겠습니까?\n\n한번 삭제된 게시물은 복구되지 않으며, 해당 게시물에 달려있는 댓글도 함께 삭제됩니다.')) { return; } var rowTemplate = new Template("uid=#{story_uid}"); param = rowTemplate.evaluate({ story_uid : uid }); el = $('storylist').select('.story_box_'+(uid*-1))[0]; el.select('.del_but')[0].hide(); el.select('.del_loading')[0].show(); this.xmlRequest = new Ajax.Request( '/inc/ajax/myhome/del_story.html', { method: 'post', parameters: param, onComplete: (function(t) { switch(t.responseText) { case "1": Effect.DropOut(el); break; case "-1": //변수오류 alert('삭제중 오류가 발생하였습니다'); have_error = 1; break; case "-2": //컨텐츠 존재여부 alert('존재하지 않는 게시물입니다.'); have_error = 1; break; case "-3": //본인 소유여부 alert('직접 작성한 게시물만 삭제가능합니다.'); have_error = 1; break; } if(have_error) { el.select('.edit .del_but')[0].show(); el.select('.edit .del_loading')[0].hide(); } }).bind(this) }); }, delete_story_reply: function(uid) { if(!confirm('정말 삭제하시겠습니까?\n\n한번 삭제된 댓글은 복구되지 않습니다.')) { return; } var rowTemplate = new Template("uid=#{reply_uid}"); param = rowTemplate.evaluate({ reply_uid : uid }); el = $('storylist').select('.reply_box .row_'+(uid))[0]; el.select('.del_but')[0].hide(); el.select('.del_loading')[0].show(); this.xmlRequest = new Ajax.Request( '/inc/ajax/myhome/del_story_reply.html', { method: 'post', parameters: param, onComplete: (function(t) { switch(t.responseText) { case "1": Effect.DropOut(el); break; case "-1": //변수오류 alert('삭제중 오류가 발생하였습니다'); have_error = 1; break; case "-2": //컨텐츠 존재여부 alert('존재하지 않는 댓글입니다.'); have_error = 1; break; case "-3": //본인 소유여부 alert('직접 작성한 댓글만 삭제가능합니다.'); have_error = 1; break; } if(have_error) { el.select('.edit .del_but')[0].show(); el.select('.edit .del_loading')[0].hide(); } }).bind(this) }); }, nextpage: function(type,taruid,sort,addinfo,steppos) { this.now_page++; if(!sort) sort=""; //등록 var rowTemplate = new Template("type=#{type}&sort=#{sort}&addinfo=#{addinfo}&steppos=#{steppos}&taruid=#{taruid}&page=#{page}"); param = rowTemplate.evaluate({ type : type, sort : sort, addinfo : addinfo, page : this.now_page, steppos : steppos, taruid : taruid }); $('nextpage_but').hide(); $('nextpage_loading').show(); this.xmlRequest = new Ajax.Request( '/inc/ajax/myhome/nextpage.html', { method: 'post', parameters: param, onComplete: (function(t) { jv = t.responseText.evalJSON(); switch(jv.result) { case -1: case 1: $(jv.target_el).insert(jv.html); $('nextpage_loading').hide(); //마지막 페이지면 if(!jv.is_lastpage) { $('nextpage_but').show(); } else { $('nextpage_end').show(); } break; } }).bind(this) }); }, blank: function() { } }