第14次修改了可删除可持久保存的前端html备忘录:增加一个翻牌钟,修改背景主题:现代深色

第14次修改了可删除可持久保存的前端html备忘录:增加一个翻牌钟,修改背景主题:现代深色

 

备忘录代码 

 

<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      list-style-type: none;
      padding: 0;
      margin: 0;
    }
    .h-div {
      display: flex;
   /* 两个之间间距 */
   gap: 60px;
    }
    /* **************************备忘录********************************** */
    textarea {
      font-size: 20px;
      &::placeholder {
        color: rgb(248, 0, 0);
        font-size: 12px;
      }
    }
    h1 {
      text-indent: 10em;
      /* 行高
         */
      line-height: 2em;
      /* 行内转块:display:block; 
      *块、行内元素转换行内块:display:inline-block;
      *块级元素转行内元素 ;
      display: inline;*/
    }
    sub {
      /* 外边距: 上右下左 */
      margin: 0px 40px 0px 20px;
    }
    .down-div {
      text-indent: 2em;
    }
    .delete {
      color: #ff0101;
      /* 靠右 */
      float: right;
    }
    .finish {
      /* 删除线 
              text-decoration: line-through; */
      /* 下划线 */
      text-decoration: underline;
      text-decoration-color: rgb(255, 0, 0);
      background-color: rgb(220, 226, 241);
      color: rgb(253, 250, 250);
      text-shadow: 1px 1px 1px #030303;
      box-shadow:
        inset -2px -2px 3px rgba(255, 255, 255, 0.6),
        inset 2px 2px 3px rgba(0, 0, 0, 0.6);
    }
    /* **************************翻牌时钟********************************** */
    .show {
      width: 200px;
      height: 75px;
      /* margin: 0px auto; */
      position: relative;
      color: #ff0000;
    }
    .time {
      display: flex;
      flex: 1;
      font-size: 40px;
      text-align: center;
      line-height: 75px;
      padding: 0 10px;
      overflow: hidden;
      position: absolute;
      top: 0px;
      left: 5px;
      right: 5px;
    }
    .beforeTime {
      z-index: 100;
    }
    .time li:nth-child(2n) {
      flex: 1;
    }
    .time li:nth-child(2n+1) {
      flex: 4;
      /* background-color: #3b3d3b; */
      position: relative;
      height: 50px;
      line-height: 50px;
      margin: auto 0px;
      /* border-radius: 10px; */
      /* box-shadow: 0 0 10px 3px white; */
    }
    .time li:nth-child(2n+1) .upBox,
    .time li:nth-child(2n+1) .downBox {
      position: absolute;
      left: 0;
      right: 0;
      /* overflow: hidden; */
      /* 删除线 */
      text-decoration: line-through;
      text-decoration-color: rgb(69, 63, 63);
    }
    .time li:nth-child(2n+1) .upBox {
      top: 0;
      bottom: 50%;
      box-sizing: border-box;
      /* border-bottom: solid 3px #3b3d3b; */
      background-color: #3b3d3b;
      transform-origin: bottom;
      border-radius: 5px 5px 0 0;
    }
    .time li:nth-child(2n+1) .downBox {
      top: 50%;
      bottom: 0;
      line-height: 0;
      box-sizing: border-box;
      background-color: #3b3d3b;
      overflow: hidden;
      transform-origin: top;
      border-radius: 0 0 5px 5px;
    }
  </style>
</head>
<body>
  <!-- ------------------------翻牌时钟--------------------------- -->
  <div class="h-div">
    <div class="h1-div">
      <h1>
        备忘录
        <dfn>(memo)</dfn>
      </h1>
    </div>
    <div class="show">
      <ul class="time">
        <li>
          <div class="upBox beforeTime"></div>
          <div class="downBox beforeTime"></div>
          <div class="upBox afterTime"></div>
          <div class="downBox afterTime"></div>
        </li>
        <li>:</li>
        <li>
          <div class="upBox beforeTime"></div>
          <div class="downBox beforeTime"></div>
          <div class="upBox afterTime"></div>
          <div class="downBox afterTime"></div>
        </li>
        <li>:</li>
        <li>
          <div class="upBox beforeTime"></div>
          <div class="downBox beforeTime"></div>
          <div class="upBox afterTime"></div>
          <div class="downBox afterTime"></div>
        </li>
      </ul>
    </div>
  </div>
  <!-- ------------------------备忘录--------------------------- -->
  <div class="up-div">
    <input type="file" name="inputfile" accept="text/plain, text/css, text/html, text/javascript, text/markdown"
      class="background3D" />
    <textarea class="up-textarea" name="uptextarea" rows="1" cols="30%"
      placeholder="请选择txt、js、css或html文件,文件内容会被自动读取"></textarea>
    <button type="text" class="up-button">添加</button>
    <button id="openButton">打开URL</button>
    <button class="a-href"><a href="https://www.baidu.com/s" target="_blank">百度一下</a></button>
    <button id="up-button1" class="delete">对选择的进行删除</button>
    <p>
      <sub>
        护眼背景 &amp;lt;style&amp;gt;
        body { background-color: rgb(110, 123, 108); color: #fff; text-shadow: 1px 1px 1px #000000; }
        &amp;lt;/style&amp;gt;
      </sub>
      <sub> &lt;button class="a-href"&gt;
        &lt;a href="输入网站地址" target="_blank"&gt;
        输入网站名称
        &lt;/a&gt; &lt;/button&gt;
      </sub>
    </p>
  </div>
  <hr>
  <div class="down-div">
  </div>
</body>
<script>
  /**/
  //格式化时间
  const formatTime = (time) => {
    if (time < 10) time = '0' + time
    return time
  }
  //翻转前面下面的盒子向上180deg
  const rotateUp = (ele, time, n) => {
    //传入的为一开始翻转的元素,即前面下面的盒子,以及新时间,以及第几个li盒子
    let rotateDeg = 0;
    ele.style.zIndex = 50;
    //这个是所有上面的盒子
    const allUpBox = document.querySelector(`li:nth-child(${n})`).querySelectorAll('.upBox');
    //所有前面的盒子
    const beforeTime = document.querySelector(`li:nth-child(${n})`).querySelectorAll('.beforeTime');
    // 让上面后面的盒子先不可见,然后设置为270°
    allUpBox[1].style.display = 'none';
    allUpBox[1].transform = `rotateX(270deg)`;
    const animation = () => {
      rotateDeg += 3;
      ele.style.transform = `perspective(500px) rotateX(${rotateDeg}deg)`;
      if (rotateDeg == 90) {
        //让它更新为最近时间后隐藏
        ele.innerHTML = time
        ele.style.zIndex = -1;
        //让刚刚上面隐藏的盒子重新显示出来并且完成90°-180°的旋转
        allUpBox[1].style.display = 'block';
        allUpBox[0].style.zIndex = 1;
        rotateDown(allUpBox[1])
        allUpBox[1].style.zIndex = 1;
      }
      if (rotateDeg == 150) {
        beforeTime[0].innerHTML = time
      }
      if (rotateDeg < 180) {
        requestAnimationFrame(animation);
      }
    }
    animation()
  }
  const rotateDown = (ele) => {
    let rotateDeg = 270;
    const animation = () => {
      rotateDeg += 3;
      ele.style.transform = `perspective(500px) rotateX(${rotateDeg}deg)`;
      if (rotateDeg < 360) {
        requestAnimationFrame(animation);
      }
    }
    animation()
  }
  let time = new Date();
  let oldHour = time.getHours();
  var oldMinute = time.getMinutes();
  var oldSecond = time.getSeconds();
  document.querySelector('li:nth-child(1)').querySelectorAll('.beforeTime').forEach(ele => ele.innerHTML = formatTime(oldHour));
  document.querySelector(' li:nth-child(3)').querySelectorAll('.beforeTime').forEach(ele => ele.innerHTML = formatTime(oldMinute));
  document.querySelector(' li:nth-child(5)').querySelectorAll('.beforeTime').forEach(ele => ele.innerHTML = formatTime(oldSecond));
  const changeTime = () => {
    let time = new Date();
    let hour = time.getHours();
    let minute = time.getMinutes();
    let second = time.getSeconds();
    const setHourBox = document.querySelector('li:nth-child(1)').querySelectorAll('.afterTime');
    if (!setHourBox[0].innerHTML || setHourBox[0].innerHTML != formatTime(hour)) {
      if (setHourBox[0].innerHTML) rotateUp(document.querySelector('li:nth-child(1)').querySelectorAll('.beforeTime')[1], formatTime(hour), 1);
      setHourBox.forEach(ele => ele.innerHTML = formatTime(hour));
    }
    const setMinuteBox = document.querySelector('li:nth-child(3)').querySelectorAll('.afterTime');
    if (!setMinuteBox[0].innerHTML || setMinuteBox[0].innerHTML != formatTime(minute)) {
      if (setMinuteBox[0].innerHTML) rotateUp(document.querySelector('li:nth-child(3)').querySelectorAll('.beforeTime')[1], formatTime(minute), 3);
      setMinuteBox.forEach(ele => ele.innerHTML = formatTime(minute));
    }
    const setSecondBox = document.querySelector('li:nth-child(5)').querySelectorAll('.afterTime')
    setSecondBox.forEach(ele => ele.innerHTML = formatTime(second));
    rotateUp(document.querySelector('li:nth-child(5)').querySelectorAll('.beforeTime')[1], formatTime(second), 5)
    setTimeout(changeTime, 1000);
  }
  changeTime();
  /**************************备忘录********************************/
  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;
  }
  /**********************finish样式函数*****************************/
  /**********************按钮点击事件*****************************/
  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 prompt = document.createElement("div");
    if (type == "success") {
      prompt.style.width = "200px";
      prompt.style.backgroundColor = "#009900";
    } else if (type == "error") {
      prompt.style.width = "280px";
      prompt.style.backgroundColor = "#990000";
    } else if (type == "info") {
      prompt.style.backgroundColor = " #e6b800";
      prompt.style.width = "600px";
    } else {
      return;
    }
    prompt.id = "prompt";
    prompt.style.textAlign = "center";
    prompt.style.position = "absolute";
    prompt.style.height = "60px";
    prompt.style.marginLeft = "-100px";
    prompt.style.marginTop = "-30px";
    prompt.style.left = "30%";
    prompt.style.top = "5%";
    prompt.style.color = "white";
    prompt.style.fontSize = "25px";
    prompt.style.borderRadius = "20px";
    prompt.style.textAlign = "center";
    prompt.style.lineHeight = "60px";
    if (document.getElementById("") == null) {
      document.body.appendChild(prompt);
      prompt.innerHTML = data;
      setTimeout(function () {
        document.body.removeChild(prompt);
      }, 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>
</html>

现代深色主题代码 

<!DOCTYPE html>
<html lang="zh">

<style>
    * {
        /* 外边距: 上右下左 */
        margin: 0px 0px 0px 0px;
        /* 内边距: 上右下左 */
        padding: 0 0 0 0;
        /* 文本颜色 */
        color: #75a8c6;
    }

    body {
        background-color: #2b2b2b;
    }

    /* 鼠标变小手 */
    input,
    button {
        cursor: pointer;
        font-size: 20px;
        padding: 0 5px;
    }

    /* ***********************h-div区************************************* */
    .h-div {
        background: linear-gradient(0.25turn, rgb(110, 123, 108), rgb(204, 232, 207), #f7d6d6);

        /* 3D立体文本的样式 */
        .h1-div {

            h1 {
                color: #f7d6d6;
                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
            }
        }

        li,
        .time li:nth-child(2n+1) .upBox,
        .time li:nth-child(2n+1) .downBox {
            color: rgb(255, 4, 4);
          

        }

        .time {
            border-radius: 30%;
        
            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: 1px 1px 1px #000000;
            border: 0px solid black;
            text-decoration-color: rgb(0, 0, 0);

        }

    }



   



    /* **********************up-div区************************************** */
    .up-div {
        /* 圆角 */
        border-radius: 10px;

        input[type="file"] {
            width: 200px;
        }

        textarea {
            line-height: 1.5em;
         
            background: #303745;
            text-shadow: 1px 1px 1px #000;

            /* text-decoration: underline;
            text-decoration-color: rgb(184, 229, 184); */
            &::placeholder {
                color: #75a8c6;
                text-shadow: 1px 1px 1px #000000;
            }
        }

        p {
            background-color: rgb(199, 237, 204);

            sub {
                text-shadow: 1px 1px 1px #030303;
                box-shadow: inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                    inset 2px 2px 3px rgba(0, 0, 0, 0.6);
            }

            sub:nth-child(1) {
                background-color: rgb(233, 235, 254);
            }

            sub+sub {
                background-color: rgb(227, 237, 205);
            }
        }
    }

    /* 3D背景的样式 */



    .a-href,
    #prompt,
    button,
    input {

        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-radius: 10px;
        text-shadow: 1px 1px 1px #000;
        border: 0px solid black;



    }

    a {
        color: green;
        /* 下划线 */
        text-decoration: underline;
        text-decoration-color: green;
        text-shadow: 2px 2px 1px #000;
    }

    .a-h {
        color: #8cd571;
    }

    /* 背景颜色 */
    .up-div {
        background-color: #1c1c1c;
    }

    .time,


    input[type="file"],
    .up-button {
        background-color: #48603f;
    }

    button {
        background-color: #b8815d;
    }

    button:hover,
    input:hover {
        background-color: rgb(255, 2, 2);
    }

    /* 按钮凹进去的样式 */
    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);
    }

    /* ***********************down-div************************************* */
    .down-div {
        text-indent: 5em;
        /* background: linear-gradient(0.25turn, #b7efea82, #cacf80ac, #f7d6d6); */
        background: #303745;

        /* 设置复选框样式*/
        input[type="checkbox"] {
            background-color: #b8815d;
            -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 #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;
        }

        span {
            /* background-color: #515e6f; */
            text-shadow: 1px 1px 1px #000000;
            box-shadow:
                inset -2px -2px 3px rgba(255, 255, 255, 0.6),
                inset 2px 2px 3px rgba(0, 0, 0, 0.6);
        }
    }

    .finish {
        /* 删除线 */
        /* text-decoration: line-through;  */
        /* 下划线 */
        text-decoration: underline;
        text-decoration-color: rgb(255, 0, 0);
        background-color: rgb(220, 226, 241);
        color: rgb(253, 250, 250);
        text-shadow: 1px 1px 1px #030303;
        box-shadow:
            inset -2px -2px 3px rgba(255, 255, 255, 0.6),
            inset 2px 2px 3px rgba(0, 0, 0, 0.6);
    }

    .a-href {
        line-height: 25px;
        background-color: #515e6f;
    }
</style>

</html>

 

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-27 19:28:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-27 19:28:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-27 19:28:03       82 阅读
  4. Python语言-面向对象

    2024-01-27 19:28:03       91 阅读

热门阅读

  1. 【leetcode100-063到068】【二分】六题合集

    2024-01-27 19:28:03       54 阅读
  2. 【C语言】(4)数组

    2024-01-27 19:28:03       50 阅读
  3. MySQL数据库备份的相关命令-运维面试常问

    2024-01-27 19:28:03       50 阅读
  4. SQL 优化建议

    2024-01-27 19:28:03       52 阅读
  5. MySQL运维实战(4.8) SQL_MODE之NO_ENGINE_SUBSTITUTION

    2024-01-27 19:28:03       50 阅读
  6. 使用scyllaDb 或者cassandra存储聊天记录

    2024-01-27 19:28:03       53 阅读
  7. 天梯赛 L3-020 至多删三个字符

    2024-01-27 19:28:03       53 阅读
  8. 《动手学深度学习(PyTorch版)》笔记4.2 4.3

    2024-01-27 19:28:03       56 阅读
  9. Implement Trie (Prefix Tree)

    2024-01-27 19:28:03       49 阅读
  10. Oracle 数据库(卸载)详细过程

    2024-01-27 19:28:03       60 阅读