<?php
/*
 Plugin Name: 顶部加载条 
 Version: 3.0
Description: 给顶部一个好看的加载条。
Author: 牛蛙
Author URL: https://www.emlog.net/author/index/4067
*/


!defined('EMLOG_ROOT') && exit('access deined!');
function nprogress_menu() {
    echo '<div class="sidebarsubmenu"><a href="./plugin.php?plugin=niuwa_jiazai">加载条配置</a></div>';
}

addAction('adm_sidebar_ext', 'nprogress_menu');
function jiazai() {
    require_once 'niuwa_jiazai_config.php'; ?>
    <script type="text/javascript">
        jQuery(function () {
            NProgress.configure({
                showSpinner: <?php if($config["off1"] == 'yes'){?>true<?php }?><?php if($config["off1"] == 'no'){?>false<?php }?>
            });

            NProgress.start();

            document.onreadystatechange = function () {
                "complete" == document.readyState && setTimeout(NProgress.done, 400);
            }
        });
    </script>
    <?php if ($config["off"] == 'yes') { ?>
        <script src="<?php echo BLOG_URL; ?>content/plugins/niuwa_jiazai/js/jquery.min.js" type="text/javascript"></script><?php } ?>
    <script src="<?php echo BLOG_URL; ?>content/plugins/niuwa_jiazai/js/nprogress.min.js"></script>
    <link rel="stylesheet" type="text/css" href="<?php echo BLOG_URL; ?>content/plugins/niuwa_jiazai/css/<?php echo $config["color"]; ?>.css"/>
<?php }

addAction('index_head', 'jiazai');