嵌入式網頁設計


主界面

 

主界面 campus_audio.html
<!DOCTYPE html>
<html lang="en" >
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <link rel="stylesheet" href="./style.css">
        <!--link rel="stylesheet" href="./index.css" /-->
        <title>校園鈴聲定制</title>
    </head>
    <body>
        <div>
            <canvas id="canvas" style="position: fixed; left: 0px; top: 0px; z-index:-8; pointer-events: none; width: 1536px; height: 1000px;background: rgb(36, 31, 61);cursor: none;padding: 0;margin: 0;list-style: none;border: none;outline: none;">您的瀏覽器不支持canvas</canvas>
        </div>
        <div id="container0" style="position: fixed; z-index: -1;opacity: 1; width: 1500px; height: 750px">
            <div class="hbox" style="position: fixed; left: 0px; top: 0px;z-index: 2">
                <canvas id="canvas1" width="300" height="225"></canvas>
                <img src="/tuku/ybrightness.png" id="sunormoon" width="50px" height="50" style="margin-left: 245px;margin-top: -60px;">
                <div width="500" height="100" style=" color: #fff;margin-left: 10px;margin-top: -50px;" class="vbox">
                    <h1>校園廣播站</h1>
                </div>
                <div class="laba" style="margin-left: 10px;margin-top: -34px;width: 90px;height: 80px;">
                    <img src="/tuku/voice_horn.png" width="50px" height="50" >
                    <img src="/tuku/add_music.png" width="25px" height="25" class="addm" id="addCards" style="z-index: 4;">
                    <img src="/tuku/whitemusic.png" width="25px" height="25" class="addm1" id="insertMusic" style="z-index: 4;">
                </div>
            </div>
            <div style="position: fixed; left: 23px; top: 250px;">
                
                <div width="500" style=" color: #fff;" class="vbox ybbox">
                    
                    <div id="main2" style="width: 250px; height:250px ;" ></div>
                </div>
            </div>
            <div style="position: fixed; left: 23px; top: 500px;">
                <div  width="300" height="225" style=" color: #fff;" class="vbox ">
                    <h3>濕度</h3>
                    <div id="main3" style="width: 250px; height:250px ;margin-top: -20px;" ></div>
                </div>
            </div>
            <div style="position: fixed;  top: 130px;  color: #fff;width: 100%;z-index: -2" class="hbox">
                <div style="width: 750px; height:700px;overflow-y:auto;margin-left: 260px;" id="audioCards" class="audioCards">
                    
                    
                </div>
                <div style="height:700px;overflow-y:auto;margin-left: 0px;">
                    <div id="main" style="width: 450px;height:300px;margin-left: 0px;margin-top: -50px;">
                        
                    </div>
                    <h2 style="margin-top: 0px;">通告:</h2>
                    <div class="noticeCard">
                        <p>本次嵌入式課設由170810218-曲昭璇和170400115-金文敏完成。分工:金文敏:前端界面和動態處理,cgi對應前台的接口。曲昭璇:數據庫、后台對接數據庫的各函數。共同完成:溫濕度傳感器的驅動實現和音樂的現實播放。</p>
                    </div>
                </div>
            </div>
            
            <script type="text/javascript" src="./mouse.js"></script>
        </div>
<!--刪除卡片彈窗-->    
        <div id="deleteW" class="addWorkBack" style="z-index: 6;">
            <div id="deW" class="addWorkWrapper">
                <div id="addWorkClose">
                    <span id="addWClosebutton">X</span>
                    <h2>確定刪除嗎</h2>
                </div>
                <div class="addWorkContent">
                    <form id="addm"  class="workform">            
                      <div class="newform0">
                          <div style="margin-left: 40%;">
                            <button type="button" id="delete_music" class="newbtn0">確定</button>
                          </div>
                      </div>
            
                    </form>
                </div>
            </div>
        </div>
        

 <!--插播彈窗-->
 <div id="add_M" class="addWorkBack" style="z-index: 6;">
    <div id="addM1" class="addWorkWrapper">
        <div id="addWorkClose">
            <span id="addMClosebutton">X</span>
            <h2>立即插播</h2>
        </div>
        <div class="addWorkContent">
            <form id="addm"  class="workform">
            
                <label for="workdesc" class="text0-item">選擇音源</label>
    
                <div class="">
                  <div class="">
                    <input type="file" name="mp3url1" id="mp3url1" class=""></input>
                  </div>
    
                </div>  
               
                
    
              <div class="newform0">
                  <div style="margin-left: 40%;">
                    <button type="button" id="add_inst_music" class="newbtn0">立即播出</button>
                  </div>
              </div>
    
            </form>
        </div>
    </div>
