5G频点计算工具 V2.0 【源代码+在线工具】

2024-07-11T18:00:00

已集成好最新版本地址(直接使用): 点击前往

版本介绍:

V2.0 Time:2024/04/15
1、增加是否输入值检查
2、输入负值弹窗提醒
3、未输入rb数目支持计算实际频点
4、进一步优化代码复杂度
5、子载波间隔选择方式换
6、修复多次计算pointA计算错误BUG
7、适配手机端,自动判断手机/电脑端不同界面
8、页面添加相关源码下载地址(免费分享!)

源代码

html:

PC端index.html

<!DOCTYPE html>
<!--
  //Autor:快乐的钟好烦
  //Blog:https://www.fanl.cn/
  //Time:2024/4/14,16:20
  //The version is 1.0.
  -->
<!--V2.0
    2024/4/15实现功能:
  1.增加是否输入值检查
  2.输入负值弹窗提醒
  3.未输入rb数目支持计算实际频点
  4.增加终端判断,若为手机则重定向到手机页面
  5.子载波间隔选择改为下拉框选项
    -->
<html>
    <head>
        <title>5G-PointA/中心载频(计算工具) - Inn云工具箱</title>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="keywords" content="5G频点计算工具,PointA计算,中心载频计算,5G计算工具,Inn云工具箱" />
        <meta name="description" content="5G计算工具是Inn云工具箱下的一个小工具,可以在线计算5G的中心载频、PointA频点等,方便快捷,免费使用!" />
        <link rel="stylesheet" href="../css/5g_calculate.css" />
    </head>
    <body>
        <div class="app-container">
            <div class="app-header">
                <h1 class="app-title">5G频段 - PointA/中心载频 &nbsp;计算工具</h1>
                <br>
                <button onclick="wtfk();">问题反馈</button>
                <button onclick="tz();">更多工具</button>
            </div>
            <!-- 内容部分 -->
            <div class="app-content">
                <!-- 频段选择 -->
                <div class="select-Frequency">
                    <p>
                        <!-- 可选频率表 -->
                        <font>频段:</font>
                        <select id="frequencyValue" name="frequency_num" onchange="checkFrequency();">
                            <option value="0" selected>-》请选择《-</option>
                            <!-- 低频 -->
                            <option value="1">n1(FDD)</option>
                            <option value="3">n3(FDD)</option>
                            <option value="5">n5(FDD)</option>
                            <option value="7">n7(FDD)</option>
                            <option value="28">n28(FDD)</option>
                            <option value="41">n41(TDD)</option>
                            <!-- 中频 -->
                            <option value="77">n77(TDD)</option>
                            <option value="78">n78(TDD)</option>
                            <option value="79">n79(TDD)</option>
                            <!-- 高频 -->
                            <option value="257">n257(TDD)</option>
                            <option value="258">n258(TDD)</option>
                            <option value="260">n260(TDD)</option>
                            <option value="261">n261(TDD)</option>
                        </select>
                        &nbsp;&nbsp;&nbsp;
                        <br>
                        <br>
                        <font color="blue">↓↓载频范围(U/D)↓↓</font><br><br>
                        <font id="absolute-Frequency">(请选择频段,当前未选择~)
                        </font>
                    </p>

                </div>
                <!-- 功能选择 -->
                <!--     <div class="select-Function">
                    计算:
                    <input type="radio" name="function-select" value=提交值 >实际频点
                    <input type="radio" name="function-select" value=提交值 >绝对频点
                    <input type="radio" name="function-select" value=提交值 >PointA频点
                    
                </div> -->
                <!-- 子载波间隔 -->

                <div class="sub-Spacing" name="Subselect">
                    <p>子载波间隔:
                        <!-- 载波间隔更换为下拉框选择 -->
                        <select id="subZBjg" onchange="subZbjg();">
                            <option value="0" selected>-》请选择《-</option>
                            <option value="15">15kHz</option>
                            <option value="30">30kHz</option>
                            <option value="60">60kHz</option>
                            <option value="120">120kHz</option>
                        </select>
                        <!-- 放弃这段
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="15">15kHz
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="30">30kHz
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="60">60kHz
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="120">120kHz -->
                    </p>
                </div>
                <!-- 系统带宽+中心载频 -->
                <div class="input-RB+c">
                    <p>
                        系统带宽(RB):<input id="rb-num" type="number" min="0" />
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        中心载频:<input id="center-cf" type="number" min="0" /></p>
                </div>
                <!-- 计算、重置按钮+计算结果展示 -->
                <div class="submit-Print">
                    <!-- 计算按钮 -->
                    <button onclick="caculate();">计算</button>&nbsp;&nbsp;&nbsp;&nbsp;<button
                        onclick="reset();">重置</button>
                    <br>
                    <br>
                    <hr />
                    <br>
                    <font color="#FF70EB">PointA:</font>&nbsp;&nbsp;<input id="pointA" value="您还未计算" />
                    &nbsp;&nbsp;&nbsp;
                    <font color="#F24A90">实际频点:</font>&nbsp;&nbsp;<input id="absoluteFrequency" value="您还未计算" />

                </div>
            </div>

            <div class="app-footer">
                <a href="https://www.fanl.cn">V2.0</a> &nbsp;版权所有 &copy; 2024 &nbsp; <a
                    href="https://tool.innyun.cn">Inn云工具箱</a>&nbsp;&nbsp;&nbsp;<a
                    href="https://www.fanl.cn/archives/1021.html"
                    style="border: 1px green solid; color: green;">开源地址</a>
            </div>
        </div>
        <script type="text/javascript" src="../js/function.js"></script>
        <script type="text/javascript" src="../js/isPhone.js"></script>
    </body>
