<?php
$wowonder_login_on  = ($wo['config']['wowonder_login'] == '1') ? 'checked' : '';
$wowonder_login_off = ($wo['config']['wowonder_login'] == '0') ? 'checked' : '';
?>
<div class="container-fluid">
    <div>
        <h3>Social Login Settings</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Settings</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Social Login Settings</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-6 col-md-6 ">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Social Login Settings</h6>
                    <div class="social-settings-alert"></div>
                    <form class="social-settings" method="POST">
						
						<div>
							<div class="float-left">
								<label for="facebookLogin" class="main-label">Facebook</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their Facebook account.</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="facebookLogin" value="0">
								<input type="checkbox" name="facebookLogin" id="facebookLogin-enabled" value="1" <?php echo ($wo['config']['facebookLogin'] == '1') ? 'checked': '';?>>
								<label for="facebookLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="VkontakteLogin" class="main-label">Vkontakte</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their Vkontakte account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="VkontakteLogin" value="0">
								<input type="checkbox" name="VkontakteLogin" id="VkontakteLogin-enabled" value="1" <?php echo ($wo['config']['VkontakteLogin'] == '1') ? 'checked': '';?>>
								<label for="VkontakteLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="googleLogin" class="main-label">Google+</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their Google+ account, (App requires reviewing)</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="googleLogin" value="0">
								<input type="checkbox" name="googleLogin" id="googleLogin-enabled" value="1" <?php echo ($wo['config']['googleLogin'] == '1') ? 'checked': '';?>>
								<label for="googleLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="twitterLogin" class="main-label">Twitter</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their Twitter account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="twitterLogin" value="0">
								<input type="checkbox" name="twitterLogin" id="twitterLogin-enabled" value="1" <?php echo ($wo['config']['twitterLogin'] == '1') ? 'checked': '';?>>
								<label for="twitterLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="wowonder_login" class="main-label">WoWonder (Your Own Site) <a href="#" data-toggle="modal" data-target="#wowonder">?</a></label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their WoWonder account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="wowonder_login" value="0">
								<input type="checkbox" name="wowonder_login" id="wowonder_login-enabled" value="1" <?php echo($wowonder_login_on);?>>
								<label for="wowonder_login-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="qqLogin" class="main-label">QQ Login</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their QQ account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="qqLogin" value="0">
								<input type="checkbox" name="qqLogin" id="qqLogin-enabled" value="1" <?php echo ($wo['config']['qqLogin'] == '1') ? 'checked': '';?>>
								<label for="qqLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="WeChatLogin" class="main-label">WeChat Login</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their WeChat account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="WeChatLogin" value="0">
								<input type="checkbox" name="WeChatLogin" id="WeChatLogin-enabled" value="1" <?php echo ($wo['config']['WeChatLogin'] == '1') ? 'checked': '';?>>
								<label for="WeChatLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="DiscordLogin" class="main-label">Discord Login</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their Discord account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="DiscordLogin" value="0">
								<input type="checkbox" name="DiscordLogin" id="DiscordLogin-enabled" value="1" <?php echo ($wo['config']['DiscordLogin'] == '1') ? 'checked': '';?>>
								<label for="DiscordLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
							<hr>
						</div>
						<div>
							<div class="float-left">
								<label for="MailruLogin" class="main-label">Mailru Login</label>
								<br><small class="admin-info">Enable the ability for users to login to your site using their Mailru account</small>
							</div>
							<div class="form-group float-right switcher">
								<input type="hidden" name="MailruLogin" value="0">
								<input type="checkbox" name="MailruLogin" id="MailruLogin-enabled" value="1" <?php echo ($wo['config']['MailruLogin'] == '1') ? 'checked': '';?>>
								<label for="MailruLogin-enabled" class="check-trail"><span class="check-handler"></span></label>
							</div>
							<div class="clearfix"></div>
						</div>
						
                        <!--
                        <label class="form-check-label" for="linkedinLogin">Linkedin</label>
                        <div class="form-group">
                            <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="linkedinLogin" id="linkedinLogin-enabled" value="1" <?php// echo ($wo['config']['linkedinLogin'] == 1) ? 'checked': '';?>>
                            <label class="form-check-label" for="linkedinLogin-enabled">Enabled</label>
                            <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="linkedinLogin" id="linkedinLogin-disabled" value="0" <?php// echo ($wo['config']['linkedinLogin'] == 0) ? 'checked': '';?>>
                            <label class="form-check-label" for="linkedinLogin-disabled" class="m-l-20">Disabled</label>
                        </div>
                        <label class="form-check-label" for="instagramLogin">Instagram</label>
                        <div class="form-group">
                            <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="instagramLogin" id="instagramLogin-enabled" value="1" <?php// echo ($wo['config']['instagramLogin'] == 1) ? 'checked': '';?>>
                            <label class="form-check-label" for="instagramLogin-enabled">Enabled</label>
                            <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="instagramLogin" id="instagramLogin-disabled" value="0" <?php// echo ($wo['config']['instagramLogin'] == 0) ? 'checked': '';?>>
                            <label class="form-check-label" for="instagramLogin-disabled" class="m-l-20">Disabled</label>
                        </div>
                        -->
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">API Keys</h6>
                    <div class="api-settings-alert"></div>
                    <form class="api-settings" method="POST">
						<div class="alert alert-info">Please note that some websites may require app verification.</div>
						<label class="form-label main-label" style="background: #1877F2; color: #fff; margin-bottom: 12px;">Facebook Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="facebookAppId" name="facebookAppId" class="form-control" value="<?php echo $wo['config']['facebookAppId']?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="facebookAppKey" name="facebookAppKey" class="form-control" value="<?php echo $wo['config']['facebookAppKey']?>" placeholder="Application Secret Key">
                            </div>
                        </div>
						<hr>
						<label class="form-label main-label" style="background: #DD5144; color: #fff; margin-bottom: 12px;">Google+ Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="googleAppId" name="googleAppId" class="form-control" value="<?php echo $wo['config']['googleAppId']?>" placeholder="Client ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="googleAppKey" name="googleAppKey" class="form-control" value="<?php echo $wo['config']['googleAppKey']?>" placeholder="Client Secret Key">
                            </div>
                        </div>
						<hr>
						<label class="form-label main-label" style="background: #1DA1F2; color: #fff; margin-bottom: 12px;">Twitter Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="twitterAppId" name="twitterAppId" class="form-control" value="<?php echo $wo['config']['twitterAppId']?>" placeholder="Consumer Key">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="twitterAppKey" name="twitterAppKey" class="form-control" value="<?php echo $wo['config']['twitterAppKey']?>" placeholder="Consumer Secret">
                            </div>
                        </div>
						<hr>
						<label class="form-label main-label" style="background: #2787F5; color: #fff; margin-bottom: 12px;">Vkontakte Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="VkontakteAppId" name="VkontakteAppId" class="form-control" value="<?php echo $wo['config']['VkontakteAppId']?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="VkontakteAppKey" name="VkontakteAppKey" class="form-control" value="<?php echo $wo['config']['VkontakteAppKey']?>" placeholder="Application Secret Key">
                            </div>
                        </div>
                        <hr>
						<label class="form-label main-label" style="background: #a84849; color: #fff; margin-bottom: 12px;">WoWonder Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="wowonder_app_ID" name="wowonder_app_ID" class="form-control" value="<?php echo($wo['config']['wowonder_app_ID']); ?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="wowonder_app_key" name="wowonder_app_key" class="form-control" value="<?php echo($wo['config']['wowonder_app_key']); ?>" placeholder="Application Secret Key">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="wowonder_domain_uri" name="wowonder_domain_uri" class="form-control" value="<?php echo($wo['config']['wowonder_domain_uri']); ?>" placeholder="WoWonder Domain">
								<small class="admin-info">The domain of your website that uses WoWonder Social Network.</small>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="wowonder_domain_icon" name="wowonder_domain_icon" class="form-control" value="<?php echo($wo['config']['wowonder_domain_icon']); ?>" placeholder="WoWonder Icon">
								<small class="admin-info">Link to your icon, example: <a href="https://demo.wowonder.com/themes/default/img/icon.png">https://demo.wowonder.com/themes/default/img/icon.png</a></small>
                            </div>
                        </div>
                        <hr>
						<label class="form-label main-label" style="background: #009BC0; color: #fff; margin-bottom: 12px;">QQ Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="qqAppId" name="qqAppId" class="form-control" value="<?php echo $wo['config']['qqAppId']?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="qqAppkey" name="qqAppkey" class="form-control" value="<?php echo $wo['config']['qqAppkey']?>" placeholder="Application Secret Key">
                            </div>
                        </div>
                        <hr>
						<label class="form-label main-label" style="background: #90D573; color: #fff; margin-bottom: 12px;">WeChat Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="WeChatAppId" name="WeChatAppId" class="form-control" value="<?php echo $wo['config']['WeChatAppId']?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="WeChatAppkey" name="WeChatAppkey" class="form-control" value="<?php echo $wo['config']['WeChatAppkey']?>" placeholder="Application Secret Key">
                            </div>
                        </div>
                        <hr>
						<label class="form-label main-label" style="background: #6E85D2; color: #fff; margin-bottom: 12px;">Discord Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="DiscordAppId" name="DiscordAppId" class="form-control" value="<?php echo $wo['config']['DiscordAppId']?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="DiscordAppkey" name="DiscordAppkey" class="form-control" value="<?php echo $wo['config']['DiscordAppkey']?>" placeholder="Application Secret Key">
                            </div>
                        </div>
                        <hr>
						<label class="form-label main-label" style="background: #005CF1; color: #fff; margin-bottom: 12px;">Mailru Configuration</label>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="MailruAppId" name="MailruAppId" class="form-control" value="<?php echo $wo['config']['MailruAppId']?>" placeholder="Application ID">
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="MailruAppkey" name="MailruAppkey" class="form-control" value="<?php echo $wo['config']['MailruAppkey']?>" placeholder="Application Secret Key">
                            </div>
                        </div>

                        <!--
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="linkedinAppId" name="linkedinAppId" class="form-control" value="<?php// echo $wo['config']['linkedinAppId']?>">
                                <label class="form-label">Linkedin APP ID</label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="linkedinAppKey" name="linkedinAppKey" class="form-control" value="<?php// echo $wo['config']['linkedinAppKey']?>">
                                <label class="form-label">Linkedin APP Key</label>
                            </div>
                        </div><br><br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="instagramAppId" name="instagramAppId" class="form-control" value="<?php// echo $wo['config']['instagramAppId']?>">
                                <label class="form-label">Instagram APP ID</label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="instagramAppkey" name="instagramAppkey" class="form-control" value="<?php// echo $wo['config']['instagramAppkey']?>">
                                <label class="form-label">Instagram APP Key</label>
                            </div>
                        </div>
                        -->
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->

    <div id="wowonder" class="modal fade" role="dialog">
        <div class="modal-dialog">

            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">WoWonder Integration</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <p>This feature allows you to integrate users from your own website that uses <a href="http://www.wowonder.com" target="_blank">WoWonder</a>.</p>
                    <p>To get started please follow those steps:</p>
                    <ul>
                        <li>Go to http://yoursite.com/developers, you'll get the following <a target="_blank" href="<?php echo Wo_LoadAdminLink('images/Screenshot_1.png'); ?>">Page</a></li>
                        <li>Click on "Create an app", and fill the required information.</li>
                        <li>On the form, make sure the info are similar as shown <a target="_blank" href="<?php echo Wo_LoadAdminLink('images/Screenshot_2.png'); ?>">Here</a>.</li>
                        <li>Save the form, get the <a  target="_blank" href="<?php echo Wo_LoadAdminLink('images/Screenshot_4.png'); ?>">Keys</a>, and use them <a target="_blank" href="<?php echo Wo_LoadAdminLink('images/Screenshot_3.png'); ?>">Here</a>.</li>
                    </ul>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>
    </div>


<script>
$(function() {
    $('.switcher input[type=checkbox]').click(function () {
        var configName = $(this).attr('name');
        var hash_id = $('input[name=hash_id]').val();
        var objData = {};
        if ($(this).is(":checked") === true) {
            objData[configName] = $(this).val();
        }
        else{
            if ($('input[name='+configName+']')[0]) {
                objData[configName] = $($('input[name='+configName+']')[0]).val();
            }
        }
        objData['hash_id'] = hash_id;
        $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_general_setting', objData);
    });

    var setTimeOutColor = setTimeout(function (){});
    $('select').on('change', function() {
         clearTimeout(setTimeOutColor);
        var thisElement = $(this);
        var configName = thisElement.attr('name');
        var hash_id = $('input[name=hash_id]').val();
        var objData = {};
        objData[configName] = this.value;
        objData['hash_id'] = hash_id;
        thisElement.addClass('warning');
        $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_general_setting', objData, function (data) {
            if (data.status == 200) {
                thisElement.removeClass('warning');
                thisElement.addClass('success');
            } else {
                thisElement.addClass('error');
            }
            var setTimeOutColor = setTimeout(function () {
                thisElement.removeClass('success');
                thisElement.removeClass('warning');
                thisElement.removeClass('error');
            }, 2000);
        });
    });
    $('input[type=text], input[type=number], input[type=password], textarea').on('keyup', delay(function() {
            clearTimeout(setTimeOutColor);
            var thisElement = $(this);
            var configName = thisElement.attr('name');
            var hash_id = $('input[name=hash_id]').val();
            var objData = {};
            objData[configName] = this.value;
            objData['hash_id'] = hash_id;
            thisElement.addClass('warning');
            $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_general_setting', objData, function (data) {
                if (data.status == 200) {
                    thisElement.removeClass('warning');
                    thisElement.addClass('success');
                } else {
                    thisElement.addClass('error');
                }
                var setTimeOutColor = setTimeout(function () {
                    thisElement.removeClass('success');
                    thisElement.removeClass('warning');
                    thisElement.removeClass('error');
                }, 2000);
                //thisElement.focus();
            });
    }, 500));
});
</script>