</div>
<!--修改音樂卡片彈窗-->
<div id="update_Work" class="addWorkBack" style="z-index: 8;">
    <div id="updateWork1" class="addWorkWrapper">
        <div id="addWorkClose">
            <span id="updateWorkClosebutton">X</span>
            <h2>修改廣播信息</h2>
        </div>
        <div class="addWorkContent">
            <form id="update_work " class="workform">

                <div class="">
                    <label for="type1" class="">廣播類型</label>
                    <div class="">
                        <div class="radio">
                            <label>
                                <input type="radio" name="type2" value="0" >
                                每日定時
                            </label>
                        </div>
                        <div class="radio">
                    <label>
                                <input type="radio" name="type2"  value="1" >
                                某時
                            </label>
                        </div>
                    </div>
                </div>
              <div class="newform0">
                <label for="workdesc" class="text0-item">選擇音源</label>

                <div class="">
                  <div class="">
                    <input type="file" name="mp3url0" id="mp3url0" ></input>
                  </div>

                </div>

                <div class="workdateselect">
                    <label for="workdesc" class="text0-item" style="margin-left: -79px;">選擇時間</label>
                    <input type="datetime-local" id="updatedate-btn" class="workdate"/>
                </div>


              <div class="newform0">

                  <div style="margin-left: 40%;">
                   <button type="button" id="add_update_btn" class="newbtn0">提交</button>
                  </div>
                </div>

            </form>
        </div>
    </div>
</div>


<!--增加音樂卡片彈窗-->
    <div id="add_Work" class="addWorkBack" style="z-index: 5;">
        <div id="addWork1" class="addWorkWrapper">
            <div id="addWorkClose">
                <span id="addWorkClosebutton">X</span>
                <h2>增加廣播信息</h2>
            </div>
            <div class="addWorkContent">
                <form id="add_work " class="workform">
                
                    <div class="">
                        <label for="type1" class="">廣播類型</label>
                        <div class="">
                            <div class="radio">
                                <label>
                                    <input type="radio" name="type1" value="0" checked="checked">
                                    每日定時
                                </label>
                            </div>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="type1"  value="1" >
                                    某時
                                </label>
                            </div>
                        </div>
                    </div>
                  <div class="newform0">
                    <label for="workdesc" class="text0-item">選擇音源</label>
        
                    <div class="">
                      <div class="">
                        <input type="file" name="mp3url" id="mp3url" ></input>
                      </div>
                      
                    </div>  
                   
                    <div class="workdateselect"> 
                        <label for="workdesc" class="text0-item" style="margin-left: -79px;">選擇時間</label>
                        <input type="datetime-local" id="begindate-btn" class="workdate"/>  
                    </div> 
                   
        
                  <div class="newform0">
        
                      <div style="margin-left: 40%;">
                        <button type="button" id="add_work_btn" class="newbtn0">提交</button>
                      </div>
                    </div>
        
                </form>
            </div>
        </div>
    </div>

   

        <script src="./jquery.min.js"></script>

        <script src="/tuku/echarts.js"></script>
        <script src="/starcontrol.js"></script>
    <script src="/gettth.js"></script>
        <script src="/audiocard.js"></script>
        <script>
     $(document).ready(function(){
        tth.inittth();
        playCards.initCards();
    })
        </script> 
        
    </body>
</html>
廣播信息前端邏輯代碼:
var div = document.getElementById('add_Work');
$("#addCards").click(function(){
    div.style.display = "block";
    console.log("ksddjjvbt");
});
$("#addWorkClosebutton").click(function(){
    div.style.display="none";
});

var di1 = document.getElementById('add_M');
$("#insertMusic").click(function(){
    di1.style.display = "block";
    console.log("ksddjjvbt");
});
$("#addMClosebutton").click(function(){
    di1.style.display="none";
});

