function renderStatisticTitle(startDate, endDate){ startDate = new Date(startDate); endDate = new Date(endDate); var lottery = $( "#lottery option:selected" ).text(); var title = 'Xổ Số '+lottery+' từ ngày '+(startDate.getMonth()+1) + '/' + startDate.getDate() + '/' + startDate.getFullYear()+' đến '+(endDate.getMonth()+1) + '/' + endDate.getDate() + '/' + endDate.getFullYear(); $('#query-info').html(title); } $(document).ready(function () { $('#btnFitScreen').click(function (){ var w = $(window).width(); var scale = w/1200; $('body').toggleClass('fit-mobile-screen'); $('#wrapper').css('zoom',scale) }) $(document).off('click','.digits-form label.radio') $(document).on('click','.digits-form label.radio', function (e){ e.preventDefault(); var type = parseInt($(this).attr('data-value')); $(document).find('.digits-form label[data-value='+type+'] input[type=radio]').prop('checked',true); var m = $(this).attr('highlight-loto'); var elementNumbers = $(this).closest('.block-result').find('span.number'); var tbl = $(this).closest('.block-result').find('table'); switch (type){ case 0: tbl.addClass('numbers-full') tbl.removeClass('numbers-2') tbl.removeClass('numbers-3') elementNumbers.each(function (){ var value = $(this).attr('data-value'); if(value !== undefined && value !== null){ if(m != 'off') { value = value.substr(0,3) + '' + value.substr(3) + ''; } $(this).html(value); } }); break; case 2: tbl.addClass('numbers-2'); tbl.removeClass('numbers-full') tbl.removeClass('numbers-3') elementNumbers.each(function (){ var value = $(this).attr('data-value'); if (value !== undefined && value !== null) { $(this).html(value.slice(-2)); } }); break; case 3: tbl.addClass('numbers-3') tbl.removeClass('numbers-full') tbl.removeClass('numbers-2') elementNumbers.each(function (){ var value = $(this).attr('data-value'); if (value !== undefined && value !== null) { var v = value.slice(-3); $(this).html(v); } }); break; } }) $('#btn-select-year').click(function (){ app.Loading.start('.date-search-bar'); var y = $('#year-select').val(); $('#my-year').html(y); $.ajax({ url: '/?com=lotterystatistic&act=specialbyyear&ajax=1&view=specialbyyearshort&year='+y, type: 'Get', dataType: 'html', success: function (response){ $('table.table-statistics tbody').html(response); app.Loading.end(); } }) }); $('#btn-select-month').click(function (){ app.Loading.start('.date-search-bar'); var y = $('#year-select').val(); var m = $('#month-select').val(); $('#my-year').html(y); $.ajax({ url: '/?com=lotterystatistic&act=specialbymonth&ajax=1&view=specialbymonthshort&year='+y+'&month='+m, type: 'Get', dataType: 'html', success: function (response){ $('#table-data').html(response); app.Loading.end(); } }) }); $('#btn-view-by-week').click(function (){ app.Loading.start('.date-search-bar'); var sDate = Date.parse($('#startDate').val()); var eDate = Date.parse($('#endDate').val()); var deltaDate = Math.floor((eDate - sDate) / (1000*60*60*24)) ; if(deltaDate<0){ app.Toast.showError('Ngày bắt đầu lớn hơn ngày kết thúc!'); app.Loading.end(); return; } var data = { 'lotteryId': $('#lottery').val(), 'startDate': $('#startDate').val() , 'endDate': $('#endDate').val() , }; $.ajax({ url: '/?com=lotterystatistic&act=specialbyweek&ajax=1&view=specialbyweekshort', type: 'POST', data: data, dataType: 'html', success: function (response){ renderStatisticTitle(data.startDate, data.endDate); $('table.table-statistics tbody').html(response); $(document).find('.items-on-off input[type=checkbox]').each(function (){ if($(this).prop('checked')){ switch ($(this).val()){ case "1": $(document).find('.table-statistics .first-digit').toggleClass( 'hide-this', !$(this).prop('checked') ); break; case "2": $(document).find('.table-statistics .last-digit').toggleClass( 'hide-this', !$(this).prop('checked') ); break; case "3": $(document).find('.table-statistics .loto').toggleClass( 'hide-this', !$(this).prop('checked') ); break; case "4": $(document).find('.table-statistics .sum-digit').toggleClass( 'hide-this', !$(this).prop('checked') ); break; } } }) $(document).find('.digits-form:first input[type=radio]:checked').first().closest('label.radio').trigger('click'); app.Loading.end(); } }) }); $(document).on('click','.table-statistics td',function (){ $(this).toggleClass('active'); }) $(document).on('change','.items-on-off input[type=checkbox]',function (){ switch ($(this).val()){ case "1": $(document).find('.table-statistics .first-digit').toggleClass( 'hide-this', !$(this).prop('checked') ); break; case "2": $(document).find('.table-statistics .last-digit').toggleClass( 'hide-this', !$(this).prop('checked') ); break; case "3": $(document).find('.table-statistics .loto').toggleClass( 'hide-this', !$(this).prop('checked') ); break; case "4": $(document).find('.table-statistics .sum-digit').toggleClass( 'hide-this', !$(this).prop('checked') ); break; } }) var isloadingData = false; if($('body').hasClass('result-book-page')){ $(window).scroll(function() { var d1= $(window).scrollTop() + $(window).height() + 200; var d2 = $(document).height(); if(d1 >= d2 && !isloadingData){ isloadingData = true; $('#loading-more-data').show(); app.Loading.start('#loading-process','Đang tải dữ liệu ...'); $.ajax({ url: '/?com=lotterystatistic&act=resultbook&view=resultbook_ajax&ajax=1', type: 'POST', dataType: 'html', data: { toDate: $('.lasted-date:last').val(), lotteryId: $('#lottery').val(), typeDate: $('#typeDate').val(), }, success: function (response){ $('#result-book').append(response) $('#loading-more-data').hide(); isloadingData = false; } }) } }); } $('#btn-view-result-book').click(function (){ app.Loading.start('#date-search-bar','Đang tải dữ liệu ...'); $.ajax({ url: '/?com=lotterystatistic&act=resultbook&view=resultbook_ajax&ajax=1', type: 'POST', dataType: 'html', data: { toDate: $('#toDate').val(), lotteryId: $('#lottery').val(), typeDate: $('#typeDate').val(), firstSearch: 1 }, success: function (response){ $('#result-book').html(response); app.Loading.end(); } }) }) $('#btn-view-by-frequency-step-loto').click(function (){ app.Loading.start('#date-search-bar','Đang tải dữ liệu ...'); $('#start-date').html($('#startDate').val()) $('#end-date').html($('#endDate').val()) $('#lottery-name').html($('#lottery option:selected').html()) $.ajax({ url: '/?com=lotterystatistic&act=frequencysteploto&view=frequencysteploto_ajax&ajax=1', type: 'POST', dataType: 'html', data: { lotteryId: $('#lottery').val(), curLottery: $('#lottery option:selected').attr('data-url'), startDate: $('#startDate').val(), endDate: $('#endDate').val(), number: $('#number').val(), }, success: function (response){ $('#lottery-name').html($('#lottery option:selected').html()) $('table.numbers-normally tbody').html(response); app.Loading.end(); } }) }) $('#btn-view-by-periodloto').click(function (){ app.Loading.start('#date-search-bar','Đang tải dữ liệu ...'); $('#lottery-name').html($('#lottery option:selected').html()) $.ajax({ url: '/?com=lotterystatistic&act=periodloto&view=periodloto_ajax&ajax=1', type: 'POST', dataType: 'html', data: { lotteryId: $('#lottery').val(), curLottery: $('#lottery option:selected').attr('data-url'), }, success: function (response){ $('table.numbers-normally tbody').html(response); app.Loading.end(); $('#filter-loto').val(''); } }) }) $('#filter-loto').keyup(function (){ var lotos = $(this).val().split(/(\s+)/).filter( function(e) { return e.trim().length > 0; } ); $('.table-statistics').find('tbody tr').each(function (){ if(lotos.length == 0){ $(this).removeClass('hide-this'); }else{ var loto = $(this).attr('data-loto'); if(lotos.includes(loto)){ $(this).removeClass('hide-this'); }else{ $(this).addClass('hide-this'); } } }) }) $('#btn-view-by-specialperiodloto').click(function (){ app.Loading.start('#date-search-bar','Đang tải dữ liệu ...'); $('#lottery-name').html($('#lottery option:selected').text()) $.ajax({ url: '/?com=lotterystatistic&act=specialperiod&view=specialperiod_ajax&ajax=1', type: 'POST', dataType: 'html', data: { lotteryId: $('#lottery').val(), curLottery: $('#lottery option:selected').attr('data-url'), toDate: $('#toDate').val(), }, success: function (response){ $('#list-statictis').html(response); app.Loading.end(); } }) }) });