<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <!--引用jquery-->
   
    <script type="text/javascript" src="/js/service.js"></script>
    <script type="text/javascript" src="/js/session.js"></script>
    <script type="text/javascript" src="/js/getService.js"></script>
    <script type="text/javascript" src="/js/service/method-get-service.js"></script>
    <script type="text/javascript" src="/lib/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="/lib/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="/lib/layer.js"></script>
    

    <script type="text/javascript">
        var srcwidth = 900;  //整个面板的宽
        var currRow = 0;  //当前操作的行


        document.onkeydown = function (e) { // 回车提交表单
        // 兼容FF和IE和Opera
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                if($('#frameMain1').is(':hidden')){
                    if (confirm("确定要保存此页面吗?")) {
                        //  var test=document.getElementsByTagName('html')[0].outerHTML; 
                        //  var encodeHtml = HtmlUtil.htmlEncode(test);
                        var encodeHtml = $("#megshow").html();
                        encodeHtml = escape(encodeURIComponent(encodeHtml))
                        var map = '{"account":"' + encodeHtml + '"}';
                        return getService.methodInsert("/fbsViewAll/fbsViewAll/add",map,aaaa);
                    }
                }else{

                    if (confirm("确定要删除此页面吗?")) {
                        const par = getService.methodPost("/fbsViewAll/fbsViewAll/delete");
                        if(par.success){
                            window.location.reload()
                        }
                    
                    }
                }
                
            }
        }

        function aaaa(data){
                // const hm = getService.methodGet("/fbsViewAll/fbsViewAll/list");
                // var decodeHtml = HtmlUtil.htmlDecode(hm.allFile);
                // window.location.replace('/pages/dashboard/test3.html?pkName=111')
                // window.location.replace('/pages/dashboard/test3.html?pkName=111')
                // const hm = getService.methodGet("/fbsViewAll/fbsViewAll/list");
                // var decodeHtml = HtmlUtil.htmlDecode(hm.allFile);
                // var test=document.getElementsByTagName('html')[0].outerHTML; 
                // // alert(decodeHtml);
                // var win;                                        
                // win = window.open('/pages/dashboard/test3.html','','scroll:1;status:0;help:0;resizable:1;dialogWidth:800px;dialogHeight:600px');          
                // win.document.write(test);  

        }


        var HtmlUtil = {
    /*1.用浏览器内部转换器实现html转码*/
    htmlEncode:function (html){
        //1.首先动态创建一个容器标签元素,如DIV
        var temp = document.createElement ("div");
        //2.然后将要转换的字符串设置为这个元素的innerText(ie支持)或者textContent(火狐,google支持)
        (temp.textContent != undefined ) ? (temp.textContent = html) : (temp.innerText = html);
        //3.最后返回这个元素的innerHTML,即得到经过HTML编码转换的字符串了
        var output = temp.innerHTML;
        temp = null;
        return output;
    },
    /*2.用浏览器内部转换器实现html解码*/
    htmlDecode:function (text){
        //1.首先动态创建一个容器标签元素,如DIV
        var temp = document.createElement("div");
        //2.然后将要转换的字符串设置为这个元素的innerHTML(ie,火狐,google都支持)
        temp.innerHTML = text;
        //3.最后返回这个元素的innerText(ie支持)或者textContent(火狐,google支持),即得到经过HTML解码的字符串了。
        var output = temp.innerText || temp.textContent;
        temp = null;
        return output;
    }
};

        $(function () {  
            const hm = getService.methodGet("/fbsViewAll/fbsViewAll/list");
            if(hm == null){
              $("#frameMain1").hide();  
            }else{
                $("#frameMain1").height($(window).height()-110);
                $("#megshow").hide();  
            }
            $('#ggkb').bind("click",function(){

                if($('#frameMain1').is(':hidden')){

                    if (confirm("确定要保存此页面吗?")) {
                        //  var test=document.getElementsByTagName('html')[0].outerHTML; 
                        //  var encodeHtml = HtmlUtil.htmlEncode(test);
                        var encodeHtml = $("#megshow").html();
                        encodeHtml = escape(encodeURIComponent(encodeHtml))
                        var map = '{"account":"' + encodeHtml + '"}';

                        return getService.methodInsert("/fbsViewAll/fbsViewAll/add",map,aaaa);
                    }

                }else{

                    if (confirm("确定要删除此页面吗?")) {
                        const par = getService.methodPost("/fbsViewAll/fbsViewAll/delete");
                        if(par.success){
                            window.location.reload()
                        }
                    
                    }
                }

                
            });


            srcwidth = $(window).width();
            const nameAll = document.getElementsByName('testFileName');
            //绑定需要拖拽改变大小的元素对象 每行的第一列 暂时支持一行两列         
            $.each(nameAll, function (i, n) {
                bindResize(n);          
            })

            // bindResize(nameAll[0]);            
            // bindResize(document.getElementById('p10'));
            // bindResize(document.getElementById('p20'));
        });
        function bindResize(el) {
            
            var els = el.style,            
            x = y = 0;            
            $(el).mousedown(function (e) {
                currRow = el.id;
                x = e.clientX - el.offsetWidth,
                y = e.clientY - el.offsetHeight;                
                el.setCapture ? (                
                    el.setCapture(),                
                    el.onmousemove = function (ev) {
                        mouseMove(ev || event);
                    },
                    el.onmouseup = mouseUp
                ) : (                    
                    $(document).bind("mousemove", mouseMove).bind("mouseup", mouseUp)
                );                
                e.preventDefault();
            });


            //移动事件
            function mouseMove(e) {
                els.width = e.clientX - x + 'px',
                els.height = e.clientY - y + 'px';

                var cx = currRow.substr(1, 1);  //当前行
                var cy = currRow.substr(2, 1);   //当前列
                      
                
                var docCur = $("#p" + cx + cy);   //current row colum                
                docCur.css({ "width": ((parseInt(docCur.css("width").replace("px", ""))) > srcwidth ? srcwidth : (parseInt(docCur.css("width")))) });                
                var docCurCopy = docCur;

                var cya = parseInt(cy) + 1;   //当前列+1      
                var docNCol = $("#p" + cx + cya);   //next colum
                if (docNCol != null) {
                    docNCol.css({ "left": (parseInt(docCur.css("left").replace("px", ""))) + (parseInt(docCur.css("width").replace("px", ""))) });
                    docNCol.css({ "width": (srcwidth - (parseInt(docCur.css("width").replace("px", "")))) });
                    docNCol.css({ "top": (docCur.css("top")) });
                    docNCol.css({ "height": docCur.css("height") });
                }

                for (var i = 1; i < 4; i++) {
                    var cxa = parseInt(cx) + i;   //当前行+1                        
                    var docNRow = $("#p" + cxa + cy);   //next row
                    if (docNRow != null) {
                        docNRow.css({ "left": (parseInt(docCurCopy.css("left").replace("px", ""))) });
                        docNRow.css({ "top": (parseInt(docCurCopy.css("top").replace("px", ""))) + (parseInt(docCurCopy.css("height").replace("px", ""))) });

                        var docNCol = $("#p" + cxa + 1);   //next colum
                        if (docNCol != null) {
                            
                            docNCol.css({ "left": (parseInt(docNRow.css("left").replace("px", ""))) + (parseInt(docNRow.css("width").replace("px", ""))) });
                            docNCol.css({ "width": (srcwidth - (parseInt(docNRow.css("width").replace("px", "")))) });
                            docNCol.css({ "top": (docNRow.css("top")) });
                            docNCol.css({ "height": docNRow.css("height") });
                        }
                    }
                    docCurCopy = docNRow;
                }                
                $("#megshow").html("#p" + els.width + els.height);
            }
            //停止事件
            function mouseUp() {                
                el.releaseCapture ? (                
                    el.releaseCapture(),                
                    el.onmousemove = el.onmouseup = null
                ) : (                    
                    $(document).unbind("mousemove", mouseMove).unbind("mouseup", mouseUp)
                );
            }
        }



    </script>
    <style type="text/css">
        
        #p00 {  top: 100px; left: 200px;  background: #f1f1f1; margin-bottom: 3px;;float:left;
                text-align: center; line-height: 100px; border: 1px solid #CCC; cursor: se-resize; }
        #p10 { top: 400px; left: 100px;  background: #f1f1f1;  margin-bottom: 3px;float:left;
                text-align: center; line-height: 100px; border: 1px solid #CCC; cursor: se-resize; }
        #p20 { top: 400px; left: 100px;  background: #f1f1f1;  margin-bottom: 3px;float: left;;
                text-align: center; line-height: 100px; border: 1px solid #CCC; cursor: se-resize; }
    </style>
