$(document).ready(function () {
    "use strict";
    
    // Клик на кнопки сервисные действий:
    $('.service-action').click(function(){
        var
            action = $(this).attr('href'),
            dataRequest;
        
        // Стр. сайтов
        if ($(this).hasClass('add-list-sites')) {
            dataRequest = {addlist: true};
        }
        if ($(this).hasClass('add-date-sites')) {
            dataRequest = {addDate: true};
        }
        if ($(this).hasClass('create-json-sites')) {
            dataRequest = {createJsonSites: true};
        }
        if ($(this).hasClass('create-providers-list')) {
            dataRequest = {createProvidersList: true};
        }
        if ($(this).hasClass('test')) {
            //dataRequest = {url: 'http://0day.kiev.ua'};
            //dataRequest = {url: 'http://ua.sinoptik.ua'};
            //dataRequest = {url: 'http://bigmir.net'};
            //dataRequest = {url: 'http://playboyua.com.ua'};
            //dataRequest = {url: 'http://kino-live.top'};
            dataRequest = {url: 'http://sinoptik.ua'};
            //dataRequest = {url: 'http://sinoptik.com.ru'};
            //dataRequest = {url: 'http://censor.net.ua'};
            //dataRequest = {url: 'http://korrespondent.net'};
            //dataRequest = {url: 'http://soccer0010.com'};
            //dataRequest = {url: 'http://soccer.ru'};
            
            
            action = 'https://addcpm.app.dev.rew.to/conf/conf.php';
            //action = 'https://addcpm.app.dev.rew.to/conf/conf.php?dev=1';
            //action = 'https://www.addcpm.com/conf/conf.php';
            //action = 'https://sconf.dev.rew.to/conf/conf.php';
            //action = 'https://sconf.dev.rew.to/';
            //action = 'https://sconf.dev.rew.to/conf/domain.php';
            //action = 'https://sconf.dev.rew.to/conf/all.php';
        }
        if ($(this).hasClass('yesterday-stat')) {
            dataRequest = {yesterdayStat: true};
        }
        
        
        // Стр. офферов
        if ($(this).hasClass('add-list-teasers')) {
            dataRequest = {addlistTeasers: true};
        }
        if ($(this).hasClass('edit-list-teasers')) {
            dataRequest = {editlistTeasers: true};
        }
        if ($(this).hasClass('create-offersnew')) {
            dataRequest = {createOffersNew: true};
        }
        if ($(this).hasClass('edit-json-tpl')) {
            dataRequest = {editJsonTpl: true};
        }
        if ($(this).hasClass('vars-tpl')) {
            dataRequest = {varsTpl: true};
        }
        if ($(this).hasClass('price-tpl')) {
            dataRequest = {priceTpl: true};
        }
        if ($(this).hasClass('rename-teasers')) {
            dataRequest = {renameTeasers: true};
        }
        if ($(this).hasClass('tpl-templates-table')) {
            dataRequest = {tplTemplatesTable: true};
        }
        
        
        $.ajax(action, {
            type: 'POST',           
            data: dataRequest,           
            success: function(data) {
                console.log('AAA success: ', data);
            },
            error: function(ajaxObj, textStatus, textError) {
                console.log('AAA error');
            }
         });              
        return false; 
    });
    
    
    
});