var di2 = document.getElementById('deleteW');
/*$("#insertMusic").click(function(){
    di2.style.display = "block";
    console.log("ksddjjvbt");
});*/
$("#addWClosebutton").click(function(){
    di2.style.display="none";
});

var di3 = document.getElementById('add_M');
$("#insertMusic").click(function(){
    di1.style.display = "block";
    console.log("ksddjjvbt");
});
$("#addMClosebutton").click(function(){
    di1.style.display="none";
});

var div4=document.getElementById('update_Work');

$("#updateWorkClosebutton").click(function(){
  div4.style.display="none";
});

//播放天氣語音
$("#sunormoon").click(function(){
    $.post("./cgi-bin/index.py",{},function(resdata){
        console.log(resdata);
    });
});
$("#add_work_btn").click(function(){

    var atype1=document.getElementsByName("type1");
    var type1=0;
    for(var i=0;i<atype1.length;i++){
        if(atype1[i].checked==true){
            type1=atype1[i].value;
        }
    }
   console.log(type1);
    var begindate = document.getElementById("begindate-btn");
   console.log(begindate.value);
    var begintime = datetoformat(new Date(begindate.value));
    var mp3url=document.getElementById("mp3url").files[0].name;
    var thisTime=new Date().getTime();
    var actionType="1";
    console.log(begintime);
    if(typeof(mp3url)=="undefined"){
        alert("沒有選擇音頻");
    }
    if(type1=="每日定時"){
        type1="0";
    }
    if(type1=="某時"){
        type1="1";
    }
    if(type1=="1" && new Date(begindate).getTime()<thisTime){
        alert("注意時間設置");
    }
    
    if(begintime.length == 0||mp3url.length==0){
        return alert("不能為空");
    }
    
    var postData ={"actionType":actionType,"mp3name":mp3url,"type":type1,"playtime":begintime};
    console.log(postData);

    $.post("/cgi-bin/audioService.py",postData,function(resdata){
        console.log(resdata);
    }) ;
});
$("#add_inst_music").click(function(){

   
    var mp3url=document.getElementById("mp3url1").files[0].name;
   
    if(typeof(mp3url)=="undefined"){
        alert("沒有選擇音頻");
    }
    
    if(mp3url.length==0){
        return alert("不能為空");
    }
    
    var postData ={"mp3name":mp3url};
    console.log(postData);

    $.post("/cgi-bin/demo.py",postData,function(resdata){
        console.log(resdata);
    });
});

function datetoformat(date){
    let oYear = date.getFullYear();
    let oMonth = date.getMonth()+1;
    let oDay = date.getDate();
    let oHour = date.getHours();
    let oMin = date.getMinutes();
    let oSen = date.getSeconds();
    let oTime = oYear +'-'+ oMonth +'-'+ oDay +' '+ oHour +':'+ oMin +':'+oSen;//拼接時間
    return oTime;
}
/* 
*音樂卡片管理
*/
var playCards={

    initCards(){
        var datas=[];
    var cards=[];
        $.post("/cgi-bin/audioService.py",{"actionType":3},function(resdata){
            console.log(resdata);
        var data0=[];
        data0=resdata.split("\n");
        var data1=[];
        data1=data0[1].split(")");
        for(var i=0;i<data1.length-1;i++){
            var cardp=[];
        cardp=data1[i].split("'");
        console.log(cardp);
        var tt=[];
        tt=cardp[0].split("(");
        var tt0=[];
        tt0=tt[1].split(",");
        var tt1=cardp[4].split(",");
        var newcard={cardid:parseInt(tt0[0]),mp3name:cardp[1],playtime:cardp[3],type1:parseInt(tt1[1]),status1:parseInt(tt1[2])};
        cards.push(newcard);
    }
        console.log(cards);
            console.log("defrgth11111");
        
    var pageHtml="";
    for(var i=0;i<cards.length;i++){
          pageHtml=pageHtml+"<div class='audioCard'><div class='left-container'><div class='title'><span>"+"廣播-"+cards[i].type1+"-"+cards[i].mp3name+"</span></div><div class='title1'><span>"+cards[i].playtime+"</span></div></div><div class='right-container'><div class='regist-container'><div class='regist' data-id="+cards[i].cardid+" onclick='CangeCard(this)'>修改</div></div><div class='actoin-container' data-id="+cards[i].cardid+" onclick='update(this)'>刪除</div></div></div>"
    }
    console.log(pageHtml);
        pageHtml=pageHtml+"<div style='margin-top:200px;'></div>";
    var divv=document.getElementById("audioCards");    
    $("#audioCards").html(pageHtml);   
    });
 },}
    function CangeCard(e){

    div4.style.display="block";

  $("#add_update_btn").click(function(){
        var id=e.getAttribute("data-id");
    var atype1=document.getElementsByName("type2");
    var type1=0;
    for(var i=0;i<atype1.length;i++){
        if(atype1[i].checked==true){
            type1=atype1[i].value;
        }
    }
   console.log(type1);
    var begindate = document.getElementById("updatedate-btn");
   console.log(begindate.value);
    var begintime = datetoformat(new Date(begindate.value));
    var mp3url=document.getElementById("mp3url0").files[0].name;
    var thisTime=new Date().getTime();
    var actionType="4";
    console.log(begintime);
    var postData ={"actionType":actionType,"mp3name":mp3url,"type":type1,"playtime":begintime,"cardid":id};
    console.log(postData);

    $.post("/cgi-bin/audioService.py",postData,function(resdata){
        console.log(resdata);
    }) ;  
        
    console.log(id);
    });}
    function update(e){
    var id=e.getAttribute("data-id");
    $.post("/cgi-bin/audioService.py",{"actionType":5,"cardid":id},function(res){
    console.log(res);
    });
       console.log(id);
    }
溫濕度數據邏輯代碼gettth.js
/*
*溫度儀表折線圖 溫濕度儀表
*/
var myChart = echarts.init(document.getElementById('main'));
var myChart1 = echarts.init(document.getElementById("main2"));
var myChart2 = echarts.init(document.getElementById("main3"));
var data=[]
// 指定圖表的配置項和數據 折線圖
option = {
    color:["#ffedbc","#ed4264"],
    title: {
        text: '未來一周氣溫變化',
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        data: ['溫度', '濕度']
    },
    toolbox: {
        show: true,
        color:["#ffedbc","#ed4264"],
        feature: {
            dataZoom: {
                yAxisIndex: 'none'
                
            },

            dataView: {readOnly: false},
            magicType: {type: ['line', 'bar']},
            restore: {},
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['9min前', '8min前', '7min前','6min前', '5min前', '4min前', '3min前', '2min前', '1min前', '此時'],
        axisLabel:{
            color:"#ed4264",
            shadowColor: "#ed4264",
        }
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value}',
            color:"#ffedbc",
            shadowColor: "#ffedbc",
        }
    },
    series: [
        {
            name: '最高氣溫',
            type: 'line',
            data: [7,10,10,11, 11, 15, 13, 12, 13, 10],
            markPoint: {
                data: [
                    {type: 'max', name: '最大值'},
                    {type: 'min', name: '最小值'}
                ]
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            }
        },
        {
            name: '濕度',
            type: 'line',
            data: [50,60,70,1, -2, 2, 5, 3, 2, 0],
            markPoint: {
                data: [
                    {name: '濕度', value: -2, xAxis: 1, yAxis: -1.5}
                ]
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'},
                    [{
                        symbol: 'none',
                        x: '90%',
                        yAxis: 'max',
                    }, {
                        symbol: 'circle',
                        label: {
                            position: 'start',
                            formatter: '最大值'
                        },
                        type: 'max',
                        name: '最高點'
                    }]
                ],shadowColor: "#ffedbc",
            }
        }
    ]
};

