AD

자유 로생 계산기

Broadcaster 로동엑샤
2023-03-10 00:02:51 25 1 0

var lastNum = 1;

var sum = 0;

var regexp = /\B(?=(\d{3})+(?!\d))/g;

var chargeDateList=[];

var chargeWayList=[];

var cashList=[];

var text = "";

var years = [2017,2018,2019,2020,2021,2022,2023,2024,2025,2026];

for(var j=years.length-1; j>=0;j--){

    $.ajax({

                url: '/Cash/GetChargeList',

                type: 'GET',

                data: { Page: 1, StartDate: years[j]+'.01.01', EndDate: years[j]+'.12.31'},

                dataType: 'html',

                async: false,

                success: function (data) {

                    var pageNum = $(data).find(".pagination__last")[0].getAttribute("onClick");

                    if(pageNum != null){

                        lastNum = pageNum.replace(/[^0-9]/g,"");

                    }

                },

                error: function (xhr, status, error) {

                    ajaxErrorHandler(xhr, status, error);

                    return;

                }

            });

    for(var i=1;i<=lastNum;i++){

        $.ajax({

                url: '/Cash/GetChargeList',

                type: 'GET',

                data: { Page: i, StartDate: years[j]+'.01.01', EndDate: years[j]+'.12.31'},

                dataType: 'html',

                async: false,

                success: function (data) {

                    $(data).find("td.list__price").each(function(){

                        var $cash = $(this)

                        cashList.push($cash.text().replace(/[^0-9]/g,""))

                    });

                    $(data).find("td.list__date").each(function(){

                        var $cash = $(this)

                        chargeDateList.push($cash.text())

                    });

                    $(data).find("td.list__way").each(function(){

                        var $cash = $(this)

                       chargeWayList.push($cash.text())

                    });

                },

                error: function (xhr, status, error) {

                    ajaxErrorHandler(xhr, status, error);

                    return;

                }

            });

    }

}


(function(console) {

    console.save = function(data, filename){

        if(!data) {

            console.error('Console.save: No data')

            return;

        }

        if(!filename) filename = 'console.html'

        if(typeof data === "object"){

            data = JSON.stringify(data, undefined, 4)

        }

        var blob = new Blob([data], {type: 'text/json'}),

            e    = document.createEvent('MouseEvents'),

            a    = document.createElement('a')


        a.download = filename

        a.href = window.URL.createObjectURL(blob)

        a.dataset.downloadurl =  ['text/json', a.download, a.href].join(':')

        e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)

        a.dispatchEvent(e)

    }

})(console)


function downloadCSV(csv, filename) {

  var csvFile;

  var downloadLink;


  //한글 처리를 해주기 위해 BOM 추가하기

  const BOM = "\uFEFF";

  csv = BOM + csv;


  csvFile = new Blob([csv], { type: "text/csv" });

  downloadLink = document.createElement("a");

  downloadLink.download = filename;

  downloadLink.href = window.URL.createObjectURL(csvFile);

  downloadLink.style.display = "none";

  document.body.appendChild(downloadLink);

  downloadLink.click();

}


cashList.forEach(function(cash){

    sum += Number(cash);

});


var csv = [];

var row = [];


row.push(

    "충전일자",

    "충전금액",

    "충전수단",

);

csv.push(row.join(","));


for(var i =cashList.length-1; i>=0;i--){

    console.log(chargeDateList[i] + " " + cashList[i].replace(regexp, ',') + "원 " + chargeWayList[i]);

    text = text + "\n"+chargeDateList[i] + " " + cashList[i].replace(regexp, ',') + "원 " + chargeWayList[i];

    row = [];

    row.push(

        chargeDateList[i],

        cashList[i],

        chargeWayList[i],

    );

    csv.push(row.join(","));

}


sum = sum.toString().replace(regexp, ',');

text = text + "\n" +"총합 : " + sum;

console.log("현재까지 "+sum+"원 사용하셨습니다");

alert("현재까지 "+sum+"원 사용하셨습니다")


function downloadResult() {

      downloadCSV(csv.join("\n"),"로아현질내역.csv")

    }


const el = document.createElement('button');

el.id = 'downloadBtn';

el.style = 'width: 100%; height: 64px; text-align: center';

el.innerText = '사용내역 다운로드';

el.onclick = downloadResult;

document.body.prepend(el);

후원댓글 0
댓글 0개  
이전 댓글 더 보기
TWIP 잔액: 확인중
▲윗글 주말 하드12노말3 불가능 로동엑샤
▼아랫글 두꺼비 존나재밌음 잉여인간이여
공지사항자유클립
1
자유
방송키십니까?
삐빠뿌뽀
02-19
1
자유
야추가 떨린다
Broadcaster 로동엑샤
02-02
1
자유
25년 몬헌 신작 [2]
잉여인간이여
12-08
1
10-18
1
자유
뭐야 맹구 망함?
Broadcaster 로동엑샤
10-15
1
자유
길드토벌전 피통
잉여인간이여
10-08
1
자유
2관클
Broadcaster 로동엑샤
10-02
1
자유
the 비틱
Broadcaster 로동엑샤
09-03
1
08-26
1
자유
핏쨩 그려봄ㅋㅋ
eafifafoot
08-25
1
자유
아마드코어 하고싶다 [1]
Broadcaster 로동엑샤
08-25
1
자유
??? 큰 결심
Broadcaster 로동엑샤
08-25
1
07-27
1
자유
....
Broadcaster 로동엑샤
07-11
1
자유
개 쓰레기 ㅈ같은게임 [1]
잉여인간이여
07-03
1
자유
개같이 멸망 [1]
Broadcaster 로동엑샤
06-25
1
05-17
1
04-19
1
04-07
1
자유
성불 [4]
Broadcaster 로동엑샤
03-21
1
03-10
»
자유
로생 계산기
Broadcaster 로동엑샤
03-10
1
자유
두꺼비 존나재밌음 [1]
잉여인간이여
02-22
1
자유
데아빌 100 클리어 [2]
Broadcaster 로동엑샤
01-30
1
자유
그거 티저영상나옴 [1]
잉여인간이여
01-13
1
자유
올해 결산 [1]
잉여인간이여
12-27
인기글 글 쓰기