修改了界面,优化电阻的选项和流水码

This commit is contained in:
Qubot 2023-07-05 18:04:35 +08:00
parent bacf645a87
commit d1886ecd15
9 changed files with 710 additions and 355 deletions

62
analyze.html Normal file
View File

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CSV文件上传和分析</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>CSV文件上传和分析</h1>
<input type="file" id="csvFileInput" accept=".csv">
<button onclick="handleFileUpload()">上传</button>
<table id="csvTable">
<thead>
<tr>
<th>BPI Code</th>
<th>Reference(s)</th>
<th>Value</th>
<th>Package</th>
<th>Qty</th>
<th>Footprint</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script>
function handleFileUpload() {
var fileInput = document.getElementById('csvFileInput');
var file = fileInput.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
var csvData = $.csv.toArrays(contents);
var tableBody = document.querySelector('#csvTable tbody');
tableBody.innerHTML = '';
for (var i = 0; i < csvData.length; i++) {
var rowData = csvData[i];
var row = document.createElement('tr');
for (var j = 0; j < rowData.length; j++) {
var cellData = rowData[j];
var cell = document.createElement('td');
cell.textContent = cellData;
row.appendChild(cell);
}
tableBody.appendChild(row);
}
};
reader.readAsText(file);
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/1.0.8/jquery.csv.min.js"></script>
</body>
</html>

View File

@ -12,10 +12,10 @@
<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="../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" />
<link rel="shortcut icon" type="image/ico" href="../images/logos/bpilogo.ico" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
@ -29,10 +29,10 @@
<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>
<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="#!">
<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="#!">
@ -100,36 +100,36 @@
<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>
<!-- 在这里添加 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="form-group">
<button onclick="convertValue()" class="btn btn-primary">转换</button>
</div>
<div class="form-group">
<p id="output" class="error-output">转换结果将在这里显示</p>
<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>
@ -151,69 +151,69 @@
});
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 = [];
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("系列号错误");
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;
}
}
if (!isNumeric(serialValue) || serialValue.length !== 3) {
errors.push("流水号错误");
function formatInputValue(inputValue) {
if (inputValue.length > 4) {
inputValue = inputValue.substring(0, 4);
} else {
while (inputValue.length < 4) {
inputValue = "0" + inputValue;
}
}
return inputValue;
}
if (errors.length > 0) {
throw new Error(errors.join(""));
function isNumeric(value) {
return /^\d+$/.test(value);
}
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);
}

378
ele/resistance.html Executable file
View File