</html>

手机端index.html

<!DOCTYPE html>
<!--
    V2.0手机端
    2024/4/16 16:15
    适配手机端...
    https://www.fanl.top
    -->
<html>
    <head>
        <title>5G-PointA/中心载频(计算工具) - Inn云工具箱</title>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta name="keywords" content="5G频点计算工具,PointA计算,中心载频计算,5G计算工具,Inn云工具箱" />
        <meta name="description" content="5G计算工具是Inn云工具箱下的一个小工具,可以在线计算5G的中心载频、PointA频点等,方便快捷,免费使用!" />
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <link rel="stylesheet" href="../../css/5g_calculate_phone.css" />
    </head>
    <body>
        <div class="app-container">
            <div class="app-header">
                <h1 class="app-title">PointA/中心载频 &nbsp;计算工具</h1>
                <br>
                <button onclick="wtfk();">问题反馈</button>
                <button onclick="tz();">更多工具</button>
            </div>
            <!-- 内容部分
            <div class="app-content">
                <!-- 频段选择 -->
            <div class="select-Frequency">
                <p>
                    <!-- 可选频率表 -->
                    <font>频段指示:</font>
                    <select id="frequencyValue" name="frequency_num" onchange="checkFrequency();">
                        <option value="0" selected>-》请选择《-</option>
                        <!-- 低频 -->
                        <option value="1">n1(FDD)</option>
                        <option value="3">n3(FDD)</option>
                        <option value="5">n5(FDD)</option>
                        <option value="7">n7(FDD)</option>
                        <option value="28">n28(FDD)</option>
                        <option value="41">n41(TDD)</option>
                        <!-- 中频 -->
                        <option value="77">n77(TDD)</option>
                        <option value="78">n78(TDD)</option>
                        <option value="79">n79(TDD)</option>
                        <!-- 高频 -->
                        <option value="257">n257(TDD)</option>
                        <option value="258">n258(TDD)</option>
                        <option value="260">n260(TDD)</option>
                        <option value="261">n261(TDD)</option>
                    </select>
                    &nbsp;&nbsp;&nbsp;
                    <br>
                    <br>
                    <font color="blue">↓↓载频范围(U/D)↓↓</font><br><br>
                    <font id="absolute-Frequency">(请选择频段,当前未选择~)
                    </font>
                </p>

            </div>
            <!-- 功能选择 -->
            <!--     <div class="select-Function">
                    计算:
                    <input type="radio" name="function-select" value=提交值 >实际频点
                    <input type="radio" name="function-select" value=提交值 >绝对频点
                    <input type="radio" name="function-select" value=提交值 >PointA频点
                    
                </div> -->
            <!-- 子载波间隔 -->

            <div class="sub-Spacing" name="Subselect">
                <p>子载波间隔:<!-- 载波间隔更换为下拉框选择 -->
                    <select id="subZBjg" onchange="subZbjg();">
                        <option value="0" selected>-》请选择《-</option>
                        <option value="15">15kHz</option>
                        <option value="30">30kHz</option>
                        <option value="60">60kHz</option>
                        <option value="120">120kHz</option>
                    </select>
                    <!-- 放弃这段
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="15">15kHz
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="30">30kHz
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="60">60kHz
                        <input onclick="getSpacing(this.value);" type="radio" name="subSelect" value="120">120kHz -->
                </p>
            </div>
            <!-- 系统带宽+中心载频 -->
            <div class="input-RB+c">
                <p>
                    系统带宽(RB):<input id="rb-num" type="number" min="0" />
                    <br>
                    <br>
                    中心载频:<input id="center-cf" type="number" min="0" />
                </p>
            </div>
            <!-- 计算、重置按钮+计算结果展示 -->
            <div class="submit-Print">
                <!-- 计算按钮 -->
                <button onclick="caculate();">计算</button>&nbsp;&nbsp;&nbsp;&nbsp;<button onclick="reset();">重置</button>
                <br>
                <hr />
                <h3>计算结果?</h3>
                <font color="#FF70EB">PointA:</font>&nbsp;&nbsp;<input id="pointA" value="您还未计算" />
                <br>
                <br>
                <font color="#F24A90">实际频点:</font>&nbsp;&nbsp;<input id="absoluteFrequency" value="您还未计算" />

            </div>
        </div>

        <div class="app-footer">
            <a href="https://www.fanl.cn">V2.0</a> &nbsp;版权所有 &copy; 2024 &nbsp; <a
                href="https://tool.innyun.cn">Inn云工具箱</a>&nbsp;&nbsp;&nbsp;<a
                href="https://www.fanl.cn/archives/1021.html" style="border: 1px green solid; color: green;">开源地址</a>
        </div>
        </div>
        <script type="text/javascript" src="../../js/function.js"></script>
        <script type="text/javascript" src="../../js/isPC.js"></script>
    </body>
