<div class="ui vertical stripe segment">
    <div class="ui middle aligned container">
        <h2>Botz Dashboard</h2>
        <p>Generate temporary content for the site.</p>

        <div class="ui segment">
            <h4>Scrape Content</h4>
            <button class="ui button" id="scrape-site">Test Endpoint</button>
            <button class="ui button" id="scrape-blog">Blog Post</button>
            <button class="ui button" id="scrape-comment">Comments</button>
            <button class="ui button" id="scrape-users">Users</button>
            <button class="ui button" id="scrape-sports-skills">Create Sports Skills</button>
            <button class="ui button" id="scrape-game-skills">Create Game Skills</button>
            <button class="ui button" id="scrape-skill-items">Skill Items</button>
        </div>

        <div class="ui segment">
            <h4>Scrape RSS Content</h4>
            <button class="ui button" id="scrape-rss-users"><i class="icon rss square"></i>Users</button>
            <button class="ui button" id="scrape-blog-rss"><i class="icon rss square"></i>Blog Posts</button>
            <button class="ui button" id="scrape-comment-rss"><i class="icon rss square"></i>Article Comments</button>
        </div>

        <div class="ui segment">
            <h4>Emulate User Activity</h4>
            <button class="ui button" id="test">Test Activity route</button>
        </div>
    </div>
</div>

<script>
    var savedResult, scrapedResult;

    // Gather content from a site.
    $ ('#scrape-site').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'https://ionicabizau.net',
                    contentSelector: JSON.stringify ({
                        title: ".header h1",
                        desc: ".header h2",
                        avatar: '.header img@src'
                    })
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-blog-rss').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape/blog',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'http://www.gameinformer.com/feeds/thefeedrss.aspx',
                    rss: true,
                    contentSelector: JSON.stringify ({
                        title: '.post-name',
                        description: '#divRenderBody > p:nth-child(2)',
                        content: ['#divRenderBody > p'],
                        image: 'p > img@src',
                        author: 'span.label:nth-child(1) > a:nth-child(1)',
                        date: '.post-author > span:nth-child(2)',
                    })
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-blog').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape/blog',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'https://nypost.com/2018/01/30/philly-cops-have-new-plan-to-keep-idiot-eagles-fans-from-light-poles/',
                    contentSelector: JSON.stringify ({
                        title: '.article-header > h1:nth-child(2) > a:nth-child(1)',
                        description: '.entry-content > p:nth-child(1)',
                        content: '.entry-content',
                        image: 'picture.featured-image:nth-child(2) > source:nth-child(1)@srcset',
                        date: '.byline-date',
                    })
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-comment').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape/comment',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'https://www.rockpapershotgun.com/2018/01/27/epic-shutting-down-paragon/',
                    scope: 'ol.commentlist > li',
                    contentSelector: JSON.stringify ([{
                        title: 'div > div.comment-content > p:nth-child(1)',
                        content: 'div > div.comment-content > p:nth-child(2)',
                        image: 'div > div > img@src',
                        date: 'p > span > span > a',
                    }])
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-comment-rss').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape/comment',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'http://feeds.feedburner.com/RockPaperShotgun',
                    scope: 'ol.commentlist > li',
                    rss: true,
                    contentSelector: JSON.stringify ([{
                        title: 'div > div.comment-content > p:nth-child(1)',
                        content: 'div > div.comment-content > p:nth-child(2)',
                        image: 'div > div > img@src',
                        date: 'p > span > span > a',
                    }])
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-users').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape/user',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'https://forum.zdoom.org/viewtopic.php?f=60&t=22457&start=5265',
                    scope: '.postprofile',
                    contentSelector: JSON.stringify ([{
                        username: 'dt > a:nth-child(3)',
                        profile: {
                            displayName: 'dt > a:nth-child(3)',
                            biography: 'dd:nth-child(2)',
                            joined: 'dd:nth-child(4)',
                            location: 'dd:nth-child(5)',
                            image: 'dt > a > img@src'
                        }
                    }])
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    $ ('#scrape-rss-users').click (function () {
        console.log ('Attempting to scrape content...');

        $.ajax (
            '/api/botz/scrape/user',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'http://feeds.feedburner.com/RockPaperShotgun',
                    scope: 'ol.commentlist > li',
                    rss: true,
                    contentSelector: JSON.stringify ([{
                        username: '.fn',
                        profile: {
                            displayName: '.fn',
                            image: 'div > div > img@src',
                            joinedOn: 'p > span > span > a',
                            biography: 'div > div.comment-content > p:nth-child(2)',
                        }
                    }])
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-sports-skills').click (function () {
        console.log ('generating skills...');

        $.ajax (
            '/api/botz/scrape/skill',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'https://en.wikipedia.org/wiki/List_of_sports#Handball_family',
                    contentSelector: {
                        skillList: ['ul:nth-child(111) > li > a']
                    }
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    $ ('#scrape-game-skills').click (function () {
        console.log ('generating skills...');

        $.ajax (
            '/api/botz/scrape/skill',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    url: 'https://en.wikipedia.org/wiki/List_of_best-selling_video_games',
                    contentSelector: {
                        skillList: ['tr > td > i > a']
                    }
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    // Gather content from a site.
    $ ('#scrape-skill-items').click (function () {
        console.log ('generating skills...');

        $.ajax (
            '/api/botz/scrape/skill/item',
            {
                accept: 'application/json',
                method: 'POST',
                headers: {
                    'Accept': 'application/json'
                },
                data: {
                    skillItemLimit: 20,
                }
            }
        ).done (function (response) {
            console.log (response);
        })
    })

    $ ('#test').click (function () {
        $.ajax (
            '/api/botz/activity/vote',
            {
                accept: 'application/json',
                method: 'GET',
                headers: {
                    'Accept': 'application/json'
                },
                data: {}
            }
        ).done (function (response) {
            console.log (response);
        })
    })
</script>
