class ViewComicComic{ constructor(param){ this.tool = new Tool(); this.ctags = null; this.click_touchend_in_progress = false; if($.cookie('lang_filter') == 'Chinese'){ this.lang = 'c'; }else{ this.lang = 'e'; } } setCtags(ctags){ this.ctags = ctags; } render(){ var html = ''; html += this.ctag_comic_form(); $('#3div').html(html); } render_cover_area(){ var html = ''; return html; } reander_base_info(){ var html = ''; return html; } render_ctag_title(){ var $html = ""; var a = ''; if( is_favorite !== undefined && is_favorite >= 1 ){ a = ''; $html += a; }else{ a = ''; $html += a; } $(".title_ctag_btn").html(a); return $html; } render_fav_title(){ var $html = ""; var a = ''; if( is_favorite !== undefined && is_favorite >= 1 ){ a = ''; a += ''; $html += a; }else{ a = ''; a += ''; $html += a; } $(".title_fav_btn").html(a); return $html; } ctag_comic_form(){ var html = ''; var text = ''; html += ''; return html; } reander_tag_list(){ var html = ''; return html; } render_rating(){ var html = ""; let s = 0; if( comic_data['isVoted'] ){ s = Math.ceil(comic_data['yourScore']); }else{ s = Math.ceil(comic_data['score']); } for( var i = 1 ; i <= 5 ; i++){ if( s >= i){ //#87CEFA let color = 'color:yellow;'; if( comic_data['isVoted'] ){ color = 'color:#87CEFA;'; } html += ''; }else{ html += ''; } } html += comic_data['score'] + '(' + comic_data['turnout'] + ')'; return html; } render_comic_info_area(){ var html = ''; html += '
'; html += '
'; html += this.reander_base_info(); html += this.reander_tag_list(); html += '
'; html += '
'; return html; } render_ctag_list(tree){ var html = ''; var self = this; for( var i = 0 ; i < tree.length ; i++ ){ var t = tree[i]; if( t['comic_id'] ){ html += ''; } else { html += ''; } html += ' '; if( t['comic_id'] ){ html += ' '; } else { html += ' '; } html += ' '; html += '   -    '; html += t.name; html += ' '; html += ''; if(t.children){ t.children.forEach(function(currentValue, index, arr){ var cv = currentValue; if( cv['comic_id'] ){ html += ''; } else { html += ''; } html += ' '; if( cv['comic_id'] ){ html += ' '; }else{ html += ' '; } html += ' '; html += '       -     '; html += cv.name; html += ' '; html += ''; }) } } $('#private_tag_list').html(html); } showCtagForm(callback){ $('#ctag_comic_form').modal('show'); callback(); } hideCtagForm(){ $('#ctag_comic_form').modal('hide'); //callback(); } handleRating(callback){ let self = this; $( ".star-area" ).on("mouseover", ".rating" ,function() { var hover_score = $(this).data('v'); $(".rating").each(function( index, value ){ if( hover_score >= $(this).data('v') ){ // checked $(this).css("color","#87CEFA"); $(this).children("i").removeClass("far"); $(this).children("i").addClass("fas"); }else{ $(this).css("color","Green"); } }); }); $( ".star-area" ).on( "mouseout" , ".rating" , function(){ //handlerOut $(".rating").each(function( index , value ){ let s = 0; if(comic_data['isVoted']){ s = Math.ceil(comic_data['yourScore']); }else{ s = Math.ceil(comic_data['score']); } if( s >= $(this).data('v') ){ let color = 'red'; if(comic_data['isVoted']){ color = '#87CEFA'; } $(this).css("color",color); }else{ //$(this).children("i").removeClass("fas"); //$(this).children("i").removeClass("fa-star"); //$(this).children("i").addClass("fa-star-o"); //$(this).children("i").addClass("fal"); $(this).children("i").removeClass("fas"); $(this).children("i").addClass("far"); $(this).css("color",""); } }); }); $( ".star-area" ).on( 'click touchend' , ".rating" ,function(){ callback(this); }); } handleFav(callback){ let self = this; $('.addFav').on('click touchend',function(event){ callback('addFavorite'); }); $('.delFav').on('click touchend',function(event){ callback('delFavorite'); }); } handleDownload(callback){ let self = this; $('.title_download_btn').on('click touchend',function(event){ callback(); }); } changeFavStatue(){ if( is_favorite !== undefined && is_favorite >= 1 ){ $('.addFav').addClass('d-none'); $('.delFav').removeClass('d-none'); $('.ctagFormBtn').removeClass('disabled'); }else{ $('.addFav').removeClass('d-none'); $('.delFav').addClass('d-none'); $('.ctagFormBtn').addClass('disabled'); } } handleCtagList(){ $("#private_tag_list").on('click tap touch', "td", function() { if( $(this).hasClass('action_btn') ){ //action button }else{ var tr = $(this).closest('tr'); var ctag_id = $(this).closest('tr').data('ctag_id'); var b = $(this).closest('tr').data('checked'); if(b==true){ $(this).closest('tr').data('checked',false); var s = '#checkbox_private_tag_id_' + ctag_id; $(s).removeClass('fa-check-square'); $(s).addClass('fa-square'); }else{ $(this).closest('tr').data('checked', true ); var s = '#checkbox_private_tag_id_' + ctag_id; $(s).removeClass('fa-square'); $(s).addClass('fa-check-square'); } if( ctag_id != 0 ){ if( $(tr).data('parent_id') ){ $("#form_parent").val($(tr).data('parent_id')); }else{ $("#form_parent").val(0); } var name = $(tr).data('name'); $("#form_action").val(1); $("#form_ctag_id").val(ctag_id); name = decodeURIComponent(escape(window.atob(name))); $("#form_name").val(name); } } }); } handleCtagResetBtn(){ var self = this; $('#ctag_reset_form').on('click touchend',function(event){ $("#form_ctag_id").val(0); $("#form_action").val(0); $("#form_name").val(''); $("#form_parent").val(0); self.form_parent_select(self.ctags); //form_parent_select(this.self,this.ctags); //list_private_tbody(tree); }); } render_ctag_parent_select(tree){ //console.log(tree); //this.ctags = tree; var html = ''; var text = 'My Private Tags'; if( this.lang == 'c'){text = '私人標籤';} html += ''; for(var i = 0 ; i < tree.length ; i++){ var t = tree[i]; html += ''; } $("#form_parent").html(html); } handleCtagFormBtn(callback){ var self = this; //this.showCtagForm(); $('.ctagFormBtn').on('click touchend', function(event){ self.showCtagForm(callback); }); } //submit_ctags handleCtagSubmit(self,callback){ $('#ctag_submit_form').on('click touchend',function(event){ callback(self); }); } handleCtagComicSubmit(self,callback){ $('#ctags_comic_submit').on('click touchend',function(event){ callback(self); }); } html_categoryActionBtn(c){ let html = ''; if( c['customer_score'] > 0){ html += ''; }else if( c['customer_score'] < 0 ){ html += ''; }else{ html += ''; } return html; } html_categoryActionBtnDropDownMenu(t){ let html = ''; let btn_color = ''; if( t['customer_score'] > 0){ html += '   Remove Category'; }else if( t['customer_score'] < 0 ){ html += '   Vote Category'; }else{ if( t['score'] == 0 ){ html += '   Vote Category'; }else{ html += '   Vote Category'; html += '   Remove Category'; } } return html; } handleCategoryBtn(callback){ let self = this; $('#1div').on('click touchend',"[data-action=addCategoryVote]",function(event){ let c_id = $(this).data('category_id'); let tmp = {}; tmp['action'] = 'addCategoryVote'; tmp['category_id'] = c_id; callback(tmp); }); $('#1div').on('click touchend',"[data-action=delCategoryVote]",function(event){ let c_id = $(this).data('category_id'); let tmp = {}; tmp['action'] = 'delCategoryVote'; tmp['category_id'] = c_id; callback(tmp); }); } changeTagFavBtn(rrr){ $("[data-action=favTag]").each(function(){ if( rrr['tag_id'] == $(this).data('tag_id') ){ $(this).attr('data-direction',rrr['direction']); $(this).data('direction',rrr['direction']); if( rrr['direction'] == 'add' ){ $("i",this).css('color','white'); $("i",this).removeClass('text-red'); $("i",this).addClass('far'); $("i",this).removeClass('fas'); }else{ $("i",this).css('color','red'); $("i",this).removeClass('text-red'); $("i",this).removeClass('far'); $("i",this).addClass('fas'); } } }); } handleTagBtn(callback){ var self = this; $("body").on('click touchend',"[data-action=favTag]",function(event){ if(self.click_touchend_in_progress)return; self.click_touchend_in_progress = true; setTimeout(function(){ self.click_touchend_in_progress = false; },100); event.stopPropagation();event.preventDefault(); let tag_id = $(this).data('tag_id'); let gk_id = comic_data['gk_id']; let gt_id = $(this).data('gt_id'); let e_id = comic_data['exhentai_id']; let cover_extension = comic_data['cover_extension']; let cover_server_id = comic_data['cover_server_id']; let direction = $(this).data('direction'); let tmp = {}; tmp['action'] = direction + 'TagFav'; tmp['tag_id'] = tag_id; tmp['gk_id'] = gk_id; tmp['gt_id'] = gt_id; tmp['e_id'] = e_id; tmp['cover_extension'] = cover_extension; tmp['cover_server_id'] = cover_server_id; callback(tmp); }); } }