<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="./css/apiutil.css" />
    <style type="text/css">
        html,
        body {
            height: 100%;
        }

        .wrap {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-flex-flow: column;
        }

        header {
            height: 44px;
            width: 100%;
            text-align: center;
            background-color: #81a9c3;
            color: #fff;
            line-height: 44px;
            font-size: 20px;
        }

        .flex-1 {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
        }

        footer {
            height: 30px;
            width: 100%;
            background-color: #81a9c3;
            color: white;
            line-height: 30px;
            text-align: center;
        }
    </style>
</head>

<body class="wrap">
    <header>APP</header>
    <section class="flex-1">

    </section>
    <footer>Copyright &copy; 2014-<span id="year"></span></footer>
</body>
<script type="text/javascript" src="./script/apiutil.js"></script>
<script type="text/javascript">
    apiready = function() {
        //输出Log,Log将显示在 Studio 控制台
        console.log("Hello World! Hello APP!");

        var header = $api.dom('header'); // 获取 header 标签元素
        var footer = $api.dom('footer'); // 获取 footer 标签元素

        // 1.修复开启沉浸式效果带来的顶部Header与手机状态栏重合的问题,最新apiutil.js方法已支持适配iPhoneX;
        // 2.默认已开启了沉浸式效果 config.xml中 <preference name="statusBarAppearance" value="true"/>
        // 3.沉浸式效果适配支持iOS7+,Android4.4+以上版本
        var headerH = $api.fixStatusBar(header);
        // 最新apiutil.js为了适配iPhoneX增加的方法,修复底部Footer部分与iPhoneX的底部虚拟横条键重叠的问题;
        var footerH = $api.fixTabBar(footer);

        api.openFrame({
            name: 'main',
            url: 'html/main.html',
            bounces: true,
            rect: { // 推荐使用Margin布局,用于适配屏幕的动态变化
                marginTop: headerH, // main页面距离win顶部的高度
                marginBottom: footerH, // main页面距离win底部的高度
                w: 'auto' // main页面的宽度 自适应屏幕宽度
            }
        });

        // 获取当前年份时间,并加载显示到页面
        var year = $api.byId('year');
        year.innerHTML = new Date().getFullYear();
    };

</script>

</html>