</html>

css:

5g_calculate.css

   body {
       font-family: Arial, sans-serif;
       margin: 0;
       padding: 0;
       background-color: #f2f2f2;
   }

   .app-container {
       background-color: #fff;
       border-radius: 10px;
       box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
       margin: 20px auto;
       max-width: 90%;
       padding: 20px;
   }

   .app-header {
       background-color: #f2f2f2;
       padding: 10px;
       text-align: center;
       border-bottom: 1px solid #ccc;
   }

   .app-title {
       font-size: 24px;
       margin: 0;
   }

   .app-content {
       text-align: center;
       font-size: 20px;
       padding: 20px 0;
       border: 1px dashed darkgray;
   }

   .app-footer {
       background-color: #f2f2f2;
       padding: 10px;
       text-align: center;
       border-top: 1px solid #ccc;
   }

   a {
       text-decoration: none;
       color: darkturquoise;
   }

   select {
       width: 122px;
       height: 40px;
       font-size: 16px;

   }

   .select-Frequency {
       margin: 25px auto;
       max-width: 65%;
   }

   #absolute-Frequency {
       color: red;
       font-size: 17px;
   }

   .select-Function {
       margin: 15px auto;
       max-width: 65%;
   }

   .sub-Spacing {
       margin: 25px auto;
       max-width: 65%;
   }

   .sub-Spacing select {
       width: 120px;
       height: 40px;
       font-size: 16px;
   }

   .submit-Print {
       margin: 25px auto;
       max-width: 65%;
   }

   .submit-Print button {
       height: 35px;
       width: 50px;
       font-size: 16px;
   }

   .submit-Print input {
       padding: 1px;
       width: 85px;
       height: 30px;
       font-size: 16px;
   }

   #rb-num {
       height: 22px;
       font-size: 16px;
       width: 55px;
   }

   #center-cf {
       height: 22px;
       font-size: 16px;
       width: 100px;
   }

   input::-webkit-outer-spin-button,
   input::-webkit-inner-spin-button {
       -webkit-appearance: none !important;
   }

   input[type="number"] {
       -moz-appearance: textfield;
       /* 此处写不写都可以 */
   }

