main.vm 4.4 KB
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title>一年四季后台管理系统</title>
    <meta name="description" content="overview &amp; stats"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <script type="text/javascript">
        var manageDomain = "$!{webUtils.getLocalPath("")}";
    </script>
    #parse("layout/css.vm")
    <script src="$!{webUtils.getAssetsPath("/js/jquery.js")}"></script>
    <script src="$!{webUtils.getAssetsPath("/js/popup.js")}"></script>
    <script src="$!{webUtils.getAssetsPath("/js/md5.js")}"></script>
    <style type="text/css">
        body {
            overflow-y: hidden;
            overflow-x: hidden;
        }
    </style>
    <script src="/static/js/tips.js"></script>
	<link href="/static/css/waitItems.css" rel="stylesheet">
</head>
<body class="no-skin">
    #parse("layout/header.vm")
<div class="main-container" id="main-container">

    #parse("layout/main_nav.vm")

    <div class="main-content" id="main-content">
        ## #set($iframePath = "welcome.do")
        #set($iframePath = $!{webUtils.indexPath})
        #if(${returnUrl} !="null")
            #set($iframePath = ${returnUrl})
        #end

        <iframe id="frame3d" name="frame3d" frameborder="0" width="100%" scrolling="auto"
                style=""
                height="100%" src="${iframePath}">

        </iframe>
    </div>
</div>
<!-- /.main-container -->

    #parse("layout/js.vm")
<script type="text/javascript">
//    window.onbeforeunload = function(){
//        $.get("http://manage.nong12.com/loginControl/logout.do",
//                function(data,status){ });
//        return "manage后台已退出登录!!";
//    }

    $(function () {
        $(document).keydown(function (e) {
            if (e.keyCode == 116) {
                //验证是否支持postMessage
                if (typeof window.postMessage === "undefined") {
                    return true;
                }
                document.getElementById("frame3d").contentWindow.postMessage("refresh", "*");
                return false;
            }
        });


        //屏幕变化
        $(window).resize(function (e) {
            resize();
        });
        resize();
        function resize() {
            var menu = $("#menu-toggler");
            var sid = $("#sidebar");
            var head = $("#navbar");
            var fram = $("#frame3d");
            var side = $("#sidebar");
            var self = $(window);
            var height, width;
            height = self.height() - head.height();
            if (menu.css("display") == "none") {
                width = self.width() - sid.width();
            } else {
                width = self.width();
            }
            fram.height(height);
            fram.width(width);
            side.height(height);
        }
    });


    /**
     * 监听消息
     */
    window.addEventListener('message', function (event) {
        /**
         * 超时提醒
         */
        if (event.data == "timeout") {
            var html = '<div style="position: absolute;bottom: 0;right: 0;z-index: 100;"><div class="alert alert-danger alert-dismissible" role="alert">' +
                    '<button type="button" class="close" data-dismiss="alert">' +
                    '   <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>' +
                    '</button>' +
                    '<strong>警告!</strong> 两分钟内不进行操作将会跳转到登录页面.</div></div>';
            $("body").append(html);
        }

//        if(event.data == "refresh"){
//            location.reload();
//        }
//        // 通过origin属性判断消息来源地址
//        if (event.origin == 'http://a.com') {
//            alert(event.data);    // 弹出"I was there!"
//            alert(event.source);  // 对a.com、index.html中window对象的引用
//            // 但由于同源策略,这里event.source不可以访问window对象
//        }
    }, false);


    /**
     * 修正URL
     */
    fixUrl();
    function fixUrl() {
        var url = window.location.href;
        if (url.indexOf("returnUrl") > 0) {
            var obj = {};
            var title = "地利后台管理系统";
            var newUrl = "/main.do"
            history.pushState(obj, title, newUrl);
        }
    }

</script>
</body>
</html>