美文网首页
使用jQuery读取本地json绑定表格

使用jQuery读取本地json绑定表格

作者: 绍重先 | 来源:发表于2018-02-05 22:20 被阅读0次

    由于js安全不允许读写本地文件,采用引用脚本方式读取json

    equation.js

    var edata = [
        {
            "eid": "1",
            "etype": "RATH",
            "ename": "RATH",
            "equation": [
                "diff(u(x,t),t)+u(x,t)*diff(u(x,t),x)+p*diff(u(x,t),x$3)=0",
                "diff(u(x,t),t)+u(x,t)*diff(u(x,t),x)-p*diff(u(x,t),x$2)+q*diff(u(x,t),x$3)=0",
                "diff(u(x,t),t)+alpha*diff(u(x,t),t)*diff(u(x,t),x$2)+beta*u(x,t)*diff(u(x,t),x$3)=0",
                "diff(u(x,t),t)+u(x,t)*diff(u(x,t),x$3)+p*diff(u(x,t),x)*diff(u(x,t),x$2)+q*u(x,t)^2*diff(u(x,t),x)+diff(u(x,t),x$5)=0"
            ],
            "desc": "Real Automated TanH-function method"
        },
        {
            "eid": "2",
            "etype": "IRATH",
            "ename": "IRATH",
            "equation": [
                "diff(u(x,t),t)+u(x,t)*diff(u(x,t),x)+p*diff(u(x,t),x$3)=0",
                "diff(u(x,t),t)+u(x,t)*diff(u(x,t),x)-p*diff(u(x,t),x$2)+q*diff(u(x,t),x$3)=0",
                "diff(u(x,t),t)+alpha*diff(u(x,t),t)*diff(u(x,t),x$2)+beta*u(x,t)*diff(u(x,t),x$3)=0",
                "diff(u(x,t),t)+u(x,t)*diff(u(x,t),x$3)+p*diff(u(x,t),x)*diff(u(x,t),x$2)+q*u(x,t)^2*diff(u(x,t),x)+diff(u(x,t),x$5)=0"
            ],
            "desc": "Improved Real Automated TanH-function method"
        },
        {
            "eid": "3",
            "etype": "RAEEM",
            "ename": "RAEEM",
            "equation": [
                "[diff(u(x,y,z,t),t)+u(x,y,z,t)^2*diff(u(x,y,z,t),x)+diff(u(x,y,z,t),x$3)+diff(u(x,y,z,t),x,y,y)+diff(u(x,y,z,t),x,z,z)=0],3,3",
                "[diff(u(x,t),t)+3*v(x,t)*diff(v(x,t),x)=0,diff(v(x,t),t)+2*diff(v(x,t),x$3)+2*u(x,t)*diff(v(x,t),x)+diff(u(x,t),x)*v(x,t)=0]",
                "[diff(u(x,y,z,t),t)+u(x,y,z,t)^2*diff(u(x,y,z,t),x)+diff(u(x,y,z,t),x$3)+diff(u(x,y,z,t),x,y,y)+diff(u(x,y,z,t),x,z,z)=0],3,3"
            ],
            "desc": "Real Automated Elliptic Equation Method"
        },
        {
            "eid": "4",
            "etype": "SEMPS",
            "ename": "SEMPS",
            "equation": [
                "[diff(u(x,t),t)+u(x,t)*diff(u(x,t),x)+p*diff(u(x,t),x$3)=0],[diff(f(x),x)=R*g(x)^2,diff(g(x),x)=mu*g(x)*f(x),g(x)^2=s+R*f(x)^2],[f(x),g(x)]",
                "[diff(u(x, t), t)+u(x, t)*(diff(u(x, t), x))+p*diff(u(x, t), x$3) = 0],[diff(f(x), x) = g(x)*h(x), diff(g(x), x) = -f(x)*h(x), diff(h(x), x) = -n^2*g(x)*f(x), g(x)^2 = 1-f(x)^2, h(x)^2 = 1-n^2*f(x)^2],[f(x), g(x), h(x)]"
            ],
            "desc": "Sub Eq Method and Polynomial Solutions"
        },
        {
            "eid": "5",
            "etype": "AutoBT",
            "ename": "AutoBT",
            "equation": [
                "diff(w(x,t),t)-6*w(x,t)*diff(w(x,t),x)+diff(w(x,t),x$3)",
                "diff(w(x,t),t)+p*w(x,t)^2*diff(w(x,t),x)+diff(w(x,t),x$3)"
            ],
            "desc": "Automated Bäcklund Transformation method"
        },
        {
            "eid": "6",
            "etype": "CRE",
            "ename": "CRE",
            "equation": [
                "[diff(u(x,t),t)+6*u(x,t)*diff(u(x,t),x)+diff(u(x,t),x$3)=0]",
                "[diff(u(x,t),t)+u(x,t)*diff(u(x,t),x)+diff(v(x,t),x)=0,diff(v(x,t),t)+diff(u(x,t),x)+diff(u(x,t)*v(x,t),x)+diff(u(x,t),x,x,x)=0]"
            ],
            "desc": "Automated Consistent Riccati Expansion Method"
        },
        {
            "eid": "7",
            "etype": "ADSP",
            "ename": "ADSP",
            "equation": [
                "[diff(u(x, t), t)+6*u(x, t)*diff(u(x, t), x)+diff(u(x, t), x$3) = 0]",
                "[diff(u(x, t), t$2)-diff(u(x, t), x$2)-diff(u(x, t), x$4)-3*diff(u(x, t)^2, x$2) = 0]",
                "[diff(u(x, t), t)-(1/4)*diff(u(x, t), x$5)-5*diff(u(x, t), x)*diff(u(x, t), x$2)-(5/2)*u(x, t)*diff(u(x, t), x$3)-(15/2)*u(x, t)^2*diff(u(x, t), x) = 0]",
                "[diff(u(x, t), t)-6*u(x, t)*diff(u(x, t), x)+diff(u(x, t), x, x, x)-6*v(x, t)*diff(v(x, t), x) = 0, diff(v(x, t), t)-6*diff(u(x, t)*v(x, t), x)+diff(v(x, t), x, x, x) = 0]"
            ],
            "desc": "Automated Derivation Solutions for PDE"
        },
        {
            "eid": "8",
            "etype": "ADMP",
            "ename": "ADMP",
            "equation": [
                "[diff(y(x),x$2)=3/4*y(x)+y(x/2)-x^2+2],[y(0)=0,D(y)(0)=0],[y(x)],output=plot,err=true,x=0..1,y=0..1,index=15,pade=[7,7]",
                "[diff(y(t),t$alpha)+y(t)=0],[y(0)=1,D(y)(0)=0],alpha=1.3,index=50,output=plot,t=0..20,y=-0.2..1,pade=[150,150]"
            ],
            "desc": "Adomian Decomposition Method Package"
        },
        {
            "eid": "9",
            "etype": "CharSets",
            "ename": "CharSets",
            "equation": [
                "[x+2*y-3*z-5,  y+4*z-2,  2*x-y+z-1],{x,y,z}",
                "[2*x^2+x*y-y+1, -3*x*y+2*y^2-x-2, -3*x*y^2+2*y^3+2*x^2-3*y+1],[x,y]"
            ],
            "desc": "A implementation of Ritt-Wu's characteristic sets method"
        },
        {
            "eid": "10",
            "etype": "wsolve",
            "ename": "wsolve",
            "equation": [
                "[x+2*y-3*z-5,  y+4*z-2,  2*x-y+z-1],{x,y,z}",
                "[2*x^2+x*y-y+1, -3*x*y+2*y^2-x-2, -3*x*y^2+2*y^3+2*x^2-3*y+1],[x,y]"
            ],
            "desc": "Nonlinear algebraic system solver developed by Dingkang Wang of KLMM"
        }
    ]
    
    

    1、读取并绑定表格

    $("#btnOverview").click(function () {;
        var eHtml = ' ';
        for (var i = 0; i < edata.length; i++) {
            console.log(edata[i]);
            console.log(eHtml);
            if (i == 0)
                eHtml += '<tr class="table-primary">';
            else
                eHtml += '<tr>';
    
            eHtml += '<th scope="row">' + edata[i].eid + '</th>'
            eHtml += '<td>' + edata[i].etype + '</td>'
            eHtml += '<td>' + edata[i].ename + '</td>'
            eHtml += '<td><strong>' + edata[i].equation[0] + '</strong></td>'
            eHtml += '<td>' + edata[i].desc + '</td>'
            eHtml += '<tr>'
        }
    
        $("#indextbody").html(eHtml);
    })
    
    

    2、按类型查询

    $("#btnSearch").click(function () {
        console.log("btnSearch");
        var searchType = $("#sType").val();
        console.log(searchType);
    
        var eHtml = ' ';
        for (var i = 0; i < edata.length; i++) {
            if (edata[i].etype == searchType) {
                for (var j = 0; j < edata[i].equation.length; j++) {
                    if (i == 0)
                        eHtml += '<tr class="table-primary">';
                    else
                        eHtml += '<tr>';
                    eHtml += '<th scope="row">' + edata[i].eid + '</th>'
                    eHtml += '<td>' + edata[i].etype + '</td>'
                    eHtml += '<td>' + edata[i].ename + '</td>'
    
                    eHtml += '<td><strong>' + edata[i].equation[j] + '</strong></td>'
    
                    eHtml += '<td>' + edata[i].desc + '</td>'
                    eHtml += '<tr>'
                }
            }
    
        }
        $("#lookuptable").html(eHtml);
    })
    

    3、录入新数据条目

    $("#btnSave").click(function () {
        console.log("btnSearch");
        var saveType = $("#sType").val();
        var saveName = $("#sName").val();
        var saveEqua = $("#sEqua").val();
        var saveDesc = $("#sDesc").val();
    
        var saveJSON = {
            "eid": edata.length+1,
            "etype": saveType,
            "ename": saveName,
            "equation": saveEqua,
            "desc": saveDesc
        }
    
        edata.push(saveJSON);
        alert("微分公式插入完成");
    })
    


    fake function 方程等同性检索

    相关文章

      网友评论

          本文标题:使用jQuery读取本地json绑定表格

          本文链接:https://www.haomeiwen.com/subject/xifwzxtx.html