Advertisement
Guest User

admincp.js

a guest
May 12th, 2021
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     $('#permanent_ban').click(function(event) {
  3.         if (this.checked) {
  4.             $("#ban_time").hide();
  5.         } else {
  6.             $("#ban_time").show();
  7.         }
  8.     });
  9.  
  10.     $('input[id^="trans-"]').on("input", function() {
  11.         var trans = $(this).attr("id").split("-")[1],
  12.             val = $(this).val();
  13.         App.saveTranslation(trans, val);
  14.     });
  15.  
  16.     $('button[id^="select_all_"]').on("click", function() {
  17.         var id = $(this).attr("id").split("_")[2];
  18.         $('#class_list_' + id + ' option').prop('selected', true);
  19.     });
  20.  
  21.     $('select[id$=-db]').on("change", function() {
  22.         var db_id = $(this).attr("id").split("-")[0];
  23.         if ($(this).val() == 'custom') {
  24.             $('#' + db_id + '_custom-db').show();
  25.         } else {
  26.             $('#' + db_id + '_custom-db').hide();
  27.         }
  28.     });
  29.  
  30.     $('input[id^="price-"]').on("input", function() {
  31.         var id = $(this).attr("id").split("-")[1],
  32.             val = $(this).val();
  33.         App.savePrice(id, val);
  34.     });
  35.  
  36.     $('#storage').on("change", function() {
  37.         if ($(this).val() == 'ipb' || $(this).val() == 'ipb4') {
  38.             $('#ipb_settings').show();
  39.         } else {
  40.             $('#ipb_settings').hide();
  41.         }
  42.         if ($(this).val() == 'rss') {
  43.             $('#rss_settings').show();
  44.         } else {
  45.             $('#rss_settings').hide();
  46.         }
  47.         if ($(this).val() == 'facebook') {
  48.             $('#fb_settings').show();
  49.             $('#per_page').hide();
  50.             $('#news_cache').hide();
  51.         } else {
  52.             $('#fb_settings').hide();
  53.             $('#per_page').show();
  54.             $('#news_cache').show();
  55.         }
  56.     });
  57.  
  58.     $('#voting_api').on("change", function() {
  59.         if ($(this).val() == 1) {
  60.             $('#xtremetop100').show();
  61.         } else {
  62.             $('#xtremetop100').hide();
  63.         }
  64.         if ($(this).val() == 2) {
  65.             $('#mmotop').show();
  66.         } else {
  67.             $('#mmotop').hide();
  68.         }
  69.         if ($(this).val() == 3) {
  70.             $('#gtop').show();
  71.         } else {
  72.             $('#gtop').hide();
  73.         }
  74.         if ($(this).val() == 4) {
  75.             $('#topg').show();
  76.         } else {
  77.             $('#topg').hide();
  78.         }
  79.         if ($(this).val() == 5) {
  80.             $('#top100arena').show();
  81.         } else {
  82.             $('#top100arena').hide();
  83.         }
  84.         if ($(this).val() == 6) {
  85.             $('#mmoserver').show();
  86.         } else {
  87.             $('#mmoserver').hide();
  88.         }
  89.         if ($(this).val() == 8) {
  90.             $('#ultratop').show();
  91.         } else {
  92.             $('#ultratop').hide();
  93.         }
  94.         if ($(this).val() == 7) {
  95.             $('#muservertop').show();
  96.         } else {
  97.             $('#muservertop').hide();
  98.         }
  99.         if ($(this).val() == 10) {
  100.             $('#supremetop100').show();
  101.         } else {
  102.             $('#supremetop100').hide();
  103.         }
  104.     });
  105.  
  106.     $('#system_type').on("change", function() {
  107.         if ($(this).val() == 2) {
  108.             $('#gm_command_list_igcn').show();
  109.         } else {
  110.             $('#gm_command_list_igcn').hide();
  111.         }
  112.     });
  113.  
  114.     $('#paypal_settings_form').find('#server').on("change", function() {
  115.         App.loadDonationSettings($(this).val(), 'paypal');
  116.     });
  117.  
  118.     $('#paymentwall_settings_form').find('#server').on("change", function() {
  119.         App.loadDonationSettings($(this).val(), 'paymentwall');
  120.     });
  121.  
  122.     $('#fortumo_settings_form').find('#server').on("change", function() {
  123.         App.loadDonationSettings($(this).val(), 'fortumo');
  124.     });
  125.  
  126.     $('#paygol_settings_form').find('#server').on("change", function() {
  127.         App.loadDonationSettings($(this).val(), 'paygol');
  128.     });
  129.  
  130.     $('#2checkout_settings_form').find('#server').on("change", function() {
  131.         App.loadDonationSettings($(this).val(), '2checkout');
  132.     });
  133.  
  134.     $('#pagseguro_settings_form').find('#server').on("change", function() {
  135.         App.loadDonationSettings($(this).val(), 'pagseguro');
  136.     });
  137.  
  138.     $('#superrewards_settings_form').find('#server').on("change", function() {
  139.         App.loadDonationSettings($(this).val(), 'superrewards');
  140.     });
  141.  
  142.     $('#paycall_settings_form').find('#server').on("change", function() {
  143.         App.loadDonationSettings(server, 'paycall');
  144.     });
  145.  
  146.     $('#interkassa_settings_form').find('#server').on("change", function() {
  147.         App.loadDonationSettings($(this).val(), 'interkassa');
  148.     });
  149.  
  150.     $('#wcoin_settings_form').find('#server').on("change", function() {
  151.         App.loadWcoinSettings($(this).val());
  152.     });
  153.  
  154.     $('#player_settings_form').find('#server').on("change", function() {
  155.         App.loadRankingsSettings($(this).val(), 'player');
  156.     });
  157.  
  158.     $('#guild_settings_form').find('#server').on("change", function() {
  159.         App.loadRankingsSettings($(this).val(), 'guild');
  160.     });
  161.  
  162.     $('#gens_settings_form').find('#server').on("change", function() {
  163.         App.loadRankingsSettings($(this).val(), 'gens');
  164.     });
  165.  
  166.     $('#voter_settings_form').find('#server').on("change", function() {
  167.         App.loadRankingsSettings($(this).val(), 'voter');
  168.     });
  169.  
  170.     $('#killer_settings_form').find('#server').on("change", function() {
  171.         App.loadRankingsSettings($(this).val(), 'killer');
  172.     });
  173.  
  174.     $('#online_settings_form').find('#server').on("change", function() {
  175.         App.loadRankingsSettings($(this).val(), 'online');
  176.     });
  177.  
  178.     $('#online_list_settings_form').find('#server').on("change", function() {
  179.         App.loadRankingsSettings($(this).val(), 'online_list');
  180.     });
  181.  
  182.     $('#bc_settings_form').find('#server').on("change", function() {
  183.         App.loadRankingsSettings($(this).val(), 'bc');
  184.     });
  185.  
  186.     $('#ds_settings_form').find('#server').on("change", function() {
  187.         App.loadRankingsSettings($(this).val(), 'ds');
  188.     });
  189.  
  190.     $('#cc_settings_form').find('#server').on("change", function() {
  191.         App.loadRankingsSettings($(this).val(), 'cc');
  192.     });
  193.  
  194.     $('#cs_settings_form').find('#server').on("change", function() {
  195.         App.loadRankingsSettings($(this).val(), 'cs');
  196.     });
  197.  
  198.     $('#duels_settings_form').find('#server').on("change", function() {
  199.         App.loadRankingsSettings($(this).val(), 'duels');
  200.     });
  201.  
  202.     $('form[id^="votereward_settings_form_"]').on("submit", function(e) {
  203.         e.preventDefault();
  204.         App.saveVoteRewardSettings($(this));
  205.     });
  206.  
  207.     $('#scheduler_settings_form').on("submit", function(e) {
  208.         e.preventDefault();
  209.         App.saveSchedulerSettings($(this));
  210.     });
  211.  
  212.     $('#edit_paypal_settings').on('click', function(e) {
  213.         e.preventDefault();
  214.         App.savePaypalSettings();
  215.     });
  216.  
  217.     $('#edit_paymentwall_settings').on('click', function(e) {
  218.         e.preventDefault();
  219.         App.savePaymentwallSettings();
  220.     });
  221.  
  222.     $('#edit_fortumo_settings').on('click', function(e) {
  223.         e.preventDefault();
  224.         App.saveFortumoSettings();
  225.     });
  226.  
  227.     $('#edit_paygol_settings').on('click', function(e) {
  228.         e.preventDefault();
  229.         App.savePaygolSettings();
  230.     });
  231.  
  232.     $('#edit_2checkout_settings').on('click', function(e) {
  233.         e.preventDefault();
  234.         App.save2CheckOutSettings();
  235.     });
  236.  
  237.     $('#edit_pagseguro_settings').on('click', function(e) {
  238.         e.preventDefault();
  239.         App.savePagSeguroSettings();
  240.     });
  241.  
  242.     $('#edit_superrewards_settings').on('click', function(e) {
  243.         e.preventDefault();
  244.         App.saveSuperRewardsSettings();
  245.     });
  246.  
  247.     $('#edit_paycall_settings').on('click', function(e) {
  248.         e.preventDefault();
  249.         App.savePayCallSettings();
  250.     });
  251.  
  252.     $('#edit_interkassa_settings').on('click', function(e) {
  253.         e.preventDefault();
  254.         App.saveInterkassaSettings();
  255.     });
  256.  
  257.     $('#edit_cuenta_digital_settings').on('click', function(e) {
  258.         e.preventDefault();
  259.         App.saveCuentaDigitalSettings();
  260.     });
  261.  
  262.     $('#edit_wcoin_settings').on('click', function(e) {
  263.         e.preventDefault();
  264.         App.saveWcoinSettings();
  265.     });
  266.  
  267.     $('#edit_referral_settings').on('click', function(e) {
  268.         e.preventDefault();
  269.         App.saveReferralSettings();
  270.     });
  271.  
  272.     $('#edit_vip_settings').on('click', function(e) {
  273.         e.preventDefault();
  274.         App.saveVipSettings();
  275.     });
  276.  
  277.     $('#edit_email_settings').on('click', function(e) {
  278.         e.preventDefault();
  279.         App.saveEmailSettings();
  280.     });
  281.  
  282.     $('#edit_security_settings').on('click', function(e) {
  283.         e.preventDefault();
  284.         App.saveSecuritySettings();
  285.     });
  286.  
  287.     $('#edit_lostpassword_settings').on('click', function(e) {
  288.         e.preventDefault();
  289.         App.saveLostPasswordSettings();
  290.     });
  291.  
  292.     $('#edit_registration_settings').on('click', function(e) {
  293.         e.preventDefault();
  294.         App.saveRegistrationSettings();
  295.     });
  296.  
  297.     $('#edit_event_settings').on('click', function(e) {
  298.         e.preventDefault();
  299.         App.saveTimerSettings();
  300.     });
  301.  
  302.     $('#edit_player_settings').on('click', function(e) {
  303.         e.preventDefault();
  304.         App.saveRankingSettings($('#player_settings_form'));
  305.     });
  306.  
  307.     $('#edit_guild_settings').on('click', function(e) {
  308.         e.preventDefault();
  309.         App.saveRankingSettings($('#guild_settings_form'));
  310.     });
  311.  
  312.     $('#edit_gens_settings').on('click', function(e) {
  313.         e.preventDefault();
  314.         App.saveRankingSettings($('#gens_settings_form'));
  315.     });
  316.  
  317.     $('#edit_voter_settings').on('click', function(e) {
  318.         e.preventDefault();
  319.         App.saveRankingSettings($('#voter_settings_form'));
  320.     });
  321.  
  322.     $('#edit_killer_settings').on('click', function(e) {
  323.         e.preventDefault();
  324.         App.saveRankingSettings($('#killer_settings_form'));
  325.     });
  326.  
  327.     $('#edit_online_settings').on('click', function(e) {
  328.         e.preventDefault();
  329.         App.saveRankingSettings($('#online_settings_form'));
  330.     });
  331.  
  332.     $('#edit_online_list_settings').on('click', function(e) {
  333.         e.preventDefault();
  334.         App.saveRankingSettings($('#online_list_settings_form'));
  335.     });
  336.  
  337.     $('#edit_bc_settings').on('click', function(e) {
  338.         e.preventDefault();
  339.         App.saveRankingSettings($('#bc_settings_form'));
  340.     });
  341.  
  342.     $('#edit_ds_settings').on('click', function(e) {
  343.         e.preventDefault();
  344.         App.saveRankingSettings($('#ds_settings_form'));
  345.     });
  346.  
  347.     $('#edit_cc_settings').on('click', function(e) {
  348.         e.preventDefault();
  349.         App.saveRankingSettings($('#cc_settings_form'));
  350.     });
  351.  
  352.     $('#edit_cs_settings').on('click', function(e) {
  353.         e.preventDefault();
  354.         App.saveRankingSettings($('#cs_settings_form'));
  355.     });
  356.  
  357.     $('#edit_duels_settings').on('click', function(e) {
  358.         e.preventDefault();
  359.         App.saveRankingSettings($('#duels_settings_form'));
  360.     });
  361.  
  362.     $('#edit_rankings_status').on('click', function(e) {
  363.         e.preventDefault();
  364.         App.saveRankingsStatus();
  365.     });
  366.  
  367.     $('#ranking_settings_form').find('#server').on('change', function(e) {
  368.         e.preventDefault();
  369.         App.reloadRankingsStatus();
  370.     });
  371.  
  372.     $('#sql_table_settings_form').find('#server').on('change', function(e) {
  373.         e.preventDefault();
  374.         App.loadTableSettings($(this).val());
  375.     });
  376.  
  377.     $('#edit_sql_table_settings').on('click', function(e) {
  378.         e.preventDefault();
  379.         App.saveSqlTableSettings();
  380.     });
  381.  
  382.     $('#pre_defined_template_form').on('submit', function(e) {
  383.         e.preventDefault();
  384.         App.loadPreDefinedSqlTableSettings();
  385.     });
  386.  
  387.     $('form[id^="max_level_settings_form_"]').on("submit", function(e) {
  388.         e.preventDefault();
  389.         var server = $(this).attr("id").split('_').slice(4).join('_');
  390.         App.saveMaxLevel(server, $(this).serialize());
  391.     });
  392.  
  393.     $('#days').on('change', function() {
  394.         var selected_days = [];
  395.         $('#days').find(':selected').each(function() {
  396.             selected_days[$(this).val()] = $(this).val();
  397.         });
  398.         App.showHideTimes(selected_days);
  399.     });
  400.  
  401.     $('#apply_to_all_classes').on('click', function() {
  402.         var value = $('#bonus_lvl_up_dw').val();
  403.         if ($.trim(value)) {
  404.             if ($.isNumeric(value)) {
  405.                 $('input[id^="bonus_lvl_up_"]').each(function() {
  406.                     $(this).val(value);
  407.                 });
  408.                 $("html, body").animate({
  409.                     scrollTop: $('#bonus_lvl_up_ml').offset().top
  410.                 }, 1000);
  411.             } else {
  412.                 noty($.parseJSON('{"text":"Value can only be numeric","layout":"topRight","type":"error"}'));
  413.             }
  414.         } else {
  415.             noty($.parseJSON('{"text":"Please enter some numeric value","layout":"topRight","type":"error"}'));
  416.         }
  417.  
  418.     });
  419.  
  420.  
  421.  
  422.     $('#all_prices').on("change, keyup", function(event) {
  423.         $('input[name^="price"]').val($(this).val());
  424.     });
  425.  
  426.     $('#check_all').click(function(event) {
  427.         if (this.checked) {
  428.             $("#import_item_form").find("input:checkbox").attr("checked", true);
  429.         } else {
  430.             $("#import_item_form").find("input:checkbox").attr("checked", false);
  431.         }
  432.     });
  433.  
  434.     $('#check_all_tickets').click(function(event) {
  435.         if (this.checked) {
  436.             $("#ticket_form").find("input:checkbox").each(function() {
  437.                 $(this).attr("checked", true);
  438.             });
  439.         } else {
  440.             $("#ticket_form").find("input:checkbox").each(function() {
  441.                 $(this).attr("checked", false);
  442.             });
  443.         }
  444.     });
  445.  
  446.     $('#set_status').change(function() {
  447.         $(this).closest('form').trigger('submit');
  448.     });
  449.  
  450.     $('ul.main-menu li a').each(function() {
  451.         if ($($(this))[0].href == String(window.location))
  452.             $(this).parent().addClass('active');
  453.     });
  454.  
  455.     $('ul.main-menu li:not(.nav-header)').hover(function() {
  456.         $(this).animate({
  457.             'margin-left': '+=5'
  458.         }, 300);
  459.     }, function() {
  460.         $(this).animate({
  461.             'margin-left': '-=5'
  462.         }, 300);
  463.     });
  464.  
  465.     $('.accordion > a').click(function(e) {
  466.         e.preventDefault();
  467.         var $ul = $(this).siblings('ul');
  468.         var $li = $(this).parent();
  469.         if ($ul.is(':visible')) $li.removeClass('active');
  470.         else $li.addClass('active');
  471.         $ul.slideToggle();
  472.     });
  473.  
  474.     $('a[id^="run_cron_task_"]').on('click', function(e) {
  475.         e.preventDefault();
  476.         App.runCronTask($(this).data('task'));
  477.     });
  478.  
  479.     $('.accordion li.active:first').parents('ul').slideDown();
  480.  
  481.     $("#downloads_sortable").find("tbody#downloads_sortable_content").sortable({
  482.         placeholder: 'ui-state-highlight',
  483.         opacity: 0.6,
  484.         cursor: 'move',
  485.  
  486.         update: function() {
  487.             App.saveDownloadsOrder();
  488.         }
  489.  
  490.     });
  491.  
  492.     $("#donate_sortable").find("tbody#donate_sortable_content").sortable({
  493.         placeholder: 'ui-state-highlight',
  494.         opacity: 0.6,
  495.         cursor: 'move',
  496.  
  497.         update: function() {
  498.             App.savePaypalOrder();
  499.         }
  500.  
  501.     });
  502.  
  503.     $("#donate_sortable_checkout").find("tbody#donate_sortable_content_checkout").sortable({
  504.         placeholder: 'ui-state-highlight',
  505.         opacity: 0.6,
  506.         cursor: 'move',
  507.  
  508.         update: function() {
  509.             App.save2CheckOutOrder();
  510.         }
  511.  
  512.     });
  513.  
  514.     $("#donate_sortable_pagseguro").find("tbody#donate_sortable_content_pagseguro").sortable({
  515.         placeholder: 'ui-state-highlight',
  516.         opacity: 0.6,
  517.         cursor: 'move',
  518.  
  519.         update: function() {
  520.             App.savePagSeguroOrder();
  521.         }
  522.  
  523.     });
  524.  
  525.     $("#donate_sortable_paycall").find("tbody#donate_sortable_paycall_content").sortable({
  526.         placeholder: 'ui-state-highlight',
  527.         opacity: 0.6,
  528.         cursor: 'move',
  529.  
  530.         update: function() {
  531.             App.savePaycallOrder();
  532.         }
  533.  
  534.     });
  535.  
  536.     $("#donate_sortable_cuenta_digital").find("tbody#donate_sortable_cuenta_digital_content").sortable({
  537.         placeholder: 'ui-state-highlight',
  538.         opacity: 0.6,
  539.         cursor: 'move',
  540.  
  541.         update: function() {
  542.             App.saveCuentaDigitalOrder();
  543.         }
  544.  
  545.     });
  546.  
  547.     $("#donate_sortable_interkassa").find("tbody#donate_sortable_interkassa_content").sortable({
  548.         placeholder: 'ui-state-highlight',
  549.         opacity: 0.6,
  550.         cursor: 'move',
  551.  
  552.         update: function() {
  553.             App.saveInterkassaOrder();
  554.         }
  555.  
  556.     });
  557.  
  558.     $("#socket_sortable").find("tbody#socket_sortable_content").sortable({
  559.         placeholder: 'ui-state-highlight',
  560.         opacity: 0.6,
  561.         cursor: 'move',
  562.         update: function() {
  563.             App.saveSocketOrder();
  564.         }
  565.     });
  566.  
  567.     $("#serverlist_sortable").find("tbody#serverlist_sortable_content").sortable({
  568.         placeholder: 'ui-state-highlight',
  569.         opacity: 0.6,
  570.         cursor: 'move',
  571.  
  572.         update: function() {
  573.             App.saveServerOrder();
  574.         }
  575.  
  576.     });
  577.    
  578.     $("#event_sortable").find("tbody#event_sortable_content").sortable({
  579.         placeholder: 'ui-state-highlight',
  580.         opacity: 0.6,
  581.         cursor: 'move',
  582.  
  583.         update: function() {
  584.             App.saveEventOrder();
  585.         }
  586.  
  587.     });
  588.  
  589.     $("#current_plugin_sortable").find("tbody#current_plugin_sortable_content").sortable({
  590.         placeholder: 'ui-state-highlight',
  591.         opacity: 0.6,
  592.         cursor: 'move',
  593.  
  594.         update: function() {
  595.             App.savePluginOrder();
  596.         }
  597.  
  598.     });
  599.  
  600.     $('#category').change(function() {
  601.         location.href = DmNConfig.base_url + 'admincp/item-list/1/' + $(this).val();
  602.  
  603.     });
  604.  
  605.     $('#category-import').on('change', function() {
  606.         var server = $('#switch_server_file').val();
  607.         var url = location.href = DmNConfig.base_url + 'admincp/import-items/' + $(this).val() + '/' + server;
  608.         if (url) {
  609.             window.location = url;
  610.         }
  611.         return false;
  612.     });
  613.    
  614.     $('#apply_account_filter').on('click', function(e) {
  615.         e.preventDefault();
  616.         App.filterAccounts();
  617.     });
  618.  
  619.     $('#reset_account_filter').on('click', function(e) {
  620.         e.preventDefault();
  621.         App.resetAccountsFilter();
  622.     });
  623.    
  624.     var accountTable = $('.accounts_datatable').DataTable({
  625.         "dom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span12'i><'span12 center'p>>",
  626.         "pagingType": "bootstrap",
  627.         "language": {
  628.             "lengthMenu": "_MENU_ records per page",
  629.             "zeroRecords": "Nothing found - sorry",
  630.             "infoEmpty": "No records available",
  631.             "search": "Search: ",
  632.             "searchPlaceholder": "Username",
  633.             "processing": ""
  634.         },
  635.         "order": [
  636.             [1, 'desc']
  637.         ],
  638.         "columnDefs": [{
  639.             "targets": 'no-sort',
  640.             "orderable": false,
  641.         }],
  642.         "stateSave": true,
  643.         "processing": true,
  644.         "serverSide": true,
  645.         "ajax": {
  646.             url: DmNConfig.base_url + 'admincp/load-accounts',
  647.             type: "post"
  648.         }
  649.     });
  650.  
  651.     docReady();
  652. });
  653. var App = {
  654.     item_slot: 0,
  655.     filterAccounts: function() {
  656.         $.ajax({
  657.             type: "post",
  658.             dataType: "json",
  659.             url: DmNConfig.base_url + "admincp/filter_account_list",
  660.             data: $('#member_filter').serialize(),
  661.             success: function(data) {
  662.                 if (data.error) {
  663.                     if ($.isArray(data.error)) {
  664.                         $.each(data.error, function(key, val) {
  665.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  666.                         });
  667.                     } else {
  668.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  669.                     }
  670.                 } else {
  671.                     $('.accounts_datatable').DataTable().ajax.reload();
  672.                 }
  673.             }
  674.         });
  675.     },
  676.     resetAccountsFilter: function() {
  677.         $.ajax({
  678.             type: "post",
  679.             dataType: "json",
  680.             url: DmNConfig.base_url + "admincp/filter_account_reset",
  681.             success: function(data) {
  682.                 if (data.error) {
  683.                     if ($.isArray(data.error)) {
  684.                         $.each(data.error, function(key, val) {
  685.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  686.                         });
  687.                     } else {
  688.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  689.                     }
  690.                 } else {
  691.                     $('#joined1').val('');
  692.                     $('#joined2').val('');
  693.                     $('#status').val('').trigger('liszt:updated');
  694.                     $('#country').val('').trigger('liszt:updated');
  695.                     $('#server').prop('selectedIndex', 0);
  696.                     $('.accounts_datatable').DataTable().ajax.reload();
  697.                 }
  698.             }
  699.         });
  700.     },
  701.     runCronTask: function(task) {
  702.         $.ajax({
  703.             type: "get",
  704.             dataType: "json",
  705.             url: DmNConfig.base_url + "admincp/run-cron-task/" + task,
  706.             beforeSend: function() {
  707.                 $("body").css("cursor", "wait");
  708.             },
  709.             complete: function() {
  710.                 $("body").css("cursor", "default");
  711.             },
  712.             success: function(data) {
  713.                 if (data.error) {
  714.                     if ($.isArray(data.error)) {
  715.                         $.each(data.error, function(key, val) {
  716.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  717.                         });
  718.                     } else {
  719.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  720.                     }
  721.                 } else {
  722.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  723.                     setTimeout(function() {
  724.                         location.reload();
  725.                     }, 500);
  726.                 }
  727.             }
  728.         });
  729.     },
  730.     changeTaskStatus: function(task, val) {
  731.         $.ajax({
  732.             type: "post",
  733.             dataType: "json",
  734.             url: DmNConfig.base_url + "admincp/change-task-status",
  735.             data: {
  736.                 task: task,
  737.                 val: val
  738.             },
  739.             success: function(data) {
  740.                 if (data.error) {
  741.                     if ($.isArray(data.error)) {
  742.                         $.each(data.error, function(key, val) {
  743.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  744.                         });
  745.                     } else {
  746.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  747.                     }
  748.                 } else {
  749.                     if (val == 1) {
  750.                         $('#change_status_' + task).toggleClass('btn-success', false).toggleClass('btn-danger', true);
  751.                         $('#change_status_' + task).attr('onclick', 'App.changeTaskStatus(\'' + task + '\', 0);').text('Disable');
  752.                         $('#status-' + task).toggleClass('label-success', false).toggleClass('label-important', true).text('Inactive');
  753.                     } else {
  754.                         $('#change_status_' + task).toggleClass('btn-success', true).toggleClass('btn-danger', false);
  755.                         $('#change_status_' + task).attr('onclick', 'App.changeTaskStatus(\'' + task + '\', 1);').text('Enable');
  756.                         $('#status-' + task).toggleClass('label-success', true).toggleClass('label-important', false).text('Active');
  757.                     }
  758.                 }
  759.             }
  760.         });
  761.     },
  762.     editTaskSchedule: function(task) {
  763.         var regexp = /^(\d?\/?,?\-?(\*?))+$/;
  764.         var minute = $('#min-' + task).val();
  765.         var hour = $('#hour-' + task).val();
  766.         var dom = $('#dmonth-' + task).val();
  767.         var month = $('#month-' + task).val();
  768.         var dweek = $('#dweek-' + task).val();
  769.         var error = false;
  770.         if (regexp.test(minute) == false) {
  771.             noty($.parseJSON('{"text":"Invalid minute format allowed characters: 0-9,-*/","layout":"topRight","type":"error"}'));
  772.             error = true;
  773.         }
  774.         if (regexp.test(hour) == false) {
  775.             noty($.parseJSON('{"text":"Invalid hour format allowed characters: 0-9,-*/","layout":"topRight","type":"error"}'));
  776.             error = true;
  777.         }
  778.         if (regexp.test(dom) == false) {
  779.             noty($.parseJSON('{"text":"Invalid day of month format allowed characters: 0-9,-*/","layout":"topRight","type":"error"}'));
  780.             error = true;
  781.         }
  782.         if (regexp.test(month) == false) {
  783.             noty($.parseJSON('{"text":"Invalid month format allowed characters: 0-9,-*/","layout":"topRight","type":"error"}'));
  784.             error = true;
  785.         }
  786.         if (regexp.test(dweek) == false) {
  787.             noty($.parseJSON('{"text":"Invalid day of week format allowed characters: 0-9,-*/","layout":"topRight","type":"error"}'));
  788.             error = true;
  789.         }
  790.         if (!error) {
  791.             $.ajax({
  792.                 type: "post",
  793.                 dataType: "json",
  794.                 url: DmNConfig.base_url + "admincp/edit-task-schedule",
  795.                 data: {
  796.                     task: task,
  797.                     minute: minute,
  798.                     hour: hour,
  799.                     dom: dom,
  800.                     month: month,
  801.                     dweek: dweek
  802.                 },
  803.                 success: function(data) {
  804.                     if (data.error) {
  805.                         if ($.isArray(data.error)) {
  806.                             $.each(data.error, function(key, val) {
  807.                                 noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  808.                             });
  809.                         } else {
  810.                             noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  811.                         }
  812.                     } else {
  813.                         noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  814.                     }
  815.                 }
  816.             });
  817.         }
  818.     },
  819.     initializeTooltip: function(elements, load_info, ajax_call) {
  820.         if (load_info == false) {
  821.             elements.tooltip({
  822.                 bodyHandler: function() {
  823.                     return elements.attr('data-info');
  824.                 },
  825.                 showURL: false,
  826.                 fade: 10,
  827.                 track: true
  828.             });
  829.         } else {
  830.             elements.tooltip({
  831.                 bodyHandler: function() {
  832.                     var id = elements,
  833.                         tip = $("<div></div>"),
  834.                         hex = id.attr('data-info'),
  835.                         info = id.attr('data-info2');
  836.                     if (typeof(info) != 'undefined') {
  837.                         if (info.length) {
  838.                             tip.html(info);
  839.                             return tip;
  840.                         }
  841.                     } else {
  842.                         tip.html('<img src="' + DmNConfig.base_url + 'assets/' + DmNConfig.tmp_dir + '/images/loading.gif" />');
  843.                         setTimeout(function() {
  844.                             $.ajax({
  845.                                 type: 'POST',
  846.                                 dataType: 'json',
  847.  
  848.                                 url: DmNConfig.base_url + ajax_call,
  849.                                 data: {
  850.                                     item_hex: hex,
  851.                                     ajax: 1
  852.                                 },
  853.                                 success: function(data) {
  854.                                     if (data.error) {
  855.                                         id.attr('data-info2', 'Invalid item!');
  856.                                         tip.html('Invalid item!');
  857.                                     } else {
  858.                                         id.attr('data-info2', data.info);
  859.                                         tip.html(data.info);
  860.                                     }
  861.                                 }
  862.                             });
  863.                         }, 300);
  864.                         return tip;
  865.                     }
  866.                 },
  867.                 showURL: false,
  868.                 fade: 10,
  869.                 track: true
  870.             });
  871.         }
  872.     },
  873.     saveTranslation: function(key, val) {
  874.         var lg = window.location.pathname.split('/');
  875.         var lang = (!isNaN(+lg[lg.length - 1])) ? lg[lg.length - 2] : lg[lg.length - 1];
  876.         $.ajax({
  877.             type: "post",
  878.             dataType: "json",
  879.             url: DmNConfig.base_url + "admincp/save_translation/" + lang,
  880.             data: {
  881.                 key: key,
  882.                 val: val
  883.             },
  884.             success: function(data) {
  885.                 if (data.error) {
  886.                     noty($.parseJSON('{"text":"Failed to save","layout":"topRight","type":"error"}'));
  887.                 } else {
  888.                     noty($.parseJSON('{"text":"Saved","layout":"topRight","type":"success"}'));
  889.                 }
  890.             }
  891.         });
  892.     },
  893.     disablePlugin: function(plugin) {
  894.         $.ajax({
  895.             type: "get",
  896.             dataType: "json",
  897.             url: DmNConfig.base_url + plugin + "/disable",
  898.             success: function(data) {
  899.                 if (data.error) {
  900.                     if ($.isArray(data.error)) {
  901.                         $.each(data.error, function(key, val) {
  902.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  903.                         });
  904.                     } else {
  905.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  906.                     }
  907.                 } else {
  908.                     $('#' + plugin + ' #status_icon').html('<span class="label label-important">Inactive</span>');
  909.                     $('#' + plugin + ' #status_button').attr({
  910.                         'class': 'btn btn-success'
  911.                     });
  912.                     $('#' + plugin + ' #status_button').html('<i class="icon-edit icon-white"></i> Enable');
  913.                     $('#' + plugin + ' #status_button').attr('onclick', 'App.enablePlugin(\'' + plugin + '\');');
  914.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  915.                 }
  916.             }
  917.         });
  918.     },
  919.     enablePlugin: function(plugin) {
  920.         $.ajax({
  921.             type: "get",
  922.             dataType: "json",
  923.             url: DmNConfig.base_url + plugin + "/enable",
  924.             success: function(data) {
  925.                 if (data.error) {
  926.                     if ($.isArray(data.error)) {
  927.                         $.each(data.error, function(key, val) {
  928.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  929.                         });
  930.                     } else {
  931.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  932.                     }
  933.                 } else {
  934.                     $('#' + plugin + ' #status_icon').html('<span class="label label-success">Active</span>');
  935.                     $('#' + plugin + ' #status_button').attr({
  936.                         'class': 'btn btn-danger'
  937.                     });
  938.                     $('#' + plugin + ' #status_button').html('<i class="icon-edit icon-white"></i> Disable');
  939.                     $('#' + plugin + ' #status_button').attr('onclick', 'App.disablePlugin(\'' + plugin + '\');');
  940.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  941.                 }
  942.             }
  943.         });
  944.     },
  945.     installPlugin: function(plugin) {
  946.         var rowCount = $('#available_plugin_sortable_content tr').length;
  947.         $.ajax({
  948.             type: "get",
  949.             dataType: "json",
  950.             url: DmNConfig.base_url + plugin + "/install",
  951.             success: function(data) {
  952.                 if (data.error) {
  953.                     if ($.isArray(data.error)) {
  954.                         $.each(data.error, function(key, val) {
  955.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  956.                         });
  957.                     } else {
  958.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  959.                     }
  960.                 }
  961.                 if (data.success) {
  962.                     if ($('#no_current_plugins').length > 0) {
  963.                         $('#no_current_plugins').remove();
  964.                     }
  965.                     $('#' + plugin + ' #status_icon').html('<span class="label label-success">Active</span>');
  966.                     $('#' + plugin + ' #status_button').attr({
  967.                         'class': 'btn btn-warning'
  968.                     });
  969.                     $('#' + plugin + ' #status_button').html('<i class="icon-edit icon-white"></i> Disable');
  970.                     $('#' + plugin + ' #status_button').attr('onclick', 'App.disablePlugin(\'' + plugin + '\');');
  971.                     $('<span style="padding-left:2px"></span><a id="uninstall_button" class="btn btn-danger" href="#" onclick="App.uninstallPlugin(\'' + plugin + '\');"><i class="icon-remove icon-white"></i>Remove</a>').insertAfter($('#' + plugin + ' #status_button'));
  972.                     $('#current_plugin_sortable > tbody:last').append('<tr id="' + plugin + '">' + $('#' + plugin).html() + '</tr>');
  973.                     $('#available_plugin_sortable #' + plugin).remove();
  974.                     if (rowCount == 1) {
  975.                         $('#available_plugin_sortable > tbody:last').append('<tr id="no_available_plugins"><td colspan="3"><div class="alert alert-info">No plugins</div></td></tr>')
  976.                     }
  977.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  978.                     setTimeout(function() {
  979.                         location.reload();
  980.                     }, 1000);
  981.                 }
  982.             }
  983.         });
  984.     },
  985.     uninstallPlugin: function(plugin) {
  986.         if (App.confirmMessage('Are you sure you want to remove this plugin?')) {
  987.             var rowCount = $('#current_plugin_sortable tr').length;
  988.  
  989.             $.ajax({
  990.                 type: "get",
  991.                 dataType: "json",
  992.                 url: DmNConfig.base_url + plugin + "/uninstall",
  993.                 success: function(data) {
  994.                     if (data.error) {
  995.                         if ($.isArray(data.error)) {
  996.                             $.each(data.error, function(key, val) {
  997.                                 noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  998.                             });
  999.                         } else {
  1000.                             noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1001.                         }
  1002.                     }
  1003.                     if (data.success) {
  1004.                         if ($('#no_available_plugins').length > 0) {
  1005.                             $('#no_available_plugins').remove();
  1006.                         }
  1007.                         $('#' + plugin + ' #status_icon').html('<span class="label">Not Installed</span>');
  1008.                         $('#' + plugin + ' #status_button').attr({
  1009.                             'class': 'btn btn-success'
  1010.                         });
  1011.                         $('#' + plugin + ' #status_button').html('<i class="icon-download-alt icon-white"></i> Install');
  1012.                         $('#' + plugin + ' #status_button').attr('onclick', 'App.installPlugin(\'' + plugin + '\');');
  1013.                         $('#' + plugin + ' #about_button').attr({
  1014.                             'class': 'btn btn-inverse'
  1015.                         });
  1016.                         $('#' + plugin + ' #about_button').html('<i class="icon-leaf icon-white"></i> About');
  1017.                         $('#' + plugin + ' #about_button').attr('onclick', 'App.aboutPlugin(\'' + plugin + '\');');
  1018.                         $('#' + plugin + ' #uninstall_button').remove();
  1019.                         $('#available_plugin_sortable > tbody:last').append('<tr id="' + plugin + '">' + $('#' + plugin).html() + '</tr>');
  1020.                         $('#current_plugin_sortable #' + plugin).remove();
  1021.                         if (rowCount == 2) {
  1022.                             $('#current_plugin_sortable > tbody:last').append('<tr id="no_current_plugins"><td colspan="3"><div class="alert alert-info">No plugins</div></td></tr>')
  1023.                         }
  1024.                         noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1025.                     }
  1026.                 }
  1027.             });
  1028.         }
  1029.     },
  1030.     aboutPlugin: function(plugin) {
  1031.         $.ajax({
  1032.             type: 'GET',
  1033.             dataType: 'json',
  1034.             url: DmNConfig.base_url + plugin + '/about',
  1035.             success: function(data) {
  1036.                 if (typeof data.error != 'undefined') {
  1037.                     if ($.isArray(data.error)) {
  1038.                         $.each(data.error, function(key, val) {
  1039.                             noty($.parseJSON('{"text":"' + val + '","layout":"topRight","type":"error"}'));
  1040.                         });
  1041.                     } else {
  1042.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1043.                     }
  1044.                 } else {
  1045.                     var plugin_dialog = $('<div id="plugin_content"><p></p></div>');
  1046.                     plugin_dialog.html(data.about);
  1047.                     plugin_dialog.dialog({
  1048.                         modal: true,
  1049.                         width: 700,
  1050.                         height: 350,
  1051.                         title: 'About Plugin',
  1052.                         show: 'clip',
  1053.                         hide: 'clip',
  1054.                         close: function() {
  1055.                             $(this).dialog('destroy');
  1056.                         }
  1057.                     });
  1058.                 }
  1059.             }
  1060.         });
  1061.     },
  1062.     savePluginOrder: function() {
  1063.         var order = $('#current_plugin_sortable_content').sortable('toArray');
  1064.         $.ajax({
  1065.             type: "post",
  1066.             dataType: "json",
  1067.             url: DmNConfig.base_url + "admincp/save_plugin_order",
  1068.             data: {
  1069.                 order: order
  1070.             },
  1071.             success: function(data) {
  1072.                 if (data.error) {
  1073.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1074.                 }
  1075.             }
  1076.         });
  1077.     },
  1078.     savePrice: function(key, val) {
  1079.         $.ajax({
  1080.             type: "post",
  1081.             dataType: "json",
  1082.             url: DmNConfig.base_url + "admincp/save_item_price/" + key,
  1083.             data: {
  1084.                 price: val
  1085.             },
  1086.             success: function(data) {
  1087.                 if (typeof data.error != 'undefined') {
  1088.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1089.                 } else {
  1090.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1091.                 };
  1092.  
  1093.             }
  1094.         });
  1095.     },
  1096.     loadDonationSettings: function(server, type) {
  1097.         $.ajax({
  1098.             type: "post",
  1099.             dataType: "json",
  1100.             url: DmNConfig.base_url + "admincp/load_donation_settings",
  1101.             data: {
  1102.                 server: server,
  1103.                 type: type
  1104.             },
  1105.             success: function(data) {
  1106.                 if (typeof data.error != 'undefined') {
  1107.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1108.                 } else {
  1109.                     if (typeof data.info != 'undefined') {
  1110.                         if (type == 'paypal') {
  1111.                             $('#paypal_settings_form').find('#server option[value=' + server + ']').prop("selected", true);
  1112.                             if (data.info.active == 1) {
  1113.                                 $('#paypal_settings_form').find('#active option[value=1]').prop("selected", true);
  1114.                             } else {
  1115.                                 $('#paypal_settings_form').find('#active option[value=0]').prop("selected", true);
  1116.                             }
  1117.                             if (data.info.sandbox == 1) {
  1118.                                 $('#paypal_settings_form #sandbox option[value=1]').prop("selected", true);
  1119.                             } else {
  1120.                                 $('#paypal_settings_form #sandbox option[value=0]').prop("selected", true);
  1121.                             }
  1122.                             if (data.info.type == 1) {
  1123.                                 $('#paypal_settings_form #type option[value=1]').prop("selected", true);
  1124.                             } else {
  1125.                                 $('#paypal_settings_form #type option[value=2]').prop("selected", true);
  1126.                                 $('#express_checkout').show();
  1127.                             }
  1128.                             $('#paypal_settings_form #email').val(data.info.email);
  1129.                             $('#paypal_settings_form #api_username').val(data.info.api_username);
  1130.                             $('#paypal_settings_form #api_password').val(data.info.api_password);
  1131.                             $('#paypal_settings_form #api_signature').val(data.info.api_signature);
  1132.                             if (data.info.punish_player == 1) {
  1133.                                 $('#paypal_settings_form #punish_player option[value=1]').prop("selected", true);
  1134.                             } else {
  1135.                                 $('#paypal_settings_form #punish_player option[value=0]').prop("selected", true);
  1136.                             }
  1137.                             if (data.info.reward_type == 1) {
  1138.                                 $('#paypal_settings_form #reward_type option[value=1]').prop("selected", true);
  1139.                             } else {
  1140.                                 $('#paypal_settings_form #reward_type option[value=2]').prop("selected", true);
  1141.                             }
  1142.                             if (typeof data.info.paypal_fee != 'undefined') {
  1143.                                 $('#paypal_settings_form #paypal_fee option[value="' + data.info.paypal_fee + '"]').prop("selected", true);
  1144.                             }
  1145.  
  1146.                             if (typeof data.info.paypal_fixed_fee != 'undefined') {
  1147.                                 $('#paypal_settings_form #paypal_fixed_fee').val(data.info.paypal_fixed_fee);
  1148.                             }
  1149.                         }
  1150.                         if (type == 'paymentwall') {
  1151.                             $('#paymentwall_settings_form #server option[value=' + server + ']').prop("selected", true);
  1152.                             if (data.info.active == 1) {
  1153.                                 $('#paymentwall_settings_form #active option[value=1]').prop("selected", true);
  1154.                             } else {
  1155.                                 $('#paymentwall_settings_form #active option[value=0]').prop("selected", true);
  1156.                             }
  1157.  
  1158.                             $('#paymentwall_settings_form #api_key').val(data.info.api_key);
  1159.                             $('#paymentwall_settings_form #secret_key').val(data.info.secret_key);
  1160.                             $('#paymentwall_settings_form #width').val(data.info.width);
  1161.                             if (data.info.sign_version == '1') {
  1162.                                 $('#paymentwall_settings_form #sign_version option[value="1"]').prop("selected", true);
  1163.                             } else if (data.info.sign_version == '2') {
  1164.                                 $('#paymentwall_settings_form #sign_version option[value="2"]').prop("selected", true);
  1165.                             } else if (data.info.sign_version == '3') {
  1166.                                 $('#paymentwall_settings_form #sign_version option[value="3"]').prop("selected", true);
  1167.                             } else if (data.info.sign_version == '4') {
  1168.                                 $('#paymentwall_settings_form #sign_version option[value="4"]').prop("selected", true);
  1169.                             } else{
  1170.                                 $('#paymentwall_settings_form #sign_version option[value="1"]').prop("selected", true);
  1171.                             }
  1172.  
  1173.                             if (data.info.widget == 'm2_1') {
  1174.                                 $('#paymentwall_settings_form #widget option[value="m2_1"]').prop("selected", true);
  1175.                             } else if (data.info.widget == 'm1_1') {
  1176.                                 $('#paymentwall_settings_form #widget option[value="m1_1"]').prop("selected", true);
  1177.                             } else if (data.info.widget == 'p4_1') {
  1178.                                 $('#paymentwall_settings_form #widget option[value="p4_1"]').prop("selected", true);
  1179.                             } else if (data.info.widget == 'p3_1') {
  1180.                                 $('#paymentwall_settings_form #widget option[value="p3_1"]').prop("selected", true);
  1181.                             } else if (data.info.widget == 'p2_1') {
  1182.                                 $('#paymentwall_settings_form #widget option[value="p2_1"]').prop("selected", true);
  1183.                             } else if (data.info.widget == 'p1_1') {
  1184.                                 $('#paymentwall_settings_form #widget option[value="p1_1"]').prop("selected", true);
  1185.                             } else if (data.info.widget == 'w1_1') {
  1186.                                 $('#paymentwall_settings_form #widget option[value="w1_1"]').prop("selected", true);
  1187.                             } else if (data.info.widget == 's2_1') {
  1188.                                 $('#paymentwall_settings_form #widget option[value="s2_1"]').prop("selected", true);
  1189.                             } else if (data.info.widget == 's1_1') {
  1190.                                 $('#paymentwall_settings_form #widget option[value="s1_1"]').prop("selected", true);
  1191.                             } else {
  1192.                                 $('#paymentwall_settings_form #widget option[value="s3_1"]').prop("selected", true);
  1193.                             }
  1194.                             if (data.info.reward_type == 1) {
  1195.                                 $('#paymentwall_settings_form #reward_type option[value=1]').prop("selected", true);
  1196.                             } else {
  1197.                                 $('#paymentwall_settings_form #reward_type option[value=2]').prop("selected", true);
  1198.                             }
  1199.                         }
  1200.                         if (type == 'fortumo') {
  1201.                             $('#fortumo_settings_form #server option[value=' + server + ']').prop("selected", true);
  1202.                             if (data.info.active == 1) {
  1203.                                 $('#fortumo_settings_form #active option[value=1]').prop("selected", true);
  1204.                             } else {
  1205.                                 $('#fortumo_settings_form #active option[value=0]').prop("selected", true);
  1206.                             }
  1207.                             if (data.info.sandbox == 1) {
  1208.                                 $('#fortumo_settings_form #sandbox option[value=1]').prop("selected", true);
  1209.                             } else {
  1210.                                 $('#fortumo_settings_form #sandbox option[value=0]').prop("selected", true);
  1211.                             }
  1212.                             $('#fortumo_settings_form #service_id').val(data.info.service_id);
  1213.                             $('#fortumo_settings_form #secret').val(data.info.secret);
  1214.                             $('#fortumo_settings_form #allowed_ip_list').tagsinput('removeAll');
  1215.                             $('#fortumo_settings_form #allowed_ip_list').tagsinput('add', data.info.allowed_ip_list);
  1216.                             if (data.info.reward_type == 1) {
  1217.                                 $('#fortumo_settings_form #reward_type option[value=1]').prop("selected", true);
  1218.                             } else {
  1219.                                 $('#fortumo_settings_form #reward_type option[value=2]').prop("selected", true);
  1220.                             }
  1221.                         }
  1222.                         if (type == 'paygol') {
  1223.                             $('#paygol_settings_form #server option[value=' + server + ']').prop("selected", true);
  1224.                             if (data.info.active == 1) {
  1225.                                 $('#paygol_settings_form #active option[value=1]').prop("selected", true);
  1226.                             } else {
  1227.                                 $('#paygol_settings_form #active option[value=0]').prop("selected", true);
  1228.                             }
  1229.                             $('#paygol_settings_form #service_id').val(data.info.service_id);
  1230.                             $('#paygol_settings_form #reward').val(data.info.reward);
  1231.                             $('#paygol_settings_form #currency_code').val(data.info.currency_code);
  1232.                             $('#paygol_settings_form #service_price').val(data.info.service_price);
  1233.                             if (data.info.reward_type == 1) {
  1234.                                 $('#paygol_settings_form #reward_type option[value=1]').prop("selected", true);
  1235.                             } else {
  1236.                                 $('#paygol_settings_form #reward_type option[value=2]').prop("selected", true);
  1237.                             }
  1238.                         }
  1239.                         if (type == '2checkout') {
  1240.                             $('#2checkout_settings_form #server option[value=' + server + ']').prop("selected", true);
  1241.                             if (data.info.active == 1) {
  1242.                                 $('#2checkout_settings_form #active option[value=1]').prop("selected", true);
  1243.                             } else {
  1244.                                 $('#2checkout_settings_form #active option[value=0]').prop("selected", true);
  1245.                             }
  1246.                             $('#2checkout_settings_form #seller_id').val(data.info.seller_id);
  1247.                             $('#2checkout_settings_form #private_key').val(data.info.private_key);
  1248.                             $('#2checkout_settings_form #private_secret_word').val(data.info.private_secret_word);
  1249.                             if (data.info.reward_type == 1) {
  1250.                                 $('#2checkout_settings_form #reward_type option[value=1]').prop("selected", true);
  1251.                             } else {
  1252.                                 $('#2checkout_settings_form #reward_type option[value=2]').prop("selected", true);
  1253.                             }
  1254.                         }
  1255.                         if (type == 'pagseguro') {
  1256.                             $('#pagseguro_settings_form #server option[value=' + server + ']').prop("selected", true);
  1257.                             if (data.info.active == 1) {
  1258.                                 $('#pagseguro_settings_form #active option[value=1]').prop("selected", true);
  1259.                             } else {
  1260.                                 $('#pagseguro_settings_form #active option[value=0]').prop("selected", true);
  1261.                             }
  1262.                             $('#pagseguro_settings_form #email').val(data.info.email);
  1263.                             $('#pagseguro_settings_form #token').val(data.info.token);
  1264.                             if (data.info.reward_type == 1) {
  1265.                                 $('#pagseguro_settings_form #reward_type option[value=1]').prop("selected", true);
  1266.                             } else {
  1267.                                 $('#pagseguro_settings_form #reward_type option[value=2]').prop("selected", true);
  1268.                             }
  1269.                         }
  1270.                         if (type == 'superrewards') {
  1271.                             $('#superrewards_settings_form #server option[value=' + server + ']').prop("selected", true);
  1272.                             if (data.info.active == 1) {
  1273.                                 $('#superrewards_settings_form #active option[value=1]').prop("selected", true);
  1274.                             } else {
  1275.                                 $('#superrewards_settings_form #active option[value=0]').prop("selected", true);
  1276.                             }
  1277.                             $('#superrewards_settings_form #app_hash').val(data.info.app_hash);
  1278.                             $('#superrewards_settings_form #postback_key').val(data.info.postback_key);
  1279.                             $('#superrewards_settings_form #allowed_ip_list').tagsinput('removeAll');
  1280.                             $('#superrewards_settings_form #allowed_ip_list').tagsinput('add', data.info.allowed_ip_list);
  1281.                             if (data.info.reward_type == 1) {
  1282.                                 $('#superrewards_settings_form #reward_type option[value=1]').prop("selected", true);
  1283.                             } else {
  1284.                                 $('#superrewards_settings_form #reward_type option[value=2]').prop("selected", true);
  1285.                             }
  1286.                         }
  1287.                         if (type == 'paycall') {
  1288.                             $('#paycall_settings_form #server option[value=' + server + ']').prop("selected", true);
  1289.                             if (data.info.active == 1) {
  1290.                                 $('#paycall_settings_form #active option[value=1]').prop("selected", true);
  1291.                             } else {
  1292.                                 $('#paycall_settings_form #active option[value=0]').prop("selected", true);
  1293.                             }
  1294.                             if (data.info.sandbox == 1) {
  1295.                                 $('#paycall_settings_form #sandbox option[value=1]').prop("selected", true);
  1296.                             } else {
  1297.                                 $('#paycall_settings_form #sandbox option[value=0]').prop("selected", true);
  1298.                             }
  1299.                             $('#paycall_settings_form #business_code').val(data.info.business_code);
  1300.                             if (data.info.reward_type == 1) {
  1301.                                 $('#paycall_settings_form #reward_type option[value=1]').prop("selected", true);
  1302.                             } else {
  1303.                                 $('#paycall_settings_form #reward_type option[value=2]').prop("selected", true);
  1304.                             }
  1305.                         }
  1306.                         if (type == 'interkassa') {
  1307.                             $('#interkassa_settings_form #server option[value=' + server + ']').prop("selected", true);
  1308.                             if (data.info.active == 1) {
  1309.                                 $('#interkassa_settings_form #active option[value=1]').prop("selected", true);
  1310.                             } else {
  1311.                                 $('#interkassa_settings_form #active option[value=0]').prop("selected", true);
  1312.                             }
  1313.                             $('#interkassa_settings_form #shop_id').val(data.info.shop_id);
  1314.                             $('#interkassa_settings_form #secret_key').val(data.info.secret_key);
  1315.                             if (data.info.reward_type == 1) {
  1316.                                 $('#interkassa_settings_form #reward_type option[value=1]').prop("selected", true);
  1317.                             } else {
  1318.                                 $('#interkassa_settings_form #reward_type option[value=2]').prop("selected", true);
  1319.                             }
  1320.                         }
  1321.                         if (type == 'cuenta_digital') {
  1322.                             $('#cuenta_digital_settings_form #server option[value=' + server + ']').prop("selected", true);
  1323.                             if (data.info.active == 1) {
  1324.                                 $('#cuenta_digital_settings_form #active option[value=1]').prop("selected", true);
  1325.                             } else {
  1326.                                 $('#cuenta_digital_settings_form #active option[value=0]').prop("selected", true);
  1327.                             }
  1328.                             if (data.info.api_type == 1) {
  1329.                                 $('#cuenta_digital_settings_form #api_type option[value=1]').prop("selected", true);
  1330.                             } else {
  1331.                                 $('#cuenta_digital_settings_form #api_type option[value=2]').prop("selected", true);
  1332.                             }
  1333.                             $('#cuenta_digital_settings_form #account_id').val(data.info.account_id);
  1334.                             $('#cuenta_digital_settings_form #voucher_api_password').val(data.info.voucher_api_password);
  1335.                             if (data.info.reward_type == 1) {
  1336.                                 $('#cuenta_digital_settings_form #reward_type option[value=1]').prop("selected", true);
  1337.                             } else {
  1338.                                 $('#cuenta_digital_settings_form #reward_type option[value=2]').prop("selected", true);
  1339.                             }
  1340.                         }
  1341.                     }
  1342.                 }
  1343.             },
  1344.             error: function(error) {
  1345.                 $('select', '#' + type + '_settings_form').each(function() {
  1346.                     if ($(this).val() == server) {
  1347.                         $(this).prop("selected", true);
  1348.                     } else {
  1349.                         $(this).val($(this).prop('defaultSelected'));
  1350.                     }
  1351.                 });
  1352.                 $('input[type=text]', '#' + type + '_settings_form').each(function() {
  1353.                     $(this).val('');
  1354.                 });
  1355.  
  1356.                 if (type == 'fortumo') {
  1357.                     $('#fortumo_settings_form #allowed_ip_list').tagsinput('removeAll');
  1358.                     $('#fortumo_settings_form #allowed_ip_list').tagsinput('add', '79.125.125.1,79.125.5.205,79.125.5.95,54.72.6.126,54.72.6.27,54.72.6.17,54.72.6.23');
  1359.                 }
  1360.                 if (type == 'superrewards') {
  1361.                     $('#superrewards #allowed_ip_list').tagsinput('removeAll');
  1362.                     $('#superrewards #allowed_ip_list').tagsinput('add', '54.85.0.76,54.84.205.80,54.84.27.163');
  1363.                 }
  1364.             }
  1365.         });
  1366.     },
  1367.     loadRankingsSettings: function(server, type) {
  1368.         $.ajax({
  1369.             type: "post",
  1370.             dataType: "json",
  1371.             url: DmNConfig.base_url + "admincp/load_ranking_settings",
  1372.             data: {
  1373.                 server: server,
  1374.                 type: type
  1375.             },
  1376.             success: function(data) {
  1377.                 if (typeof data.error != 'undefined') {
  1378.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1379.                 } else {
  1380.                     if (typeof data.info != 'undefined') {
  1381.                         if (type == 'player' || type == 'killer') {
  1382.                             var selector = (type == 'player') ? $('#player_settings_form') : $('#killer_settings_form');
  1383.                             selector.find('#server option[value=' + server + ']').prop("selected", true);
  1384.                             if (data.info.is_sidebar_module == 1) {
  1385.                                 selector.find('#is_sidebar_module option[value=1]').prop("selected", true);
  1386.                             } else {
  1387.                                 selector.find('#is_sidebar_module option[value=0]').prop("selected", true);
  1388.                             }
  1389.                             selector.find("#count").val(data.info.count);
  1390.                             selector.find("#count_in_sidebar").val(data.info.count_in_sidebar);
  1391.                             selector.find("#cache_time").val(data.info.cache_time);
  1392.                             selector.find("#excluded_list").tagsinput('removeAll');
  1393.                             selector.find("#excluded_list").tagsinput('add', data.info.excluded_list);
  1394.                             if (data.info.display_resets == 1) {
  1395.                                 selector.find('#display_resets option[value=1]').prop("selected", true);
  1396.                             } else {
  1397.                                 selector.find('#display_resets option[value=0]').prop("selected", true);
  1398.                             }
  1399.                             if (data.info.display_gresets == 1) {
  1400.                                 selector.find('#display_gresets option[value=1]').prop("selected", true);
  1401.                             } else {
  1402.                                 selector.find('#display_gresets option[value=0]').prop("selected", true);
  1403.                             }
  1404.                             if (data.info.display_master_level == 1) {
  1405.                                 selector.find('#display_master_level option[value=1]').prop("selected", true);
  1406.                             } else {
  1407.                                 selector.find('#display_master_level option[value=0]').prop("selected", true);
  1408.                             }
  1409.                             if (type == 'player') {
  1410.                                 if (data.info.display_status == 1) {
  1411.                                     selector.find('#display_status option[value=1]').prop("selected", true);
  1412.                                 } else {
  1413.                                     selector.find('#display_status option[value=0]').prop("selected", true);
  1414.                                 }
  1415.                             }
  1416.                             if (data.info.display_gms == 1) {
  1417.                                 selector.find('#display_gms option[value=1]').prop("selected", true);
  1418.                             } else {
  1419.                                 selector.find('#display_gms option[value=0]').prop("selected", true);
  1420.                             }
  1421.                             if (data.info.display_country == 1) {
  1422.                                 selector.find('#display_country option[value=1]').prop("selected", true);
  1423.                             } else {
  1424.                                 selector.find('#display_country option[value=0]').prop("selected", true);
  1425.                             }
  1426.                         }
  1427.                         if (type == 'guild' || type == 'online') {
  1428.                             var selector2 = (type == 'guild') ? $('#guild_settings_form') : $('#online_settings_form');
  1429.                             selector2.find('#server option[value=' + server + ']').prop("selected", true);
  1430.                             if (data.info.is_sidebar_module == 1) {
  1431.                                 selector2.find('#is_sidebar_module option[value=1]').prop("selected", true);
  1432.                             } else {
  1433.                                 selector2.find('#is_sidebar_module option[value=0]').prop("selected", true);
  1434.                             }
  1435.                             selector2.find("#count").val(data.info.count);
  1436.                             selector2.find("#count_in_sidebar").val(data.info.count_in_sidebar);
  1437.                             selector2.find("#cache_time").val(data.info.cache_time);
  1438.                             selector2.find("#excluded_list").tagsinput('removeAll');
  1439.                             selector2.find("#excluded_list").tagsinput('add', data.info.excluded_list);
  1440.                             if (type == 'guild'){
  1441.                                  selector2.find('#order_by option[value='+data.info.order_by+']').prop("selected", true);
  1442.                             }
  1443.                             if (type == 'online') {
  1444.                                 if (data.info.display_country == 1) {
  1445.                                     selector2.find('#display_country option[value=1]').prop("selected", true);
  1446.                                 } else {
  1447.                                     selector2.find('#display_country option[value=0]').prop("selected", true);
  1448.                                 }
  1449.                             }
  1450.                         }
  1451.                        
  1452.                         if (type == 'gens') {
  1453.                             $('#gens_settings_form').find('#server option[value=' + server + ']').prop("selected", true);
  1454.                             $('#gens_settings_form').find("#count").val(data.info.count);
  1455.                             $('#gens_settings_form').find("#cache_time").val(data.info.cache_time);
  1456.                             if (data.info.type == 'scf') {
  1457.                                 $('#gens_settings_form').find('#type option[value="scf"]').prop("selected", true);
  1458.                             } else if (data.info.type == 'zteam') {
  1459.                                 $('#gens_settings_form').find('#type option[value="zteam"]').prop("selected", true);
  1460.                             } else if (data.info.type == 'exteam') {
  1461.                                 $('#gens_settings_form').find('#type option[value="exteam"]').prop("selected", true);
  1462.                             } else if (data.info.type == 'xteam') {
  1463.                                 $('#gens_settings_form').find('#type option[value="xteam"]').prop("selected", true);
  1464.                             } else if (data.info.type == 'muengine') {
  1465.                                 $('#gens_settings_form').find('#type option[value="muengine"]').prop("selected", true);
  1466.                             } else {
  1467.                                 $('#gens_settings_form').find('#type option[value="igcn"]').prop("selected", true);
  1468.                             }
  1469.                         }
  1470.                         if (type == 'voter' || type == 'bc' || type == 'ds' || type == 'cc' || type == 'duels') {
  1471.                             var selector4 = $('#' + type + '_settings_form');
  1472.                             selector4.find('#server option[value=' + server + ']').prop("selected", true);
  1473.                             if (data.info.is_sidebar_module == 1) {
  1474.                                 selector4.find('#is_sidebar_module option[value=1]').prop("selected", true);
  1475.                             } else {
  1476.                                 selector4.find('#is_sidebar_module option[value=0]').prop("selected", true);
  1477.                             }
  1478.                             selector4.find("#count").val(data.info.count);
  1479.                             selector4.find("#count_in_sidebar").val(data.info.count_in_sidebar);
  1480.                             selector4.find("#cache_time").val(data.info.cache_time);
  1481.                             selector4.find("#excluded_list").tagsinput('removeAll');
  1482.                             selector4.find("#excluded_list").tagsinput('add', data.info.excluded_list);
  1483.                             if (type == 'voter') {
  1484.                                 if (data.info.display_country == 1) {
  1485.                                     selector4.find('#display_country option[value=1]').prop("selected", true);
  1486.                                 } else {
  1487.                                     selector4.find('#display_country option[value=0]').prop("selected", true);
  1488.                                 }
  1489.                             }
  1490.                             if (data.info.is_monthly_reward == 1) {
  1491.                                 selector4.find('#is_monthly_reward option[value=1]').prop("selected", true);
  1492.                             } else {
  1493.                                 selector4.find('#is_monthly_reward option[value=0]').prop("selected", true);
  1494.                             }
  1495.  
  1496.                             if (typeof data.info.amount_of_players_to_reward != undefined) {
  1497.                                 selector4.find('#amount_of_players_to_reward option[value=' + data.info.amount_of_players_to_reward + ']').prop("selected", true);
  1498.                             }
  1499.                             selector4.find("#reward_formula").val(data.info.reward_formula);
  1500.                             if (data.info.reward_type == 2) {
  1501.                                 selector4.find('#reward_type option[value=2]').prop("selected", true);
  1502.                             } else {
  1503.                                 selector4.find('#reward_type option[value=1]').prop("selected", true);
  1504.                             }
  1505.                         }
  1506.                         if (type == 'online_list') {
  1507.                             var selector3 = $('#online_list_settings_form');
  1508.                             selector3.find('#server option[value=' + server + ']').prop("selected", true);
  1509.                             if (data.info.active == 1) {
  1510.                                 selector3.find('#active option[value=1]').prop("selected", true);
  1511.                             } else {
  1512.                                 selector3.find('#active option[value=0]').prop("selected", true);
  1513.                             }
  1514.                             selector3.find("#cache_time").val(data.info.cache_time);
  1515.                             selector3.find("#excluded_list").tagsinput('removeAll');
  1516.                             selector3.find("#excluded_list").tagsinput('add', data.info.excluded_list);
  1517.                             if (data.info.display_resets == 1) {
  1518.                                 selector3.find('#display_resets option[value=1]').prop("selected", true);
  1519.                             } else {
  1520.                                 selector3.find('#display_resets option[value=0]').prop("selected", true);
  1521.                             }
  1522.                             if (data.info.display_gresets == 1) {
  1523.                                 selector3.find('#display_gresets option[value=1]').prop("selected", true);
  1524.                             } else {
  1525.                                 selector3.find('#display_gresets option[value=0]').prop("selected", true);
  1526.                             }
  1527.                             if (data.info.display_gms == 1) {
  1528.                                 selector3.find('#display_gms option[value=1]').prop("selected", true);
  1529.                             } else {
  1530.                                 selector3.find('#display_gms option[value=0]').prop("selected", true);
  1531.                             }
  1532.                             if (data.info.display_country == 1) {
  1533.                                 selector3.find('#display_country option[value=1]').prop("selected", true);
  1534.                             } else {
  1535.                                 selector3.find('#display_country option[value=0]').prop("selected", true);
  1536.                             }
  1537.                         }
  1538.                     }
  1539.                 }
  1540.             },
  1541.             error: function(error) {
  1542.                 $('select', '#' + type + '_settings_form').each(function() {
  1543.                     if ($(this).val() == server) {
  1544.                         $(this).prop("selected", true);
  1545.                     } else {
  1546.                         $(this).val($(this).prop('defaultSelected'));
  1547.                     }
  1548.                 });
  1549.                 $('input[type=text]', '#' + type + '_settings_form').each(function() {
  1550.                     $(this).val('');
  1551.                 });
  1552.  
  1553.                 if ($("#excluded_list").length) {
  1554.                     $("#excluded_list").tagsinput('removeAll');
  1555.                 }
  1556.             }
  1557.         });
  1558.     },
  1559.     loadTableSettings: function(server) {
  1560.         $.ajax({
  1561.             type: "post",
  1562.             dataType: "json",
  1563.             url: DmNConfig.base_url + "admincp/load_table_settings",
  1564.             data: {
  1565.                 server: server
  1566.             },
  1567.             success: function(data) {
  1568.                 if (typeof data.error != 'undefined') {
  1569.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1570.                 } else {
  1571.                     if (typeof data.info != 'undefined') {
  1572.                         if (typeof data.info.resets != 'undefined') {
  1573.                             App.updateSqlSettings(data.info.resets, 'resets');
  1574.                         }
  1575.                         if (typeof data.info.grand_resets != 'undefined') {
  1576.                             App.updateSqlSettings(data.info.grand_resets, 'grand_resets');
  1577.                         }
  1578.                         if (typeof data.info.wcoins != 'undefined') {
  1579.                             App.updateSqlSettings(data.info.wcoins, 'wcoins');
  1580.                         }
  1581.                         if (typeof data.info.master_level != 'undefined') {
  1582.                             App.updateSqlSettings(data.info.master_level, 'master_level');
  1583.                         }
  1584.                         if (typeof data.info.bc != 'undefined') {
  1585.                             App.updateSqlSettings(data.info.bc, 'bc');
  1586.                         }
  1587.                         if (typeof data.info.ds != 'undefined') {
  1588.                             App.updateSqlSettings(data.info.ds, 'ds');
  1589.                         }
  1590.                         if (typeof data.info.cc != 'undefined') {
  1591.                             App.updateSqlSettings(data.info.cc, 'cc');
  1592.                         }
  1593.                         if (typeof data.info.cs != 'undefined') {
  1594.                             App.updateSqlSettings(data.info.cs, 'cs');
  1595.                         }
  1596.                         if (typeof data.info.duels != 'undefined') {
  1597.                             App.updateSqlSettings(data.info.duels, 'duels');
  1598.                         }
  1599.                     }
  1600.                 }
  1601.             },
  1602.             error: function(error) {
  1603.                 $('select', '#sql_table_settings_form').each(function() {
  1604.                     if ($(this).val() == server) {
  1605.                         $(this).prop("selected", true);
  1606.                     } else {
  1607.                         $(this).val($(this).prop('defaultSelected'));
  1608.                     }
  1609.                 });
  1610.                 $('input[type=text]', '#sql_table_settings_form').each(function() {
  1611.                     $(this).val('');
  1612.                 });
  1613.             }
  1614.         });
  1615.     },
  1616.     updateSqlSettings: function(data, id) {
  1617.         var db_info = ['account', 'game', 'web'];
  1618.         var selector = $('#sql_table_settings_form');
  1619.         if (db_info.indexOf(data.db) == -1) {
  1620.             selector.find('#' + id + '-db option[value=custom]').prop("selected", true);
  1621.             $('#' + id + '_custom-db').val(data.db).show();
  1622.         } else {
  1623.             selector.find('#' + id + '-db option[value=' + data.db + ']').prop("selected", true);
  1624.         }
  1625.         selector.find('#' + id + '-table').val(data.table);
  1626.         selector.find('#' + id + '-column').val(data.column);
  1627.         if (typeof data.column2 != 'undefined') {
  1628.             selector.find('#' + id + '-column2').val(data.column2);
  1629.         }
  1630.         if (typeof data.column3 != 'undefined') {
  1631.             selector.find('#' + id + '-column3').val(data.column3);
  1632.         }
  1633.         selector.find('#' + id + '-identifier_column').val(data.identifier_column);
  1634.  
  1635.     },
  1636.     loadWcoinSettings: function(server) {
  1637.         $.ajax({
  1638.             type: "post",
  1639.             dataType: "json",
  1640.             url: DmNConfig.base_url + "admincp/load_wcoin_settings",
  1641.             data: {
  1642.                 server: server,
  1643.             },
  1644.             success: function(data) {
  1645.                 if (typeof data.error != 'undefined') {
  1646.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1647.                 } else {
  1648.                     if (typeof data.info != 'undefined') {
  1649.                         $('#wcoin_settings_form #server option[value=' + server + ']').prop("selected", true);
  1650.                         if (data.info.active == 1) {
  1651.                             $('#wcoin_settings_form #active option[value=1]').prop("selected", true);
  1652.                         } else {
  1653.                             $('#wcoin_settings_form #active option[value=0]').prop("selected", true);
  1654.                         }
  1655.                         $('#wcoin_settings_form #reward_coin').val(data.info.reward_coin);
  1656.                         if (data.info.credits_type == 1) {
  1657.                             $('#wcoin_settings_form #credits_type option[value=1]').prop("selected", true);
  1658.                         } else {
  1659.                             $('#wcoin_settings_form #credits_type option[value=2]').prop("selected", true);
  1660.                         }
  1661.                         if (data.info.change_back == 1) {
  1662.                             $('#wcoin_settings_form #change_back option[value=1]').prop("selected", true);
  1663.                         } else {
  1664.                             $('#wcoin_settings_form #change_back option[value=0]').prop("selected", true);
  1665.                         }
  1666.                         $('#wcoin_settings_form #min_rate').val(data.info.min_rate);
  1667.                         if (data.info.display_wcoins == 1) {
  1668.                             $('#wcoin_settings_form #display_wcoins option[value=1]').prop("selected", true);
  1669.                         } else {
  1670.                             $('#wcoin_settings_form #display_wcoins option[value=0]').prop("selected", true);
  1671.                         }
  1672.                     }
  1673.                 }
  1674.             },
  1675.             error: function(error) {
  1676.                 $('select', '#wcoin_settings_form').each(function() {
  1677.                     if ($(this).val() == server) {
  1678.                         $(this).prop("selected", true);
  1679.                     } else {
  1680.                         $(this).val($(this).prop('defaultSelected'));
  1681.                     }
  1682.                 });
  1683.                 $('input[type=text]', '#wcoin_settings_form').each(function() {
  1684.                     $(this).val('');
  1685.                 });
  1686.             }
  1687.         });
  1688.     },
  1689.     loadReferralSettings: function() {
  1690.         $.ajax({
  1691.             type: "post",
  1692.             dataType: "json",
  1693.             url: DmNConfig.base_url + "admincp/load_referral_settings",
  1694.             data: {
  1695.                 load_settings: 1,
  1696.             },
  1697.             success: function(data) {
  1698.                 if (typeof data.error != 'undefined') {
  1699.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1700.                 } else {
  1701.                     if (typeof data.info != 'undefined') {
  1702.                         if (data.info.active == 1) {
  1703.                             $('#referral_settings_form #active option[value=1]').prop("selected", true);
  1704.                         } else {
  1705.                             $('#referral_settings_form #active option[value=0]').prop("selected", true);
  1706.                         }
  1707.                         $('#referral_settings_form #reward_on_registration').val(data.info.reward_on_registration);
  1708.                         if (data.info.reward_type == 1) {
  1709.                             $('#referral_settings_form #reward_type option[value=1]').prop("selected", true);
  1710.                         } else {
  1711.                             $('#referral_settings_form #reward_type option[value=2]').prop("selected", true);
  1712.                         }
  1713.                         if (data.info.claim_type == 0) {
  1714.                             $('#referral_settings_form #claim_type option[value=0]').prop("selected", true);
  1715.                         } else {
  1716.                             $('#referral_settings_form #claim_type option[value=1]').prop("selected", true);
  1717.                         }
  1718.                         if (data.info.compare_ips == 0) {
  1719.                             $('#referral_settings_form #compare_ips option[value=0]').prop("selected", true);
  1720.                         } else {
  1721.                             $('#referral_settings_form #compare_ips option[value=1]').prop("selected", true);
  1722.                         }
  1723.                     }
  1724.                 }
  1725.             },
  1726.             error: function(error) {
  1727.                 $('select', '#referral_settings_form').each(function() {
  1728.                     if ($(this).val() == server) {
  1729.                         $(this).prop("selected", true);
  1730.                     } else {
  1731.                         $(this).val($(this).prop('defaultSelected'));
  1732.                     }
  1733.                 });
  1734.                 $('input[type=text]', '#referral_settings_form').each(function() {
  1735.                     $(this).val('');
  1736.                 });
  1737.             }
  1738.         });
  1739.     },
  1740.     saveWcoinSettings: function() {
  1741.         $.ajax({
  1742.             type: "post",
  1743.             dataType: "json",
  1744.             url: DmNConfig.base_url + "admincp/save_wcoin_settings",
  1745.             data: $('#wcoin_settings_form').serialize(),
  1746.             success: function(data) {
  1747.                 if (data.error) {
  1748.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1749.                 } else {
  1750.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1751.                 }
  1752.             }
  1753.         });
  1754.     },
  1755.     saveEmailSettings: function() {
  1756.         $.ajax({
  1757.             type: "post",
  1758.             dataType: "json",
  1759.             url: DmNConfig.base_url + "admincp/save_email_settings",
  1760.             data: $('#email_settings_form').serialize(),
  1761.             success: function(data) {
  1762.                 if (data.error) {
  1763.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1764.                 } else {
  1765.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1766.                 }
  1767.             }
  1768.         });
  1769.     },
  1770.     saveSecuritySettings: function() {
  1771.         $.ajax({
  1772.             type: "post",
  1773.             dataType: "json",
  1774.             url: DmNConfig.base_url + "admincp/save_security_settings",
  1775.             data: $('#security_settings_form').serialize(),
  1776.             success: function(data) {
  1777.                 if (data.error) {
  1778.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1779.                 } else {
  1780.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1781.                 }
  1782.             }
  1783.         });
  1784.     },
  1785.     saveLostPasswordSettings: function() {
  1786.         $.ajax({
  1787.             type: "post",
  1788.             dataType: "json",
  1789.             url: DmNConfig.base_url + "admincp/save_lostpassword_settings",
  1790.             data: $('#lostpassword_settings_form').serialize(),
  1791.             success: function(data) {
  1792.                 if (data.error) {
  1793.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1794.                 } else {
  1795.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1796.                 }
  1797.             }
  1798.         });
  1799.     },
  1800.     saveRegistrationSettings: function() {
  1801.         $.ajax({
  1802.             type: "post",
  1803.             dataType: "json",
  1804.             url: DmNConfig.base_url + "admincp/save_registration_settings",
  1805.             data: $('#registration_settings_form').serialize(),
  1806.             success: function(data) {
  1807.                 if (data.error) {
  1808.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1809.                 } else {
  1810.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1811.                 }
  1812.             }
  1813.         });
  1814.     },
  1815.     saveVipSettings: function() {
  1816.         $.ajax({
  1817.             type: "post",
  1818.             dataType: "json",
  1819.             url: DmNConfig.base_url + "admincp/save_vip_settings",
  1820.             data: $('#vip_settings_form').serialize(),
  1821.             success: function(data) {
  1822.                 if (data.error) {
  1823.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1824.                 } else {
  1825.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1826.                 }
  1827.             }
  1828.         });
  1829.     },
  1830.     changeVipStatus: function(id, status) {
  1831.         $.ajax({
  1832.             type: "post",
  1833.             dataType: "json",
  1834.             url: DmNConfig.base_url + "admincp/change_vip_status",
  1835.             data: {
  1836.                 id: id,
  1837.                 status: status
  1838.             },
  1839.             success: function(data) {
  1840.                 if (data.error) {
  1841.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1842.                 } else {
  1843.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1844.                     if (status == 1) {
  1845.                         $('#vip_status_icon_' + id).html('<span class="label label-success">Active</span>');
  1846.                         $('#vip_status_button_' + id).attr({
  1847.                             'class': 'btn btn-danger'
  1848.                         });
  1849.                         $('#vip_status_button_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  1850.                         $('#vip_status_button_' + id).attr('onclick', 'App.changeVipStatus(' + id + ', 0);');
  1851.                     } else {
  1852.                         $('#vip_status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  1853.                         $('#vip_status_button_' + id).attr({
  1854.                             'class': 'btn btn-success'
  1855.                         });
  1856.                         $('#vip_status_button_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  1857.                         $('#vip_status_button_' + id).attr('onclick', 'App.changeVipStatus(' + id + ', 1);');
  1858.                     }
  1859.                 }
  1860.             }
  1861.         });
  1862.     },
  1863.     deleteVipPackage: function(id) {
  1864.         $.ajax({
  1865.             type: "post",
  1866.             dataType: "json",
  1867.             url: DmNConfig.base_url + "admincp/delete_vip_package",
  1868.             data: {
  1869.                 id: id
  1870.             },
  1871.             success: function(data) {
  1872.                 if (data.error) {
  1873.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1874.                 } else {
  1875.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1876.                     $('tr#' + id).hide();
  1877.                 }
  1878.             }
  1879.         });
  1880.     },
  1881.     saveTimerSettings: function() {
  1882.         $.ajax({
  1883.             type: "post",
  1884.             dataType: "json",
  1885.             url: DmNConfig.base_url + "admincp/save_timer_settings",
  1886.             data: $('#event_settings_form').serialize(),
  1887.             success: function(data) {
  1888.                 if (data.error) {
  1889.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1890.                 } else {
  1891.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1892.                 }
  1893.             }
  1894.         });
  1895.     },
  1896.     saveRankingSettings: function(element) {
  1897.         $.ajax({
  1898.             type: "post",
  1899.             dataType: "json",
  1900.             url: DmNConfig.base_url + "admincp/save_ranking_settings",
  1901.             data: element.serialize(),
  1902.             success: function(data) {
  1903.                 if (data.error) {
  1904.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1905.                 } else {
  1906.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1907.                 }
  1908.             }
  1909.         });
  1910.     },
  1911.     saveSqlTableSettings: function() {
  1912.         $.ajax({
  1913.             type: "post",
  1914.             dataType: "json",
  1915.             url: DmNConfig.base_url + "admincp/save_table_settings",
  1916.             data: $('#sql_table_settings_form').serialize(),
  1917.             success: function(data) {
  1918.                 if (data.error) {
  1919.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1920.                 } else {
  1921.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1922.                 }
  1923.             }
  1924.         });
  1925.     },
  1926.     loadPreDefinedSqlTableSettings: function() {
  1927.         var team = $('#team_template').val();
  1928.         var server = $('#sql_table_settings_form').find('#server').val();
  1929.         if (team != '' && server != '') {
  1930.             $.ajax({
  1931.                 type: "post",
  1932.                 dataType: "json",
  1933.                 url: DmNConfig.base_url + "admincp/load_pre_defined_table_settings",
  1934.                 data: {
  1935.                     team: team,
  1936.                     server: server
  1937.                 },
  1938.                 success: function(data) {
  1939.                     if (data.error) {
  1940.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1941.                     } else {
  1942.                         if (typeof data.info != 'undefined') {
  1943.                             if (typeof data.info.resets != 'undefined') {
  1944.                                 App.updateSqlSettings(data.info.resets, 'resets');
  1945.                             }
  1946.                             if (typeof data.info.grand_resets != 'undefined') {
  1947.                                 App.updateSqlSettings(data.info.grand_resets, 'grand_resets');
  1948.                             }
  1949.                             if (typeof data.info.wcoins != 'undefined') {
  1950.                                 App.updateSqlSettings(data.info.wcoins, 'wcoins');
  1951.                             }
  1952.                             if (typeof data.info.master_level != 'undefined') {
  1953.                                 App.updateSqlSettings(data.info.master_level, 'master_level');
  1954.                             }
  1955.                             if (typeof data.info.bc != 'undefined') {
  1956.                                 App.updateSqlSettings(data.info.bc, 'bc');
  1957.                             }
  1958.                             if (typeof data.info.ds != 'undefined') {
  1959.                                 App.updateSqlSettings(data.info.ds, 'ds');
  1960.                             }
  1961.                             if (typeof data.info.cc != 'undefined') {
  1962.                                 App.updateSqlSettings(data.info.cc, 'cc');
  1963.                             }
  1964.                             if (typeof data.info.cs != 'undefined') {
  1965.                                 App.updateSqlSettings(data.info.cs, 'cs');
  1966.                             }
  1967.                             if (typeof data.info.duels != 'undefined') {
  1968.                                 App.updateSqlSettings(data.info.duels, 'duels');
  1969.                             }
  1970.                             $("html, body").animate({
  1971.                                 scrollTop: $('#edit_sql_table_settings').offset().top
  1972.                             }, 2000);
  1973.                         }
  1974.                     }
  1975.                 }
  1976.             });
  1977.         }
  1978.     },
  1979.     saveReferralSettings: function() {
  1980.         $.ajax({
  1981.             type: "post",
  1982.             dataType: "json",
  1983.             url: DmNConfig.base_url + "admincp/save_referral_settings",
  1984.             data: $('#referral_settings_form').serialize(),
  1985.             success: function(data) {
  1986.                 if (data.error) {
  1987.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  1988.                 } else {
  1989.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  1990.                 }
  1991.             }
  1992.         });
  1993.     },
  1994.     addReferralReward: function() {
  1995.         $.ajax({
  1996.             type: "post",
  1997.             dataType: "json",
  1998.             url: DmNConfig.base_url + "admincp/add_referral_package",
  1999.             data: {
  2000.                 req_lvl: $("#req_lvl").val(),
  2001.                 req_res: $("#req_res").val(),
  2002.                 req_gres: $("#req_gres").val(),
  2003.                 reward: $("#reward").val(),
  2004.                 reward_type: $("#reward_type_custom").val(),
  2005.                 server: $("#server").val()
  2006.             },
  2007.             success: function(data) {
  2008.                 if (data.error) {
  2009.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2010.                 } else {
  2011.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2012.                     var html = '<tr id="' + data.id + '"><td>' + $("#req_lvl").val() + '</td>';
  2013.                     html += '<td class="center">' + $("#req_res").val() + '</td>';
  2014.                     html += '<td class="center">' + $("#req_gres").val() + '</td>';
  2015.                     html += '<td class="center">' + $("#reward").val() + ' ' + data.reward_type + '</td>';
  2016.                     html += '<td class="center">' + data.server + '</td>';
  2017.                     html += '<td class="center" id="status_icon_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_' + data.id + '" onclick="App.changeReferralRewardStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-danger" href="#" onclick="App.deleteReferralReward(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2018.                     $('#referral_sortable > tbody:last').append(html);
  2019.                 }
  2020.             }
  2021.         });
  2022.     },
  2023.     changeReferralRewardStatus: function(id, status) {
  2024.         $.ajax({
  2025.             type: "post",
  2026.             dataType: "json",
  2027.             url: DmNConfig.base_url + "admincp/change_referral_reward_status",
  2028.             data: {
  2029.                 id: id,
  2030.                 status: status
  2031.             },
  2032.             success: function(data) {
  2033.                 if (data.error) {
  2034.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2035.                 } else {
  2036.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2037.                     if (status == 1) {
  2038.                         $('#status_icon_' + id).html('<span class="label label-success">Active</span>');
  2039.                         $('#status_button_' + id).attr({
  2040.                             'class': 'btn btn-danger'
  2041.                         });
  2042.                         $('#status_button_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2043.                         $('#status_button_' + id).attr('onclick', 'App.changeReferralRewardStatus(' + id + ', 0);');
  2044.                     } else {
  2045.                         $('#status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  2046.                         $('#status_button_' + id).attr({
  2047.                             'class': 'btn btn-success'
  2048.                         });
  2049.                         $('#status_button_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2050.                         $('#status_button_' + id).attr('onclick', 'App.changeReferralRewardStatus(' + id + ', 1);');
  2051.                     }
  2052.                 }
  2053.             }
  2054.         });
  2055.     },
  2056.     deleteReferralReward: function(id) {
  2057.         $.ajax({
  2058.             type: "post",
  2059.             dataType: "json",
  2060.             url: DmNConfig.base_url + "admincp/delete_referral_reward",
  2061.             data: {
  2062.                 id: id
  2063.             },
  2064.             success: function(data) {
  2065.                 if (data.error) {
  2066.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2067.                 } else {
  2068.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2069.                     $('tr#' + id).hide();
  2070.                 }
  2071.             }
  2072.         });
  2073.     },
  2074.     deleteEventTimer: function(id) {
  2075.         $.ajax({
  2076.             type: "post",
  2077.             dataType: "json",
  2078.             url: DmNConfig.base_url + "admincp/delete_event_timer",
  2079.             data: {
  2080.                 id: id
  2081.             },
  2082.             success: function(data) {
  2083.                 if (data.error) {
  2084.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2085.                 } else {
  2086.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2087.                     $('tr#' + id).hide();
  2088.                 }
  2089.             }
  2090.         });
  2091.     },
  2092.     saveSchedulerSettings: function(form) {
  2093.         $.ajax({
  2094.             type: "post",
  2095.             dataType: "json",
  2096.             url: DmNConfig.base_url + "admincp/save_scheduler_settings",
  2097.             data: form.serialize(),
  2098.             success: function(data) {
  2099.                 if (data.error) {
  2100.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2101.                 } else {
  2102.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2103.                 }
  2104.             }
  2105.         });
  2106.     },
  2107.     saveVoteRewardSettings: function(form) {
  2108.         $.ajax({
  2109.             type: "post",
  2110.             dataType: "json",
  2111.             url: DmNConfig.base_url + "admincp/save_votereward_settings",
  2112.             data: form.serialize(),
  2113.             success: function(data) {
  2114.                 if (data.error) {
  2115.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2116.                 } else {
  2117.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2118.                 }
  2119.             }
  2120.         });
  2121.     },
  2122.     savePaypalSettings: function() {
  2123.         $.ajax({
  2124.             type: "post",
  2125.             dataType: "json",
  2126.             url: DmNConfig.base_url + "admincp/save_paypal_settings",
  2127.             data: $('#paypal_settings_form').serialize(),
  2128.             success: function(data) {
  2129.                 if (data.error) {
  2130.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2131.                 } else {
  2132.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2133.                 }
  2134.             }
  2135.         });
  2136.     },
  2137.     savePaymentwallSettings: function() {
  2138.         $.ajax({
  2139.             type: "post",
  2140.             dataType: "json",
  2141.             url: DmNConfig.base_url + "admincp/save_paymentwall_settings",
  2142.             data: $('#paymentwall_settings_form').serialize(),
  2143.             success: function(data) {
  2144.                 if (data.error) {
  2145.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2146.                 } else {
  2147.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2148.                 }
  2149.             }
  2150.         });
  2151.     },
  2152.     saveFortumoSettings: function() {
  2153.         $.ajax({
  2154.             type: "post",
  2155.             dataType: "json",
  2156.             url: DmNConfig.base_url + "admincp/save_fortumo_settings",
  2157.             data: $('#fortumo_settings_form').serialize(),
  2158.             success: function(data) {
  2159.                 if (data.error) {
  2160.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2161.                 } else {
  2162.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2163.                 }
  2164.             }
  2165.         });
  2166.     },
  2167.     savePaygolSettings: function() {
  2168.         $.ajax({
  2169.             type: "post",
  2170.             dataType: "json",
  2171.             url: DmNConfig.base_url + "admincp/save_paygol_settings",
  2172.             data: $('#paygol_settings_form').serialize(),
  2173.             success: function(data) {
  2174.                 if (data.error) {
  2175.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2176.                 } else {
  2177.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2178.                 }
  2179.             }
  2180.         });
  2181.     },
  2182.     save2CheckOutSettings: function() {
  2183.         $.ajax({
  2184.             type: "post",
  2185.             dataType: "json",
  2186.             url: DmNConfig.base_url + "admincp/save_twocheckout_settings",
  2187.             data: $('#2checkout_settings_form').serialize(),
  2188.             success: function(data) {
  2189.                 if (data.error) {
  2190.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2191.                 } else {
  2192.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2193.                 }
  2194.             }
  2195.         });
  2196.     },
  2197.     savePagSeguroSettings: function() {
  2198.         $.ajax({
  2199.             type: "post",
  2200.             dataType: "json",
  2201.             url: DmNConfig.base_url + "admincp/save_pagseguro_settings",
  2202.             data: $('#pagseguro_settings_form').serialize(),
  2203.             success: function(data) {
  2204.                 if (data.error) {
  2205.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2206.                 } else {
  2207.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2208.                 }
  2209.             }
  2210.         });
  2211.     },
  2212.     saveSuperRewardsSettings: function() {
  2213.         $.ajax({
  2214.             type: "post",
  2215.             dataType: "json",
  2216.             url: DmNConfig.base_url + "admincp/save_superrewards_settings",
  2217.             data: $('#superrewards_settings_form').serialize(),
  2218.             success: function(data) {
  2219.                 if (data.error) {
  2220.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2221.                 } else {
  2222.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2223.                 }
  2224.             }
  2225.         });
  2226.     },
  2227.     savePayCallSettings: function() {
  2228.         $.ajax({
  2229.             type: "post",
  2230.             dataType: "json",
  2231.             url: DmNConfig.base_url + "admincp/save_paycall_settings",
  2232.             data: $('#paycall_settings_form').serialize(),
  2233.             success: function(data) {
  2234.                 if (data.error) {
  2235.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2236.                 } else {
  2237.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2238.                 }
  2239.             }
  2240.         });
  2241.     },
  2242.     saveInterkassaSettings: function() {
  2243.         $.ajax({
  2244.             type: "post",
  2245.             dataType: "json",
  2246.             url: DmNConfig.base_url + "admincp/save_interkassa_settings",
  2247.             data: $('#interkassa_settings_form').serialize(),
  2248.             success: function(data) {
  2249.                 if (data.error) {
  2250.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2251.                 } else {
  2252.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2253.                 }
  2254.             }
  2255.         });
  2256.     },
  2257.     saveCuentaDigitalSettings: function() {
  2258.         $.ajax({
  2259.             type: "post",
  2260.             dataType: "json",
  2261.             url: DmNConfig.base_url + "admincp/save_cuenta_digital_settings",
  2262.             data: $('#cuenta_digital_settings_form').serialize(),
  2263.             success: function(data) {
  2264.                 if (data.error) {
  2265.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2266.                 } else {
  2267.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2268.                 }
  2269.             }
  2270.         });
  2271.     },
  2272.     saveDownloadsOrder: function() {
  2273.         var order = $('#downloads_sortable_content').sortable('toArray');
  2274.         $.ajax({
  2275.             type: "post",
  2276.             dataType: "json",
  2277.             url: DmNConfig.base_url + "admincp/save_downloads_order",
  2278.             data: {
  2279.                 order: order
  2280.             },
  2281.             success: function(data) {}
  2282.  
  2283.         });
  2284.     },
  2285.     savePaypalOrder: function() {
  2286.         var order = $('#donate_sortable_content').sortable('toArray');
  2287.         $.ajax({
  2288.             type: "post",
  2289.             dataType: "json",
  2290.             url: DmNConfig.base_url + "admincp/save_paypal_order",
  2291.             data: {
  2292.                 order: order
  2293.             },
  2294.             success: function(data) {}
  2295.  
  2296.         });
  2297.     },
  2298.     editPaypal: function(id) {
  2299.         $.ajax({
  2300.             type: "post",
  2301.             dataType: "json",
  2302.             url: DmNConfig.base_url + "admincp/edit_paypal_package",
  2303.             data: {
  2304.                 id: id,
  2305.                 title: $("#pack_title_" + id).val(),
  2306.                 price: $("#pack_price_" + id).val(),
  2307.                 currency: $("#pack_currency_" + id).val(),
  2308.                 reward: $("#pack_reward_" + id).val(),
  2309.                 server: $("#pack_server_" + id).val()
  2310.             },
  2311.             success: function(data) {
  2312.                 if (data.error) {
  2313.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2314.                 } else {
  2315.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2316.                 }
  2317.             }
  2318.         });
  2319.     },
  2320.     deletePaypal: function(id) {
  2321.         $.ajax({
  2322.             type: "post",
  2323.             dataType: "json",
  2324.             url: DmNConfig.base_url + "admincp/delete_paypal_package",
  2325.             data: {
  2326.                 id: id
  2327.             },
  2328.             success: function(data) {
  2329.                 if (data.error) {
  2330.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2331.                 } else {
  2332.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2333.                     $('tr#' + id).hide();
  2334.                 }
  2335.             }
  2336.         });
  2337.     },
  2338.     changePaypalStatus: function(id, status) {
  2339.         $.ajax({
  2340.             type: "post",
  2341.             dataType: "json",
  2342.             url: DmNConfig.base_url + "admincp/change_paypal_status",
  2343.             data: {
  2344.                 id: id,
  2345.                 status: status
  2346.             },
  2347.             success: function(data) {
  2348.                 if (data.error) {
  2349.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2350.                 } else {
  2351.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2352.                     if (status == 1) {
  2353.                         $('#status_icon_' + id).html('<span class="label label-success">Active</span>');
  2354.                         $('#status_button_' + id).attr({
  2355.                             'class': 'btn btn-danger'
  2356.                         });
  2357.                         $('#status_button_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2358.                         $('#status_button_' + id).attr('onclick', 'App.changePaypalStatus(' + id + ', 0);');
  2359.                     } else {
  2360.                         $('#status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  2361.                         $('#status_button_' + id).attr({
  2362.                             'class': 'btn btn-success'
  2363.                         });
  2364.                         $('#status_button_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2365.                         $('#status_button_' + id).attr('onclick', 'App.changePaypalStatus(' + id + ', 1);');
  2366.                     }
  2367.                 }
  2368.             }
  2369.         });
  2370.     },
  2371.     addPaypalPackage: function() {
  2372.         $.ajax({
  2373.             type: "post",
  2374.             dataType: "json",
  2375.             url: DmNConfig.base_url + "admincp/add_paypal_package",
  2376.             data: {
  2377.                 title: $("#title_new").val(),
  2378.                 price: $("#price_new").val(),
  2379.                 currency: $("#currency_new").val(),
  2380.                 reward: $("#reward_new").val(),
  2381.                 server: $("#server_new").val()
  2382.             },
  2383.             success: function(data) {
  2384.                 if (data.error) {
  2385.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2386.                 } else {
  2387.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2388.                     var html = '<tr id="' + data.id + '"><td><input class="input-medium" type="text" id="pack_title_' + data.id + '" value="' + $("#title_new").val() + '" /></td>';
  2389.                     html += '<td class="center"><input class="input-small" type="text" id="pack_price_' + data.id + '" value="' + $("#price_new").val() + '" /></td>';
  2390.                     html += '<td class="center"><input class="input-small" type="text" id="pack_currency_' + data.id + '" value="' + $("#currency_new").val() + '" /></td>';
  2391.                     html += '<td class="center"><input class="input-small" type="text" id="pack_reward_' + data.id + '" value="' + $("#reward_new").val() + '" /></td>';
  2392.                     html += '<td class="center"><select id="pack_server_' + data.id + '" class="input-medium">';
  2393.                     $.each(data.servers, function(key, val) {
  2394.                         var selected = (key == data.server) ? 'selected="selected"' : '';
  2395.                         html += '<option value="' + key + '" ' + selected + '>' + val.title + '</option>';
  2396.                     });
  2397.                     html += '</select></td>';
  2398.                     html += '<td class="center" id="status_icon_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_' + data.id + '" onclick="App.changePaypalStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-info" href="#" onclick="App.editPaypal(' + data.id + ');"><i class="icon-edit icon-white"></i> Edit</a>  <a class="btn btn-danger" href="#" onclick="App.deletePaypal(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2399.                     $('#donate_sortable > tbody:last').append(html);
  2400.                 }
  2401.             }
  2402.         });
  2403.     },
  2404.     save2CheckOutOrder: function() {
  2405.         var order = $('#donate_sortable_content_checkout').sortable('toArray');
  2406.         $.ajax({
  2407.             type: "post",
  2408.             dataType: "json",
  2409.             url: DmNConfig.base_url + "admincp/save_twocheckout_order",
  2410.             data: {
  2411.                 order: order
  2412.             },
  2413.             success: function(data) {}
  2414.  
  2415.         });
  2416.     },
  2417.     edit2CheckOut: function(id) {
  2418.         $.ajax({
  2419.             type: "post",
  2420.             dataType: "json",
  2421.             url: DmNConfig.base_url + "admincp/edit_twocheckout_package",
  2422.             data: {
  2423.                 id: id,
  2424.                 title: $("#pack_title_2checkout_" + id).val(),
  2425.                 price: $("#pack_price_2checkout_" + id).val(),
  2426.                 currency: $("#pack_currency_2checkout_" + id).val(),
  2427.                 reward: $("#pack_reward_2checkout_" + id).val(),
  2428.                 server: $("#pack_server_2checkout_" + id).val()
  2429.             },
  2430.             success: function(data) {
  2431.                 if (data.error) {
  2432.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2433.                 } else {
  2434.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2435.                 }
  2436.             }
  2437.         });
  2438.     },
  2439.     delete2CheckOut: function(id) {
  2440.         $.ajax({
  2441.             type: "post",
  2442.             dataType: "json",
  2443.             url: DmNConfig.base_url + "admincp/delete_twocheckout_package",
  2444.             data: {
  2445.                 id: id
  2446.             },
  2447.             success: function(data) {
  2448.                 if (data.error) {
  2449.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2450.                 } else {
  2451.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2452.                     $('tr#2checkout_' + id).hide();
  2453.                 }
  2454.             }
  2455.         });
  2456.     },
  2457.     change2CheckOutStatus: function(id, status) {
  2458.         $.ajax({
  2459.             type: "post",
  2460.             dataType: "json",
  2461.             url: DmNConfig.base_url + "admincp/change_twocheckout_status",
  2462.             data: {
  2463.                 id: id,
  2464.                 status: status
  2465.             },
  2466.             success: function(data) {
  2467.                 if (data.error) {
  2468.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2469.                 } else {
  2470.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2471.                     if (status == 1) {
  2472.                         $('#status_icon_2checkout_' + id).html('<span class="label label-success">Active</span>');
  2473.                         $('#status_button_2checkout_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2474.                         $('#status_button_2checkout_' + id).attr('onclick', 'App.change2CheckOutStatus(' + id + ', 0);');
  2475.                         $('#status_button_2checkout_' + id).attr({
  2476.                             'class': 'btn btn-danger'
  2477.                         });
  2478.                     } else {
  2479.                         $('#status_icon_2checkout_' + id).html('<span class="label label-important">Inactive</span>');
  2480.                         $('#status_button_2checkout_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2481.                         $('#status_button_2checkout_' + id).attr('onclick', 'App.change2CheckOutStatus(' + id + ', 1);');
  2482.                         $('#status_button_2checkout_' + id).attr({
  2483.                             'class': 'btn btn-success'
  2484.                         });
  2485.                     }
  2486.                 }
  2487.             }
  2488.         });
  2489.     },
  2490.     add2CheckOutPackage: function() {
  2491.         $.ajax({
  2492.             type: "post",
  2493.             dataType: "json",
  2494.             url: DmNConfig.base_url + "admincp/add_twocheckout_package",
  2495.             data: {
  2496.                 title: $("#title_new_2checkout").val(),
  2497.                 price: $("#price_new_2checkout").val(),
  2498.                 currency: $("#currency_new_2checkout").val(),
  2499.                 reward: $("#reward_new_2checkout").val(),
  2500.                 server: $("#server_new_2checkout").val()
  2501.             },
  2502.             success: function(data) {
  2503.                 if (data.error) {
  2504.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2505.                 } else {
  2506.                     var html = '<tr id="2checkout_' + data.id + '"><td><input class="input-medium" type="text" id="pack_title_' + data.id + '" value="' + $("#title_new_2checkout").val() + '" /></td>';
  2507.                     html += '<td class="center"><input class="input-small" type="text" id="pack_price_' + data.id + '" value="' + $("#price_new_2checkout").val() + '" /></td>';
  2508.                     html += '<td class="center"><input class="input-small" type="text" id="pack_currency_' + data.id + '" value="' + $("#currency_new_2checkout").val() + '" /></td>';
  2509.                     html += '<td class="center"><input class="input-small" type="text" id="pack_reward_' + data.id + '" value="' + $("#reward_new_2checkout").val() + '" /></td>';
  2510.                     html += '<td class="center"><select id="pack_server_' + data.id + '" class="input-medium">';
  2511.                     $.each(data.servers, function(key, val) {
  2512.                         var selected = (key == data.server) ? 'selected="selected"' : '';
  2513.                         html += '<option value="' + key + '" ' + selected + '>' + val.title + '</option>';
  2514.                     });
  2515.                     html += '</select></td>';
  2516.                     html += '<td class="center" id="status_icon_2checkout_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_2checkout_' + data.id + '" onclick="App.change2CheckOutStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-info" href="#" onclick="App.edit2CheckOut(' + data.id + ');"><i class="icon-edit icon-white"></i> Edit</a>  <a class="btn btn-danger" href="#" onclick="App.delete2CheckOut(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2517.                     $('#donate_sortable_checkout > tbody:last').append(html);
  2518.                 }
  2519.             }
  2520.         });
  2521.     },
  2522.     savePagSeguroOrder: function() {
  2523.         var order = $('#donate_sortable_content_pagseguro').sortable('toArray');
  2524.         $.ajax({
  2525.             type: "post",
  2526.             dataType: "json",
  2527.             url: DmNConfig.base_url + "admincp/save_pagseguro_order",
  2528.             data: {
  2529.                 order: order
  2530.             },
  2531.             success: function(data) {}
  2532.  
  2533.         });
  2534.     },
  2535.     editPagSeguro: function(id) {
  2536.         $.ajax({
  2537.             type: "post",
  2538.             dataType: "json",
  2539.             url: DmNConfig.base_url + "admincp/edit_pagseguro_package",
  2540.             data: {
  2541.                 id: id,
  2542.                 title: $("#pack_title_pagseguro_" + id).val(),
  2543.                 price: $("#pack_price_pagseguro_" + id).val(),
  2544.                 currency: $("#pack_currency_pagseguro_" + id).val(),
  2545.                 reward: $("#pack_reward_pagseguro_" + id).val(),
  2546.                 server: $("#pack_server_pagseguro_" + id).val()
  2547.             },
  2548.             success: function(data) {
  2549.                 if (data.error) {
  2550.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2551.                 } else {
  2552.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2553.                 }
  2554.             }
  2555.         });
  2556.     },
  2557.     deletePagSeguro: function(id) {
  2558.         $.ajax({
  2559.             type: "post",
  2560.             dataType: "json",
  2561.             url: DmNConfig.base_url + "admincp/delete_pagseguro_package",
  2562.             data: {
  2563.                 id: id
  2564.             },
  2565.             success: function(data) {
  2566.                 if (data.error) {
  2567.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2568.                 } else {
  2569.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2570.                     $('tr#pagseguro_' + id).hide();
  2571.                 }
  2572.             }
  2573.         });
  2574.     },
  2575.     changePagSeguroStatus: function(id, status) {
  2576.         $.ajax({
  2577.             type: "post",
  2578.             dataType: "json",
  2579.             url: DmNConfig.base_url + "admincp/change_pagseguro_status",
  2580.             data: {
  2581.                 id: id,
  2582.                 status: status
  2583.             },
  2584.             success: function(data) {
  2585.                 if (data.error) {
  2586.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2587.                 } else {
  2588.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2589.                     if (status == 1) {
  2590.                         $('#status_icon_pagseguro_' + id).html('<span class="label label-success">Active</span>');
  2591.                         $('#status_button_pagseguro_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2592.                         $('#status_button_pagseguro_' + id).attr('onclick', 'App.changePagSeguroStatus(' + id + ', 0);');
  2593.                         $('#status_button_pagseguro_' + id).attr({
  2594.                             'class': 'btn btn-danger'
  2595.                         });
  2596.                     } else {
  2597.                         $('#status_icon_pagseguro_' + id).html('<span class="label label-important">Inactive</span>');
  2598.                         $('#status_button_pagseguro_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2599.                         $('#status_button_pagseguro_' + id).attr('onclick', 'App.changePagSeguroStatus(' + id + ', 1);');
  2600.                         $('#status_button_pagseguro_' + id).attr({
  2601.                             'class': 'btn btn-success'
  2602.                         });
  2603.                     }
  2604.                 }
  2605.             }
  2606.         });
  2607.     },
  2608.     addPagSeguroPackage: function() {
  2609.         $.ajax({
  2610.             type: "post",
  2611.             dataType: "json",
  2612.             url: DmNConfig.base_url + "admincp/add_pagseguro_package",
  2613.             data: {
  2614.                 title: $("#title_new_pagseguro").val(),
  2615.                 price: $("#price_new_pagseguro").val(),
  2616.                 currency: $("#currency_new_pagseguro").val(),
  2617.                 reward: $("#reward_new_pagseguro").val(),
  2618.                 server: $("#server_new_pagseguro").val()
  2619.             },
  2620.             success: function(data) {
  2621.                 if (data.error) {
  2622.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2623.                 } else {
  2624.                     var html = '<tr id="pagseguro_' + data.id + '"><td><input class="input-medium" type="text" id="pack_title_pagseguro_' + data.id + '" value="' + $("#title_new_pagseguro").val() + '" /></td>';
  2625.                     html += '<td class="center"><input class="input-small" type="text" id="pack_price_pagseguro_' + data.id + '" value="' + $("#price_new_pagseguro").val() + '" /></td>';
  2626.                     html += '<td class="center"><input class="input-small" type="text" id="pack_currency_pagseguro_' + data.id + '" value="' + $("#currency_new_pagseguro").val() + '" /></td>';
  2627.                     html += '<td class="center"><input class="input-small" type="text" id="pack_reward_pagseguro_' + data.id + '" value="' + $("#reward_new_pagseguro").val() + '" /></td>';
  2628.                     html += '<td class="center"><select id="pack_server_pagseguro_' + data.id + '" class="input-medium">';
  2629.                     $.each(data.servers, function(key, val) {
  2630.                         var selected = (key == data.server) ? 'selected="selected"' : '';
  2631.                         html += '<option value="' + key + '" ' + selected + '>' + val.title + '</option>';
  2632.                     });
  2633.                     html += '</select></td>';
  2634.                     html += '<td class="center" id="status_icon_pagseguro_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_pagseguro_' + data.id + '" onclick="App.changePagSeguroStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-info" href="#" onclick="App.editPagSeguro(' + data.id + ');"><i class="icon-edit icon-white"></i> Edit</a>  <a class="btn btn-danger" href="#" onclick="App.deletePagSeguro(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2635.                     $('#donate_sortable_pagseguro > tbody:last').append(html);
  2636.                 }
  2637.             }
  2638.         });
  2639.     },
  2640.     saveInterkassaOrder: function() {
  2641.         var order = $('#donate_sortable_interkassa_content').sortable('toArray');
  2642.         $.ajax({
  2643.             type: "post",
  2644.             dataType: "json",
  2645.             url: DmNConfig.base_url + "admincp/save_interkassa_order",
  2646.             data: {
  2647.                 order: order
  2648.             },
  2649.             success: function(data) {}
  2650.  
  2651.         });
  2652.     },
  2653.     editInterkassa: function(id) {
  2654.         $.ajax({
  2655.             type: "post",
  2656.             dataType: "json",
  2657.             url: DmNConfig.base_url + "admincp/edit_interkassa_package",
  2658.             data: {
  2659.                 id: id,
  2660.                 title: $("#pack_title_interkassa_" + id).val(),
  2661.                 price: $("#pack_price_interkassa_" + id).val(),
  2662.                 currency: $("#pack_currency_interkassa_" + id).val(),
  2663.                 reward: $("#pack_reward_interkassa_" + id).val(),
  2664.                 server: $("#pack_server_interkassa_" + id).val()
  2665.             },
  2666.             success: function(data) {
  2667.                 if (data.error) {
  2668.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2669.                 } else {
  2670.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2671.                 }
  2672.             }
  2673.         });
  2674.     },
  2675.     deleteInterkassa: function(id) {
  2676.         $.ajax({
  2677.             type: "post",
  2678.             dataType: "json",
  2679.             url: DmNConfig.base_url + "admincp/delete_interkassa_package",
  2680.             data: {
  2681.                 id: id
  2682.             },
  2683.             success: function(data) {
  2684.                 if (data.error) {
  2685.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2686.                 } else {
  2687.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2688.                     $('tr#interkassa_' + id).hide();
  2689.                 }
  2690.             }
  2691.         });
  2692.     },
  2693.     changeInterkassaStatus: function(id, status) {
  2694.         $.ajax({
  2695.             type: "post",
  2696.             dataType: "json",
  2697.             url: DmNConfig.base_url + "admincp/change_interkassa_status",
  2698.             data: {
  2699.                 id: id,
  2700.                 status: status
  2701.             },
  2702.             success: function(data) {
  2703.                 if (data.error) {
  2704.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2705.                 } else {
  2706.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2707.                     if (status == 1) {
  2708.                         $('#status_icon_interkassa_' + id).html('<span class="label label-success">Active</span>');
  2709.                         $('#status_button_interkassa_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2710.                         $('#status_button_interkassa_' + id).attr('onclick', 'App.changeInterkassaStatus(' + id + ', 0);');
  2711.                         $('#status_button_interkassa_' + id).attr({
  2712.                             'class': 'btn btn-danger'
  2713.                         });
  2714.                     } else {
  2715.                         $('#status_icon_interkassa_' + id).html('<span class="label label-important">Inactive</span>');
  2716.                         $('#status_button_interkassa_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2717.                         $('#status_button_interkassa_' + id).attr('onclick', 'App.changeInterkassaStatus(' + id + ', 1);');
  2718.                         $('#status_button_interkassa_' + id).attr({
  2719.                             'class': 'btn btn-success'
  2720.                         });
  2721.                     }
  2722.                 }
  2723.             }
  2724.         });
  2725.     },
  2726.     addInterkassaPackage: function() {
  2727.         $.ajax({
  2728.             type: "post",
  2729.             dataType: "json",
  2730.             url: DmNConfig.base_url + "admincp/add_interkassa_package",
  2731.             data: {
  2732.                 title: $("#title_new_interkassa").val(),
  2733.                 price: $("#price_new_interkassa").val(),
  2734.                 currency: $("#currency_new_interkassa").val(),
  2735.                 reward: $("#reward_new_interkassa").val(),
  2736.                 server: $("#server_new_interkassa").val()
  2737.             },
  2738.             success: function(data) {
  2739.                 if (data.error) {
  2740.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2741.                 } else {
  2742.                     var html = '<tr id="interkassa_' + data.id + '"><td><input class="input-medium" type="text" id="pack_title_interkassa_' + data.id + '" value="' + $("#title_new_interkassa").val() + '" /></td>';
  2743.                     html += '<td class="center"><input class="input-small" type="text" id="pack_price_interkassa_' + data.id + '" value="' + $("#price_new_interkassa").val() + '" /></td>';
  2744.                     html += '<td class="center"><input class="input-small" type="text" id="pack_currency_interkassa_' + data.id + '" value="' + $("#currency_new_interkassa").val() + '" /></td>';
  2745.                     html += '<td class="center"><input class="input-small" type="text" id="pack_reward_interkassa_' + data.id + '" value="' + $("#reward_new_interkassa").val() + '" /></td>';
  2746.                     html += '<td class="center"><select id="pack_server_interkassa_' + data.id + '" class="input-medium">';
  2747.                     $.each(data.servers, function(key, val) {
  2748.                         var selected = (key == data.server) ? 'selected="selected"' : '';
  2749.                         html += '<option value="' + key + '" ' + selected + '>' + val.title + '</option>';
  2750.                     });
  2751.                     html += '</select></td>';
  2752.                     html += '<td class="center" id="status_icon_interkassa_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_interkassa_' + data.id + '" onclick="App.changeInterkassaStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-info" href="#" onclick="App.editInterkassa(' + data.id + ');"><i class="icon-edit icon-white"></i> Edit</a>  <a class="btn btn-danger" href="#" onclick="App.deleteInterkassa(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2753.                     $('#donate_sortable_interkassa > tbody:last').append(html);
  2754.                 }
  2755.             }
  2756.         });
  2757.     },
  2758.     saveCuentaDigitalOrder: function() {
  2759.         var order = $('#donate_sortable_cuenta_digital_content').sortable('toArray');
  2760.         $.ajax({
  2761.             type: "post",
  2762.             dataType: "json",
  2763.             url: DmNConfig.base_url + "admincp/save_cuenta_digital_order",
  2764.             data: {
  2765.                 order: order
  2766.             },
  2767.             success: function(data) {}
  2768.  
  2769.         });
  2770.     },
  2771.     editCuentaDigital: function(id) {
  2772.         $.ajax({
  2773.             type: "post",
  2774.             dataType: "json",
  2775.             url: DmNConfig.base_url + "admincp/edit_cuenta_digital_package",
  2776.             data: {
  2777.                 id: id,
  2778.                 title: $("#pack_title_cuenta_digital_" + id).val(),
  2779.                 price: $("#pack_price_cuenta_digital_" + id).val(),
  2780.                 currency: $("#pack_currency_cuenta_digital_" + id).val(),
  2781.                 reward: $("#pack_reward_cuenta_digital_" + id).val(),
  2782.                 server: $("#pack_server_cuenta_digital_" + id).val()
  2783.             },
  2784.             success: function(data) {
  2785.                 if (data.error) {
  2786.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2787.                 } else {
  2788.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2789.                 }
  2790.             }
  2791.         });
  2792.     },
  2793.     deleteCuentaDigital: function(id) {
  2794.         $.ajax({
  2795.             type: "post",
  2796.             dataType: "json",
  2797.             url: DmNConfig.base_url + "admincp/delete_cuenta_digital_package",
  2798.             data: {
  2799.                 id: id
  2800.             },
  2801.             success: function(data) {
  2802.                 if (data.error) {
  2803.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2804.                 } else {
  2805.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2806.                     $('tr#cuenta_digital_' + id).hide();
  2807.                 }
  2808.             }
  2809.         });
  2810.     },
  2811.     changeCuentaDigitalStatus: function(id, status) {
  2812.         $.ajax({
  2813.             type: "post",
  2814.             dataType: "json",
  2815.             url: DmNConfig.base_url + "admincp/change_cuenta_digital_status",
  2816.             data: {
  2817.                 id: id,
  2818.                 status: status
  2819.             },
  2820.             success: function(data) {
  2821.                 if (data.error) {
  2822.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2823.                 } else {
  2824.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2825.                     if (status == 1) {
  2826.                         $('#status_icon_cuenta_digital_' + id).html('<span class="label label-success">Active</span>');
  2827.                         $('#status_button_cuenta_digital_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2828.                         $('#status_button_cuenta_digital_' + id).attr('onclick', 'App.changeCuentaDigitalStatus(' + id + ', 0);');
  2829.                         $('#status_button_cuenta_digital_' + id).attr({
  2830.                             'class': 'btn btn-danger'
  2831.                         });
  2832.                     } else {
  2833.                         $('#status_icon_cuenta_digital_' + id).html('<span class="label label-important">Inactive</span>');
  2834.                         $('#status_button_cuenta_digital_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2835.                         $('#status_button_cuenta_digital_' + id).attr('onclick', 'App.changeCuentaDigitalStatus(' + id + ', 1);');
  2836.                         $('#status_button_cuenta_digital_' + id).attr({
  2837.                             'class': 'btn btn-success'
  2838.                         });
  2839.                     }
  2840.                 }
  2841.             }
  2842.         });
  2843.     },
  2844.     addCuentaDigitalPackage: function() {
  2845.         $.ajax({
  2846.             type: "post",
  2847.             dataType: "json",
  2848.             url: DmNConfig.base_url + "admincp/add_cuenta_digital_package",
  2849.             data: {
  2850.                 title: $("#title_new_cuenta_digital").val(),
  2851.                 price: $("#price_new_cuenta_digital").val(),
  2852.                 currency: $("#currency_new_cuenta_digital").val(),
  2853.                 reward: $("#reward_new_cuenta_digital").val(),
  2854.                 server: $("#server_new_cuenta_digital").val()
  2855.             },
  2856.             success: function(data) {
  2857.                 if (data.error) {
  2858.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2859.                 } else {
  2860.                     var html = '<tr id="cuenta_digital_' + data.id + '"><td><input class="input-medium" type="text" id="pack_title_cuenta_digital_' + data.id + '" value="' + $("#title_new_cuenta_digital").val() + '" /></td>';
  2861.                     html += '<td class="center"><input class="input-small" type="text" id="pack_price_cuenta_digital_' + data.id + '" value="' + $("#price_new_cuenta_digital").val() + '" /></td>';
  2862.                     html += '<td class="center"><input class="input-small" type="text" id="pack_currency_cuenta_digital_' + data.id + '" value="' + $("#currency_new_cuenta_digital").val() + '" /></td>';
  2863.                     html += '<td class="center"><input class="input-small" type="text" id="pack_reward_cuenta_digital_' + data.id + '" value="' + $("#reward_new_cuenta_digital").val() + '" /></td>';
  2864.                     html += '<td class="center"><select id="pack_server_cuenta_digital_' + data.id + '" class="input-medium">';
  2865.                     $.each(data.servers, function(key, val) {
  2866.                         var selected = (key == data.server) ? 'selected="selected"' : '';
  2867.                         html += '<option value="' + key + '" ' + selected + '>' + val.title + '</option>';
  2868.                     });
  2869.                     html += '</select></td>';
  2870.                     html += '<td class="center" id="status_icon_cuenta_digital_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_cuenta_digital_' + data.id + '" onclick="App.changeCuentaDigitalStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-info" href="#" onclick="App.editCuentaDigital(' + data.id + ');"><i class="icon-edit icon-white"></i> Edit</a>  <a class="btn btn-danger" href="#" onclick="App.deleteCuentaDigital(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2871.                     $('#donate_sortable_cuenta_digital > tbody:last').append(html);
  2872.                 }
  2873.             }
  2874.         });
  2875.     },
  2876.     savePaycallOrder: function() {
  2877.         var order = $('#donate_sortable_paycall_content').sortable('toArray');
  2878.         $.ajax({
  2879.             type: "post",
  2880.             dataType: "json",
  2881.             url: DmNConfig.base_url + "admincp/save_paycall_order",
  2882.             data: {
  2883.                 order: order
  2884.             },
  2885.             success: function(data) {}
  2886.  
  2887.         });
  2888.     },
  2889.     editPaycall: function(id) {
  2890.         $.ajax({
  2891.             type: "post",
  2892.             dataType: "json",
  2893.             url: DmNConfig.base_url + "admincp/edit_paycall_package",
  2894.             data: {
  2895.                 id: id,
  2896.                 title: $("#pack_title_paycall_" + id).val(),
  2897.                 price: $("#pack_price_paycall_" + id).val(),
  2898.                 reward: $("#pack_reward_paycall_" + id).val(),
  2899.                 server: $("#pack_server_paycall_" + id).val()
  2900.             },
  2901.             success: function(data) {
  2902.                 if (data.error) {
  2903.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2904.                 } else {
  2905.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2906.                 }
  2907.             }
  2908.         });
  2909.     },
  2910.     deletePaycall: function(id) {
  2911.         $.ajax({
  2912.             type: "post",
  2913.             dataType: "json",
  2914.             url: DmNConfig.base_url + "admincp/delete_paycall_package",
  2915.             data: {
  2916.                 id: id
  2917.             },
  2918.             success: function(data) {
  2919.                 if (data.error) {
  2920.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2921.                 } else {
  2922.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2923.                     $('tr#paycall_' + id).hide();
  2924.                 }
  2925.             }
  2926.         });
  2927.     },
  2928.     changePaycallStatus: function(id, status) {
  2929.         $.ajax({
  2930.             type: "post",
  2931.             dataType: "json",
  2932.             url: DmNConfig.base_url + "admincp/change_paycall_status",
  2933.             data: {
  2934.                 id: id,
  2935.                 status: status
  2936.             },
  2937.             success: function(data) {
  2938.                 if (data.error) {
  2939.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2940.                 } else {
  2941.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  2942.                     if (status == 1) {
  2943.                         $('#status_icon_paycall_' + id).html('<span class="label label-success">Active</span>');
  2944.                         $('#status_button_paycall_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  2945.                         $('#status_button_paycall_' + id).attr('onclick', 'App.changePaycallStatus(' + id + ', 0);');
  2946.                         $('#status_button_paycall_' + id).attr({
  2947.                             'class': 'btn btn-danger'
  2948.                         });
  2949.                     } else {
  2950.                         $('#status_icon_paycall_' + id).html('<span class="label label-important">Inactive</span>');
  2951.                         $('#status_button_paycall_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  2952.                         $('#status_button_paycall_' + id).attr('onclick', 'App.changePaycallStatus(' + id + ', 1);');
  2953.                         $('#status_button_paycall_' + id).attr({
  2954.                             'class': 'btn btn-success'
  2955.                         });
  2956.                     }
  2957.                 }
  2958.             }
  2959.         });
  2960.     },
  2961.     addPaycallPackage: function() {
  2962.         $.ajax({
  2963.             type: "post",
  2964.             dataType: "json",
  2965.             url: DmNConfig.base_url + "admincp/add_paycall_package",
  2966.             data: {
  2967.                 title: $("#title_new_paycall").val(),
  2968.                 price: $("#price_new_paycall").val(),
  2969.                 reward: $("#reward_new_paycall").val(),
  2970.                 server: $("#server_new_paycall").val()
  2971.             },
  2972.             success: function(data) {
  2973.                 if (data.error) {
  2974.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  2975.                 } else {
  2976.                     var html = '<tr id="paycall_' + data.id + '"><td><input class="input-medium" type="text" id="pack_title_paycall_' + data.id + '" value="' + $("#title_new_paycall").val() + '" /></td>';
  2977.                     html += '<td class="center"><input class="input-small" type="text" id="pack_price_paycall_' + data.id + '" value="' + $("#price_new_paycall").val() + '" /></td>';
  2978.                     html += '<td class="center"><input class="input-small" type="text" id="pack_reward_paycall_' + data.id + '" value="' + $("#reward_new_paycall").val() + '" /></td>';
  2979.                     html += '<td class="center"><select id="pack_server_paycall_' + data.id + '" class="input-medium">';
  2980.                     $.each(data.servers, function(key, val) {
  2981.                         var selected = (key == data.server) ? 'selected="selected"' : '';
  2982.                         html += '<option value="' + key + '" ' + selected + '>' + val.title + '</option>';
  2983.                     });
  2984.                     html += '</select></td>';
  2985.                     html += '<td class="center" id="status_icon_paycall_' + data.id + '"><span class="label label-success">Active</span></td><td class="center"><a class="btn btn-danger" href="#" id="status_button_paycall_' + data.id + '" onclick="App.changePaycallStatus(' + data.id + ', 0);"><i class="icon-edit icon-white"></i> Disable</a>  <a class="btn btn-info" href="#" onclick="App.editPaycall(' + data.id + ');"><i class="icon-edit icon-white"></i> Edit</a>  <a class="btn btn-danger" href="#" onclick="App.deletePaycall(' + data.id + ');"><i class="icon-trash icon-white"></i> Delete</a></td></tr>';
  2986.                     $('#donate_sortable_paycall > tbody:last').append(html);
  2987.                 }
  2988.             }
  2989.         });
  2990.     },
  2991.     saveSocketOrder: function() {
  2992.         var order = $('#socket_sortable_content').sortable('toArray');
  2993.         $.ajax({
  2994.             type: "post",
  2995.             dataType: "json",
  2996.             url: DmNConfig.base_url + "admincp/save_socket_order",
  2997.             data: {
  2998.                 order: order
  2999.             },
  3000.             success: function(data) {}
  3001.  
  3002.         });
  3003.     },
  3004.     changeSocketStatus: function(id, status) {
  3005.         $.ajax({
  3006.             type: "post",
  3007.             dataType: "json",
  3008.             url: DmNConfig.base_url + "admincp/change_socket_status",
  3009.             data: {
  3010.                 id: id,
  3011.                 status: status
  3012.             },
  3013.             success: function(data) {
  3014.                 if (data.error) {
  3015.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3016.                 } else {
  3017.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3018.                     if (status == 1) {
  3019.                         $('#status_icon_' + id).html('<span class="label label-success">Active</span>');
  3020.                         $('#status').html('<i class="icon-edit icon-white"></i> Disable');
  3021.                         $('#status').attr('onclick', 'App.changeSocketStatus(' + id + ', 0);');
  3022.                     } else {
  3023.                         $('#status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  3024.                         $('#status').html('<i class="icon-edit icon-white"></i> Enable');
  3025.                         $('#status').attr('onclick', 'App.changeSocketStatus(' + id + ', 1);');
  3026.                     }
  3027.                 }
  3028.             }
  3029.         });
  3030.     },
  3031.     editSocket: function(id) {
  3032.         $.ajax({
  3033.             type: "post",
  3034.             dataType: "json",
  3035.             url: DmNConfig.base_url + "admincp/edit_socket_package",
  3036.             data: {
  3037.                 id: id,
  3038.                 name: $("#socketname_" + id).val(),
  3039.                 price: $("#socketprice_" + id).val(),
  3040.                 part_type: $("#socketpart_" + id).val()
  3041.             },
  3042.             success: function(data) {
  3043.                 if (data.error) {
  3044.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3045.                 } else {
  3046.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3047.                 }
  3048.             }
  3049.         });
  3050.     },
  3051.     changeHarmonyStatus: function(id, status) {
  3052.         $.ajax({
  3053.             type: "post",
  3054.             dataType: "json",
  3055.             url: DmNConfig.base_url + "admincp/change_harmony_status",
  3056.             data: {
  3057.                 id: id,
  3058.                 status: status
  3059.             },
  3060.             success: function(data) {
  3061.                 if (data.error) {
  3062.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3063.                 } else {
  3064.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3065.                     if (status == 1) {
  3066.                         $('#status_icon_' + id).html('<span class="label label-success">Active</span>');
  3067.                         $('#status').html('<i class="icon-edit icon-white"></i> Disable');
  3068.                         $('#status').attr('onclick', 'App.changeHarmonyStatus(' + id + ', 0);');
  3069.                     } else {
  3070.                         $('#status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  3071.                         $('#status').html('<i class="icon-edit icon-white"></i> Enable');
  3072.                         $('#status').attr('onclick', 'App.changeHarmonyStatus(' + id + ', 1);');
  3073.                     }
  3074.                 }
  3075.             }
  3076.         });
  3077.     },
  3078.     editHarmony: function(id) {
  3079.         $.ajax({
  3080.             type: "post",
  3081.             dataType: "json",
  3082.             url: DmNConfig.base_url + "admincp/edit_harmony_package",
  3083.             data: {
  3084.                 id: id,
  3085.                 name: $("#harmonyn_" + id).val(),
  3086.                 price: $("#harmonyp_" + id).val()
  3087.             },
  3088.             success: function(data) {
  3089.                 if (data.error) {
  3090.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3091.                 } else {
  3092.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3093.                 }
  3094.             }
  3095.         });
  3096.     },
  3097.     deleteItem: function() {
  3098.         if (App.confirmMessage('Are you sure you want to delete this item?')) {
  3099.             $.ajax({
  3100.                 type: "post",
  3101.                 dataType: "json",
  3102.                 url: DmNConfig.base_url + 'admincp/del_item',
  3103.                 data: {
  3104.                     'ajax': 1,
  3105.                     'slot': App.item_slot
  3106.                 },
  3107.                 success: function(data) {
  3108.                     if (data.error) {
  3109.                         if ($.isArray(data.error)) {
  3110.                             $.each(data.error, function(key, val) {
  3111.                                 noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3112.                             });
  3113.                         } else {
  3114.                             noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3115.                         }
  3116.                     } else {
  3117.                         noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3118.                         $('#item-slot-' + App.item_slot).hide();
  3119.                         $('div[id^="item-slot-"]').each(function() {
  3120.                             App.initializeTooltip($(this), true, 'warehouse/item_info');
  3121.                         });
  3122.                     }
  3123.                 }
  3124.             });
  3125.         }
  3126.     },
  3127.     loadItemList: function(cat) {
  3128.         $.ajax({
  3129.             type: "post",
  3130.             dataType: "json",
  3131.             url: DmNConfig.base_url + 'admincp/load_items',
  3132.             data: {
  3133.                 'ajax': 1,
  3134.                 'cat': cat
  3135.             },
  3136.             success: function(data) {
  3137.                 if (data.error) {
  3138.                     if ($.isArray(data.error)) {
  3139.                         $.each(data.error, function(key, val) {
  3140.                             noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3141.                         });
  3142.                     } else {
  3143.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3144.                     }
  3145.                     if ($('#item_options').is(':visible')) {
  3146.                         $('#item_options').hide();
  3147.                     }
  3148.                 } else {
  3149.                     var html = '';
  3150.                     if ($.isArray(data.items)) {
  3151.                         $.each(data.items, function(key, val) {
  3152.                             html += '<option value="' + val.id + '">' + val.name + '</option>';
  3153.                         });
  3154.                         $('#items_wh').html(html);
  3155.                         if ($('#item_options').is(':hidden')) {
  3156.                             $('#item_options').show();
  3157.                         }
  3158.                         if ($('#socket_opts').is(':visible')) {
  3159.                             $('#socket_opts').hide();
  3160.                         }
  3161.                         App.resetHarmony();
  3162.                     }
  3163.                 }
  3164.             }
  3165.         });
  3166.     },
  3167.     checkItem: function(id) {
  3168.         $.ajax({
  3169.             type: "post",
  3170.             dataType: "json",
  3171.             url: DmNConfig.base_url + 'admincp/check_item',
  3172.             data: {
  3173.                 'ajax': 1,
  3174.                 'id': id
  3175.             },
  3176.             success: function(data) {
  3177.                 if (data.error) {
  3178.                     if ($.isArray(data.error)) {
  3179.                         $.each(data.error, function(key, val) {
  3180.                             noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3181.                         });
  3182.                     } else {
  3183.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3184.                     }
  3185.                 } else {
  3186.                     if (data.sockets != false) {
  3187.                         var html = '';
  3188.                         if ($.isArray(data.sockets)) {
  3189.                             $.each(data.sockets, function(key, val) {
  3190.                                 html += '<option value="' + val.seed + '-' + val.socket_id + '">' + val.socket_name + '</option>';
  3191.                             });
  3192.                             $('#socket1').html(html);
  3193.                             $('#socket2').html(html);
  3194.                             $('#socket3').html(html);
  3195.                             $('#socket4').html(html);
  3196.                             $('#socket5').html(html);
  3197.                             if ($('#socket_opts').is(':hidden')) {
  3198.                                 $('#socket_opts').show();
  3199.                             }
  3200.                         }
  3201.                     } else {
  3202.                         if ($('#socket_opts').is(':visible')) {
  3203.                             $('#socket_opts').hide();
  3204.                         }
  3205.                     }
  3206.                 }
  3207.             }
  3208.         });
  3209.     },
  3210.     resetItemList: function() {
  3211.         $('#items_wh').html('<option value="">None</option>');
  3212.         if ($('#item_options').is(':visible')) {
  3213.             $('#item_options').hide();
  3214.         }
  3215.     },
  3216.     checkHarmony: function() {
  3217.         if (!isNaN($('#items_harm option:selected').val()) && $('#items_harm option:selected').val() != '') {
  3218.             if (!isNaN($('#category_wh').val()) && $('#category_wh').val() != '') {
  3219.                 $.ajax({
  3220.                     type: "post",
  3221.                     dataType: "json",
  3222.                     url: DmNConfig.base_url + 'admincp/loadharmonylist',
  3223.                     data: {
  3224.                         ajax: 1,
  3225.                         cat: $('#category_wh').val(),
  3226.                         hopt: $('#items_harm').val()
  3227.                     },
  3228.                     success: function(data) {
  3229.                         if (typeof data.harmonylist != 'undefined') {
  3230.                             var html = '<option value="-1" selected="selected">--select--</option>';
  3231.                             $.each(data.harmonylist, function(key, val) {
  3232.                                 html += '<option value="' + val.hvalue + '">' + val.hname + '</option>';
  3233.                             });
  3234.                             $('#harmonyvalue').html(html);
  3235.                             $('#harmonyoption').show();
  3236.                         } else {
  3237.                             if (data.error) {
  3238.                                 noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3239.                             } else {
  3240.                                 noty($.parseJSON('{"text":"No harmony data found","layout":"topRight","type":"error"}'));
  3241.                             }
  3242.                             $('#harmonyoption').hide();
  3243.  
  3244.                         }
  3245.                     }
  3246.                 });
  3247.             } else {
  3248.                 noty($.parseJSON('{"text":"Please select category first.","layout":"topRight","type":"error"}'));
  3249.             }
  3250.         } else {
  3251.             $('#harmonyoption').hide();
  3252.         }
  3253.     },
  3254.     resetHarmony: function() {
  3255.         $('#harmonyvalue').html('<option value="">None</option>');
  3256.         $('#harmonyoption').hide();
  3257.         $('#items_harm').prop('selectedIndex', 0);
  3258.     },
  3259.     sentItem: function() {
  3260.         $.ajax({
  3261.             type: "post",
  3262.             dataType: "json",
  3263.             url: DmNConfig.base_url + 'admincp/add_wh_item',
  3264.             data: $('#item_form').serialize() + '&' + $.param({
  3265.                 'ajax': 1
  3266.             }),
  3267.             beforeSend: function() {
  3268.                 $(document.body).css({
  3269.                     'cursor': 'wait'
  3270.                 })
  3271.             },
  3272.             complete: function() {
  3273.                 $(document.body).css({
  3274.                     'cursor': 'default'
  3275.                 })
  3276.             },
  3277.             success: function(data) {
  3278.                 if (data.error) {
  3279.                     if ($.isArray(data.error)) {
  3280.                         $.each(data.error, function(key, val) {
  3281.                             noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3282.                         });
  3283.                     } else {
  3284.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3285.                     }
  3286.                 } else {
  3287.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3288.                     $('#item-slot-' + data.slot).replaceWith(data.div);
  3289.                     App.initializeTooltip($('#item-slot-' + data.slot), true, 'warehouse/item_info');
  3290.                 }
  3291.             }
  3292.         });
  3293.     },
  3294.     saveServerOrder: function() {
  3295.         var order = $('#serverlist_sortable_content').sortable('toArray');
  3296.         $.ajax({
  3297.             type: "post",
  3298.             dataType: "json",
  3299.             url: DmNConfig.base_url + "admincp/save_server_order",
  3300.             data: {
  3301.                 order: order
  3302.             },
  3303.             success: function(data) {
  3304.                 if (data.error) {
  3305.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3306.                 }
  3307.             }
  3308.         });
  3309.     },
  3310.     saveEventOrder: function() {
  3311.         var order = $('#event_sortable_content').sortable('toArray');
  3312.         $.ajax({
  3313.             type: "post",
  3314.             dataType: "json",
  3315.             url: DmNConfig.base_url + "admincp/save_event_order",
  3316.             data: {
  3317.                 order: order
  3318.             },
  3319.             success: function(data) {
  3320.                 if (data.error) {
  3321.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3322.                 }
  3323.             }
  3324.         });
  3325.     },
  3326.     changeServerStatus: function(id, status) {
  3327.         $.ajax({
  3328.             type: "post",
  3329.             dataType: "json",
  3330.             url: DmNConfig.base_url + "admincp/change_server_status",
  3331.             data: {
  3332.                 id: id,
  3333.                 status: status
  3334.             },
  3335.             success: function(data) {
  3336.  
  3337.                 if (data.error) {
  3338.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3339.                 } else {
  3340.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3341.                     if (status == 1) {
  3342.                         $('#status_icon_' + id).html('<span class="label label-success">Active</span>');
  3343.                         $('#status_button_' + id).attr({
  3344.                             'class': 'btn btn-danger'
  3345.                         });
  3346.                         $('#status_button_' + id).html('<i class="icon-edit icon-white"></i> Disable');
  3347.                         $('#status_button_' + id).attr('onclick', 'App.changeServerStatus("' + id + '", 0);');
  3348.                     } else {
  3349.                         $('#status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  3350.                         $('#status_button_' + id).attr({
  3351.                             'class': 'btn btn-success'
  3352.                         });
  3353.                         $('#status_button_' + id).html('<i class="icon-edit icon-white"></i> Enable');
  3354.                         $('#status_button_' + id).attr('onclick', 'App.changeServerStatus("' + id + '", 1);');
  3355.                     }
  3356.                 }
  3357.             }
  3358.         });
  3359.     },
  3360.     deleteServer: function(id) {
  3361.         if (App.confirmMessage('Are you sure you want to delete this server?')) {
  3362.             $.ajax({
  3363.                 type: "post",
  3364.                 dataType: "json",
  3365.                 url: DmNConfig.base_url + "admincp/delete_server",
  3366.                 data: {
  3367.                     id: id
  3368.                 },
  3369.                 success: function(data) {
  3370.                     if (data.error) {
  3371.                         noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3372.                     } else {
  3373.                         noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3374.                         $('#' + id).hide();
  3375.                     }
  3376.                 }
  3377.             });
  3378.         }
  3379.     },
  3380.     setUseMultiAccountDB: function(status) {
  3381.         $.ajax({
  3382.             type: "post",
  3383.             dataType: "json",
  3384.             url: DmNConfig.base_url + "admincp/change_multi_account_db",
  3385.             data: {
  3386.                 status: status
  3387.             },
  3388.             success: function(data) {
  3389.                 if (data.error) {
  3390.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3391.                 } else {
  3392.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3393.                 }
  3394.             }
  3395.         });
  3396.     },
  3397.     changeBuyLevelStatus: function(status, server) {
  3398.         $.ajax({
  3399.             type: "post",
  3400.             dataType: "json",
  3401.             url: DmNConfig.base_url + "admincp/change_buylevel_status",
  3402.             data: {
  3403.                 status: status,
  3404.                 server: server
  3405.             },
  3406.             success: function(data) {
  3407.                 if (data.error) {
  3408.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3409.                 } else {
  3410.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3411.                 }
  3412.             }
  3413.         });
  3414.     },
  3415.     deleteBuyLevelSettings: function(key, server) {
  3416.         var rowCount = $('#buylevel-settings-' + server + ' tr').length;
  3417.         $.ajax({
  3418.             type: "post",
  3419.             dataType: "json",
  3420.             url: DmNConfig.base_url + "admincp/delete_buylevel_settings",
  3421.             data: {
  3422.                 key: key,
  3423.                 server: server
  3424.             },
  3425.             success: function(data) {
  3426.                 if (data.error) {
  3427.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3428.                 } else {
  3429.                     $('#level-' + key + '-' + server).remove();
  3430.                     if (rowCount == 1) {
  3431.                         $('#buylevel-settings-' + server).append('<tr><td colspan="3"><div class="alert alert-info">No settings for this server.</div></td></tr>');
  3432.                     }
  3433.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3434.                 }
  3435.             }
  3436.         });
  3437.     },
  3438.     saveMaxLevel: function(server, data) {
  3439.         $.ajax({
  3440.             type: "post",
  3441.             dataType: "json",
  3442.             url: DmNConfig.base_url + "admincp/buylevel_save_max_level",
  3443.             data: '&' + $.param({
  3444.                 'server': server
  3445.             }) + '&' + data,
  3446.             success: function(data) {
  3447.                 if (data.error) {
  3448.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3449.                 } else {
  3450.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3451.                 }
  3452.             }
  3453.         });
  3454.     },
  3455.     changeResetStatus: function(status, server) {
  3456.         $.ajax({
  3457.             type: "post",
  3458.             dataType: "json",
  3459.             url: DmNConfig.base_url + "admincp/change_reset_status",
  3460.             data: {
  3461.                 status: status,
  3462.                 server: server
  3463.             },
  3464.             success: function(data) {
  3465.                 if (data.error) {
  3466.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3467.                 } else {
  3468.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3469.                 }
  3470.             }
  3471.         });
  3472.     },
  3473.     deleteResSettings: function(key, server) {
  3474.         var rowCount = $('#reset-settings-' + server + ' tr').length;
  3475.         $.ajax({
  3476.             type: "post",
  3477.             dataType: "json",
  3478.             url: DmNConfig.base_url + "admincp/delete_reset_settings",
  3479.             data: {
  3480.                 key: key,
  3481.                 server: server
  3482.             },
  3483.             success: function(data) {
  3484.                 if (data.error) {
  3485.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3486.                 } else {
  3487.                     $('#reset-' + key + '-' + server).remove();
  3488.                     if (rowCount == 1) {
  3489.                         $('#reset-settings-' + server).append('<tr><td colspan="3"><div class="alert alert-info">No settings for this server.</div></td></tr>');
  3490.                     }
  3491.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3492.                 }
  3493.             }
  3494.         });
  3495.     },
  3496.     changeGResetStatus: function(status, server) {
  3497.         $.ajax({
  3498.             type: "post",
  3499.             dataType: "json",
  3500.             url: DmNConfig.base_url + "admincp/change_greset_status",
  3501.             data: {
  3502.                 status: status,
  3503.                 server: server
  3504.             },
  3505.             success: function(data) {
  3506.                 if (data.error) {
  3507.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3508.                 } else {
  3509.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3510.                 }
  3511.             }
  3512.         });
  3513.     },
  3514.     deleteGResSettings: function(key, server) {
  3515.         var rowCount = $('#greset-settings-' + server + ' tr').length;
  3516.         $.ajax({
  3517.             type: "post",
  3518.             dataType: "json",
  3519.             url: DmNConfig.base_url + "admincp/delete_greset_settings",
  3520.             data: {
  3521.                 key: key,
  3522.                 server: server
  3523.             },
  3524.             success: function(data) {
  3525.                 if (data.error) {
  3526.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3527.                 } else {
  3528.                     $('#greset-' + key + '-' + server).remove();
  3529.                     if (rowCount == 1) {
  3530.                         $('#greset-settings-' + server).append('<tr><td colspan="3"><div class="alert alert-info">No settings for this server.</div></td></tr>');
  3531.                     }
  3532.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3533.                 }
  3534.             }
  3535.         });
  3536.     },
  3537.  
  3538.  
  3539.  
  3540.  
  3541.     confirmMessage: function(message) {
  3542.         var conf = confirm(message);
  3543.         return (conf == true);
  3544.  
  3545.  
  3546.  
  3547.  
  3548.     },
  3549.     changeLanguageStatus: function(id, status) {
  3550.         $.ajax({
  3551.             type: "post",
  3552.             dataType: "json",
  3553.             url: DmNConfig.base_url + "admincp/change_language_status",
  3554.             data: {
  3555.                 id: id,
  3556.                 status: status
  3557.             },
  3558.             success: function(data) {
  3559.                 if (typeof data.error != "undefined") {
  3560.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3561.                 } else {
  3562.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3563.                     if (status == 1) {
  3564.                         $('#lang_status_icon_' + id).html('<span class="label label-success">Active</span>');
  3565.                         $('#status_' + id).html('<i class="icon-edit icon-black"></i> Disable');
  3566.                         $('#status_' + id).attr('onclick', 'App.changeLanguageStatus(\'' + id + '\', 0);');
  3567.                         $('#status_' + id).attr('class', 'btn btn-danger');
  3568.                     } else {
  3569.                         $('#lang_status_icon_' + id).html('<span class="label label-important">Inactive</span>');
  3570.                         $('#status_' + id).html('<i class="icon-edit icon-black"></i> Enable');
  3571.                         $('#status_' + id).attr('onclick', 'App.changeLanguageStatus(\'' + id + '\', 1);');
  3572.                         $('#status_' + id).attr('class', 'btn btn-success');
  3573.                     }
  3574.                 }
  3575.             }
  3576.         });
  3577.     },
  3578.     deleteLanguage: function(id) {
  3579.         $.ajax({
  3580.             type: "post",
  3581.             dataType: "json",
  3582.             url: DmNConfig.base_url + "admincp/delete_language",
  3583.             data: {
  3584.                 id: id
  3585.             },
  3586.             success: function(data) {
  3587.                 if (typeof data.error != "undefined") {
  3588.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3589.                 } else {
  3590.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3591.                     $('#language_' + id).hide();
  3592.                 }
  3593.             }
  3594.         });
  3595.     },
  3596.     checkNewsStorage: function() {
  3597.         var storage = $('#storage').val();
  3598.         if (storage == 'ipb' || storage == 'ipb4') {
  3599.             $('#ipb_settings').show();
  3600.         } else {
  3601.             $('#ipb_settings').hide();
  3602.         }
  3603.         if (storage == 'rss') {
  3604.             $('#rss_settings').show();
  3605.         } else {
  3606.             $('#rss_settings').hide();
  3607.         }
  3608.         if (storage == 'facebook') {
  3609.             $('#fb_settings').show();
  3610.             $('#per_page').hide();
  3611.             $('#news_cache').hide();
  3612.         } else {
  3613.             $('#fb_settings').hide();
  3614.             $('#per_page').show();
  3615.             $('#news_cache').show();
  3616.         }
  3617.     },
  3618.     showHideTimes: function(selected_days) {
  3619.         if (typeof selected_days[1] != "undefined") {
  3620.             $('#timers_monday').show();
  3621.         } else {
  3622.             $('#timers_monday').hide();
  3623.         }
  3624.         if (typeof selected_days[2] != "undefined") {
  3625.             $('#timers_tuesday').show();
  3626.         } else {
  3627.             $('#timers_tuesday').hide();
  3628.         }
  3629.         if (typeof selected_days[3] != "undefined") {
  3630.             $('#timers_wednesday').show();
  3631.         } else {
  3632.             $('#timers_wednesday').hide();
  3633.         }
  3634.         if (typeof selected_days[4] != "undefined") {
  3635.             $('#timers_thursday').show();
  3636.         } else {
  3637.             $('#timers_thursday').hide();
  3638.         }
  3639.         if (typeof selected_days[5] != "undefined") {
  3640.             $('#timers_friday').show();
  3641.         } else {
  3642.             $('#timers_friday').hide();
  3643.         }
  3644.         if (typeof selected_days[6] != "undefined") {
  3645.             $('#timers_saturday').show();
  3646.         } else {
  3647.             $('#timers_saturday').hide();
  3648.         }
  3649.         if (typeof selected_days[7] != "undefined") {
  3650.             $('#timers_sunday').show();
  3651.         } else {
  3652.             $('#timers_sunday').hide();
  3653.         }
  3654.         if (typeof selected_days[0] != "undefined") {
  3655.             $('#all_timers').show();
  3656.             $('#timers_monday').hide();
  3657.             $('#timers_tuesday').hide();
  3658.             $('#timers_wednesday').hide();
  3659.             $('#timers_thursday').hide();
  3660.             $('#timers_friday').hide();
  3661.             $('#timers_saturday').hide();
  3662.             $('#timers_sunday').hide();
  3663.         } else {
  3664.             $('#all_timers').hide();
  3665.         }
  3666.     },
  3667.     saveRankingsStatus: function() {
  3668.         $.ajax({
  3669.             type: "post",
  3670.             dataType: "json",
  3671.             url: DmNConfig.base_url + "admincp/save_rankings_status",
  3672.             data: {
  3673.                 server: $('#server').val(),
  3674.                 status: $('#active').val()
  3675.             },
  3676.             success: function(data) {
  3677.                 if (typeof data.error != "undefined") {
  3678.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3679.                 } else {
  3680.                     noty($.parseJSON('{"text":"' + data.success + '","layout":"topRight","type":"success"}'));
  3681.                 }
  3682.             }
  3683.         });
  3684.     },
  3685.     reloadRankingsStatus: function() {
  3686.         $.ajax({
  3687.             type: "post",
  3688.             dataType: "json",
  3689.             url: DmNConfig.base_url + "admincp/reload_rankings_status",
  3690.             data: {
  3691.                 server: $('#server').val()
  3692.             },
  3693.             success: function(data) {
  3694.                 if (typeof data.error != "undefined") {
  3695.                     noty($.parseJSON('{"text":"' + data.error + '","layout":"topRight","type":"error"}'));
  3696.                 } else {
  3697.                     if (data.status == 1) {
  3698.                         $('#ranking_settings_form').find('#active option[value=1]').prop("selected", true);
  3699.                     } else {
  3700.                         $('#ranking_settings_form').find('#active option[value=0]').prop("selected", true);
  3701.                     }
  3702.                 }
  3703.             }
  3704.         });
  3705.     }
  3706. };
  3707.  
  3708.  
  3709. function docReady() {
  3710.     $('div[id^="item-slot-"]').on('mousedown', function(e) {
  3711.         App.item_slot = $(this).attr('id').split('-')[2];
  3712.         switch (e.which) {
  3713.             case 3:
  3714.                 App.deleteItem();
  3715.                 break;
  3716.         }
  3717.     });
  3718.  
  3719.     $('#category_wh').on('change', function(e) {
  3720.         e.preventDefault();
  3721.         if ($(this).val() != '') {
  3722.             App.loadItemList($(this).val());
  3723.             if ($(this).val() < 5) {
  3724.                 $('#Weapons').prop('disabled', false);
  3725.                 $('#Staffs').prop('disabled', true);
  3726.                 $('#Sets').prop('disabled', true);
  3727.             } else if ($(this).val() == 5) {
  3728.                 $('#Weapons').prop('disabled', true);
  3729.                 $('#Staffs').prop('disabled', false);
  3730.                 $('#Sets').prop('disabled', true);
  3731.             } else {
  3732.                 $('#Weapons').prop('disabled', true);
  3733.                 $('#Staffs').prop('disabled', true);
  3734.                 $('#Sets').prop('disabled', false);
  3735.             }
  3736.         }
  3737.         if ($(this).val() == '') {
  3738.             App.resetItemList();
  3739.             App.resetHarmony();
  3740.         }
  3741.  
  3742.     });
  3743.  
  3744.     $('#items_wh').on('change', function(e) {
  3745.         e.preventDefault();
  3746.         if ($(this).val() != '') {
  3747.             App.checkItem($(this).val());
  3748.         }
  3749.     });
  3750.  
  3751.     $('#items_exe_type').on('change', function() {
  3752.         if ($(this).val() == '') {
  3753.             $('input:checkbox').attr('checked', false);
  3754.             $('div[id^="exe-"]').hide();
  3755.         } else {
  3756.             $('input:checkbox').attr('checked', false);
  3757.             $('div[id^="exe-"]').hide();
  3758.             $('#exe-' + $(this).val()).show();
  3759.         }
  3760.     });
  3761.  
  3762.     $('#items_harm').on('change', function() {
  3763.         App.checkHarmony();
  3764.     });
  3765.  
  3766.     $('#item_form').on('submit', function(e) {
  3767.         e.preventDefault();
  3768.         App.sentItem();
  3769.     });
  3770.  
  3771.     $('a[href="#"][data-top!=true]').click(function(e) {
  3772.         e.preventDefault();
  3773.     });
  3774.  
  3775.     $('span[id^="log_item_"]').each(function() {
  3776.         App.initializeTooltip($(this), true, 'warehouse/item_info_image');
  3777.     });
  3778.  
  3779.     $('div[id^="item-slot-"]').each(function() {
  3780.         App.initializeTooltip($(this), true, 'warehouse/item_info');
  3781.     });
  3782.  
  3783.     $('.datepicker').datepicker();
  3784.     $('.datepicker_account_filter').datepicker({
  3785.         dateFormat: 'yy-mm-dd'
  3786.     });
  3787.     $('.datetimepicker').datetimepicker({
  3788.         dateFormat: "yy/mm/dd",
  3789.         timeFormat: "HH:mm"
  3790.     });
  3791.  
  3792.     $('.noty').click(function(e) {
  3793.         e.preventDefault();
  3794.         var options = $.parseJSON($(this).attr('data-noty-options'));
  3795.         noty(options);
  3796.     });
  3797.  
  3798.     $("input:checkbox, input:radio, input:file").not('[data-no-uniform="true"],#uniform-is-ajax').uniform();
  3799.  
  3800.     $('[data-rel="chosen"],[rel="chosen"]').chosen();
  3801.  
  3802.     $('.sortable').sortable({
  3803.         revert: true,
  3804.         cancel: '.btn,.box-content,.nav-header',
  3805.         update: function(event, ui) {}
  3806.     });
  3807.  
  3808.     $('.slider').slider({
  3809.         range: true,
  3810.         values: [10, 65]
  3811.     });
  3812.  
  3813.     $('[rel="tooltip"],[data-rel="tooltip"]').tooltip({
  3814.         "placement": "bottom",
  3815.         delay: {
  3816.             show: 400,
  3817.             hide: 200
  3818.         }
  3819.     });
  3820.  
  3821.     $('textarea.autogrow').autogrow();
  3822.  
  3823.     $('[rel="popover"],[data-rel="popover"]').popover();
  3824.  
  3825.     $('.iphone-toggle').iphoneStyle();
  3826.  
  3827.     $('.raty').raty({
  3828.         score: 4
  3829.     });
  3830.  
  3831.     $('ul.gallery li').hover(function() {
  3832.         $('img', this).fadeToggle(1000);
  3833.         $(this).find('.gallery-controls').remove();
  3834.         $(this).append('<div class="well gallery-controls">' +
  3835.             '<p><a href="#" class="gallery-delete btn"><i class="icon-remove"></i></a></p>' +
  3836.             '</div>');
  3837.         $(this).find('.gallery-controls').stop().animate({
  3838.             'margin-top': '-1'
  3839.         }, 400, 'easeInQuint');
  3840.     }, function() {
  3841.         $('img', this).fadeToggle(1000);
  3842.         $(this).find('.gallery-controls').stop().animate({
  3843.             'margin-top': '-30'
  3844.         }, 200, 'easeInQuint', function() {
  3845.             $(this).remove();
  3846.         });
  3847.     });
  3848.  
  3849.     $('.thumbnails').on('click', '.gallery-delete', function(e) {
  3850.         e.preventDefault();
  3851.         var that = $(this);
  3852.         $.ajax({
  3853.             type: 'POST',
  3854.             dataType: 'json',
  3855.             data: {
  3856.                 id: that.parent().parent().parent().attr('id').split("-")[1]
  3857.             },
  3858.             url: DmNConfig.base_url + 'admincp/delete_image',
  3859.             success: function(data) {
  3860.                 if (data.error) {
  3861.                     alert(data.error);
  3862.                 } else {
  3863.                     that.parents('.thumbnail').fadeOut();
  3864.                 }
  3865.             }
  3866.         });
  3867.  
  3868.     });
  3869.  
  3870.  
  3871.     $('.thumbnails').on('click', '.gallery-edit', function(e) {
  3872.         e.preventDefault();
  3873.     });
  3874.  
  3875.     $('.thumbnail a').colorbox({
  3876.         rel: 'thumbnail a',
  3877.         transition: "elastic",
  3878.         maxWidth: "95%",
  3879.         maxHeight: "95%"
  3880.     });
  3881.  
  3882.     $('.btn-close').click(function(e) {
  3883.         e.preventDefault();
  3884.         $(this).parent().parent().parent().fadeOut();
  3885.     });
  3886.     $('.btn-minimize').click(function(e) {
  3887.         e.preventDefault();
  3888.         var $target = $(this).parent().parent().next('.box-content');
  3889.         if ($target.is(':visible')) $('i', $(this)).removeClass('icon-chevron-up').addClass('icon-chevron-down');
  3890.         else $('i', $(this)).removeClass('icon-chevron-down').addClass('icon-chevron-up');
  3891.         $target.slideToggle();
  3892.     });
  3893.    
  3894. }
  3895.  
  3896. function ask_url(ask, url, target) {
  3897.     var detStatus = confirm(ask);
  3898.     if (detStatus) {
  3899.         if (target) {
  3900.             location.href = url;
  3901.         } else {
  3902.             top.location = url;
  3903.  
  3904.  
  3905.         }
  3906.  
  3907.     } else {
  3908.         return false;
  3909.     }
  3910. }
  3911.  
  3912.  
  3913. $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings) {
  3914.     return {
  3915.         "iStart": oSettings._iDisplayStart,
  3916.         "iEnd": oSettings.fnDisplayEnd(),
  3917.         "iLength": oSettings._iDisplayLength,
  3918.         "iTotal": oSettings.fnRecordsTotal(),
  3919.         "iFilteredTotal": oSettings.fnRecordsDisplay(),
  3920.         "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
  3921.         "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
  3922.     };
  3923. }
  3924. $.extend($.fn.dataTableExt.oPagination, {
  3925.     "bootstrap": {
  3926.         "fnInit": function(oSettings, nPaging, fnDraw) {
  3927.             var oLang = oSettings.oLanguage.oPaginate;
  3928.             var fnClickHandler = function(e) {
  3929.                 e.preventDefault();
  3930.                 if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) {
  3931.                     fnDraw(oSettings);
  3932.                     var targetOffset = $('.accounts_datatable').offset().top - 550;
  3933.                     $('html,body').animate({
  3934.                         scrollTop: targetOffset
  3935.                     }, 500);
  3936.                 }
  3937.             };
  3938.  
  3939.             $(nPaging).addClass('pagination').append(
  3940.                 '<ul>' +
  3941.                 '<li class="prev disabled"><a href="#">&#171;</a></li>' +
  3942.                 '<li class="next disabled"><a href="#">&#187;</a></li>' +
  3943.                 '</ul>'
  3944.             );
  3945.             var els = $('a', nPaging);
  3946.             $(els[0]).bind('click.DT', {
  3947.                 action: "previous"
  3948.             }, fnClickHandler);
  3949.             $(els[1]).bind('click.DT', {
  3950.                 action: "next"
  3951.             }, fnClickHandler);
  3952.         },
  3953.  
  3954.         "fnUpdate": function(oSettings, fnDraw) {
  3955.             var iListLength = 5;
  3956.             var oPaging = oSettings.oInstance.fnPagingInfo();
  3957.             var an = oSettings.aanFeatures.p;
  3958.             var i, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2);
  3959.  
  3960.             if (oPaging.iTotalPages < iListLength) {
  3961.                 iStart = 1;
  3962.                 iEnd = oPaging.iTotalPages;
  3963.             } else if (oPaging.iPage <= iHalf) {
  3964.                 iStart = 1;
  3965.                 iEnd = iListLength;
  3966.             } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) {
  3967.                 iStart = oPaging.iTotalPages - iListLength + 1;
  3968.                 iEnd = oPaging.iTotalPages;
  3969.             } else {
  3970.                 iStart = oPaging.iPage - iHalf + 1;
  3971.                 iEnd = iStart + iListLength - 1;
  3972.             }
  3973.  
  3974.             for (i = 0, iLen = an.length; i < iLen; i++) {
  3975.                 $('li:gt(0)', an[i]).filter(':not(:last)').remove();
  3976.  
  3977.  
  3978.                 for (j = iStart; j <= iEnd; j++) {
  3979.                     sClass = (j == oPaging.iPage + 1) ? 'class="active"' : '';
  3980.                     $('<li ' + sClass + '><a href="#">' + j + '</a></li>')
  3981.                         .insertBefore($('li:last', an[i])[0])
  3982.                         .bind('click', function(e) {
  3983.                             e.preventDefault();
  3984.                             oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength;
  3985.                             fnDraw(oSettings);
  3986.                             var targetOffset = $('.accounts_datatable').offset().top - 550;
  3987.                             $('html,body').animate({
  3988.                                 scrollTop: targetOffset
  3989.                             }, 500);
  3990.                         });
  3991.                 }
  3992.  
  3993.                 if (oPaging.iPage === 0) {
  3994.  
  3995.  
  3996.  
  3997.  
  3998.                     $('li:first', an[i]).addClass('disabled');
  3999.                 } else {
  4000.                     $('li:first', an[i]).removeClass('disabled');
  4001.                 }
  4002.  
  4003.  
  4004.                 if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) {
  4005.                     $('li:last', an[i]).addClass('disabled');
  4006.  
  4007.  
  4008.  
  4009.                 } else {
  4010.                     $('li:last', an[i]).removeClass('disabled');
  4011.                 }
  4012.             }
  4013.         }
  4014.  
  4015.  
  4016.  
  4017.     }
  4018. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement