사용자:Hsl0/연구소

리버티게임, 모두가 만들어가는 자유로운 게임
< 사용자:Hsl0
imported>Hsl0님의 2020년 12월 27일 (일) 01:39 판 (→‎낙서장)

낙서장

$('#gamelist-liv li').map(function() {
    var data = $(this).find('.old-gameicon-status').data();
    data = {
        progress: data.progress === ""? null : data.progress,
        edit: data.edit === ""? null : data.edit,
        tech: data.tech === ""? null : data.tech,
        rating: data.rating === ""? null : data.rating
    };
    var nameElement = this.querySelector('.old-gameicon-name a');
    var title = decodeURI(new URL(nameElement.href).pathname.slice(6));
    data.name = nameElement.innerText;
    var maker = $(this).find('.old-gameicon-maker');
    data.helper = maker.find('.old-gameicon-helper a').map(function() {
        var url = new URL(this.href);
        if(url.searchParams.has('title')) return url.searchParams.get('title').slice(4).split('/')[0].replace(/_/g, ' ');
        else return decodeURI(url.pathname.slice(6)).slice(4).split('/')[0].replace(/_/g, ' ');
    }).toArray();
    if(!data.helper.length) data.helper = null;
    else if(data.helper.length === 1) data.helper = data.helper[0];
    data.maker = maker.find('a:not(.old-gameicon-helper a)').map(function() {
        var url = new URL(this.href);
        if(url.searchParams.has('title')) return url.searchParams.get('title').slice(4).split('/')[0].replace(/_/g, ' ');
        else return decodeURI(url.pathname.slice(6)).slice(4).split('/')[0].replace(/_/g, ' ');
    }).toArray();
    if(data.maker.length === 1) data.maker = data.maker[0];
    return data;
});