@ -0,0 +1,378 @@
<!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" -->
<br><br><br>
<div class="navbar-fixed">
<div>
<div class="caption center-align">
<h4 class="light text-lighten-3">电阻物料编码生成</h4>
</div>
</div>
</div>
<div class="box">
<div class="card-container">
<div class="card">
<label for="typeSelect" class="label1">&nbsp;&nbsp;选择电阻类型:</label>
<select id="typeSelect" class="browser-default">
<option value="choose">点这里选择电阻类型</option>
<option value="general-re">普通电阻</option>
<option value="metal-re">金属膜电阻</option>
<option value="temp-re">热敏电阻</option>
<option value="lignt-re">光敏电阻</option>
<option value="other-re">其他类IC</option>
</select>
</div>
<div class="card">
<label for="valueInput" class="label1">&nbsp;&nbsp;阻值:</label>
<div class="col">
<input type="text" id="valueInput" class="form-control" placeholder="&nbsp;&nbsp;电阻阻值支持单位k,m,g及小于1的阻值"
onkeydown="handleKeyDown(event)">
</div>
</div>
<div class="card">
<label for="printSelect" class="label1">&nbsp;&nbsp;选择封装类型:</label>
<select id="printSelect" class="browser-default">
<option value="chooseprint">&nbsp;&nbsp;点这里选择封装类型</option>
<option value="dip-re">直插</option>
<option value="smd-re">贴片</option>
</select>
</div>
<div class="card">
<label for="serialSelect" class="label1">&nbsp;&nbsp;选择封装:</label>
<select id="serialSelect" class="browser-default">
<option value="chooseserial">&nbsp;&nbsp;点这里选择封装</option>
<option value="0201">0201</option>
<option value="0402">0402</option>
<option value="0603">0603</option>
<option value="0805">0805</option>
<option value="1206">1206</option>
<option value="1210">1210</option>
<option value="1812">1812</option>
<option value="2010">2010</option>
<option value="2512">2512</option>
</select>
</div>
<div class="card">
<label for="precisionSelect" class="label1">&nbsp;&nbsp;选择精度:</label>
<select id="precisionSelect" class="browser-default">
<option value="chooseprecision">&nbsp;&nbsp;点这里选择精度</option>
<option value="precision1">±1%</option>
<option value="precision5">±5%</option>
<option value="precision01">±0.1%</option>
</select>
</div>
</div>
<br>
<div class="form-group">
<center><button onclick="convertValue()" class="btn btn-primary">转换</button></center>
</div>
<br><br>
<div class="card">
<div class="form-group">
<p id="output" class="error-output">转换结果将在这里显示</p>
</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 () {
$("#resistance").addClass("light-blue white-text bold");
});
function convertValue() {
const typeSelect = document.getElementById("typeSelect");//电阻类型选择
const valueInput = document.getElementById("valueInput");//阻值选择
const printSelect = document.getElementById("printSelect");//直插贴片选择
const serialSelect = document.getElementById("serialSelect");//封装选择
const precisionSelect = document.getElementById("precisionSelect");//精度选择
const outputElement = document.getElementById("output");//输出
const valueType = typeSelect.value;//电阻类型
let inputValue = valueInput.value;//阻值类型
const printType = printSelect.value;//直插贴片类型
const serialType = serialSelect.value;//封装类型
const precisionType = precisionSelect.value;//精度类型
const errors = [];
try {
if (valueType === "choose") {
errors.push("请选择电阻类型");
}
if (valueType === "chooseprint") {
errors.push("请选择封装类型");
}
if (valueType === "chooseprecision") {
errors.push("请选择精度");
}
if (valueType === "chooseserial") {
errors.push("请选择封装");
}
//1%
if (precisionType == "precision1" && (serialType == "0201")) {
serialValue = "00";
} else if (precisionType == "precision1" && (serialType == "0402")) {
serialValue = "01";
} else if (precisionType == "precision1" && (serialType == "0603")) {
serialValue = "02";
} else if (precisionType == "precision1" && (serialType == "0805")) {
serialValue = "03";
} else if (precisionType == "precision1" && (serialType == "1206")) {
serialValue = "04";
} else if (precisionType == "precision1" && (serialType == "1210")) {
serialValue = "05";
} else if (precisionType == "precision1" && (serialType == "1812")) {
serialValue = "06";
} else if (precisionType == "precision1" && (serialType == "2010")) {
serialValue = "07";
} else if (precisionType == "precision1" && (serialType == "2512")) {
serialValue = "08";
}
//1%
if (precisionType == "precision5" && (serialType == "0201")) {
serialValue = "10";
} else if (precisionType == "precision5" && (serialType == "0402")) {
serialValue = "11";
} else if (precisionType == "precision5" && (serialType == "0603")) {
serialValue = "12";
} else if (precisionType == "precision5" && (serialType == "0805")) {
serialValue = "13";
} else if (precisionType == "precision5" && (serialType == "1206")) {
serialValue = "14";
} else if (precisionType == "precision5" && (serialType == "1210")) {
serialValue = "15";
} else if (precisionType == "precision5" && (serialType == "1812")) {
serialValue = "16";
} else if (precisionType == "precision5" && (serialType == "2010")) {
serialValue = "17";
} else if (precisionType == "precision5" && (serialType == "2512")) {
serialValue = "18";
}
//0.1%
if (precisionType == "precision01" && (serialType == "0201")) {
serialValue = "10";
} else if (precisionType == "precision01" && (serialType == "0402")) {
serialValue = "11";
} else if (precisionType == "precision01" && (serialType == "0603")) {
serialValue = "12";
} else if (precisionType == "precision01" && (serialType == "0805")) {
serialValue = "13";
} else if (precisionType == "precision01" && (serialType == "1206")) {
serialValue = "14";
} else if (precisionType == "precision01" && (serialType == "1210")) {
serialValue = "15";
} else if (precisionType == "precision01" && (serialType == "1812")) {
serialValue = "16";
} else if (precisionType == "precision01" && (serialType == "2010")) {
serialValue = "17";
} else if (precisionType == "precision01" && (serialType == "2512")) {
serialValue = "18";
}
if (errors.length > 0) {
throw new Error(errors.join(""));
}
if (printType === "dip-re") {
printValue = "1";
} else if (printType === "smd-re") {
printValue = "0";
}
let convertedValue;
if (valueType === "general-re") {
convertedValue = "1110" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "metal-re") {
convertedValue = "1111" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "temp-re") {
convertedValue = "1112" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "lignt-re") {
convertedValue = "1113" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "other-re") {
convertedValue = "1119" + res_namer(inputValue) + printValue + serialValue;
}
outputElement.textContent = "物料编码:" + convertedValue;
} catch (error) {
outputElement.textContent = "错误:" + error.message;
}
}
function res_namer(value_str) {
value_str = value_str.toLowerCase();
if (value_str.includes('k')) {
base = 1000;
} else if (value_str.includes('m')) {
base = 1000000;
} else if (value_str.includes('g')) {
base = 1000000000;
} else if (value_str.includes('r')) {
base = 1;
} else {
throw '错误的值';
}
value_flt = parseFloat(value_str);
inner_flt = value_flt * base;
if (inner_flt < 1 && inner_flt > 0) {
inner_flt = inner_flt * 10
code = "0" + inner_flt.toString().replace('.', '')+"0";
if (code.length == 3)
{
code = code + "0";
}
}
else if (inner_flt < 10 && inner_flt > 1) {
code = inner_flt.toString().replace('.', '');
} else {
code = inner_flt.toString().slice(0, 3) + (inner_flt.toString().length - 1);
}
return code;
}
function isNumeric(value) {
return /^\d+$/.test(value);
}
function handleKeyDown(event) {
if (event.key === "Enter") {
convertValue();
}
}
</script>
</body>
<!-- InstanceEnd -->
</html>

