HTML5本地存储账号密码

news2024/10/6 14:31:08

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML5本地存储账号密码</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        /* 文本禁止选中: none; */
        user-select: none;
    }
    body {
        background-color: #144756;
    }
    ::placeholder {
        color: #ff9f05;
        text-shadow: 1px 1px 1px #100000;
    }
    button {
        /* 鼠标移入变小手 */
        cursor: pointer;
    }
    button,
    input {
        border: none;
        outline: none;
        height: 32px;
        font-size: 20px;
        background-color: green;
        padding: 0 10px;
    }
    /* 标题开始 */
    .header_title {
        position: fixed;
        top: 160px;
        left: 80px;
        width: 140px;
        height: 66px;
        border-radius: 50%;
        img {
            float: left;
            width: 66px;
            height: 66px;
            border-radius: 50%;
            transition: transform 0.3s ease;
            &:hover {
                transform: scale(1.2);
            }
        }
        h2 {
            background-image: linear-gradient(to top left,
                    rgba(0, 0, 0, 0.2),
                    rgba(0, 0, 0, 0.2) 30%,
                    rgba(0, 0, 0, 0));
            box-shadow: inset 4px 4px 4px rgba(255, 255, 255, 0.6),
                inset -4px -4px 5px rgba(0, 0, 0, 0.6);
            text-shadow: 0px 1px 0px #999,
                0px 2px 0px #888,
                0px 3px 0px #777,
                0px 4px 0px #666,
                0px 5px 0px #555,
                0px 6px 0px #444,
                0px 7px 0px #333,
                0px 8px 7px #001135;
            /* letter-spacing: -8px; */
            color: #ffffff;
            background-color: #f30303;
            border-radius: 50%;
            background-image: linear-gradient(to top left,
                    rgba(0, 0, 0, 0.2),
                    rgba(0, 0, 0, 0.2) 30%,
                    rgba(0, 0, 0, 0));
            box-shadow: inset 4px 4px 4px rgba(255, 255, 255, 0.6),
                inset -4px -4px 5px rgba(0, 0, 0, 0.6);
            border: 0px solid black;
        }
    }
    /* 标题结束 */
    /* 查看按钮开始 */
    .search_text {
        position: relative;
        top: 2px;
        left: 345px;
        /* 首页按钮 开始*/
        .home_page {
            position: absolute;
            top: 0px;
            left: -200px;
            background-color: #4CAF50;
            color: white;
            border: 1px solid #4CAF50;
            &:hover {
                background-color: #ddd;
                color: rgb(245, 5, 5);
            }
        }
        a {
            font-size: 22px;
            float: left;
            margin: 0 15px;
            text-decoration: none;
            transition: background-color .3s;
            border: 1px solid #ddd;
            color: rgb(252, 232, 130);
            &:hover:not(.home_page) {
                background-color: #ddd;
                font-size: 26px;
                color: rgb(255, 255, 255);
            }
        }
        /* 首页按钮 结束*/
        input {
            border-radius: 50px;
            z-index: 5;
            box-shadow: 0px 0px 24px rgba(253, 253, 253, 0.333);
        }
        button {
            position: absolute;
            top: 0.5px;
            left: 203px;
            height: 30px;
            border-radius: 0 50px 50px 0;
            background-color: rgb(255, 0, 0);
            color: #ffffff;
            &:hover {
                background-color: rgb(7, 7, 7);
                color: #ff0101;
            }
            &:active {
                background-color: rgba(255, 209, 3, 0.986);
                color: #fcf9f9;
                box-shadow: inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                    inset 2px 2px 3px rgba(0, 0, 0, 0.6);
            }
        }
        span {
            color: #fffdfd;
            text-shadow: 1px 1px 1px #100000;
        }
    }
    /* 查看按钮结束 */
    /* 显示查看开始 */
    #find_result {
        position: relative;
        top: 2px;
        left: 345px;
        text-shadow: 1px 1px 1px #100000;
        color: #fff;
        span {
            border-radius: 50px;
            user-select: text;
            color: rgb(254, 255, 254);
            padding: 0 10px;
            background-color: rgb(255, 0, 0);
            font-size: 26px;
        }
    }
    /* 显示查看结束 */
    /* 新增输入框开始 */
    .userform {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 40px;
        left: 30px;
        input:nth-child(1) {
            border-radius: 48px 48px 0 0;
            box-shadow: 0px -8px 24px rgba(255, 255, 255, 0.333);
        }
        input:nth-child(2) {
            position: relative;
            top: 0px;
            left: -25px;
            border-radius: 50px;
            &::placeholder {
                position: relative;
                top: 0px;
                left: 25px;
            }
            background-color: rgba(1, 112, 1, 0.219);
        }
        input:nth-child(3) {
            border-radius: 0 0 48px 48px;
            box-shadow: 0px 8px 24px rgba(255, 255, 255, 0.333);
        }
        input {
            padding: 16px 52px 16px 35px;
            border: none;
            outline: none;
            width: 100%;
            font-size: 16px;
            color: #fffafa;
            background: linear-gradient(to right, rgba(0, 128, 0, 0.292), green);
        }
        button {
            position: absolute;
            top: 0px;
            left: 200px;
            width: 95px;
            height: 95px;
            padding: 2px;
            border-radius: 50%;
            font-size: 60px;
            background-color: green;
            box-shadow: 8px 0px 24px rgba(255, 255, 255, 0.333);
            &:hover {
                background-color: #0c333f;
                color: #ffffff;
            }
            &:active {
                background-color: rgba(255, 209, 3, 0.986);
                color: #fcf9f9;
                box-shadow: inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                    inset 2px 2px 3px rgba(0, 0, 0, 0.6);
            }
            .plus {
                display: block;
                width: 100%;
                height: 100%;
                background: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
                background-size: 50% 2px, 2px 50%;
                background-position: center;
                background-repeat: no-repeat;
            }
        }
        button::before {
            content: "";
            position: absolute;
            top: 0px;
            left: -220px;
            width: 100%;
            height: 100%;
            background-color: rgb(1, 84, 1);
            border-radius: 50%;
            z-index: -1;
            box-shadow: -8px 0px 24px rgba(255, 255, 255, 0.333);
        }
    }
    /* 新增输入框结束 */
    /* 表格样式开始 */
    #list {
        table {
            position: relative;
            top: 3px;
            left: 345px;
            text-shadow: 1px 1px 1px #100000;
            color: #ffffff;
            td {
                text-align: center;
                font-size: 20px;
                button {
                    background-color: #0c333f;
                    border-radius: 50%;
                    color: #ffffff;
                    cursor: no-drop;
                }
                input {
                    background-color: #0c333f;
                    /* 鼠标移入变小手 */
                    cursor: pointer;
                }
                ;
            }
            th:nth-child(3n),
            td:nth-child(3n) {
                display: none;
            }
        }
        td:nth-child(2n) {
            /*文本可以选中复制*/
            user-select: text;
            color: green;
            padding: 0 10px;
        }
        button,
        input {
            border: none;
            outline: none;
            height: 32px;
            font-size: 20px;
            background-color: green;
            padding: 0 10px;
        }
        button {
            background-color: rgba(255, 0, 0, 0.064);
            color: #ff0101;
            text-shadow: 1px 1px 1px #100000;
            /* 粗字体 */
            font-weight: bold;
            &:hover {
                background-color: rgb(255, 0, 0);
                color: #ffffff;
            }
            &:active {
                background-color: rgba(255, 209, 3, 0.986);
                color: #fcf9f9;
                box-shadow: inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                    inset 2px 2px 3px rgba(0, 0, 0, 0.6);
            }
        }
        td input {
            &:hover {
                background-color: rgb(7, 7, 7);
                color: #ff0101;
            }
            &:active {
                background-color: rgba(255, 209, 3, 0.986);
                color: #fcf9f9;
                box-shadow: inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                    inset 2px 2px 3px rgba(0, 0, 0, 0.6);
            }
        }
        /* 表格样式结束 */
    }
    /* 复选框样式开始 */
    input[type="checkbox"] {
        margin: 0px 10px;
        -webkit-appearance: none;
        appearance: none;
        width: 25px;
        height: 25px;
        position: relative;
        border-radius: 50%;
    }
    input[type="checkbox"]::after {
        content: "";
        width: 100%;
        height: 100%;
        border: 2px solid #e9f504;
        position: absolute;
        left: -3px;
        top: -3px;
        border-radius: 50%;
    }
    /* 设置复选框点击之后的样式*/
    input[type="checkbox"]:checked::after {
        height: 15px;
        width: 25px;
        border-top: none;
        border-right: none;
        border-radius: 0;
        transform: rotate(-45deg);
        transition: all 0.5s ease-in-out;
    }
    /* 设置复选框点击之后的样式结束*/
    /* 复选框样式结束 */
</style>
<body>
    <div class="header_title">
        <img src="file:///D:\My homepage\img\jpg\tuzi3.jpg" alt="与妖为邻">
        <h2>账号</h2>
        <h2>密码</h2>
    </div>
    <div>
        <form class="search_text" onsubmit="findOne(event)" action="#">
            <a href="file:///C:\Users\90917\Desktop\备忘录.html" class="home_page">首页</a>
            <input type="text" id="search_site" name="search_site" placeholder="请输入账号查看密码" />
            <button onclick="findOne()">查看</button> <span>提示:有个问题是账号和密码一样才能删除。虽然有点乱,但也记录了很多新知识</span>
        </form>
        <hr />
        <p id="find_result">
        </p>
        <hr />
        <form class="userform" action="#">
            <input type="text" id="keyname" name="keyname" class="text" placeholder="请输入账号" />
            <input type="password" id="sitename" name="sitename" class="text" placeholder="请输入密码" />
            <input type="text" id="siteurl" name="siteurl" placeholder="请输入说明" />
            <button onclick="save()"> <i class="plus"></i></button>
        </form>
    </div>
    <div id="list">
    </div>
    <script>
        //保存数据  
        userAll();
        function save() {
            var site = new Object;
            site.keyname = document.getElementById("keyname").value;
            site.sitename = document.getElementById("sitename").value;
            site.siteurl = document.getElementById("siteurl").value;
            var tode = JSON.stringify(site); //将对象转换为JSON字符串
            localStorage.setItem(site.keyname, tode);
            // alert("保存成功");
            userAll();
            // 清空输入框
            document.getElementById("keyname").value = "";
            document.getElementById("sitename").value = "";
            document.getElementById("siteurl").value = "";
        }
        //查询数据    
        function findOne(event) {
            event.preventDefault(); // 阻止表单提交
            var search_site = document.getElementById("search_site").value;
            var siteurl = localStorage.getItem(search_site);
            var site = JSON.parse(siteurl);
            var find_result = document.getElementById("find_result");
            find_result.innerHTML = '<span>' + search_site + '</span>' + "的密码是:" + '<span>' + site.sitename + '</span>';
        }
        //显示数据
        function userAll() {
            var list = document.getElementById("list");
            if (localStorage.length > 0) {
                var result = "<table border='1'>";
                result += "<tr><th>序号</th><th>账号</th><th>密码</th><th>说明</th><th> <button id='delete'>删除</button></th></tr>";
                for (var i = 0; i < localStorage.length; i++) {
                    var keyname = localStorage.key(i);
                    var tode = localStorage.getItem(keyname);
                    try {
                        var site = JSON.parse(tode);
                        result += "<tr>" +
                            "<td>" + '<button>' + (i + 1) + '</button>' + "</td>" +
                            "<td>" + site.keyname + "</td>" +
                            "<td>" + site.sitename + "</td>" +
                            "<td>" + site.siteurl + "</td>" +
                            "<td> <input type='checkbox' name='checkbox'></td>" +
                            "</tr>";
                    } catch (e) {
                        console.error("Error parsing JSON for key: " + keyname, e);
                    }
                }
                result += "</table>";
                list.innerHTML = result;
                document.body.innerHTML = document.body.innerHTML.replace(/undefined/ig, "<span style='color: red; font-size: 10px;'>$&</span>");
            } else {
                list.innerHTML = "数据为空...";
            }
            // 重新绑定删除按钮事件
            var deleteBtn = document.getElementById("delete");
            deleteBtn.onclick = function () {
                if (confirm("是否删除所选?")) {
                    var checkboxes = document.getElementsByName("checkbox");
                    for (var i = 0; i < checkboxes.length; i++) {
                        if (checkboxes[i].checked) {
                            var keyname = checkboxes[i].parentNode.previousElementSibling.previousElementSibling.textContent;
                            localStorage.removeItem(keyname);
                            checkboxes[i].parentNode.parentNode.parentNode.removeChild(checkboxes[i].parentNode.parentNode);
                            // i--;
                            i = i - 1; // 恢复到之前的索引
                        }
                    }
                    userAll();
                }
            };
            // 重新绑定删除按钮事件结束
        };
    </script>
