HKGalden內務臺
發表文章發起投票
「狂賀」膠 . 登 . 準 . 備 . 執 . 柒 . 倒 . 數 . 區
'+emoji.emojiId+''); }) }); /* Load image which the webpage unscrollable(no scrollbar) */ /* if($('body').height() < $(window).height()) */ $('img.lazy').lazyload({threshold:320,effect:'fadeIn'}).removeClass('lazy'); /* For ajax loaded content */ $(document).on('mouseover','.blkusr',function(){ if(!$(this).attr('title')){ $(this).attr('title',function(){ return '\\u5C01\u9396\u6703\u54E1 - '+$(this).closest('.gpt').find('.l .dtl a').text(); }); } }); $(document).on('click','.blkusr',function(e){ var uname = $(this).closest('.gpt').find('.l .dtl a').text(); var uid = $(this).closest('.gpt').data('authorid'); $.post('/ajax/blockUser',{'blkusr':uid},function(rdata){ var ele = $('section.gpt[data-authorid="'+uid+'"]'); ele.each(function(e){ var new_data = '// temporary unblock user '+uname+' //'; $(this).addClass('blked'); $(this).empty().html(new_data); }); },'json'); }); curpg = 1; ttlpg = 0; highlight = 0; $(window).keydown(function(e){ if(e.target.tagName.toLowerCase() !== 'input' && e.target.tagName.toLowerCase() !== 'textarea' && e.keyCode == 37 || e.target.tagName.toLowerCase() !== 'input' && e.target.tagName.toLowerCase() !== 'textarea' && e.keyCode == 39){ if(e.keyCode == 37 && curpg-1 > 0){ location.href = '/forum/view/428268?page='+(curpg-1); } if(e.keyCode == 39 && curpg+1 <= ttlpg){ location.href = '/forum/view/428268?page='+(curpg+1); } return false; } }); ajaxloaded = 0; npAfter = 3; $('.nxpgldr span b.s').text(npAfter); $(window).scroll(function(){ if($(window).scrollTop() == ($(document).height()-$(window).height()) && ttlpg > 1 && curpg < ttlpg && !$('input,textarea').is(':focus')){ var npCounter = npAfter; if($(window).scrollTop() != ($(document).height()-$(window).height())){ window.clearInterval(npCntInterval); $('.nxpgldr span b.s').text(npAfter); } var npCntInterval = setInterval(function(){ npCounter--; if($(window).scrollTop() != ($(document).height()-$(window).height())){ window.clearInterval(npCntInterval); $('.nxpgldr span b.s').text(npAfter); }else{ if(npCounter >= 0){ $('.nxpgldr span b.s').text(npCounter); } if(npCounter === 0){ while(npCntInterval !== null){ window.clearInterval(npCntInterval); npCntInterval = null; } setTimeout(function(){ $.post('/ajax/loadReplies',{page:curpg+1,post_id:428268,feat:highlight},function(rdata){ if(npCntInterval === null){ curpg++; history.pushState({url:'#np'+curpg},document.title,'#np'+curpg); if(ttlpg !== rdata.ttlpg){ ttlpg = rdata.ttlpg; $('').appendTo($('td.opt select')); } $('#ratrap #GoodRate').html(rdata.rate.good); $('#ratrap #BadRate').html(rdata.rate.bad); $('.hkga-pagin.btm').find('td.opt select option:selected',this).removeAttr('selected'); $('.hkga-pagin.btm').find('td.opt select option[value="'+curpg+'"]').prop('selected',true); $(rdata.replies_html).insertAfter($('article').find('.gpt.replies:last')); if(!$('.hkga-pagin.btm').find('td.prev a').length){ $('.hkga-pagin.btm').find('td.prev').append('上一頁'); } else if($('.hkga-pagin.btm').find('td.prev a').length){ $('.hkga-pagin.btm').find('td.prev a').replaceWith('上一頁'); }; if (curpg === ttlpg){ $('.hkga-pagin.btm').find('td.next a').remove(); $('.nxpgldr').remove(); } else { $('.nxpgldr span b.s').text(npAfter); $('.nxpgldr span b.p').text(function(i,txt){return txt.replace(/\\d+/,curpg+1);}); if($('.hkga-pagin.btm').find('td.next a').length){ $('.hkga-pagin.btm').find('td.next a').replaceWith('下一頁'); } } ajaxloaded = 1; var authorList = document.getElementsByClassName('author-x'); for(var i = 0; i < authorList.length; i++){ window.createAuthorComponent(authorList[i]); } } },'json'); },200); } } },1000); } }); $(window).bind('popstate',function(e){ if(e.originalEvent.state !== null){ $('html,body').animate({scrollTop:$(e.originalEvent.state.url).offset().top-64},500); curpg--; } }); /* Redirect to url hash page number after refresh */ if(window.location.hash && ajaxloaded === 0){ let page = window.location.hash.substr(1).replace('np','','g'); location.href = '/forum/view/428268?page='+page; } var logged = false; var rated = false; /*if(!logged || rated){ $('.rate_button').attr("disabled", true); }*/ if(!logged){ $('#ratrap').addClass('dised').attr('title','請先登入'); } else { if (rated) { $('#ratrap').addClass('dised').attr('title','你已經對這題目評分了'); } else { $.get('/ajax/isRated/428268',function(res){ if (!res.rate_func) { $('#ratrap').addClass('dised').attr('title','評分系統暫停使用'); } else { if(rated){ $('#ratrap').addClass('dised').attr('title','你已經對這題目評分了'); } } }); } } if(highlight > 0){ $('.gpt[data-authorid='+highlight+']').addClass('feat'); }; $('.fancybox-media').fancybox({ openEffect:'none', closeEffect:'none', helpers:{ media:{} }, }); $(document).on('click','a.profile',function(e){ e.preventDefault(); $.fancybox.showActivity; $.ajax({ type:'POST', url:'/ajax/profile/' +$(this).attr('data-mid'), success: function(data){ $.fancybox({ maxWidth:600, maxHeight:400, fitToView: true, width:'70%', height:'70%', autoSize:true, closeClick:false, 'content':data, }); $.fancybox.hideActivity; } }); }); /*$(document).on('mouseenter','#fpy',function(){*/ $(document).on('click','#fpy',function(){ $(this).addClass('fcs'); $(this).find('#gae #ta').focus(); }); $(document).on('click',function(e){ if(e.target.id == 'fpy' || $(e.target).parents('#fpy').length && $('#fpy').hasClass('fcs')){} else if($(e.target).hasClass('fancybox-overlay')){} else{ $('#fpy').removeClass('fcs'); } }); $(document).on('keydown',function(e){ if(e.which == 82 && e.shiftKey && (e.target.nodeName !== 'INPUT' || e.target.nodeName !== 'TEXTAREA') && !$('#fpy').hasClass('fcs')){ $('#fpy').addClass('fcs'); } }); $(document).on('click','.fast_quote',function(){ mQuoteVals = {'quote_type':$(this).attr('data-type'),'quote_id':$(this).attr('data-id')}; $.ajax({ type:'POST', url:'/ajax/quote/', data:mQuoteVals, dataType:'json', success:function(rdata){ $('#fpy').addClass('fcs'); $('#gae #ta').focus().val('').val(rdata.quote_content+"\n"); } }); }); $(document).on('click','.rate_button',function(){ if (!rated) { mQuoteVals = {'rate':$(this).attr('data-value'),'id':'428268','type':'post'}; $.ajax({ type:'POST', url:'/ajax/rate/', data:mQuoteVals, dataType:'json', success:function(rdata){ $('#GoodRate').text(rdata['result']['good']); $('#BadRate').text(rdata['result']['bad']); $('#ratrap').addClass('dised'); $('#ratrap').attr('title','你已經對這題目評分了'); } }); } }); $(document).on('click','#preview_fast_reply',function(e){ e.preventDefault(); $.fancybox.showActivity; if($('#gae #ta').val().length > 0){ $.ajax({ type:'POST', url:'/ajax/preview/reply', data:$('#fast_reply').serialize(), success:function(data){ $.fancybox({ minWidth:'70%', minHeight:'70%', 'content':data, }); $.fancybox.hideActivity; } }); }else{ notify('請輸入回覆內容'); } }); $(document).on('click','#submit_fast_reply',function(e){ e.preventDefault(); if($('#gae #ta').val().length > 0){ $('#submit_fast_reply').attr('disabled',true); $.ajax({ type:'POST', url:'/ajax/fastreply', data:$('#fast_reply').serialize(), success: function(data){ if(data.status == true){ $('#reply_content').val(''); window.location.reload(); }else if(data.status == false){ alert('Error:'+data.msg); window.location.reload(); } } }); }else{ notify('請輸入回覆內容'); } }); /* Ctrl + Enter plugin */ $(document).on('keydown','#gae #ta',function(e){ if(e.ctrlKey && e.keyCode == 13){ $('#submit_fast_reply').click(); } }); $(document).on('click','#gae .emt a',function(e){ e.preventDefault(); var c = $(this).attr('data-code')+' '; gaeSetTag(c); }); $(document).on('click','.loadBlk',function(){ var rid = $(this).closest('.gpt').data('id'); var type = $(this).closest('.gpt').data('type'); if(type == 'reply'){ $.ajax({ type:'get', url:'/ajax/loadReply/'+rid, dataType:'json', success:function(r){ $('.gpt[data-id="'+rid+'"]').removeClass('blked'); $('.gpt[data-id="'+rid+'"]').html(r.data); $('.gpt[data-id="'+rid+'"] .bab .hig').html('#'+$('.gpt[data-id="'+rid+'"]').attr('data-rno')); } }); }else{ $.ajax({ type:'get', url:'/ajax/loadTopic/'+rid, dataType:'json', success:function(r){ $('.gpt[data-id="'+rid+'"]').removeClass('blked'); $('.gpt[data-id="'+rid+'"]').html(r.data); } }); } }); }); $(document).ajaxStop(function(){ $('img.lazy').lazyload({threshold:320,effect:'fadeIn'}).removeClass('lazy'); });