//溫度的設置
option1 = {
    title: {

        text: '溫度',
        left:'center',
        top:40,
        textStyle:{
            color:'#fff',
            fontStyle:'oblique',
            fontSize:15
        }
    },


    toolbox: {
        feature: {
            restore: {},
            saveAsImage: {}
        }
    },

    series: [
    {
        name: '',
        min:-50,
        max:100,
        splitNumber: 10,
        title: {

            text: '溫度',
            left:'center',
            top:40,
            textStyle:{
                color:'#fff',
                fontStyle:'',
                fontSize:15
            }
        },
        type: 'gauge',
        pointer : { //指針樣式
                length: '65%',
                
                color:"#7DFFD1",
                width: 3,
                shadowColor : '#7DFFD1', //默認透明
                    shadowBlur: 70
            },
        detail: {formatter:'{value}℃',value:{color:"#fff",fontSize:15}},
        data: [{value: 0, name: '當前氣溫'}],
        axisLine: {
                show: true,
                lineStyle: { // 屬性lineStyle控制線條樣式
                    color: [
                    [ 1, "#7DFFD1" ],
                    
                    ],
                    width: 4,
                    shadowColor : '#7DFFD1', //默認透明
                    shadowBlur: 70
                },
                
    },
    axisLabel : { //文字樣式(及“10”、“20”等文字樣式)
                color : "white",
                distance : 5 //文字離表盤的距離
            },
            splitLine : { //分割線樣式(及10、20等長線樣式)
                length : 10,
                
                lineStyle : { // 屬性lineStyle控制線條樣式
                    width : 2,
                    color:"#7DFFD1",
                    shadowColor : '#7DFFD1', //默認透明
                    shadowBlur: 70,
                }
            },
            axisTick : { //刻度線樣式(及短線樣式)
                    length : 7,
                    lineStyle : { // 屬性lineStyle控制線條樣式
                    width : 2,
                    color:"#7DFFD1",
                    shadowColor : '#7DFFD1', //默認透明
                    shadowBlur: 70,
                }
                    
            },
        }
    ]

};
option2={
    title: {
        text: '濕度',
        left:'center',
        textStyle:{
            color:'#fff',
            fontSize:40
        }
    },
    color:["rgba(255,255,245,0.2)","#9144fc"],
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    graphic:{       //圖形中間文字
        type:"text",
        left:"center",
        top:"center",
        style:{
            text:"",
            textAlign:"center",
            fill:"#fff",
            fontSize:30
        }
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            dataView : {show: true, readOnly: false},
            magicType : {
                show: true, 
                type: 'pie',
                option: {
                    funnel: {
                        x: '0%',
                        width: '100%',
                        funnelAlign: 'center',
                        max: 100
                    }
                }
            },
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    text:"溫度",
    calculable : true,
    series : [
        {
            name:'濕度',
            type:'pie',
            radius : ['62%', '70%'],
            title:{
                text:"dkb",
            },
            itemStyle : {
                normal : {
                    label : {
                        show : false
                    },
                    labelLine : {
                        show : false
                    },
                    shadowColor : '#9144fc', //默認透明
                    shadowBlur: 40
                },
                emphasis : {
                    
                    label : {
                        show : true,
                        position : 'center',
                        textStyle : {
                            fontSize : '15',
                            fontWeight : 'bold',
                            color:'#fff'
                        },
                        shadowColor : '#9144fc', //默認透明
                    shadowBlur: 40
                    }
                }
            },
            data:[
                {value:50, name:''},
                {value:20,name:"",}
            ]
        }
    ]
    
                         
};
option1.series[0].data[0].value = 30;
option2.series[0].data[0].value=80;
myChart1.setOption(option1, true);
shidu=[];
wendu=[];
// 使用剛指定的配置項和數據顯示圖表。
myChart.setOption(option);
myChart2.setOption(option2);

var tth={
    inittth:function(){
    this.getlast10();
    
    },
    getlast10:function(){
        $.post("http://192.168.124.10/cgi-bin/audioService.py",{"actionType":2},function(res){
          console.log(res);
        var data0=[];
        data0=res.split("\n");
        var data1=[];
        data1=data0[1].split(")");
        console.log(data1);
        
        for(var i=0;i<10;i++){
        var wsd=[];
        wsd=data1[i].split("'");
        console.log(wsd);
        wendu[i]=(parseInt(wsd[1]));
        shidu[i]=(parseInt(wsd[3]));

       }
     console.log(wendu);
     console.log(shidu);
    myChart1.clear();
        console.log(wendu[0]);
        option1.series[0].data[0].value=wendu[0];
        myChart1.setOption(option1);
        myChart2.clear();
        option2.series[0].data[0].value=100-shidu[0];
    option2.graphic.style.text=(100-shidu[0]).toString()+"%";
        myChart2.setOption(option2);
        myChart.clear();
        option.series[0].data=wendu;
        option.series[1].data=shidu;
        myChart.setOption(option);

        });

    }

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM