<div class="page-margin">
	<div class="row">
		<div class="col-md-2 leftcol"><?php echo Wo_LoadPage("sidebar/left-sidebar"); ?></div>
		<div class="col-md-7 middlecol">
			<div class="page-margin wow_content mt-0">
				<div class="wo_page_hdng pag_neg_padd pag_alone">
					<div class="wo_page_hdng_innr big_size">
						<span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M7,7V9H9V7H7M11,7V9H13V7H11M15,7V9H17V7H15M7,11V13H9V11H7M11,11V13H13V11H11M15,11V13H17V11H15M7,15V17H9V15H7M11,15V17H13V15H11M15,15V17H17V15H15Z"></path></svg></span> App Details
					</div>
				</div>
			</div>
			
			<div class="page-margin">
				<div class="wow_content">
					<div class="wo_page_hdng pag_neg_padd pag_alone">
						<div class="wo_page_hdng_menu">
							<ul class="list-unstyled nav nav-tabs" style="border: 0;">
								<li class="active" style="float: none;margin: 0;width: auto;"><a data-target="#keys" href="#" data-toggle="tab" style="border: 0;height: auto;">App Keys</a></li>
								<li style="float: none;margin: 0;width: auto;"><a data-target="#app-setting" href="#" data-toggle="tab" style="border: 0;height: auto;">App Setting</a></li>
							</ul>
						</div>
					</div>
				</div>
				<div class="page-margin tab-content wow_content wow_sett_content" id="tabs">
					<div class="tab-pane active" id="keys">
						<div class="app-update-alert setting-update-alert"></div>
						<div class="wow_form_fields">
							<label for="app_id">App ID</label>
							<input id="app_id" name="app_id" type="text" readonly value="<?php echo $wo['app']['app_id']; ?>" onClick="this.select();">
							<span class="help-block">Your application ID.</span>
						</div>
						<div class="wow_form_fields">
							<label for="app_secret">App secret</label>
							<input id="app_secret" name="app_secret" type="text" readonly value="<?php echo $wo['app']['app_secret']; ?>" onClick="this.select();">
							<span class="help-block">Your application secret key.</span>
						</div>
						<div class="text-center">
							<a class="btn btn-mat" data-ajax="?link1=apps" href="<?php echo Wo_SeoLink('index.php?link1=apps');?>">
								<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"></path></svg> My Apps
							</a>
						</div>
					</div>
					<div class="tab-pane" id="app-setting">
						<form class="app-update-form" method="post" style="margin-top: 0px;">
							<div class="wow_form_fields">
								<label for="app_name"><?php echo $wo['lang']['name']; ?></label>
								<input id="app_name" name="app_name" type="text" max="32" value="<?php echo $wo['app']['app_name']; ?>">
								<span class="help-block">Your application name. This is used to attribute the source user-facing authorization screens. 32 characters max.</span>
							</div>
							<div class="wow_form_fields">
								<label for="app_website_url">App website</label>
								<input id="app_website_url" name="app_website_url" type="url" value="<?php echo $wo['app']['app_website_url']; ?>">
								<span class="help-block">Your application's publicly accessible home page.</span>
							</div>
							<div class="wow_form_fields">
								<label for="app_callback_url">App callback url</label>
								<input id="app_callback_url" name="app_callback_url" type="url" value="<?php echo $wo['app']['app_callback_url']; ?>">
								<span class="help-block">Where should we return after successfully authenticating?</span>
							</div>
							<div class="wow_form_fields">
								<label for="app_description">App description</label>
								<textarea name="app_description" id="app_description" rows="4"><?php echo $wo['app']['app_description']; ?></textarea>
								<span class="help-block">Your application description, which will be shown in user-facing authorization screens. Between 10 and 200 characters max.</span>
							</div>
							<div class="wow_form_fields">
								<label><?php echo $wo['lang']['image'];?></label>
								<span class="help-block">Your application thumbnail</span>
								<div class="wow_fcov_image">
									<div id="wow_fcov_img_holder">
										<img src="<?php echo $wo['config']['theme_url'];?>/img/ad_pattern.png">
									</div>
									<div class="upload_ad_image" onclick="document.getElementById('app_avatar').click(); return false">
										<div class="upload_ad_image_content">
											<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z"></path></svg> <?php echo $wo['lang']['choose_image'] ?>
										</div>
									</div>
								</div>
							</div>
							<div class="hidden">
								<input name="app_avatar" id="app_avatar" type="file" accept="image/x-png, image/gif, image/jpeg">
							</div>
							<div class="app-update-alert setting-update-alert"></div>
							<input name="app_id" id="app_id" type="hidden" value="<?php echo $wo['app']['id']; ?>">
							<div class="text-center">
								<a class="btn btn-mat" data-ajax="?link1=apps" href="<?php echo Wo_SeoLink('index.php?link1=apps');?>">
									<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"></path></svg> My Apps
								</a>
								<button class="btn btn-main btn-mat btn-mat-raised add_wow_loader" name="save_setting" value="Save" id="save-setting" type="submit"><?php echo $wo['lang']['save']; ?></button>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="sidebar"><?php echo Wo_LoadPage('sidebar/content');?></div>
	</div>
</div>
<script>
$("#app_avatar").change(function(event) {
	$("#wow_fcov_img_holder").html("<img src='" + window.URL.createObjectURL(this.files[0]) + "' alt='Picture'>")
});

  $(function() {
    $('form.app-update-form').ajaxForm({
      url: Wo_Ajax_Requests_File() + '?f=apps&s=update_app',
      beforeSend: function() {
        $('.app-update-form').find('.add_wow_loader').addClass('btn-loading');
      },
      success: function(data) {
        if (data.status == 200) {
          $('[id^=app-name]').text(data.name);
          $('.app-avatar').attr('src', data.image);
          $('.app-update-alert').html('<div class="alert alert-success">' + data.message + '</div>');
          $('.alert-success').fadeIn('fast', function() {
             $(this).delay(2500).slideUp(500, function() {
                $(this).remove();
              });
          });
        } else {
            var errors = data.errors.join("<br>");
            $('.app-update-alert').html('<div class="alert alert-danger">' + errors + '</div>');
            $('.alert-danger').fadeIn(300);
        }
        $('.app-update-form').find('.add_wow_loader').removeClass('btn-loading');
      }
    });
  });
</script>