第10次修改了可删除可持久保存的前端html备忘录

news2024/9/23 23:30:25

第10次修改了可删除可持久保存的前端html备忘录

 

 

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>与妖为邻的备忘录</title>
    <style>
        * {
            /* 外边距: 上右下左 */
            margin: 0px 0px 0px 0px;
            /* 内边距: 上右下左 */
            padding: 0 0 0 0;
            /* 文本颜色 */
            color: #fff;
        }
        body {  background: #cfd1e1;
            /* 文本缩进 */
            text-indent: 5em;
            /* background: linear-gradient(0.25turn, #f7d6d6, #cacf80ac, #b7efea82); */
            /* background-image: url("file:///D:/%E5%9B%BE%E7%89%87/yyds.jpg");
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-size: 100% 100%; */
        }
        /* ********************背景颜色区**************************************** */
        /* 3D立体文本的样式 */
        dfn {
            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
        }
        /* 3D背景的样式 */
        .down-div,
        .finish,
        input,
        sub,
        button {
            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 2px 2px 3px rgba(255, 255, 255, 0.6),
                inset -2px -2px 3px rgba(0, 0, 0, 0.6);
            text-shadow: 1px 1px 1px #100000;
            border: 0;
            line-height: 30px;
            padding: 0 10px;
            border-radius: 10px;
        }
        /* 按钮凹进去的样式 */
        button:active,
        input:active {
            box-shadow:
                inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                inset 2px 2px 3px rgba(0, 0, 0, 0.6);
        }
        /* 背景颜色 */
        .up-button,
        sub,
        .updiv {
            background-color: #59f43aec;
        }
        button {
            background-color: #f4770a;
        }
        input {
            background-color: #f6d607;
        }
        input:hover,
        button:hover,
        .up-button3 {
            background-color: #ff0000fb;
        }
        .down-div {
            background-color: rgba(51, 154, 25, 0.502);
        }
        /* 鼠标变小手 */
        input,
        button {
            cursor: pointer;
        }
        /* ***********************h1-div区************************************* */
        .h-div {
            h1,
            p {
                display: inline;
                color: #000000;
            }
        }
        /* **********************up-div区************************************** */
        .up-div {
            /* 圆角 */
            border-radius: 10px;
            .up-button+input {
                width: 150px;
            }
            ;
            textarea {
                /* 文本对齐 居中*/
                text-align: center;
                /* 字体大小 */
                color: rgb(0, 0, 0);
                &::placeholder {
                    color: rgb(248, 0, 0);
                    /* 文本间隔 */
                }
            }
        }
        /* ***********************down-div************************************* */
        /* -设置checkbox样式----*/
        input[type="checkbox"] {
            -webkit-appearance: none;
            appearance: none;
            width: 25px;
            height: 25px;
            position: relative;
            margin-right: 10px;
            border-radius: 50%;
        }
        input[type="checkbox"]::after {
            content: "";
            width: 100%;
            height: 100%;
            border: 2px solid #f10505;
            position: absolute;
            left: -3px;
            top: -3px;
            border-radius: 50%;
        }
        /* 设置checkbox点击之后的样式*/
        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;
        }
        /* 选中文本样式 */
        .finish {
            /* text-decoration: line-through; */
            background: #000000;
        }
    </style>
</head>
<body>
    <div class="h-div">
        <h1>
            备忘录
            <dfn>(memorandum)</dfn>
        </h1>
        <p><sub>
                &lt;a href="输入网站地址" target="_blank"&gt;
                输入网站名称
                &lt;/a&gt;
            </sub>
        </p>
    </div>
    <div class="up-div">
        <textarea class="up-textarea" name="uptextarea" rows="2" cols="30%"
            placeholder="请选择txt、js、css或html文件,文件内容会被自动读取"></textarea>
        <button type="text" class="up-button">添加</button>
        <input type="file" name="inputfile" accept="text/plain, text/css, text/html, text/javascript, text/markdown"
            class="background3D" />
        <button><a href="https://www.baidu.com/s" target="_blank">百度一下</a></button>
        <button id="openButton">打开URL</button>
        <button id="up-button1" class="up-button3">对选择的进行删除</button>
    </div>
    </div>
    <hr>
    <div class="down-div">
    </div>
    <script>
        var uptext = document.querySelector(".up-textarea");
        var addto = document.querySelector(".up-button");
        var text = document.querySelector(".down-div");
        /*************添加事件*****************/
        addto.onclick = function () {
            inserhtml(uptext.value, '');
            // 添加后清空输入框
            uptext.value = '';
            // 焦点放回输入框
            uptext.focus();
            savetodo();
        }
        /*************savetodo函数****************/
        var savetodo = function () {
            let todoarr = [];
            let todojs = {};
            var econtent = document.querySelectorAll('.content');
            for (let index = 0; index < econtent.length; index++) {
                todojs.name = econtent[index].innerHTML;
                todojs.finish = econtent[index].classList.contains('finish');
                todoarr.push(todojs);
                todojs = {};
            }
            save(todoarr);
        }
        var loadtodo = function () {
            let todoarr = load();
            for (let index = 0; index < todoarr.length; index++) {
                inserhtml(todoarr[index].name, todoarr[index].finish ? 'finish' : '');
            }
        }
        /**********************本地持久储存(localStorage)函数*****************************/
        var save = function (arr) {
            /**JSON.stringify(arr) 先将数组转换为字符串   
             *localStorage.todos 然后将字符串保存到本地的todos中*/
            localStorage.todos = JSON.stringify(arr);
        }
        /**
         *读取函数,把todos转成数组
         *然后返回数组*/
        var load = function (arr) {
            var arr = JSON.parse(localStorage.todos);
            return arr;
        }
        /**********************按钮点击事件*****************************/
        text.onclick = function () {
            var tg = event.target;
            // 获取父元素下的所有子元素
            var tgkids = tg.parentElement.children;
            /*******************************对复选框的点击事件******************************/
            if (tgkids[0].checked) {
                tgkids[1].classList.add("finish");
            }
            else {
                tgkids[1].classList.remove("finish");
            }
            // 保存更改的样式
            savetodo();
            /*******************************对选择的进行删除********************************************/
            var Select = document.getElementById("up-button1");
            Select.onclick = function () {
                if (confirm("是否删除所选?")) {
                    var check = document.getElementsByName("checkbox");
                    for (var i = 0; i < check.length; i++) {
                        if (check[i].checked) {
                            check[i].parentElement.remove();
                            i--;
                            // 删除后保存
                            savetodo();
                        }
                    }
                }
            }
        }
        var inserhtml = function (val, cls) {
            text.insertAdjacentHTML("beforeend",
                `<div>
                    <input  type="checkbox" name='checkbox'>               
                    <span class='content ${cls}'>${val}</span>   
                </div>`
            )
        }
        loadtodo();
        /*****************************提示弹窗无需点击的函数**********************************************/
        function displayAlert(type, data, time) {
            var a = document.createElement("div");
            if (type == "success") {
                a.style.width = "200px";
                a.style.backgroundColor = "#009900";
            } else if (type == "error") {
                a.style.width = "280px";
                a.style.backgroundColor = "#990000";
            } else if (type == "info") {
                a.style.backgroundColor = " #e6b800";
                a.style.width = "600px";
            } else {
                return;
            }
            a.id = "lunbo";
            a.style.textAlign = "center";
            a.style.position = "absolute";
            a.style.height = "60px";
            a.style.marginLeft = "-100px";
            a.style.marginTop = "-30px";
            a.style.left = "30%";
            a.style.top = "5%";
            a.style.color = "white";
            a.style.fontSize = "25px";
            a.style.borderRadius = "20px";
            a.style.textAlign = "center";
            a.style.lineHeight = "60px";
            if (document.getElementById("") == null) {
                document.body.appendChild(a);
                a.innerHTML = data;
                setTimeout(function () {
                    document.body.removeChild(a);
                }, time);
            }
        }
        /**************************打开URL按钮的JavaScript******************************************/
        // 获取打开URL按钮元素
        var openBtn = document.getElementById("openButton");
        // 添加点击事件处理程序
        openBtn.addEventListener('click', function () {
            // 获取文件路径
            // 这里假设您已经有一个函数来获取文件路径,例如 prompt('请输入文件路径', 'D:/前端学习', '_blank');
            var filePath = prompt("请输入网站地址或者本地文件路径", "D:/前端学习");
            if (filePath) {
                // 使用window.location对象的assign()方法导航到指定文件
                // window.location.assign(filePath);
                // 或者使用window.open()方法打开新窗口导航到指定文件
                window.open(filePath);
            } else {
                displayAlert('info', '未提供有效的文件路径!', 1500);
                // alert("未提供有效的文件路径!");
            }
        });
        /**************************本地文件读取的函数******************************************/
        window.onload = function () {
            var text = document.getElementsByName('uptextarea')[0],
                inputFile = document.getElementsByName('inputfile')[0];
            //上传文件
            inputFile.onchange = function () {
                console.log(this.files);
                var reader = new FileReader();
                reader.readAsText(this.files[0], 'UTF-8');
                reader.onload = function (e) {
                    // urlData就是对应的文件内容
                    var urlData = this.result;
                    text.value = urlData;
                };
            };
        };
    </script>
</body>
</html>

 

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

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

相关文章

03_list

文章目录 list接口list的APIlistIterator方法subList方法 ArrayListArrayList的源码阅读 LinkedListVectorStack list接口 特点&#xff1a; List是Collection的子接口&#xff0c;是描述数据存储的接口数据结构表现为线性表&#xff0c;可以通过下标来操作存储数据有序可以存…

x-cmd pkg | frp - 内网穿透工具

简介 frp&#xff08;Fast Reverse Proxy&#xff09;是一个专注于内网穿透的高性能反向代理应用&#xff0c;可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。 它采用 C/S 模式&#xff0c;将服务端部署在具有公网 IP 的机器上&#xff0c;客户端部…

身份验证遇到问题,登陆ChatGPT时提示:“we ran into an issue while authenticating you…”

oops&#xff01; we ran into an issue while authenticating you, if this issue persists, please contact us through our help center at help.openai.com 说明&#xff1a;哎呀&#xff01;我们在验证您的身份时遇到了一个问题&#xff0c;如果这个问题仍然存在&#xff…

【Linux】【实战系列】10 分钟掌握日常开发中 Linux 网络处理相关命令

文章目录 lsofnetstatpingnslookupsshssh-keygenscpsftp 网络工具 curl网络工具 wget最后个人简介 hello&#xff0c;大家好&#xff0c;我是 Lorin&#xff0c;上一期和大家分享一期日常开发中常用的 Linux 文件和文本命令实战教学&#xff0c;这一期给大家带来常用的网络处理…

五、垃圾回收

1. 垃圾回收基础 1.1 什么是垃圾 简单说就是&#xff1a;内存中已经不再被使用到的内存空间就是垃圾。 1.2 如何判定是垃圾 1.2.1 引用计数法 引用计数法&#xff1a;给对象添加一个引用计数器&#xff0c;有访问就 1&#xff0c;引用失效就 -1 引用计数法的优缺点&#…

docker容器下php框架laravel的使用问题与解决方案

DB_CONNECTIONmysqlDB_HOSTlocalhost DB_CONNECTIONmysqlDB_HOSTdocker33-mysql-1 容器中只有数据库结构 进入MySQL容器内&#xff0c;创建表结构&#xff0c;添加数据 代码层面需要转换成数组 $query->get([*])->toArray(); 分页数据框架会返回带有data的数据&#xf…

【QT+QGIS跨平台编译】之六:【LZMA+Qt跨平台编译】(一套代码、一套框架,跨平台编译)

文章目录 一、lzma介绍二、文件下载三、文件分析四、pro文件五、编译实践一、lzma介绍 LZMA(Lempel-Ziv-Markov chain-Algorithm的缩写),是一个Deflate和LZ77算法改良和优化后的压缩算法。 libLzma是基于LZMA压缩算法封装的开源库。2001年被首次应用于7-Zip压缩工具中,是 …

vscode设置terminal的最大行数

今天跑代码出现一个问题&#xff0c;就是整个程序跑完&#xff0c;整个程序的输出信息过多&#xff0c;最开始输出的信息已经被vscode的缓存冲掉了&#xff0c;只能看到最后的一部分&#xff0c;具体的原因是vscode的terminal默认只能保存1000行的信息&#xff0c;所以如果想保…

C# 获取QQ会话聊天信息

目录 利用UIAutomation获取QQ会话聊天信息 效果 代码 目前遇到一个问题 其他解决办法 利用UIAutomation获取QQ会话聊天信息 效果 代码 AutomationElement window AutomationElement.FromHandle(get.WindowHwnd); AutomationElement QQMsgList window.FindFirst(Tr…

大模型实战营Day5笔记

大模型部署背景 大模型部署是指将训练好的模型在特定的软硬件环境中启动的过程&#xff0c;使模型能够接收输入并返回预测结果。大模型的内存开销巨大&#xff0c;7B模型仅权重需要14G内存。另外大模型是自回归生成&#xff0c;需要缓存Attention的 k/v。 LMDeploy 简…

HCIA——23DNS层次域名空间、域名服务器、域名解析的原理的选择、解答

学习目标&#xff1a; 计算机网络 1.掌握计算机网络的基本概念、基本原理和基本方法。 2.掌握计算机网络的体系结构和典型网络协议&#xff0c;了解典型网络设备的组成和特点&#xff0c;理解典型网络设备的工作原理。 3.能够运用计算机网络的基本概念、基本原理和基本方法进行…

Oracle 19c 配置并启用PDB数据库

一、问题发现 在Oracle 19c多租户环境中&#xff0c;默认情况下&#xff0c;使用startup命令启动数据库实例后&#xff0c;你会发现PDB数据库的状态为MOUNT状态,PDB不会随着CDB启动而启动。 二、查看当前使用的数据库类型 使用sqlplus以管理员身份登录数据库 sqlplus / as s…

Git教程-搭建服务器上GitBlit代码仓库(超详细)

在日常编码时&#xff0c;我常常会有将代码保存到云端的需求&#xff0c;因此我选择将 Git 安装在我的 云服务器上&#xff0c;通过在服务器上搭建 GitBlit 服务&#xff0c;配合本地使用 TortoiseGit 上传代码&#xff0c;实现跨设备的云端代码版本管理。本篇文章将介绍如何在…

Camera 基础知识

一、Camera 基础知识 1.1 Camera 工作原理 外部光线穿过镜头Lens 后&#xff0c; 经过 Color Filter 滤波后照射到CMOS Sensor 上&#xff0c; CMOS Sensor 将从 Lens 上传导过来的光线转换为电信号&#xff0c;再通过内部的AD模数转换&#xff0c;转换为数字信号。如果 Sens…

unity项目《样板间展示》开发:火焰和UI设计

第二章&#xff1a;火焰和UI设计 前言一、火焰模型管理灶台火焰壁炉火焰 二、电视机播放三、UI设计结语 前言 这次带大家从0到1做一个unity项目&#xff1a;《样板间展示》。 顾名思义&#xff0c;项目内容是展示样板间&#xff0c;即玩家可以与房间中的物体、家具进行交互。 至…

【网络安全 -> 防御与保护】信息安全概述

目录 一、信息安全现状及挑战 二、信息安全脆弱性及常见安全攻击 1、网络环境的开放性 2、协议栈的脆弱性及常见攻击 3、操作系统的脆弱性及常见攻击 4、终端的脆弱性及常见攻击 5、其他常见攻击 三、信息安全要素 四、整体安全解决方案 一、信息安全现状及挑战 &…

51单片机LED点阵屏

LED点阵屏 LED点阵屏是一种由许多小型LED灯组成的矩阵式显示屏。这些LED灯可以是单色、双色或全彩的&#xff0c;它们排列成行和列的网格&#xff0c;可以根据需要点亮来显示图像、文字或动画等内容。LED点阵屏广泛应用于户外广告牌、室内显示、交通信号灯、电子价格标签和其他…

gradle打包分离依赖jar

正常打包的jar是包含项目所依赖的jar包资源&#xff0c;而且大多数场景下的依赖资源是不会频繁的变更的&#xff0c;所以实际把项目自身jar和其所依赖的资源分离可以实现jar包瘦身&#xff0c;减小上传的jar包总大小&#xff0c;能实现加速部署的效果 一 原本结构 二 配置buil…

CSS 蜡烛效果

<template><view class="holder"><!-- 身子 --><view class="candle"><!-- 光源 --><view class="blinking-glow"></view><!-- 火星子 --><view class="thread"></view>…