Skip to main content

✅Bar-Gen.php

Here's a page that helps you convert text into a Bar code that can be scanned.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Text2BarCode Gen</title>
    <!-- 引入条形码生成器 -->
    <script src="https://cdn.jsdelivr.net/jsbarcode/3.3.7/JsBarcode.all.min.js"></script>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=0.8">
    <style>
        @media (max-width: 980px) {
          body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #007eca;
          }
        }
        @media (min-width: 981px) {
          body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #007eca;
            background-image: url("https://dl.itslittlekevin.com/projects/5069.png");
            background-repeat: no-repeat;
            background-position: right center;
            background-size: auto 100%;
          }
        }
        h1, p, h4 {
          text-shadow: 2px 2px 2px #00000055;
        }
        * {
            color: white;
        }
        #input-container, #btn-container {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 20px;
        }
        input[type="text"] {
            color: black;
            margin: 10px;
            border-radius: 5px;
            padding: 5px 15px
        }
        h4 a {
            text-decoration: none;
        }
        #barcode,#btn-container {
            display: none;
        }
        button {
            font-size: 15px;
            background-color: #00325565;
            padding: 5px 15px;
            border-radius: 5px;
            border-width: 0px;
            margin: 5px;
            cursor: pointer;
        }
        #refresh-btn {
            margin-left: 10px;
        }
        /* 添加间距 */
        .spacer {
            height: 55px;
        }
    </style>
</head>
<body>
    <h1 align="center">条形码生成器 <br> BarCode Generator</h1>
    <div id="input-container">
        <input type="text" placeholder="输入文本/Input Your Text" id="text-input">
        <div style="height:10px;"></div> <!-- 添加间距 -->
        <button onclick="generateBarCode()">生成 | Generate</button>
    </div>
    <svg id="barcode"></svg>
    <!-- 添加间距 -->
    <div class="spacer"></div>
    <div id="btn-container">
        <button id="refresh-btn" onclick="refresh()"> 刷新 | Clear </button>
    </div>
    <h4><a href="https://itslittlekevin.com/gadgetslist">»返回工具列表 | Return to Gadgets List«</a></h4>
    <p>© itsLittleKevin · All rights reserved.</p>
    <script>
        var inputContainer = document.querySelector("#input-container");
        var barcodeContainer = document.querySelector("#barcode");
        var btnContainer = document.querySelector("#btn-container");
        var textInput = document.querySelector("#text-input");

        function generateBarCode() {
            if (textInput.value) {
                JsBarcode("#barcode", textInput.value);
                inputContainer.style.display = "none";
                barcodeContainer.style.display = "block";
                btnContainer.style.display = "flex";
            }
        }

        function refresh() {
            textInput.value = "";
            inputContainer.style.display = "flex";
            barcodeContainer.style.display = "none";
            btnContainer.style.display = "none";
            barcodeContainer.innerHTML = '';
        }
    </script>
</body>
</html>