</head>
<body>
    
     <div class="row no-padding head-bar" style="height:81px">
        <div class="col-lg-1 col-md-1">
        </div>
        <div class="col-lg-4 col-md-4 page-title"><span id="ggkb">公告看板</span>
        </div>
        <div class="col-lg-4 col-md-4">
        </div>
    </div>
    <div id="frameMain1" style="width: 100%;height:100%;">
        <iframe id="frameMain" width="100%" height="100%" border="0" frameborder="0" v-bind:src="filepath" style="background-color:#ffffff"></iframe>
    </div>
   <div id="megshow" style="width: 100%;height:97%;">
        <div id="div-main" >
            <div class="col-lg-2 col-md-2 center no-padding" style="width:100%;height:100%;"></div>
        </div>
        <span v-for="task in taskList">
            <div id="p00" name="testFileName"  v-if="task.isImg">
                <img id="imgType" :src="'/upVedio/'+task.fileName" width="100%" height="100%" /> 
            </div>
            <div id="p10" name="testFileName"  v-if="!task.isImg">
                <video id="videoType" :src="'/upVedio/'+task.fileName" controls width="100%" height="100%" > </video> 
            </div> 
        </span>
    </div> 



        <script src="/lib/echarts/echarts.min.js"></script>
        <script src="/lib/echarts/theme/macarons.js"></script>
        <script src="/lib/vue.min.js"></script>
        <script src="/js/service/produce-task.js"></script>

        <link href="/lib/bootstrap/bootstrap.min.css" rel="stylesheet" />
        <link href="/css/dashboard.css" rel="stylesheet" />

        <script type="text/javascript">
    
        const taskList = ServiceProduceTask.getVedioFileList();
        
            var vm = new Vue({
                    el: '#megshow',
                    data: {
                        taskList: taskList,
                        num:'00000'
                    }
                })

                var vm2 = new Vue({
                    el: '#frameMain1',
                    data: {
                        filepath:"/pages/dashboard/videoFile.html"
                    }
                })
            </script>

</body>
</html>