5g_calculate_phone.css

   body {
       font-family: Arial, sans-serif;
       margin: 0;
       padding: 0;
       background-color: #f2f2f2;
       text-align: center;
   }

   .app-container {
       background-color: #fff;
       border-radius: 10px;
       box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
       margin: 20px auto;
       max-width: 90%;
       padding: 20px;
   }

   .app-header {
       background-color: #f2f2f2;
       padding: 10px;
       text-align: center;
       border-bottom: 1px solid #ccc;
   }

   .app-title {
       font-size: 24px;
       margin: 0;
   }

   .app-content {
       text-align: center;
       font-size: 20px;
       padding: 20px 0;
       border: 1px dashed darkgray;
   }

   .app-footer {
       background-color: #f2f2f2;
       padding: 10px;
       text-align: center;
       border-top: 1px solid #ccc;
   }

   a {
       text-decoration: none;
       color: darkturquoise;
   }

   select {
       width: 115px;
       height: 35px;
       font-size: 15px;

   }

   .select-Frequency {
       margin: 25px auto;
       max-width: 65%;
   }

   #absolute-Frequency {
       color: red;
       font-size: 14px;
   }

   .select-Function {
       margin: 15px auto;
       max-width: 65%;
   }

   .sub-Spacing {
       margin: 25px auto;
       max-width: 65%;
   }

   .sub-Spacing select {
       width: 115px;
       height: 35px;
       font-size: 16px;
   }

   .submit-Print {
       margin: 25px auto;
       max-width: 65%;
   }

   .submit-Print button {
       height: 35px;
       width: 50px;
       font-size: 16px;
   }

   .submit-Print input {
       padding: 1px;
       width: 85px;
       height: 30px;
       font-size: 16px;
   }

   #rb-num {
       height: 22px;
       font-size: 16px;
       width: 55px;
   }

   #center-cf {
       height: 22px;
       font-size: 16px;
       width: 100px;
   }

   input::-webkit-outer-spin-button,
   input::-webkit-inner-spin-button {
       -webkit-appearance: none !important;
   }

   input[type="number"] {
       -moz-appearance: textfield;
       /* 此处写不写都可以 */
   }

js:

function.js

// 默认选中位n1频段,信道栅格:5,绝对频点偏置:0,实际频点偏置:0;
var frequeny = 0;
var xdsg = 0;
var jdpdpz = 0;
var sjpdpz = 0;
var zzbjg = 0;
var rb = 0;
var zxzp = 0;
var pointa = 0;
var sjpd = 0;
//默认无余数
var yys = 0;

function checkFrequency() {
    // 选中select框架
    var selectfre = document.getElementById("frequencyValue");
    // 创建选项索引
    var index = selectfre.selectedIndex;
    // 获取新选中的频段值
    frequeny = selectfre.options[index].value;
    // 判断频段属于那个频(高低中),并给对应的信道栅格
    if (frequeny < 77) {
        xdsg = 5;
    } else if (frequeny < 257) {
        xdsg = 15;
        jdpdpz = 600000;
        sjpdpz = 3000000;
    } else {
        xdsg = 60;
        jdpdpz = 2016667;
        sjpdpz = 24250080;
    }
    // alert(frequeny);确认生效,注释掉
    // alert(xdsg);,判断生效,注释掉
    // 如果选中了其他频段则改变到对应的绝对频点
    // 中心载频计算
    switch (frequeny) {
        case "0":
            document.getElementById("absolute-Frequency").innerHTML = "(请选择频段,当前未选择~)";
            break;
        case "1":
            document.getElementById("absolute-Frequency").innerHTML = "U:384000-<20>-396000<br>D:422000-<20>-434000";
            break;
        case "3":
            // alert("3")
            document.getElementById("absolute-Frequency").innerHTML = "U:342000-<20>-357000<br>D:361000-<20>-376000";
            break;
        case "5":
            document.getElementById("absolute-Frequency").innerHTML = "U:164800-<20>-169800<br>D:173800-<20>-178800)";
            break;
        case "7":
            document.getElementById("absolute-Frequency").innerHTML = "U:500000-<20>-214000<br>D:524000-<20>-538000)";
            break;
        case "28":
            document.getElementById("absolute-Frequency").innerHTML = "U:140600-<20>-149600<br>D:151600-<20>-160600)";
            break;
        case "41":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:499200-<20>-537999";
            break;
        case "77":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:620000-<1/2>-680000";
            break;
        case "78":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:620000-<1/2>-653333";
            break;
        case "79":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:693333-<1/2>-733333";
            break;
        case "257":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:2054167-<1/2>-20104166";
            break;
        case "258":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:2016667-<1/2>-2070833";
            break;
        case "260":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:2229167-<1/2>-2279166";
            break;
        case "261":
            document.getElementById("absolute-Frequency").innerHTML = "U/D:2070833-<1/2>-2084999";
            break;
        default:
            alert("未选择频段!");
            break;
    }
}

