233 lines
9.5 KiB
HTML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="cn"><!-- InstanceBegin template="/Templates/product-template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>BPI编码转换工具</title>
<!-- InstanceEndEditable -->
<meta name="theme-color" content="#03a9f4">
<meta name="description" content="BPI官方网站 Banana Pi DIY 电脑开发板包括 BPI-M1, 四核的BPI-M2+ , 八核的BPI-M3 单板电脑, BPI-R1 路由器等.">
<meta name="keywords"
content="香蕉派, 开发板BPI-M2U, Banana Pi, BPI, development board, DIY, banana pi m3, banana pi m2, banana pi m64, banana pi m1, bpi-m3, bpi-m2, bpi-m1, android, nas" />
<!-- CSS -->
<link href="../style/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection" />
<link href="../style/css/style.css" type="text/css" rel="stylesheet" media="screen,projection" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link rel="shortcut icon" type="image/ico" href="../images/logos/bpilogo.ico" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body class="white">
<!-- start of the header and drawer-------------------------------------------------------------------------------------------->
<!-- BREAK -->
<div class="navbar-fixed">
<nav class="white" role="navigation">
<div class="nav-wrapper">
<a id="logo-container" href="../index.html" style="margin-left:15px;" class="brand-logo black-text"><img
style="max-height:55px; margin-top:10px;" src="../images/logos/logo-home.png"></a>
<ul class="right hide-on-med-and-down">
<li><a class="dropdown-button waves-effect waves-light black-text" href="ic.html">
<hnav>电子料</hnav>
</a></li>
<li><a class="dropdown-button waves-effect waves-light black-text" href="#!">
<hnav>塑料类</hnav>
</a></li>
<!-- <li><a class="waves-effect waves-light black-text" href="blog.html"><hnav>博客</hnav></a></li> -->
<li><a class="waves-effect waves-light black-text" href="download.html">
<hnav>机构杂料类</hnav>
</a></li>
<li><a class="dropdown-button waves-effect waves-light black-text" href="shop.html">
<hnav>BPI产品</hnav>
</a></li>
</div>
</nav>
</div>
<!-- end of header and drawer------------------------------------------------------------------------------------------------->
<!-- the start of the main content--------------------------------------------------------------------------------------------->
<!-- main download area--------------------------------------------------------------------------------------------->
<div>
<nav style="box-shadow:none;" onLoad="myFunction3()">
<div class="nav-wrapper" style="background-color:#FFF;">
<ul id="nav-mobile" class="left hide-on-med-and-down" style="height:50px;">
<li><a id="ic" href="ic.html">IC类</a></li>
<li><a id="resistance" href="resistance.html">电阻</a></li>
<li><a id="capacitance" href="capacitance.html">电容</a></li>
<li><a id="diode" href="diode.html">二极管</a></li>
<li><a id="triode" href="triode.html">三极管</a></li>
<li><a id="mos" href="mos.html">场效应管MOS管</a></li>
<li><a id="inductance" href="inductance.html">电感类</a></li>
<li><a id="oscillator" href="oscillator.html">晶振类</a></li>
<li><a id="electroacoustic" href="electroacoustic.html">电声器件</a></li>
<li><a id="lcd" href="lcd.html">LCD类</a></li>
<li><a id="led" href="led.html">(背)光源</a></li>
<li><a id="motor" href="motor.html">电机/马达类</a></li>
<li><a id="ant" href="ant.html">待用(天线)</a></li>
<li><a id="camera" href="camera.html">摄像头</a></li>
<li><a id="fuse" href="fuse.html">保险丝</a></li>
<li><a id="pcb" href="pcb.html">PCB板类</a></li>
<li><a id="zebra" href="zebra.html">斑马纸</a></li>
<li><a id="key" href="key.html">按键/开关类</a></li>
<li><a id="socket" href="socket.html">插座/接插件类</a></li>
<li><a id="cable" href="cable.html">连接线</a></li>
<li><a id="power" href="power.html">电源类</a></li>
<li><a id="card" href="card.html">电脑软件/存储卡类</a></li>
</ul>
</div>
</nav>
</div>
<!-- InstanceBeginEditable name="overview" -->
<div class="navbar-fixed">
<div>
<div class="caption center-align">
<h4 class="light text-lighten-3">IC物料编码生成</h4>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="card">
<!-- 在这里添加 card 的内容 -->
<label for="typeSelect">选择主控类型:</label>
<select id="typeSelect" class="browser-default">
<option value="choose">点这里选择主控类型</option>
<option value="control-ic">主控类IC</option>
<option value="memory-ic">存储类IC</option>
<option value="power-ic">电源类IC</option>
<option value="connector-ic">接口类IC</option>
<option value="other-ic">其他类IC</option>
</select>
<div class="form-group row">
<div class="col">
<label for="valueInput">型号中的系列号:</label>
<input type="text" id="valueInput" class="form-control" placeholder="IC型号中的系列号"
onkeydown="handleKeyDown(event)">
</div>
<div class="col">
<label for="serialInput">流水号:</label>
<input type="text" id="serialInput" class="form-control" placeholder="IC流水号"
onkeydown="handleKeyDown(event)">
</div>
</div>
<div class="form-group">
<button onclick="convertValue()" class="btn btn-primary">转换</button>
</div>
<div class="form-group">
<p id="output" class="error-output">转换结果将在这里显示</p>
</div>
</div>
</div>
</div>
</div>
<!-- InstanceEndEditable -->
<!-- the end of the main content----------------------------------------------------------------------------------------------->
<!-- start of footer area-------------------------------------------------------------------------------------------------------------->
<!-- Scripts-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="style/js/materialize.js"></script>
<script src="style/js/init.js"></script>
<script>
$(document).ready(function () {
$("#ic").addClass("light-blue white-text bold");
});
function convertValue() {
const typeSelect = document.getElementById("typeSelect");
const valueInput = document.getElementById("valueInput");
const serialInput = document.getElementById("serialInput");
const outputElement = document.getElementById("output");
const valueType = typeSelect.value;
let inputValue = valueInput.value;
const serialValue = serialInput.value;
const errors = [];
try {
if (valueType === "choose") {
errors.push("请选择IC类型");
}
if (!isNumeric(inputValue) || (inputValue.length > 4 && /[a-zA-Z]/.test(inputValue))) {
errors.push("系列号错误");
}
if (!isNumeric(serialValue) || serialValue.length !== 3) {
errors.push("流水号错误");
}
if (errors.length > 0) {
throw new Error(errors.join(""));
}
let convertedValue;
if (valueType === "control-ic") {
convertedValue = "1100" + formatInputValue(inputValue) + serialValue;
} else if (valueType === "memory-ic") {
convertedValue = "1101" + formatInputValue(inputValue) + serialValue;
} else if (valueType === "power-ic") {
convertedValue = "1102" + formatInputValue(inputValue) + serialValue;
} else if (valueType === "connector-ic") {
convertedValue = "1103" + formatInputValue(inputValue) + serialValue;
} else if (valueType === "other-ic") {
convertedValue = "1109" + formatInputValue(inputValue) + serialValue;
}
outputElement.textContent = "转换结果:" + convertedValue;
} catch (error) {
outputElement.textContent = "错误:" + error.message;
}
}
function formatInputValue(inputValue) {
if (inputValue.length > 4) {
inputValue = inputValue.substring(0, 4);
} else {
while (inputValue.length < 4) {
inputValue = "0" + inputValue;
}
}
return inputValue;
}
function isNumeric(value) {
return /^\d+$/.test(value);
}
function handleKeyDown(event) {
if (event.key === "Enter") {
convertValue();
}
}
</script>
</body>
<!-- InstanceEnd -->
</html>