BIN
images/logos/ele.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

BIN
images/logos/screw.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

BIN
images/logos/shield.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 KiB

149
index.html Normal file
View File

@ -0,0 +1,149 @@
<!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 -->
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-76831844-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments) };
gtag('js', new Date());
gtag('config', 'UA-76831844-3');
</script>
</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="#!">
<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--------------------------------------------------------------------------------------------->
<!-- InstanceBeginEditable name="Main Content" -->
<!-- new column STEAM--------------------------------------------------------------------------->
<div style="background-color:#f5f5f5; margin-bottom:0px;">
<div class="container">
<div class="row">
<center>
<h4 style="padding-top:50px; margin-bottom:10px;">Banana Pi 物料生成系统</h4>
</div>
<div class="row">
<div class="col s12 m6 l4">
<div class="card medium">
<div class="card-image">
<img src="images/logos/ele.jpg">
<span class="card-title black-text" style="background-color:rgba(197,202,233,0.45)">电子类</span>
</div>
<div class="card-content">
<p>包括IC电阻电容二极管三极管MOS管电感晶振等等
</p>
</div>
<div class="card-action">
<a class="waves-effect waves-light btn centered" href="ele/ic.html"><i
class="material-icons right">label_outline</i>点击进入</a>
</div>
</div>
</div>
<div class="col s12 m6 l4">
<div class="card medium">
<div class="card-image">
<img src="images/logos/shield.png">
<span class="card-title black-text" style="background-color:rgba(197,202,233,0.45)">塑料类</span>
</div>
<div class="card-content">
<p>包括外壳等
</p>
</div>
<div class="card-action">
<a class="waves-effect waves-light btn centered" href="product.html"><i
class="material-icons right">label_outline</i>点击进入</a>
</div>
</div>
</div>
<div class="col s12 m6 l4">
<div class="card medium">
<div class="card-image">
<img src="images/logos/screw.jpg">
<span class="card-title black-text" style="background-color:rgba(197,202,233,0.45)">机构杂类</span>
</div>
<div class="card-content">
<p>包括螺丝垫圈等
</p>
</div>
<div class="card-action">
<a class="waves-effect waves-light btn centered" href="product.html"><i
class="material-icons right">label_outline</i>点击进入</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end of STEM --------------------------------------------------------------------------------->
<!-- 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>
</body>
<!-- InstanceEnd -->
</html>