// function getSpacing(value) {
//     //子载波间隔
//     //判断是否标准,2.0再写
//     zzbjg = value;
//     // alert(zzbjg);
// }
function subZbjg() {
    var subzbjg1 = document.getElementById("subZBjg");
    var index2 = subzbjg1.selectedIndex;
    zzbjg = subzbjg1.options[index2].value;
    // alert(zzbjg); 判断选中,注释掉
    // 后面再写判断子载波是否再频段范围
}

function caculate() {
    rb = document.getElementById("rb-num").value;
    zxzp = document.getElementById("center-cf").value;
    if (rb < 0) {
        alert("干啥子嘞?");
        return false;
    } else if (zxzp < 0) {
        alert("你贡样子怎么算侬?");
        return false;
    }

    // alert(rb);
    // alert(zxzp);
    sjpd = (((zxzp - jdpdpz) * xdsg) + sjpdpz) / 1000;
    // alert(sjpd);
    if ((rb % 2) === 0) {
        //偶数,无需处理
    } else {
        // 奇数
        yys = 6 * zzbjg;
    }
    pointa = ((((zxzp - jdpdpz) * xdsg) - 12 * zzbjg * parseInt(rb / 2) - yys) / xdsg) + jdpdpz;
    // 每次计算清除yys,防止错乱
    yys = 0;
    //2.0 判断性输出
    //判断是否选择频段
    if (frequeny != 0) {

        //判断是否输入值
        if (zxzp == 0) {
            alert("侬咋算的嘛,中心载频怎么不填塞?")
            // alert(zzbjg)
            return false;
        } else if (rb == 0 && zxzp != 0) {
            document.getElementById("pointA").value = "未输入RB";
            document.getElementById("absoluteFrequency").value = sjpd;
        } else
            // 判断是否选择子载波带宽
            if (zzbjg != 0) {
                if (rb > 0 && zxzp > 0) {
                    document.getElementById("pointA").value = pointa;
                    document.getElementById("absoluteFrequency").value = sjpd;

                } else {
                    alert("未知错误")
                    return false;
                }
            } else {
                alert("您还未选择子载波带宽!")
                // alert(zzbjg)
                return false;
            }
    } else {
        alert("您还未选择频段!");
        // alert(frequeny)
        return false;
    }



}

function reset() {
    //频段选择重置
    var resetSelect = document.getElementById("frequencyValue");
    resetSelect.selectedIndex = 0;
    document.getElementById("absolute-Frequency").innerHTML = "(请选择频段,当前未选择~)";
    //清空子载波选中
    var resetSubselect = document.getElementsByName("subSelect");
    // var resetSub
    for (var i = 0; i < resetSubselect.length; i++) {
        if (resetSubselect[i].checked) {
            resetSubselect[i].checked = false;
        }
    }
    // 2.0清除
    //清空RB数
    document.getElementById("rb-num").value = "";
    //清空中心载频
    document.getElementById("center-cf").value = "";
    //清空子载波间隔
    document.getElementById("subZBjg").value = "0";
    // 把过去都归零吧!
    frequeny = 0;
    xdsg = 0;
    jdpdpz = 0;
    sjpdpz = 0;
    zzbjg = 0;
    rb = 0;
    zxzp = 0;
    pointa = 0;
    sjpd = 0;
    yys = 0;
    //清空结果
    document.getElementById("pointA").value = "您还未计算";
    document.getElementById("absoluteFrequency").value = "您还未计算";
}
function tz(){
    window.location.replace("https://tool.innyun.cn/");

}
function wtfk(){
    alert("问题反馈联系qq:738476494");
}

isPC.js

function isDesktopDevice() {
// 检测用户设备类型
  return !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
}

// 重定向到新的页面
function redirectToDesktopPage() {
  window.location.href = "../index.html";
}

// 如果是电脑设备,则重定向到新的页面
if (isDesktopDevice()) {
  redirectToDesktopPage();
}

isPhone.js

// 检测用户设备类型
function isMobileDevice() {
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}

// 重定向到新的页面
function redirectToMobilePage() {
    window.location.href = "phone/index.html";
    
}

// 如果是手机设备,则重定向到新的页面
if (isMobileDevice()) {
  redirectToMobilePage();
}
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »