���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/lnovel/layout/novel/js/ |
var ChapterApp = function(){ var sendViewed = false; var scrollEvent = function(){ window.onscroll = function(){ if(document.getElementById('chapter-wrap').getBoundingClientRect().top - window.scrollY<=0){ document.getElementById('chapter-controller').className = 'fixed'; }else{ document.getElementById('chapter-controller').className = ''; } }; }; var chapterInfo = function(){ API.get('/chapters/'+chapter.chapterID,null,null,function(data){ var params = Utils.getParams(); var pr = (params!==false && params.preview==1)?'?preview=1':''; if(data.next){ $('.next').removeClass('disabled').attr('href',Utils.chapterLink(story,data.next)+pr); } if(data.prev){ $('.prev').removeClass('disabled').attr('href',Utils.chapterLink(story,data.prev)+pr); } document.addEventListener('keyup',function(e){ if(e.keyCode==37){ if($('.prev').hasClass('disabled')) return; location.href = $('.prev').attr('href'); }else if(e.keyCode==39){ if($('.next').hasClass('disabled')) return; location.href = $('.next').attr('href'); }else if(e.keyCode==123){ $('#chapter-wrap').remove(); } }); }); }; var chapterList = function(storyID){ API.get('/stories/'+storyID+'/chapters',null,{limit:'-1'},function(data){ var params = Utils.getParams(); var pr = (params!==false && params.preview==1)?'?preview=1':''; var html = '<ul class="chapter-list">'; for(var i=0;i<data.chapters.length;i++) html += '<li id="c'+data.chapters[i].chapterID+'"><a href="'+Utils.chapterLink(story,data.chapters[i])+pr+'">'+Utils.chapter_fullname(data.chapters[i])+'</a></li>'; html += '</ul>'; Main.modal(function(){ Modal.show('modal-chapters',langs.list_chapters+'('+data.total+')',html,''); var currentLi = document.getElementById('c'+chapterID); currentLi.className = 'current'; document.getElementById('modal-chapters').scroll(0,currentLi.offsetTop); }); }); }; var configPanel = function(){ var readerConfig = getCookie('readerConfig'); if(!readerConfig) readerConfig = { background: 'faf5eb', fontsize: 21, pagewidth: 1000, fontfamily: 'Piazzolla' }; else readerConfig = JSON.parse(readerConfig); var colour = ['faf5eb','f5eacc','e6f2e6','e4f1f5','f5e4e4','191b1c']; var families = ['Piazzolla','Palatino Linotype','Bookerly','Segoe UI','Patrick Hand','Times New Roman','Verdana','Tahoma','Arial']; var html = '<a href="javascript:" rel="nofollow" class="close-panel">×</a><header>'+langs.configs.title+'</header><div class="config-group"> <label>'+langs.configs.background+'</label>'+ '<div class="checkbox-color-list">'; for(var i=0;i<colour.length;i++) html += '<a href="#'+colour[i]+'" class="change-bg" style="background:#'+colour[i]+';"></a>'; html += '</div></div>'; html += '<div class="config-group"><label>'+langs.configs.fontsize+'</label><div class="size-group" data-min="14" data-max="32" data-step="1" data-config="fontsize">'+ '<a href="#" rel="nofollow" class="size-control" data-type="down">A-</a><span>'+readerConfig.fontsize+'</span><a href="#" rel="nofollow" class="size-control" data-type="up">A+</a></div></div>'; html += '<div class="config-group"><label>'+langs.configs.fontfamily+'</label><div class="select-group"><select id="config-font-family">'; for(i=0;i<families.length;i++) html += '<option value="'+families[i]+'">'+families[i]+'</option>'; html += '</select></div></div>'; if(window.innerWidth>500){ html += '<div class="config-group"><label>'+langs.configs.pagewidth+'</label><div class="size-group" data-min="480" data-max="1000" data-step="20" data-config="pagewidth">'+ '<a href="#" rel="nofollow" class="size-control" data-type="down">▯-</a><span>'+readerConfig.pagewidth+'</span><a href="#" rel="nofollow" class="size-control" data-type="up">▯+</a></div></div>'; } $('#panel-setting').html(html); $('#panel-setting .close-panel').on('click',function(e){ e.preventDefault(); $('#chapter-controller .open').removeClass('open'); $('#panel-setting').css('display','none'); }); $('#panel-setting .change-bg[href="#'+readerConfig.background+'"]').addClass('checked'); $('#panel-setting .change-bg').on('click',function(e){ e.preventDefault(); $('#panel-setting .change-bg.checked').removeClass('checked'); $(this).addClass('checked'); readerConfig.background = $(this).attr('href').replace('#',''); setCookie('readerConfig', JSON.stringify(readerConfig),365*24); if($(this).attr('href')=='#191b1c'){ $(document.body).addClass('darkmode'); }else{ $('#chapter-wrap').css('background-color',$(this).attr('href')); $(document.body).removeClass('darkmode'); } }); $('#config-font-family').val(readerConfig.fontfamily); $('#config-font-family').on('change',function(){ readerConfig.fontfamily = this.value; setCookie('readerConfig', JSON.stringify(readerConfig),365*24); $('#chapter-content,.chapter-note').css('font-family',this.value); }); $('#panel-setting .size-control').on('click',function(e){ e.preventDefault(); var min = parseInt($(this.parentNode).data('min')); var max = parseInt($(this.parentNode).data('max')); var step = parseInt($(this.parentNode).data('step')); var config = $(this.parentNode).data('config'); var value = parseInt(this.parentNode.getElementsByTagName('span')[0].textContent); if($(this).data('type')=='down'){ value -= step; if(value<min) value = min; }else{ value += step; if(value>max) value=max; } this.parentNode.getElementsByTagName('span')[0].textContent = value; readerConfig[config] = value; setCookie('readerConfig', JSON.stringify(readerConfig),365*24); switch(config){ case 'fontsize': $('#chapter-content').css('font-size',readerConfig.fontsize+'px'); break; case 'pagewidth': $('#chapter-wrap').css('width',readerConfig.pagewidth+'px'); break; } }); }; var chapterControllEvents = function(){ var readerConfig = getCookie('readerConfig'); if(!readerConfig) readerConfig = { background: 'faf5eb', fontsize: 21, pagewidth: 1000, fontfamily: 'Piazzolla' }; else readerConfig = JSON.parse(readerConfig); if(readerConfig.background=='191b1c'){ document.body.className += ' darkmode'; }else{ $('#chapter-wrap').css('background-color','#'+readerConfig.background); } var divs = []; var is = $('#chapter-wrap').get(0).children; for(var i=0;i<is.length;i++) if(is[i].id && is[i].id!='chapter-controller') divs.push(is[i]); is = $('#chapter-wrap .chapter-infos').get(0).children; for(i=0;i<is.length;i++) if(is[i].id) divs.push(is[i]); for(i=0;i<divs.length;i++){ $(divs[i]).css('font-size',readerConfig.fontsize+'px'); $(divs[i]).css('font-family',readerConfig.fontfamily); } if(window.innerWidth>=800) $('#chapter-wrap').css('width',readerConfig.pagewidth+'px'); $('#chapter-controller .config').on('click',function(e){ e.preventDefault(); if($(this.parentNode).hasClass('open')){ $(this.parentNode).removeClass('open'); $('#panel-setting').css('display','none'); } if($('#panel-setting').html()=='') configPanel(); $('#chapter-controller li').removeClass('open'); $(this.parentNode).addClass('open'); $('#panel-setting').css('display','block'); }); }; var donateBox = function(){ if(!story.donate || parseInt(story.donate)==0) return; var s = ''; if(story.schedule) s = ' '+langs.messages.schedule.replace('%s','<strong>'+Utils.schedule_desc(story.schedule)+'</strong>')+'.'; var html = '<p>'+ langs.messages.donate_call.replace('%t',langs.type[story.type]) .replace('%a','<a href="'+Utils.profileLink(user)+'">'+user.display_name+'</a>') .replace('%s',s).replace('%l',langs.author_label[story.type])+ '</p><a href="#" rel="nofollow" class="button button-primary" id="donate">'+langs.actions.donate+'</a>'; var div = document.createElement('div'); div.className='donate-box'; div.innerHTML = html; document.getElementById('chapter-wrap').insertBefore(div,$('#chapter-wrap>.ads').get(0)); $('#donate').on('click',function(e){ e.preventDefault(); if(!userData){ return Main.triggerLogin(function(){ donateModal(); }); } donateModal(); }); }; var renderCommentList = function(container,items){ var item; var liked = getCookie('comment_liked').split(','),l; for(var i=0;i<items.length;i++){ l = liked.indexOf(items[i].commentID)!=-1?true:false; item = commentItem(items[i],l); container.appendChild(item); if(!l) $(item).find('.action-like-comment').on('click',likeCommentEvent); $(item).find('.action-reply-comment').on('click',replyCommentEvent); } initImageLazy(); }; var commentEvent = function(){ $('#comment-message').on('input',function(e){ $('#comment-char-count span').html(this.value.length); if(this.value.length>15 && this.value.length<500) $('#comment-char-count span').attr('class','valid'); else $('#comment-char-count span').attr('class','invalid'); }); $('#comment-more a').on('click',function(e){ e.preventDefault(); var paged = parseInt($(this).data('paged')); API.get('stories/'+story.storyID+'/comments',null,{offset:(paged-1)*20},function(data){ var commentList = document.getElementById('comment-list'); renderCommentList(commentList,data.comments); if(data.total>paged*20) $('#comment-more a').data('paged',paged+1); else $('#comment-more').css('display','none'); window.scrollTo(0,document.getElementById('comment-list').offsetTop); }); }); }; var replyCommentEvent = function(e){ e.preventDefault(); var frm = document.createElement('form'); frm.innerHTML = '<input type="hidden" name="replyTo" value="'+this.getAttribute('data-id')+'">'+ '<textarea aria-label="comment" name="message" placeholder="'+langs.comment_form.textarea_placeholder+'"></textarea>'+ '<p class="comment-char-count">'+langs.comment_form.character_count+': <span>0</span></p><div class="text-right">'+ '<button type="submit" class="button button-primary"><i class="fas fa-paper-plane" aria-hidden="true"></i> '+langs.comment_form.send_reply+'</button></div>'; frm.className = 'comment-form reply-form'; var li = document.getElementById('comment'+this.getAttribute('data-id')); var next = li.nextSibling; if(next) li.parentNode.insertBefore(frm, next); else li.parentNode.appendChild(frm); $(frm['message']).on('input',function(e){ $(frm).find('.comment-char-count span').html(this.value.length); }); frm.addEventListener('submit',function(e){ e.preventDefault(); handlePostComment(this); }); }; var likeCommentEvent = function(e){ e.preventDefault(); API.put('/stories/0/comments/'+this.getAttribute('data-id'),null,null,function(data){ var liked = getCookie('comment_liked'); if(liked=='') liked = []; else liked = liked.split(','); liked.push(data.commentID); setCookie('comment_liked',liked.join(','),365*24); $('#comment'+data.commentID+' .action-like-comment').addClass('liked'); document.getElementById('comment'+data.commentID).getElementsByClassName('action-like-comment')[0].removeEventListener('click', likeCommentEvent); var $likeCount = $('#comment'+data.commentID+' .likeCount').html(); var l = parseInt($likeCount.html().replace('. ','')); l++; $likeCount.html('. '+l); }); }; var handlePostComment = function(form){ if(!userData){ return Main.triggerLogin(function(data){ handlePostComment(document.getElementById('comment-form')); }); } var postData = { replyTo: form['replyTo'].value, message: form['message'].value, chapter: chapter }; API.post('/stories/'+storyID+'/comments',{},postData,true,function(data){ Toast.success(langs.messages.comment_success); form['message'].value = ''; },function(request){ Toast.error(langs.messages['comment_'+request.status]); }); }; var commentItem = function(item,liked){ var li = document.createElement('li'); li.id = 'comment'+item.commentID; li.className = 'comment clearfix lvl-'+item.level; if(item.parent>0) li.className = li.className+' subComment'; li.className = li.className += ' premium_'+item.premium; li.setAttribute('data-user-id',item.userID); li.setAttribute('data-parent',item.parent); li.setAttribute('data-id',item.commentID); var label = ''; var vip_level = (typeof item.vip_level != "undefined" && parseInt(item.vip_level)>0)?'<em>VIP '+item.vip_level+'</em>':''; if(item.icons == null) item.icons = ''; var icons = item.icons.split(';'); var icon_str = ''; for(var i=0;i<icons.length;i++){ if(icons[i]!='') icon_str += ' <i class="uicon '+icons[i]+'"></i>'; } if(item.userID==story.userID) label = '<small>'+langs.author_label[story.type]+' '+langs.labels.story+' <strong>'+story.title+'</strong></small>'; var html = '<div class="avatar avatar-border '+item.border+'"><img data-layzr="'+Utils.userAvatar(item)+'" alt="'+Utils.htmlEntities(item.display_name)+'" width="40" height="40"/></div>'+' <div class="comment-content"><p class="userinfo"><a rel="nofollow" href="'+Utils.profileLink(item)+'">'+item.display_name+'</a>'+vip_level+icon_str+'<span>'+Utils.formatDate(Utils.date2time(item.created),'d/m/Y')+'</span>'+label+'</p>'+ '<p class="message">'+Utils.nl2br(item.message)+'</p><div class="acts">'+ '<a href="#" rel="nofollow" class="action-reply-comment" title="Trả lời" data-type="story" data-object="'+storyID+'" data-id="'+item.commentID+'">'+ '<i class="fa fa-reply"></i> '+langs.reply+'</a><a href="#" rel="nofollow" class="action-like-comment'+(liked?' liked':'')+'" data-id="'+item.commentID+'">'+ '<i class="fa fa-thumbs-o-up"></i> '+langs.like+' <span class="likeCount">. '+item.liked+'</span></a></div></div>'; li.innerHTML = html; return li; }; var readActions = function(){ $('#read-actions').html(''); if(getCookie('auto-unlock')==1){ document.getElementById('toggle-auto1').checked = true; } var userData = Utils.parseUser(); $('.switcher label').on('click',function(){ if(getCookie('auto-unlock')==1){ setCookie('auto-unlock',0,-1); }else{ setCookie('auto-unlock',1,30*24); if(userData) QmHJgvQWxi(); } }); if(userData){ API.get('chapters/'+chapter.chapterID+'/buy',null,null,function(data){ QmHJgvQWxi(); },function(request){ switch (request.status){ case 401: Toast.error(langs.errors['401']); break; case 404: Toast.error(langs.buyChapter[404]); break; case 402: var data = JSON.parse(request.responseText); var text = 'Bạn đang có <strong>'+Utils.number_format(data.user.point)+'<i class="nut"></i></strong>'; if(parseInt(data.user.point)<chapter.point){ text += ', không đủ hạt dẻ để đọc chương này.'; $('#read-actions').append('<p>'+text+'</p><p> Vui lòng nạp thêm <a href="https://enovel.mobi/users/topup" class="text-primary toggleTopup">tại đây</a>'); }else{ var discount = 0; if(userData.premium_exp){ var exp = Utils.date2time(userData.premium_exp); if(exp>(new Date())){ const discounts = {1:0.05,2:0.1}; discount = discounts[userData.premium]; } } text = '<p>'+text+'</p><p style="margin-top: 20px;"><a href="#" class="loadChapter">'+langs.buyChapter.confirm_btn.replace('%d',chapter.point*(1-discount)); if(discount>0){ text += '<br/><small><em>(Đã giảm '+(discount*100)+'% từ gói '+langs.premium[userData.premium]+')</em></small>'; } text += '</a></p>'; $('#read-actions').append(text); $('.loadChapter').on('click',function(e){ e.preventDefault(); QmHJgvQWxi(); }); if(getCookie('auto-unlock')==1){ QmHJgvQWxi(); setCookie('auto-unlock',1,30*24); } } break; } }); }else{ callbackLogin = readActions; $('#read-actions').append('<p>Vui lòng <a href="#" class="text-primary toggleLogin">đăng nhập</a> để đọc tiếp</p>'); } }; var pickupPineal = function(){ if(getCookie('pickup_pineal_limited')) return; setTimeout(function(){ API.get('/users/pickupPineal',null,null,function(data){ if(typeof data.limited) setCookie('pickup_pineal_limited',1,0.5); if(data.detect){ var body = document.body, html = document.documentElement; var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); var showPineal = function(){ if(window.scrollY>height/2){ var p = document.createElement('p'); p.id = 'pickup-pineal'; p.innerHTML = '<i class="pineal" style="font-size: 48px;"></i><span></span><br/>'+langs.labels.pickup_pineal; document.body.appendChild(p); window.removeEventListener('scroll',showPineal); $('#pickup-pineal').on('click',function(){ document.body.removeChild(this); API.post('/users/pickupPineal',null,null,true,function(data){ Toast.success(langs.messages.pickup_pineal_success.replace('%s','<i class="pineal"></i>')); },function(request){ if(request.status==400) return Toast.custom(langs.messages.pickup_pineal_fail,{ icon: 'https://cdn.enovel.mobi/images/shit.gif', title: 'Ewww!', close_style: 'background:#f44336;' }); }); }); } } window.addEventListener('scroll',showPineal); } }); },5000); }; var onlineTracking = function(){ if(!userData || getCookie('online_finish')) return; var sendPing = function(){ API.get('users/online',null,null,function(){},function(xhr){ if(xhr.status==409){ var d = new Date(); var eod = new Date(d.getFullYear(),d.getMonth(),d.getDate(),23,59,59); document.cookie = "online_finish=1;expires=" + eod.toUTCString() + ";path=/"; clearInterval(onlineTimer); } }); }; var online_stack = getCookie('online_stack')?parseInt(getCookie('online_stack')):0; var onlineTimerFunc = function(){ online_stack++; if(online_stack>=60){ online_stack=0; sendPing(); } setCookie('online_stack',online_stack,0.1); }; var onlineTimer = null; window.addEventListener('blur',function(){ console.log('x'); clearInterval(onlineTimer); onlineTimer = null; }); window.addEventListener('focus',function(){ console.log('y'); onlineTimer = setInterval(onlineTimerFunc,1000); resetScrollBounce(); }); var onScrollBounce = null; var resetScrollBounce = function(){ clearTimeout(onScrollBounce); setTimeout(function(){ clearInterval(onlineTimer); onlineTimer = null; },60000); }; resetScrollBounce(); window.addEventListener('scroll',function(){ if(!onlineTimer) onlineTimer = setInterval(onlineTimerFunc,1000); resetScrollBounce(); }); }; return { init:function(){ setTimeout(function(){ if(!getCookie(chapter.chapterID)){ API.put('/stories/'+story.storyID+'/viewed',null,{chapter:chapter.chapterID},true); setCookie(chapter.chapterID,'1',2); } },5000); chapterInfo(); onlineTracking(); if($('#read-actions').length){ readActions(); } donateBox(); if(userData){ API.get('/stories/'+storyID+'/buy',null,null,function(data){ $('.buy-story-box').remove(); },function(request){ }); pickupPineal(); } $('#unlock-story').on('click',function(e){ e.preventDefault(); if(!userData){ return Main.triggerLogin(function(data){$('#unlock-story').click();}); } API.post('/stories/'+storyID+'/buy',null,{},true,function(data){ },function(request){ if(typeof langs.buyStory.messages != "undefined") return Toast.error(langs.buyStory.messages[request.status]); return Toast.error(langs.errors[request.status]); }); }); if(story.notification){ var noti = document.createElement('div'); noti.className = 'story-notification'; var ls = story.notification.split("\r\n"); noti.innerHTML = '<label>'+langs.titles.author_notification.replace('%s',langs.author_label[story.type])+'</label><p>'+ls.join('<br/>')+'</p>'; document.getElementById('chapter-wrap').insertBefore(noti,$('#chapter-wrap>.ads').get(0)); } if(parseInt(story.limited)>0){ var warning = document.createElement('div'); warning.className = 'story-warning limited-'+story.limited; warning.innerHTML = langs.messages['story_limit_'+story.limited]; $('.chapter-infos')[0].insertBefore(warning,$('.metas')[0].nextSibling); } if(window.outerWidth>500){ scrollEvent(); $(document).on('contextmenu',function(){ $('#chapter-wrap').remove(); }); } $('.directory').on('click',function(e){ e.preventDefault(); chapterList(storyID); }); chapterControllEvents(); setTimeout(function(){ var reading = getCookie('reading'); if(reading=='') reading = {}; else reading = JSON.parse(reading); reading[story.storyID] = chapter; setCookie('reading', JSON.stringify(reading),30*24); API.get('stories/'+story.storyID+'/comments',null,{chapterID:chapter.chapterID},function(data){ var commentList = document.getElementById('comment-list'); renderCommentList(commentList,data.comments); if(data.total>20){ $('#comment-more').css('display','block'); } }); },2000); commentEvent(); $('#comment-form').on('submit',function(e){ e.preventDefault(); handlePostComment(this); }); if($('.content-message').length){ if(!userData){ $('.content-message').append('<a href="#" rel="nofollow" class="button button-primary" id="login-to-continue">'+langs.login_form.login+'</a>'); $('#login-to-continue,.toggleLogin').on('click',function(e){ e.preventDefault(); Main.triggerLogin(function(){location.reload()}); }); } } var likes = getCookie('likes'); if(likes){ likes = JSON.parse(likes); if(likes.indexOf(chapterID)!==-1) $('.like-chapter').addClass('liked').html('<i class="fas fa-thumbs-up"></i> '+langs.labels.liked); } $(document).on('click','#chapter_error',function(e){ e.preventDefault(); reportModal(); $('#chapter_error').remove(); }).on('click','#unlock-story',function(e){ e.preventDefault(); if(!userData){ return Main.triggerLogin(function(data){$('#unlock-story').click();}); } API.post('/stories/'+storyID+'/buy', null,{},true,function(data){ },function(request){ if(typeof langs.buyStory.messages != "undefined") return Toast.error(langs.buyStory.messages[request.status]); return Toast.error(langs.errors[request.status]); }); }); $('.like-chapter').on('click',function(e){ if($(this).hasClass('liked')) return Toast.error(langs.messages.chapter_liked); var chapterID = parseInt($(this).data('id')); var likes = getCookie('likes'); if(!likes) likes = []; else likes = JSON.parse(likes); if(likes.indexOf(chapterID)!==-1) Toast.error(langs.messages.chapter_liked); else{ API.put('chapters/'+chapterID.toString(),null,null,true,function(data){ Toast.success(langs.messages.chapter_liked); likes.push(chapterID); setCookie('likes',JSON.stringify(likes),365*24); $('.like-chapter').addClass('liked'); }); } }); var genres = story.genres.split(','),c; for(var i=0;i<genres.length;i++){ c = getCookie('genre-'+genres[i]); if(!c) c = 1; else c = parseInt(c)+1; setCookie('genre-'+genres[i],c,365*24); } if(!userData && !getCookie('invite_login')){ $(document).on('click','#login-modal .modal-header .close',function(e){ setCookie('invite_login',1,24); }); setTimeout(function(){ Main.triggerLogin(function(){ setCookie('invite_login',1,24); },function(){ setCookie('invite_login',1,24); }); },5000); } } } }(); document.addEventListener('DOMContentLoaded', function() { ChapterApp.init(); }); function onlyUnique(value, index, self) { return self.indexOf(value) === index; } function reportModal(){ var processing = false,loadingTimer,k=1; Main.modal(function(){ var html = '<div class="form-group"><label>'+langs.labels.report_content+'</label>' + '<select class="form-control" id="report_content">'; var options = [ 'Sử dụng từ ngữ thô tục', 'Nội dung có yếu tố chính trị', 'Nội dung xuyên tạc lịch sử', 'Nội dung không phù hợp với độ tuổi', 'Nội dung tuyên truyền mê tín dị đoan', 'Truyện không chính chủ' ]; for(var i=0;i<options.length;i++) html += '<option value="'+options[i]+'">'+options[i]+'</option>'; html += '</select><br/><em>Tôi cam kết báo cáo đúng sự thật.</em></div>'; Modal.show('report-modal',langs.labels.report_title,html,'<a href="#" id="send-report" class="button button-primary">'+langs.actions.send_report+'</a>'); $('#send-report').on('click',function(e){ e.preventDefault(); if(processing) return; processing = true; loadingTimer = setInterval(function(){ $('#send-report').html('Processing'+'.'.repeat(k)); k++; if(k>5) k=0; },500); API.post('/chapters/'+chapter.chapterID+'/report',null,{ content: $('#report_content').val() },true,function(data){ processing = false; $('#send-report').html(langs.actions.send_report); clearInterval(loadingTimer); Toast.success(langs.messages.report_success); $('#report-modal').remove(); }); }); }); } function donateModal(){ var processing = false,loadingTimer,k=1; Main.modal(function(){ var html = '<h5 style="margin-bottom: 15px;">'+$('.donate-box p').html()+'</h5>' + '<div class="form-group"><label>'+langs.labels.donate_nut+'</label><select id="donate-point" class="form-control">'; var ps=[10,20,30,40,50,100,200,300,400,500,1000]; for(var p=0;p<ps.length;p++) html += '<option value="'+ps[p]+'">'+ps[p]+' '+langs.nut+'</option>'; html += '</select></div><div class="form-group"><label>'+langs.labels.donate_message+'</label>' + '<textarea class="form-control" id="donate-message"></textarea></div>'; Modal.show('donate-modal',langs.actions.donate,html,'<a href="#" id="send-donate" class="button button-primary">'+langs.actions.donate+'</a>'); $('#send-donate').on('click',function(e){ e.preventDefault(); if(processing) return; processing = true; loadingTimer = setInterval(function(){ $('#send-donate').html('Processing'+'.'.repeat(k)); k++; if(k>5) k=0; },500); API.post('/stories/'+story.storyID+'/donate',null,{ point: $('#donate-point').val(), message: $('#donate-message').val() },true,function(data){ processing = false; $('#send-donate').html(langs.actions.donate); clearInterval(loadingTimer); Toast.success(langs.messages.donate_success); $('#donate-modal').remove(); }); }); }); }