</body>
</html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1638563.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言/数据结构——每日一题(合并两个有序链表)

一.前言 嗨嗨嗨&#xff0c;大家好久不见&#xff01;今天我在LeetCode看到了一道单链表题&#xff1a;https://leetcode.cn/problems/merge-two-sorted-lists想着和大家分享一下&#xff0c;废话不多说&#xff0c;让我们开始今天的题目分享吧。 二.正文 1.1题目描述 1.2题…

2.2 Java全栈开发前端+后端(全栈工程师进阶之路)-前端框架VUE3-基础-Vue基本语法

文本渲染指令 文本渲染指令-v-html与v-text Vue使用了基于HTML的模板语法&#xff0c;允许开发者声明式地将DOM绑定至底层Vue实例的数据。所有Vue的模板都是 合法的HTML&#xff0c;所以能被遵循规范的浏览器和HTML解析器解析。 在前面&#xff0c;我们一直使用的是字符串插…

利用STM32实现语音识别功能

引言 随着物联网和智能设备的普及&#xff0c;语音识别技术正逐渐成为用户交互的主流方式之一。 STM32微控制器具备处理高效率语音识别算法的能力&#xff0c;使其成为实现低成本、低功耗语音交互系统的理想选择。 本教程将介绍如何在STM32平台上开发和部署一个基础的语音识…

创建codereview

创建codereview流程 一、开始创建二、选择分支三、添加细节 一、开始创建 点击codereivew按钮 为新的codereview选择一个工程后点击create review 二、选择分支 选择目标分支和要比对的分支&#xff0c;比如develop 三、添加细节 Add branch后&#xff0c;可以继续Edit …

Linux深入学习内核 - 中断与异常(下)

软中断&#xff0c;Tasklet和Work Queue 由内核执行的几个任务之间有一些不是紧急的&#xff0c;他们可以被延缓一段时间&#xff01;把可延迟的中断从中断处理程序中抽出来&#xff0c;有利于使得内核保持较短的响应时间&#xff0c;所以我们现在使用以下面的这些结构&#x…

JVM的垃圾回收机制(GC机制)

在Java代码运行的过程中&#xff0c;JVM发现 某些资源不需要再使用的时候&#xff0c;就会自动把资源所占的内存给回收掉&#xff0c;就不需要程序员自行操作了。“自动回收资源”就是JVM的“垃圾回收机制”&#xff0c;“垃圾回收机制”也称"GC机制"。 对于Java代码…

文心一言 VS 讯飞星火 VS chatgpt (250)-- 算法导论18.2 3题

三、请说明如何在一棵 B 树中找出最小关键字&#xff0c;以及如何找出某一给定关键字的前驱。如果要写代码&#xff0c;请用go语言。 文心一言&#xff1a; 在B树&#xff08;也称为B-tree&#xff09;中&#xff0c;最小的关键字总是位于最左边的叶子节点的最左边的元素。要…

C++ | 类和对象(中) (构造函数 | 析构函数 | 拷贝构造函数 | 赋值运算符重载 | 取地址 | const取地址)

目录 默认成员函数 构造函数 构造函数是什么 构造函数特征 什么是默认构造函数 注意事项 编译器自动生成的默认构造 缺省值 对象如何传值给构造函数 初始化列表 析构函数 析构函数的特征 编译器默认生成的析构函数 总结 拷贝构造函数 拷贝构造函数的使用场景 拷…

MySQL数据库练习(13)

schooldb库——utf8字符集——utf8_general_ci排序规则 61. DDL CREATE TABLE settlements (settlementId int(11) NOT NULL AUTO_INCREMENT COMMENT 自增ID,settlementNo varchar(20) NOT NULL COMMENT 结算单号,settlementType tinyint(4) NOT NULL DEFAULT 0 COMMENT 结算…

金融案例:统一查询方案助力数据治理与分析应用更高效、更安全

随着企业数据规模的增长和业务多元化发展&#xff0c;海量数据实时、多维地灵活查询变成业务常见诉求。同时多套数据库系统成为常态&#xff0c;这既带来了数据管理的复杂性&#xff0c;又加大了数据使用的难度&#xff0c;面对日益复杂的数据环境和严格的数据安全要求&#xf…

Centos7 安装Git、使用

Centos7 安装Git 一、安装步骤1.1 查看版本1.2 卸载1.3 安装 二、创建仓库2.1 新增仓库2.2 新增配置项 三、管理文件3.1 文件创建3.2 文件修改、add、commit3.3 tree结构探索 四、分支4.1 创建分支&#xff1a;4.2 查看分支4.3 切换分支4.4 删除分支4.5 合并冲突 一、安装步骤 …

【蓝桥杯嵌入式】第七届省赛 - 模拟液位检测告警系统

代码开源&#xff0c;Gitee自取 代码开源&#xff0c;Gitee自取 代码开源&#xff0c;Gitee自取 目录 0 前言 1 展示 1.1 源码 1.2 演示视频 1.3 题目展示 2 工程配置 3 资源配置&代码实现 3.1 定时器 3.2 液位检测 3.3 液位阈值设定 3.4 液位阈值设定 3.5 串…

使用unreal engine5.3.2创建c++第一人称游戏

UE5系列文章目录 文章目录 UE5系列文章目录前言一、NuGet 简介二、解决方法&#xff1a; 前言 为了使用unreal engine5.3.2创建c第一人称游戏&#xff0c;今天安装了Visual Studio 2022专业版。在ue5中创建c工程&#xff0c;结果编译器报错&#xff1a; 严重性 代码 说明 项目…

UDP和TCP(传输层)

这里写目录标题 UDPUDP的基本特点UDP协议报文格式 TCPTCP协议报文格式TCP特点可靠传输实现机制确认应答超时重传数据丢了应答报文丢了 小结 UDP UDP的基本特点 无连接不可靠传输面向数据报全双工 UDP协议报文格式 2个字节有效范围(无符号): 0 ~ 65535(2^16 - 1). 2个字节有效范…

Web开发:<div>作用

< div >元素作用 解释用途1. 布局&#xff1a;2. 样式化&#xff1a;3. 结构化&#xff1a;4. JavaScript操作&#xff1a;5. 响应式设计&#xff1a;6. 模块化和重用&#xff1a;7. 包裹其他元素&#xff1a;8. 清除浮动&#xff1a; 总结举例示例结果分析 解释 在Web开…

全栈开发之路——前端篇(1)介绍、框架确定、ide设置与项目创建

文章目录 前言一、前端框架React和VueReactVue 二、编译器选择和配置1.传统的下载和使用2.你可能遇到的问题1.ERR&#xff01; syscall mkdir2.vue : File C:\nodejs\node_global\vue.ps1 cannot be loaded because running scripts is disabled on3.出现乱码问题 3.运行Vue 三…

模型智能体开发之metagpt-单智能体实践

需求分析 根据诉求完成函数代码的编写&#xff0c;并实现测试case&#xff0c;输出代码 代码实现 定义写代码的action action是动作的逻辑抽象&#xff0c;通过将预设的prompt传入llm&#xff0c;来获取输出&#xff0c;并对输出进行格式化 具体的实现如下 定义prompt模版 …

python算法题

需求 代码 class Solution:def searchInsert(self, nums: List[int], target: int) -> int:if max(nums) >target:for i in range(len(nums)-1):if nums[i1] > target and nums[i] <target:return i1if max(nums) <target:return len(nums)if min(nums) > …

解析transformer中的各模块结构

transformer是一种编解码&#xff08;encoder-decoer&#xff09;结构&#xff0c;用于自然语言处理、计算机视觉等领域&#xff0c;编解码结构是当前大模型必包含的部分。 文章目录 1. 词嵌入模块 2.位置编码模块 3. 多头注意力机制模块 3.1 自注意力机制模块 3.2 多头注…

Golang图片验证码的使用

一、背景 最近在使用到Golang进行原生开发&#xff0c;注册和登录页面都涉及到图片验证码的功能。找了下第三方库的一些实现&#xff0c;发现了这个库用得还是蛮多的。并且支持很多类型的验证方式&#xff0c;例如支持数字类型、字母类型、音频验证码、中文验证码等等。 项目地…