View File

@ -1,269 +0,0 @@
<!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="#!">
<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">电阻物料编码生成</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="general-re">普通电阻</option>
<option value="metal-re">金属膜电阻</option>
<option value="temp-re">热敏电阻</option>
<option value="lignt-re">光敏电阻</option>
<option value="other-re">其他类IC</option>
</select>
<div class="form-group row">
<div class="col">
<label for="valueInput">阻值:</label>
<input type="text" id="valueInput" class="form-control" placeholder="电阻阻值支持单位k,m,g及小于1的阻值"
onkeydown="handleKeyDown(event)">
</div>
<br><br>
<br><br>
<label for="printSelect">选择封装类型:</label>
<select id="printSelect" class="browser-default">
<option value="chooseprint">点这里选择封装类型</option>
<option value="dip-re">直插</option>
<option value="smd-re">贴片</option>
</select>
<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 () {
$("#resistance").addClass("light-blue white-text bold");
});
function convertValue() {
const typeSelect = document.getElementById("typeSelect");
const valueInput = document.getElementById("valueInput");
const printSelect = document.getElementById("printSelect");
const serialInput = document.getElementById("serialInput");
const outputElement = document.getElementById("output");
const valueType = typeSelect.value;
let inputValue = valueInput.value;
const printType = printSelect.value;
const serialValue = serialInput.value;
const errors = [];
try {
if (valueType === "choose") {
errors.push("请选择电阻类型");
}
if (valueType === "choose") {
errors.push("请选择封装类型");
}
if (!isNumeric(serialValue) || serialValue.length !== 2) {
errors.push("流水号错误");
}
if (errors.length > 0) {
throw new Error(errors.join(""));
}
if (printType === "dip-re") {
printValue = "1" ;
} else if (printType === "smd-re") {
printValue = "0" ;
}
let convertedValue;
if (valueType === "general-re") {
convertedValue = "1110" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "metal-re") {
convertedValue = "1111" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "temp-re") {
convertedValue = "1112" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "lignt-re") {
convertedValue = "1113" + res_namer(inputValue) + printValue + serialValue;
} else if (valueType === "other-re") {
convertedValue = "1119" + res_namer(inputValue) + printValue + serialValue;
}
outputElement.textContent = "转换结果:" + convertedValue;
} catch (error) {
outputElement.textContent = "错误:" + error.message;
}
}
function res_namer(value_str) {
value_str = value_str.toLowerCase();
if (value_str.includes('k')) {
base = 1000;
} else if (value_str.includes('m')) {
base = 1000000;
} else if (value_str.includes('g')) {
base = 1000000000;
} else if (value_str.includes('r')) {
base = 1;
} else {
throw '错误的值';
}
value_flt = parseFloat(value_str);
inner_flt = value_flt * base;
if (inner_flt < 1 && inner_flt > 0) {
inner_flt=inner_flt*10
code = "0"+"R"+inner_flt.toString().replace('.', '');
}
else if (inner_flt < 10 && inner_flt > 1) {
code = inner_flt.toString().replace('.', '');
} else {
code = inner_flt.toString().slice(0, 3) + (inner_flt.toString().length - 1);
}
return code;
}
function isNumeric(value) {
return /^\d+$/.test(value);
}
function handleKeyDown(event) {
if (event.key === "Enter") {
convertValue();
}
}
</script>
</body>
<!-- InstanceEnd -->
</html>

View File

@ -120,3 +120,38 @@ footer.page-footer {
.box {
border: 1px solid #ccc; /* 添加包含层的边框样式 */
padding: 20px; /* 添加包含层的内边距 */
width: 80%; /* 设置包含层的宽度为父容器的80% */
margin: 0 auto; /* 水平居中 */
border-radius: 10px; /* 设置圆角大小 */
box-shadow: 2px 8px 20px rgba(0, 0, 0, 0.2);
}
.card-container {
display: flex;
}
.card {
border-radius: 10px; /* 设置圆角大小 */
flex: 1;
margin-right: 20px;
padding:20px;
}
.card:last-child {
margin-right: 0;
}
.label1 {
font-size: 15px;
color:#e63d3d
}
.form-group {
padding-left:20px;
}